NEWS
LinuxCNC 2.5.2 Release
LinuxCNC 2.5.2 Update Released (changelog).
 
LinuxCNC 2.5.1 Release

LinuxCNC 2.5.1 Update Released (changelog). If the Package Manager does not prompt you to upgrade see this page.

 
LinuxCNC 2.5.0 Release
New major release (changelog). See the instructions to update your system from EMC 2.4 to LinuxCNC 2.5.
 
Home Forum Configuring LinuxCNC pyVCP Passing a value in a spinbox to GCode command

Welcome, Guest
Username: Password: Remember me

TOPIC: Passing a value in a spinbox to GCode command

Passing a value in a spinbox to GCode command 14 Jul 2011 08:46 #11524

  • photomankc
  • photomankc's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 64
  • Karma: 1
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?
The administrator has disabled public write access.

Re:Passing a value in a spinbox to GCode command 14 Jul 2011 09:09 #11527

  • andypugh
  • andypugh's Avatar
  • OFFLINE
  • Moderator
  • Posts: 4135
  • Thank you received: 141
  • Karma: 129
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 administrator has disabled public write access.

Re:Passing a value in a spinbox to GCode command 14 Jul 2011 12:13 #11536

  • photomankc
  • photomankc's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 64
  • Karma: 1
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 12:23 by photomankc.
The administrator has disabled public write access.

Re:Passing a value in a spinbox to GCode command 14 Jul 2011 12:37 #11537

  • andypugh
  • andypugh's Avatar
  • OFFLINE
  • Moderator
  • Posts: 4135
  • Thank you received: 141
  • Karma: 129
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 12:37 by andypugh.
The administrator has disabled public write access.

Re:Passing a value in a spinbox to GCode command 17 Jul 2011 09:53 #11582

  • photomankc
  • photomankc's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 64
  • Karma: 1
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?
The administrator has disabled public write access.

Re:Passing a value in a spinbox to GCode command 17 Jul 2011 10:21 #11583

  • Rick G
  • Rick G's Avatar
  • OFFLINE
  • Moderator
  • Posts: 1070
  • Thank you received: 15
  • Karma: 80
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
The administrator has disabled public write access.

Re:Passing a value in a spinbox to GCode command 17 Jul 2011 10:33 #11584

  • photomankc
  • photomankc's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 64
  • Karma: 1
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 10:38 by photomankc.
The administrator has disabled public write access.

Re:Passing a value in a spinbox to GCode command 17 Jul 2011 10:48 #11585

  • photomankc
  • photomankc's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 64
  • Karma: 1
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.
The administrator has disabled public write access.

Re:Passing a value in a spinbox to GCode command 17 Jul 2011 11:46 #11586

  • andypugh
  • andypugh's Avatar
  • OFFLINE
  • Moderator
  • Posts: 4135
  • Thank you received: 141
  • Karma: 129
(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?
The administrator has disabled public write access.

Re:Passing a value in a spinbox to GCode command 17 Jul 2011 14:33 #11589

  • photomankc
  • photomankc's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 64
  • Karma: 1
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 14:46 by photomankc.
The administrator has disabled public write access.
Time to create page: 2.408 seconds
Powered by Kunena Forum
© 2013 LinuxCNC.org
Joomla! is Free Software released under the GNU General Public License.