CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Machine Controllers Software and Solutions > CamSoft Products


CamSoft Products Discuss Camsoft PC based CNC controller products here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 05-21-2005, 10:22 AM
Karl_T's Avatar  
Join Date: Mar 2004
Location: Dassel,MN,USA
Posts: 1,308
Karl_T is on a distinguished road
parametric programming

I'm rewritng a very old Gcode program to run on a Camsoft Pro control... FWIW, need more softjaws on a lathe that does not have reversible jaws, have to cut the teeth.

Anyway, my last two controls allowed versions of IFTHEN and GOTO to loop sections of code over and over (until condition is met) within the Gcode program. I'm not finding a way to do this in Camsoft Pro.

I'll get this part made by using M98, to get me by, today. I can see M98 just runs the GOSUB command. A clever person could find a way to implement loops and conditional logic within Gcodes using this, somehow.

Anyway, my question. Can I do loops (GOTO) and conditional branching (IFTHEN) within a Gcode prgram? How?

Karl

P.S. This is the code I'm reworking:

;TEETH,ADJUST TRUE SOFT JAWS
;set second jaw back 0.100", third back 0.200"

(*BLEC'*',CMST';',CNDL3,CNDR4,ZRSP0,PDOF0.05,FDOV0*)

%LAPPER = 0
%ZDEPTH = 0.5000

%START:
%COUNTER = 0
%ZDEPTH = %ZDEPTH + 0.025 *;DEPTH OF CUT FOR EACH PASS
%LAPPER = %LAPPER + 1

G92 X 0.00 Y 0.00 Z %ZDEPTH
G90
G00 X 0.000 Y -0.250 Z 0.00


%LOOP:
%COUNTER = %COUNTER + 1

G42 T 02
G01 X 0.008 Y 0.000 F 3.0
G01 X 0.122 Y 0.000
G03 X 0.096 Y 0.750 I -1.304 J 0.330
G01 X 0.000 Y 0.750
G02 X 0.008 Y 0.000 I -3.986 J -0.420
G01 X 0.008 Y -0.125
G01 G 40 X 0.2857 Y -0.25
G92 X 0.000 Y -0.25 Z 0.00

IF (%COUNTER LE 9) GOTO %LOOP

G54
G00 X 0.00 Y 0.00 Z 0.00

IF (%LAPPER LE 5) GOTO %START *;DO ALL TEETH 5 TIMES
Tweet this Post!Share on Facebook
Reply With Quote

  #2   Ban this user!
Old 05-21-2005, 10:51 AM
 
Join Date: Nov 2004
Location: USA
Age: 50
Posts: 446
murphy625 is on a distinguished road

Ok. I dont know bleep about G Codes but if your interface is anything like mine, this might help you..

In my interface program.. I can use a GOTO command to jump anywhere..
But, when I write a program into a text file, I must use the JUMP command inplace of the GOTO command..

IF THEN still works fine..

Did this help you? I dont have the pro version.. Mine is just Graphical OI.

Murphy
Tweet this Post!Share on Facebook
Reply With Quote

  #3   Ban this user!
Old 05-21-2005, 12:33 PM
Karl_T's Avatar  
Join Date: Mar 2004
Location: Dassel,MN,USA
Posts: 1,308
Karl_T is on a distinguished road

Yes, gave me something to look up. I got this nonsence program to show me that IFTHEN and JUMP don't work for me:

{COUNTER=2}
N101 G0 X0
N102 G0 X1
JUMP N101
G0 X{COUNTER}
IF{COUNTER<5}THEN{COUNTER=5}
G0 X{COUNTER}

Machine ended up at X=5. I couldn't get the JUMP command right. Check my syntax above, this should have put the control in an endless loop. Machine just moved to X0 then X1 then X2 then X5

Next I changed < to >:

{COUNTER=2}
N101 G0 X0
N102 G0 X1
JUMP N101
G0 X{COUNTER}
IF{COUNTER>5}THEN{COUNTER=5}
G0 X{COUNTER}

