G-Code Macro String Prompt

All things related to the Centroid Acorn CNC Controller

Moderator: cnckeith

Post Reply
qjones
Posts: 23
Joined: Tue Dec 11, 2018 11:11 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC11: Yes
CPU10 or CPU7: No

G-Code Macro String Prompt

Post by qjones »

I am working on a custom macro where I would like to prompt the user for a string. I believe I am doing this correctly and writing it to a #300+ user variable. I have googled for a bit and I cannot find an example of an IF, THEN block that can branch using a string. I get an error when this processes. It works fine if I use a numerical value, like "Press 1 for X, and 2 for Y". But I cannot get something to work with where you could just specify a string "X" or "Y" and branch on a string/character. If anyone has any tips let me know.

Thanks,
Ken Rychlik
Posts: 353
Joined: Wed Jan 23, 2019 4:19 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 80F5B5B92C3A-0213236854
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: G-Code Macro String Prompt

Post by Ken Rychlik »

What are you trying to get your macro to do?
Ken
tblough
Posts: 3102
Joined: Tue Mar 22, 2016 10:03 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: Yes
CNC Control System Serial Number: 100505
100327
102696
103432
7804732B977B-0624192192
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Boston, MA
Contact:

Re: G-Code Macro String Prompt

Post by tblough »

Code: Select all

IF [#300 == 78] THEN GOTO 1000 ; if "N" skip next part
--edit - changed typo #200 to #300
Last edited by tblough on Wed Mar 06, 2019 1:44 pm, edited 1 time in total.
Cheers,

Tom
Confidence is the feeling you have before you fully understand the situation.
I have CDO. It's like OCD, but the letters are where they should be.
qjones
Posts: 23
Joined: Tue Dec 11, 2018 11:11 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC11: Yes
CPU10 or CPU7: No

Re: G-Code Macro String Prompt

Post by qjones »

I have several macros I am working on and I have no issue getting them to work. I would just like to change out some of the user prompts for strings to clean things up.

So it looks like we can just use the ASCII value of the character. I thought this might be the case but was having a hard time getting my code to work right to verify it. I don't see though where we can use #200 as a user variable though. Is this generic GCODE or known to work with the acorn? I see that user variables #300-#399 are for String Literals is that the variable type I should actually use?

Thanks,
Centroid_Tech
Posts: 286
Joined: Thu Mar 18, 2010 2:24 pm

Re: G-Code Macro String Prompt

Post by Centroid_Tech »

You can't use a string as a condition. If the operator is using a single letter then you can have that as a condition as long as you are checking the ASCII value of that letter.

Typically, user variables are #100 thru #159. User variables #150 thru #159 are stored in non-volatile memory which means that those variables will remain even after the system loses power. User variables #100 thru #149 will initialized to 0 at the start of job processing. User variables #300 thru #399 are string variables but these variables are more intended for display purposes.

I am going to assume that tblough code may have had a typo as #200 is not a valid user variable for a Centroid system and if you try to run that code, you should be getting an "Undefined variable" message.
When requesting support, please ALWAYS post a current report. Find out how to take a report from your Acorn, CNC11 or CNC10 system here: https://www.youtube.com/watch?v=Ecvg0VJp1oQ.

If your question is PLC, Macro or program related, please also post a copy of the program or macro as well.

Without the above information we may not be able to help and/or reply until the required information is posted..
qjones
Posts: 23
Joined: Tue Dec 11, 2018 11:11 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC11: Yes
CPU10 or CPU7: No

Re: G-Code Macro String Prompt

Post by qjones »

Okay thanks for the clarification. So if you are receiving an ASCII single letter code it is best to prompt for a #100+ variable and not a #300+ string variable correct?
Post Reply