![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| G-Code Programing Discuss G-code programing and problems here! |
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
I'm using Wincnc and am attempting to write some simple subroutines. I've got the actual gcode figured out and how to write it in Wincnc, the problem is, I can't figure out when you call it, where you're calling it from. Where would the subroutine be filed? There's no folder for subs in Wincnc, although there's one for macros. I tried putting it in the main Wincnc folder and also the folder I normally run programs from without success. I've searched for info and there's plenty on calling subroutines but never where they live. I got a feeling it's really simple so it's never mentioned......
__________________ www.harryhamilldesigns.com CAD sculpting and services |
|
#2
| ||||
| ||||
| From a casual read of the manual, it looks like they use M98 "Filename" to call the subprogram and M99 to return from the sub. The main program will contain the M98 Filename command on the exact line where you want to leave the main program. Obviously, you put either the name of your file in place of Filename, or else, standard practice would dictate that you use a program number to describe the program, but instead of using the big O for the filename, you would use P or sometimes another letter. So if the subprogram is a file called O12345, M98 P12345 would be a typical subcall. Now perhaps they've got this setup so that you can use a DOS type 8 character filename, but I'd try it simple first, to get it working. At the end of your subprogram, you'll need a simple M99 and the controller should then return to the main program. As for paths, one would think that if you kept both the main and the sub programs in the same folder, that the control should be able to find it.
__________________ First you get good, then you get fast. Then grouchiness sets in. (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management) |
|
#3
| |||
| |||
| Thanks, I'll try a different naming format, I just tried a standard text name without any luck. As you saw, they don't specify how to name the sub but the manual tends written for those who already know what they are doing, not for those who don't.
__________________ www.harryhamilldesigns.com CAD sculpting and services |
|
#4
| |||
| |||
| HuFlung is correct with calling a sub program. Here is an example of a typical sub call. O0001(Main Program) G0G90G54 X0Y0Z0 M98P1234------------This will leave program 1 and start running 1234 G0G80 M30 O1234(Sub Program) ... ... ... M99-------------------This is were program 1234 will end and go back to program 1. It will go back to program 1 were it left from so it will start with the G0G80 line and continue. A macro Call works the exact same way except you would use G65P1234 and the assign variables to carry over with it. A, B, H, D, R etc. This would all be in the same line and you would say A=5 for number of holes B=81 for drilling cycle H=20 for part height etc. This would call to program 1234 then when it reads M99 will come back to here but start at the M30 program end. This however uses your local variable assignments #1 #2 #3 etc. So your sub would be using something like G0Z#3. G65P1234A5.B81H20. M30 Stevo |
|
#5
| |||
| |||
| Hmmm, I tried what you guys suggested and it's still not working. When I run a simple test program and it calls the sub, I get an error "Can't find sub123" or whatever I name it. I've tried placing it in different locations, although putting it in the folder I use for my usual programs seems the most logical.
__________________ www.harryhamilldesigns.com CAD sculpting and services |
| Sponsored Links |
|
#6
| |||
| |||
| Your not running this on the control? You are running from a PC? I am not sure how the folders are suppose to be set up when running from the PC. When the M98P123 is seen by the control it is looking for program 123 in the machine directory. If it is not registered in the directory it will give you and alarm "program not found". If you are doing it via PC is there a reason that you want sub programs? The other way to make it work would be to write your sub program and register it in the control as program O0123. Then when the control sees M98P123 in the main program it will run it from memory. Stevo |
|
#7
| ||||
| ||||
| if you are using your control to call the sub from a PC you need to use M198Pxxxx not M98 Pxxxx there is a parameter you have to set so the control is looking for a prog and not a file, not sure what it is on your control.
__________________ If you can ENVISION it I can make it |
|
#8
| |||
| |||
| I have never called sub programs from PC we run everything from the control. The king is right about the M198Pxxxx according to the book. I do not know what kind of control you are on but for the 15B series control it appears to be parameter #2404 bit 5. If =1 specify file, if =0 specify program. Then on the 18i series controls it appears to be parameter #3404 bit 2. If =1specify program, if =0 specify file. Stevo |
|
#9
| |||||
| |||||
__________________ www.harryhamilldesigns.com CAD sculpting and services |
|
#10
| |||
| |||
| I've gotten it figured out, thanks for all the help. I actually got help from a support person at Wincnc, it's a rare event, but I hear they have different management these days so hopefully it will be more common. You have to set up your subs as a macro and the file has to have a .MAC extension and be in their main folder. You can name it what you want and M98 "name" will work.
__________________ www.harryhamilldesigns.com CAD sculpting and services |
| Sponsored Links |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need Help!- M97, M98 subroutine call. How to use | bob1112 | Haas Mills | 11 | 03-12-2008 07:41 PM |
| Example of a Subroutine? | donl517 | Fadal | 14 | 06-27-2007 10:05 AM |
| Help with calling a subroutine | hindocarina | Mach Mill | 2 | 02-11-2007 09:32 PM |
| trying to call a subroutine | hindocarina | G-Code Programing | 4 | 02-11-2007 08:01 PM |
| Need help with subroutine | 2_jammer | General CAM Discussion | 1 | 01-17-2005 10:46 PM |