Program ran the same,ended at X5, I wanted the IFTHEN to just drop through.

Have I just got some stupid sytax errors???
Karl
Tweet this Post!Share on Facebook
Reply With Quote

  #4   Ban this user!
Old 05-21-2005, 12:40 PM
Karl_T's Avatar  
Join Date: Mar 2004
Location: Dassel,MN,USA
Posts: 1,308
Karl_T is on a distinguished road

OK, found one syntax error. Got to pull the {} after the IF. What's wrong with JUMP?

Karl
Tweet this Post!Share on Facebook
Reply With Quote

  #5   Ban this user!
Old 05-21-2005, 12:47 PM
 
Join Date: Nov 2004
Location: USA
Age: 50
Posts: 446
murphy625 is on a distinguished road

When I use the JUMP command, I make sure to put the line number on a line by itself.
IE:

N101
!IF Bla Bla THEN JUMP N101

Try putting your line number on a seperate line..

Sorry I can not give you better answers.. Your software is a bit different than mine is.
Im not even sure if it must be on a line by itself.. Its just the way I do it..

Murphy

Last edited by murphy625; 05-21-2005 at 12:51 PM. Reason: Update
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 05-21-2005, 02:49 PM
Karl_T's Avatar  
Join Date: Mar 2004
Location: Dassel,MN,USA
Posts: 1,308
Karl_T is on a distinguished road

I tried every syntax variation I could think of with JUMP. No joy.

I'll ask Camsoft on Monday.

Karl
Tweet this Post!Share on Facebook
Reply With Quote

  #7   Ban this user!
Old 05-21-2005, 03:30 PM
 
Join Date: Nov 2004
Location: USA
Age: 50
Posts: 446
murphy625 is on a distinguished road

Karl,

The code you wrote did not make sense to me..

{COUNTER=2}
N101 G0 X0
N102 G0 X1
JUMP N101
G0 X{COUNTER}
IF{COUNTER<5}THEN{COUNTER=5}
G0 X{COUNTER}

It would seem to me that the computer makes COUNTER=2 then the computer executes X0 then the computer executes X1 then the computer jumps to N101 and executes X0 again..
From my perspective, it doesnt seem as though the program will every progress to the line GO X{COUNTER} because it is running into the JUMP N101 line..
Am I mistaken?

When I was doing mine, I was writing allot of 3 or 4 line programs that did nothing just so I could test code... Seems that's what your doing to in order to experiment. The solution has to be simple..

What is COUNTER ?? Is this a user defined variable of some sort? Or a function within your software like the ESTOP command? The reason I ask that is because you have the COUNTER enclosed with {} which are math brackets in my software.
If this is some type of command that is in your software, try removing the {} all together.. The math brackets {} as I understand, are only to be used when the computer must skip forward in the line and perform a math function in order to finish a math function as in:
IF 5={4+1} THEN BLA BLA BLA.

Where as, if I just want to compare two simple values the command would be
IF 5=\12 then bla bla bla
or
IF 5=A then bla bla bla..

Any of this helping??

Murphy
Tweet this Post!Share on Facebook
Reply With Quote

  #8   Ban this user!
Old 05-22-2005, 12:00 AM
Karl_T's Avatar  
Join Date: Mar 2004
Location: Dassel,MN,USA
Posts: 1,308
Karl_T is on a distinguished road

Murphy,
This is just a junk program to test things. Makes no sence. No offence, but I can see you don't do G code.

The Pro manual talks about different syntax for Gcode fiiles. In the control, a variable is: \## and you'd write stuff like \99=1. In Gcode, variables can have names, ie COUNTER, and assigining values must be in curlies {COUNTER=1}.

G0 is the standard gcode for rapid to point defined in cartesion X Y Z values.

You're right about the JUMP, the program is ignoring this command. That's what I was testing here.

