Code Syntax Help Please

All things related to the Centroid Acorn CNC Controller

Moderator: cnckeith

Gary Campbell
Posts: 2164
Joined: Sat Nov 18, 2017 2:32 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: Acorn 238
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Marquette, MI
Contact:

Code Syntax Help Please

Post by Gary Campbell »

I am looking to make a minor change to my tool measure macro. (attached)

I am looking to set variable #105 (line 16) to parm [#9071] (tt1 height) for use when on the spoilboard. That parm is used on line 148
This will be used for tool numbers 1 thru 20.

Can be seen at 3:16 into this video: https://youtu.be/xqTpEXHOWPw

When using the rotary, with tool numbers 21-30 I need an "IF / Then" statement similar to: IF tool# > 20 Then #105 = {fixed number}
This number will be set and hard coded into file once rotary is in place

Are there any examples that I can look at?
mfunc6FixedToolTouchOff.mac
(9.65 KiB) Downloaded 113 times
GCnC Control
CNC Control & Retrofits
https://www.youtube.com/user/Islaww1/videos
diycncscott

Re: Code Syntax Help Please

Post by diycncscott »

Hi Gary,

That macro is comprised almost entirely of IF/THEN

If I understand you correctly:

#105 = user variable - note: #100-#149 are reset to 0 after every job. They should only be used in macros that initialize their value explicitly.
#4120 = system variable used to store requested tool from g code

IF #4120 < 21 THEN #105 = #9071
IF #4120 >= 21 THEN #105 = 1.2345


Does that answer your question? Maybe you were looking for an "ELSE" (I generally prefer not to use them as I find the second IF more obvious that it is explicitly applied to only tools >= 21)
IF #4120 < 21 THEN #105 = #9071 ELSE #105 = 1.2345
Gary Campbell
Posts: 2164
Joined: Sat Nov 18, 2017 2:32 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: Acorn 238
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Marquette, MI
Contact:

Re: Code Syntax Help Please

Post by Gary Campbell »

That did it! You are the man!

Thank you
GCnC Control
CNC Control & Retrofits
https://www.youtube.com/user/Islaww1/videos
Gary Campbell
Posts: 2164
Joined: Sat Nov 18, 2017 2:32 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: Acorn 238
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Marquette, MI
Contact:

Re: Code Syntax Help Please

Post by Gary Campbell »

OK, I have another one that has me stumped. I am writing a short macro to set Parm 71 to the distance between the spoilboard and tool measure switch height. All works well, except I cant get the G10 line that writes the parm to accept my "R" value, which is a variable. I have tried seting user variable 105 to system var 5043, tried using #5043 as the "R" parameter... tried with and without every combo of square brackets, but I keep getting either error 704 Invalid parm or 501 invalid character. What am I missing?


Clip of macro here:

M115 /Z P[#104] F[#102] ;Move at fast probing rate until TT1 detected
M116 /Z P-[#104] F[#103] ;Retract at slow probing rate until TT1 clears
M115 /Z P[#104]F[#103] ;Move at slow probing rate until TT1 detected

#105 = #5043 ; Sets #105 to Current Z position
G4 P1
G10 P71 R#105 ; Writes Switch height to Parm
G4 P1 ;Wait 1 second

G53 Z0

M225 #101 "#)**SWITCH HEIGHT SET**\nPress Cycle Start to continue"


N1000 ;End of Macro
GCnC Control
CNC Control & Retrofits
https://www.youtube.com/user/Islaww1/videos
diycncscott

Re: Code Syntax Help Please

Post by diycncscott »

Not all parameters are writable and not all parameters will store a floating pt. value. P71 is Read-Only. P181 is an old baud rate parameter that is no longer used. It is writable and will store a floating pt. number.

BTW - P14 is already used as a "fast probe rate" (read using #9014), slow probe rate is p15(read using #9015). Neither is writable however.

You can also read the probe input directly with either #5000# where # = plc input number or #9011 if p11 is set to the value of your probe plc input

M115 /z p#50007 F#9014

or M115 /x p#9011 F#9014
Gary Campbell
Posts: 2164
Joined: Sat Nov 18, 2017 2:32 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: Acorn 238
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Marquette, MI
Contact:

Re: Code Syntax Help Please

Post by Gary Campbell »

Thanks Scott...
Trying to write to a read only makes sense... now.

I'm setting the speeds in this file faster than normal for probing and intentionally not using the stored values. I do use them with the touch plate

Still wont work.


If I enter G10 P181 R[#5043] into the mdi the variable is written properly no matter where the z is positioned. When the macro is run p181 is written as 1.2000 any ideas on what I have screwed up now?
Attachments
mfunc71.mac
(2.3 KiB) Downloaded 93 times
report_9884E39427E5-1206170338_2018-02-21_14-25-45.zip
(170.42 KiB) Downloaded 87 times
GCnC Control
CNC Control & Retrofits
https://www.youtube.com/user/Islaww1/videos
diycncscott

Re: Code Syntax Help Please

Post by diycncscott »

Try wrapping it in IF #50001 to prevent look ahead from setting value prematurely

Works fine for me. Also, make sure #5043 is a positive number (Z axis position). No such thing as a tool post with a negative height

IF #50001
G10 P181 R#5043
IF #50001
Gary Campbell
Posts: 2164
Joined: Sat Nov 18, 2017 2:32 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: Acorn 238
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Marquette, MI
Contact:

Re: Code Syntax Help Please

Post by Gary Campbell »

I think I found it.

Did the "wrap' with #50001 worked, then it didn't

It appeaars that if the value (z pos) is less than 1 (maybe 1.20) it sets the parm as 1.2000

My spoilboard will always be lower, so it should not return an error in normal operation

Does parm 181 have any restriction (input masks)? 1.2k baud rate? Shades of Prodigy :lol:

Thanks for your time. Life is good
GCnC Control
CNC Control & Retrofits
https://www.youtube.com/user/Islaww1/videos
diycncscott

Re: Code Syntax Help Please

Post by diycncscott »

Sorry, use p251 no floor, no ceiling within reason. writable. positive, negative....
Gary Campbell
Posts: 2164
Joined: Sat Nov 18, 2017 2:32 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: Acorn 238
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Marquette, MI
Contact:

Re: Code Syntax Help Please

Post by Gary Campbell »

Got it, thanks
GCnC Control
CNC Control & Retrofits
https://www.youtube.com/user/Islaww1/videos
Post Reply