Passing a value in a spinbox to GCode command
- photomankc
- Offline
- Premium Member
- Posts: 96
- Thank you received: 4
x: -0.100
y: 0.100
I want to set those in the spin box then use the pendant to jog over and the zero buttons would now include that offset when used. What I can not figure out is how I take the number in the spinbox and get GCode executed that includes that variable number. The current setup just executes an MDI-COMMAND line from the .ini file where the position is hard-coded to zero. I can make a custom M command but I can't figure out how that could then execute a line of GCODE or multiple lines for that matter.
Any ideas on this?
Please Log in or Create an account to join the conversation.
www.linuxcnc.org/docview/html/gcode_main...ec:M66-Input-Control
You can see an example of the full system here:
www.bodgesoc.org/lathe/lathe.html
Please Log in or Create an account to join the conversation.
- photomankc
- Offline
- Premium Member
- Posts: 96
- Thank you received: 4
Ok, so I take it that refers to a file? Do you just give it that name as a file, or is the file name just 'turning.ngc'. If so that helps me out a ton. There are several things I wanted to do that required just a few lines of code to complete. A subroutine would obviously help but I thought the sub had to be in the G-Code file. Didn't know it could call it up as a separate file but I guess that makes sense.
HUGE thank you for sharing that info though. That's a load of help right there.
Please Log in or Create an account to join the conversation.
MDI_COMMAND = O<turning> CALL
Ok, so I take it that refers to a file? Do you just give it that name as a file, or is the file name just 'turning.ngc'.
A file called turning.ngc which is in the PROGRAM_PREFIX directory (normally home/emc2/nc_files ) and which needs to have the
o<turning> sub
…
o<turning>endsub
tags in it too.
I am not entirely sure which versions it works in. I think it works in 2.4, but I am using 2.5.
Please Log in or Create an account to join the conversation.
- photomankc
- Offline
- Premium Member
- Posts: 96
- Thank you received: 4
Very aggravating. I have the analog inputs all setup and wired and they are working. I can run the commands:
M66 E0 L0
#1 = #5399
G92 X#1
in MDI and they do exactly what I want. They give me the offset from the spinbox. However, the line O<touchx> CALL does nothing. I know that something is happening because the title of the AXIS window changes to "touchx.ngc" but it never executes the contents of the subroutine:
;Touch Off X Axis
O<touchx> SUB
M66 E0 L0
#1 = #5399 (X OFFSET)
G92 X#1 (SET X POSITION TO CURRENT OFFSET)
O<touchX> ENDSUB
M2
No errors no nothing, just doesn't execute the lines in the subroutine for all I can tell?
Please Log in or Create an account to join the conversation.
O<touchX> ENDSUB
Do you have touchx and touchX one cap X and one small x in the sub or just when you typed here?
Rick G
Please Log in or Create an account to join the conversation.
- photomankc
- Offline
- Premium Member
- Posts: 96
- Thank you received: 4
If I put movement commands in they run. If I set the coordinate for G92 to a fixed value it runs. If I set the value of #1 to a fixed number and set G92 with that variable it runs. If i put in the M66 command then boom, nothing works even if I never use the value. I also note that until I add the m66 command the title bar doesn't change from the current file when i call the subroutine or it's too fast to see. When i add the m66 command it changes to touchx.ngc and stays there.
Please Log in or Create an account to join the conversation.
- photomankc
- Offline
- Premium Member
- Posts: 96
- Thank you received: 4
Please Log in or Create an account to join the conversation.
At various point might clarify things.
I was scratching my head with my subs yesterday, eventually I found that there was an M2 before the endsub.
I wonder if there is some sort of state-memory built in to sub calling?
Please Log in or Create an account to join the conversation.
- photomankc
- Offline
- Premium Member
- Posts: 96
- Thank you received: 4
O<touchx> SUB
(debug, #5399)
M66 E0 L0
(debug, #5399)
#1 = #5399 (X OFFSET)
G92 X#1 (SET X POSITION TO CURRENT OFFSET)
O<touchX> ENDSUB
M2
Run with the m66 line commented gets
0.000000
0.000000
Title bar is still axis.ngc and the X axis is set to zero.
Run with the m66 line active gets
0.000000
And the title bar stuck at touchx.ngc and X axis never changes.
Infuriating.
Please Log in or Create an account to join the conversation.