Karl
Tweet this Post!Share on Facebook
Reply With Quote

  #9   Ban this user!
Old 05-22-2005, 07:06 AM
jon jon is offline
 
Join Date: May 2005
Location: norway
Posts: 8
jon is on a distinguished road

I did not know that g-code supported jump without modification.

We have a fanuc robot at work that we use those commands on but we use "jmp" instead of "jump"
It might be a long shot, but you can see if that makes any difference.

Our code looks like this:

LBL[515];
blah blah blah
JMP LBL[515];

Last edited by jon; 05-22-2005 at 01:39 PM.
Tweet this Post!Share on Facebook
Reply With Quote

  #10   Ban this user!
Old 05-22-2005, 11:05 AM
 
Join Date: Nov 2004
Location: USA
Age: 50
Posts: 446
murphy625 is on a distinguished road

Sorry I can't help you more Karl,,

Your right about one thing.. I dont know bleep about Gcodes!!! LOL.. My CNC control has nothing to do with a normal CNC machining center..

I have gotten pretty good at using my version of Graphical OI so I thought I would step in and try.. It was a good try .. LOL

I hope you solve your problem..

Murphy
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 05-23-2005, 11:00 AM
 
Join Date: Apr 2003
Location: United States
Posts: 267
camsoft is on a distinguished road

Variables, Math, Marcos, Jumps and G code usage.

There are numerous sections of the manuals that cover these topics.

Usage and Syntax does change between the Graphical OI, CNC Lite, Plus and Professional versions. All of the commands are the same syntax between each package, but the degree of access and power changes. For example a subset of FANUC variables and Macros are only available in the CNC Professional, while CamSoft variables and macros are available in all versions. The JUMP command is available in all versions and the syntax in the same. See below for instructions and examples for proper usage.

The documentation is lengthy, so we are only providing a limited answer below. The best way to find answers is to electronically search using the Search for Solutions button on CNCsetup.exe or Setup.exe. You can search for answers using key words like a web-browser.

QUESTION 121
Can I use variables and/or do math in my G Code Program?

The controller does have the ability to store unlimited variable names. A legal variable name is a name that begins with any letter of the alphabet. To save a value to a variable in a G Code program, enclose the math and the variable name followed by an equal sign (=) inside curly braces {}. For example, to store 5.5 to the variable

KEEPME: {KEEPME=5.5}

For example, to do math to an existing X axis coordinate in a G Code line where X needs to have .75 added to its value, write the G Code line like this: N100 G01 X{5.5+.75} Y6.2 F30

For example, to add the value of a variable to an existing X axis coordinate in a G Code line, enter: N100 G01 X{5.5+KEEPME} Y6.2 F30

For example, pre-store the values of variables at the top of the program.

At the top of the program:
{FIRSTX=3.489}
{SECONDY=-4.555}
{NUMOFPARTS=1}

For example, to add the variable FIRSTX to the X axis coordinate in your G Code program, enter: N100 G01 X{5.5+FIRSTX} Y5


QUESTION 197
What are the limitations of subprograms and variables within the G code program?

You should first be aware that we allow two formats to be used to assign variables, call macros and do math within the G code program.

Curly Braces { } or Fanuc Style Square Brackets [ ] may be used in macros or to perform math equations. Named variables can be replaced by FANUC style # numbered variables.

Example #1
{MYNAME=45*TAN(MYVARB)}

Same as:

Example #2
#9=45*TAN[#151]

Whereas:
#9 same as MYNAME
#151 same as MYVARB
[ ] same as { } or ( )

These variables, in either named or numbered formats, are public/global throughout the entire time the computer remains on even between different G code programs. They will only be erased when you exit the CNC or overwrite them.

There are three types of variables: LOCAL, USER and SYSTEM variables. LOCAL variables: These are variables that are only available locally within each subprogram. If you call a subprogram with M98, the variables in the main program are not seen by the subprogram. They are not shared. Variables automatically become local when they are placed inside a subprogram.

