Passing a value in a spinbox to GCode command

More
14 Jul 2011 15:46 #11524 by photomankc
I've created a panel for my mill and one of the things I really would like to be able to do is setup offsets for edge finding. I have buttons on my pendant that will zero the X/Y/Z but it zeros them at exactly the current position. I want to use the spin boxes to set an offset for the zero so that I can use an edge finder without going back to the mouse and keyboard all the time. So for instance if I zero at the back left my offsets would be:

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.

More
14 Jul 2011 16:09 #11527 by andypugh
The way I have done it on my lathe is to wire the spinboxes to one of the motion.analog-in pins, and then read the value into G-code with M66.
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
The following user(s) said Thank You: IrishMoss

Please Log in or Create an account to join the conversation.

More
14 Jul 2011 19:13 - 14 Jul 2011 19:23 #11536 by photomankc
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'. 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.
Last edit: 14 Jul 2011 19:23 by photomankc.

Please Log in or Create an account to join the conversation.

More
14 Jul 2011 19:37 - 14 Jul 2011 19:37 #11537 by andypugh
photomankc wrote:

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.
Last edit: 14 Jul 2011 19:37 by andypugh.

Please Log in or Create an account to join the conversation.

More
17 Jul 2011 16:53 #11582 by photomankc
Well,

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.

More
17 Jul 2011 17:21 #11583 by Rick G
O<touchx> SUB


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.

More
17 Jul 2011 17:33 - 17 Jul 2011 17:38 #11584 by photomankc
They are both O<touchx> that was a miss-type.

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.
Last edit: 17 Jul 2011 17:38 by photomankc.

Please Log in or Create an account to join the conversation.

More
17 Jul 2011 17:48 #11585 by photomankc
And even more fun.... if I just make a fie with those commands and run them as a program..... yes Johnny, thats right, they run just fine. It appears they only refuse to run as a subroutine in the manor that I need to use them. Of course.

Please Log in or Create an account to join the conversation.

More
17 Jul 2011 18:46 #11586 by andypugh
(debug, #5399)
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.

More
17 Jul 2011 21:33 - 17 Jul 2011 21:46 #11589 by photomankc
Its 0.000000 when the M66 line is commented out. It never gets executed when I uncomment that line. It won't execute another line of code after that.

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.
Last edit: 17 Jul 2011 21:46 by photomankc.

Please Log in or Create an account to join the conversation.

Time to create page: 0.097 seconds
Powered by Kunena Forum