USER variables: Are seen by all G code programs since the computer has been turned on. They are known as public or global and can be shared.

SYSTEM variables: Are for the installer's internal use only in logic routines. All variables in the G code program are also kept totally separate from the SYSTEM variables that the installer used within the internal system logic. The user cannot change the SYSTEM variable values; however, the installer does have access to the USER variables and can internally read and set the USER variables within the G code program.

Subprograms called using M98 or the command GOSUB must be complete enough to be able to run on their own, by themselves, including the use of user variables in G code, G41, G42, SmartPath or the 3-5 axes tool comp features.

To access a SYSTEM variable from a G code program:

Whereas in logic a SYSTEM variable gets assigned like this:
\100={100+10}

To make a SYSTEM variable such as \100 accessible to a G code program, reassign it to a named USER variable:
{SIZE=\100}

From within the G code program you would write this:
G00 X{SIZE}


Other Examples

When using names as variables for math functions, note where we are using the {} and () characters because the placement of these are important for it to work correctly. LDANG is a named variable that can be used in a G code program and read into logic for calculation or directly used in the G code program. Note that the \112 variable is not valid in a G code program, only in logic files. Refer to the “Pre-Programmed G & M Programming Codes” section in this manual for examples on Fanuc style macro named variables that can be used with trig functions.

{LDANG=45.0}
\112={\110*COS(LDANG)/SIN(LDANG)}


See the 2 pages Titled "Example of macro variables used in G code program."


QUESTION 49
How do I write logic to use a value entered by the user in a text box on the screen?


QUESTION 237
How can we ask the user a question so that the answer can be used in a G code program?


JUMP
This command enables the user to jump or switch the execution of the G code program to a specific G code line that contains a match for the parameter after the JUMP command. The parameter may be a line number, an axis position, a certain feed rate or spindle speed or just about any identical match that can be found in a G code line. The object you are jumping to must appear first in the line of G code. When found, the program will start executing at the line where the match was found. It is important that there is a space following the search item in the G code program.
EXAMPLE: JUMP N350

Tech Support
CamSoft Corp.
951-674-8100
support@camsoftcorp.com
__________________
(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Tweet this Post!Share on Facebook
Reply With Quote

  #12   Ban this user!
Old 05-23-2005, 08:41 PM
 
Join Date: Mar 2003
Location: USA
Posts: 332
keithorr is on a distinguished road

I search all over to the point the lettering on F3 is wearing off.

In CNCLite I tried a simple back and forth motion:

N1 G10 Y20.0 F50.
N2 G10 Y0.0
N3 G10 Y20.0
N4 G10 Y0.0
N5 G10 Y20.0
JUMP N2
N6 G10 Y0.0

(G10 isn't modal.)
Nuthin.

Tried
!JUMP N2

Nuthin

Added WAITUNTIL STOP on a prior line.

Still nuthin.

In the "Line" box, I will see "2" after the jump line is read, but then the screen flickers just a little and then N10 is run.

REWIND doesn't.

Neither does GOTO

If anyone knows how to use these commands, please step forward.
In another controller, I just place GOTO Nxx and it does. Without being admonished to read the manual.
Tweet this Post!Share on Facebook
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming PLC on Fanuc 0M MetLHead Machine Problems, Solutions , Wireless DNC, serial port 19 06-27-2011 07:47 PM
Gsoft Online CNC Programming Tool tslawnyk Product Announcements & Manufacturer News 5 12-07-2007 08:18 AM
Mazak C axis programming dpinson General Metal Working Machines 1 07-02-2005 04:06 PM
API Programming Anyone Al_The_Man Computers and Networking 3 02-14-2005 09:31 PM
Conversational CNC Programming BlueChip Product Announcements & Manufacturer News 0 07-24-2004 02:37 PM




All times are GMT -5. The time now is 04:48 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353