SPINBOX DATA to G-Code Variable

More
31 Jan 2015 12:08 #55498 by Askjerry
Askjerry created the topic: SPINBOX DATA to G-Code Variable
Ok... it isn't like I haven't been reading the forum, Google, etc. In fact it's been two days... and I'm no closer to getting a resolve.

So here is the deal... I create a SPINBOX on my panel... I call it spinbox-01 and I have a button under it which calls routine_01.

The routine is pretty simple... just a test program because Once I get the concept... I'll be able to continue...

So here is the test routine...

O <routine_01> sub
(MSG, Routine 01)
#1 = 2
G1 X #1 F20
G0 X0
O<routine_01> endsub
M2


Not much too it... it moves the spindle 2 inches then back... whoo.

What I WANT to do... is dial the SPINBOX to some number from 1 to 5 inches... click the button and have it run the routine with the data passed along... this is NOT the way to do it... but it will give you the idea of what I am TRYING to implement...

O <routine_01> sub
(MSG, Routine 01)
#1 = pyvcp.spinbox-01
G1 X #1 F20
G0 X0
O<routine_01> endsub
M2


I probably have to use net to point the pyvcp.spinbox-01 at some variable and call it... I know i can create custom variables like #<_spinbox01> in G-Code... so it may be something like... an edit to a .hal file to include something like...

net spinner01 #<_hal[pyvcp.spinbox-01]> <= pyvcp.spinbox-01

or that may not even be remotely close.

Can someone help?

If I can connect the pyvcp.spinbox-01 to the G-Code variable in this example... I should be able to then make something more complex and pass variables to it. Like... a peck drill cycle where you enter the depth, the peck distance, and click "DRILL"... that would be useful.

Anyway... I'll keep hacking at it... perhaps I'll get lucky... :blink:

Thanks in advance.
Jerry
More
01 Feb 2015 00:58 #55512 by ArcEye
ArcEye replied the topic: SPINBOX DATA to G-Code Variable
Hi

There is a limit to what you can do, you can certainly read hal pins in gcode, you can't set them however.

The other alternative is passing the value via M66 etc

Some reading for you, with links to the definitive pages

linuxcnc.org/lucid/index.php/french/foru...-and-hal-pins-values

linuxcnc.org/lucid/emc2/index.php/italia...ing-hal-pin-from-ngc

linuxcnc.org/dapper/index.php/english/fo...-parameters-in-gcode

regards
More
01 Feb 2015 03:52 - 02 Feb 2015 04:00 #55521 by Askjerry
Askjerry replied the topic: SPINBOX DATA to G-Code Variable
I am just on the edge... but I'm still missing something... I just don't know what!!!!!!

Ok... I finally figured out that i needed to have this in my TESTING.INI file...

[RS274NGC]
PARAMETER FILE = linuxcnc.var
SUBROUTINE PATH = ./ROUTINES/
FEATURES = 12

Got that part... took me awhile to figure they just wanted the number, not all the text... but I'm past that now...

I read up on the M66 command...

M66 E0 L0
E- - specifies the analog input number from 0 to 3.
L- - specifies the wait mode type: Mode 0: IMMEDIATE - no waiting, returns immediately.

Fine... I see that we need to call that in order to activate the ability to read an input... and since the spinbox is a float variable... it is NOT a digital (T or F) number.

The example shows: "net signal-name motion.digital-in-00 <= parport.0.pin10-in"

So...
in theory... replace signal-name with spinbox01
in theory... replace motion.digital-in-00 with motion.analog-in-00
in theory... replace parport.0.pin10-in with pyvcp.spinbox-01

So... in theory... this should be the proper net command...
net spinbox01 motion.analog-in-00 <= pyvcp.spinbox-01

And that should route it to where I can reference
#<_hal[spinbox01]>
from within my routine... which is...

O <routine_01> sub
(MSG, Routine 01)
M66 E0 L0
#1000 = #<_hal[spinbox01]>
(DEBUG, Output: #1000)
O <routine_01> endsub
M2


FAIL !

I get...
Named Parameter #<_hal[spinbox01]> not defined

So... I modified the routine to look for...
#<_hal[motion.analog-in-00]>

FAIL !

I get...
Named Parameter #<_hal[motion.analog-in-00]> not defined

Ahhggggg !!!

Any ideas???
Last Edit: 02 Feb 2015 04:00 by Askjerry.
More
01 Feb 2015 18:22 - 01 Feb 2015 20:52 #55546 by ArcEye
ArcEye replied the topic: SPINBOX DATA to G-Code Variable
Hi

It is quite simple honest.

I created a xml panel with 2 spinboxes
<?xml version='1.0' encoding='UTF-8'?>
<pyvcp>
    <vbox>
        <spinbox>
	    <halpin>"spinbox0"</halpin>
    	    <min_>-12</min_>
            <max_>33</max_>
	    <initval>10</initval>
    	    <resolution>0.1</resolution>
            <format>"2.3f"</format>
	    <font>("Arial",16)</font>
            <param_pin>1</param_pin>	    
        </spinbox>

	<spinbox>
    	    <halpin>"spinbox1"</halpin>
            <min_>-12</min_>
	    <max_>33</max_>
    	    <initval>20</initval>
            <resolution>0.1</resolution>
	    <format>"2.3f"</format>
    	    <font>("Arial",16)</font>
            <param_pin>1</param_pin>
        </spinbox>
    </vbox>
</pyvcp>

Then I put it in the ini file
[DISPLAY]

PYVCP = custompanel.xml

and also the line to enable hal pin examination.
The BIG thing is to ensure your version supports this, I am using a RIP of 2.7 for this demo
[RS274NGC]

FEATURES = 12

The spinboxes are not 'netted' to anything, there is no need, their value can be interogated directly in gcode

Then I started the sim and set HAL Configuration to monitor 2 existing params which had a value and the 2 spinboxes

Then I use the (DEBUG, ........) statements in the MDI window to show the value of the 2 parameters and the 2 spinboxes

voila





regards
Attachments:
Last Edit: 01 Feb 2015 20:52 by ArcEye.
The following user(s) said Thank You: Askjerry
More
02 Feb 2015 00:26 #55555 by Askjerry
Askjerry replied the topic: SPINBOX DATA to G-Code Variable
Okay then... it must be my version.

I have AXIS 2.5.4 which is the original version installed by the downloaded ISO.
The SYSTEM shows the following...
- Ubuntu 10.04
- Kernel Linux 2.6.32-122-rtai
- GNOME 2.30.2


So are you saying that you have AXIS 2.7.0 ?
And if so... how do I do the update? (Still new to Linux.)

But that would explain why I was going crazy... I was like, "this SHOULD be working!!!"

Thanks for the help!!
Jerry
More
02 Feb 2015 00:30 - 02 Feb 2015 00:32 #55556 by ArcEye
ArcEye replied the topic: SPINBOX DATA to G-Code Variable

So are you saying that you have AXIS 2.7.0 ?


No, I am sure it is in Linuxcnc 2.6, I just happened to have 2.7 available.

You can upgrade to 2.6.5 on Ubuntu 10.04 quite easily
wiki.linuxcnc.org/cgi-bin/wiki.pl?UpdatingTo2.6

regards
Last Edit: 02 Feb 2015 00:32 by ArcEye.
The following user(s) said Thank You: Askjerry
More
02 Feb 2015 01:14 - 02 Feb 2015 01:15 #55558 by Askjerry
Askjerry replied the topic: SPINBOX DATA to G-Code Variable
:laugh: :P :woohoo: :)
THAT GOT IT!!

I did the update as you suggested AXIS 2.6.5 and now it works perfectly.
I also tried a DIAL... same thing... works exactly as planned.

You have NO IDEA how crazy I was going yesterday... I was like, "But this SHOULD work!!!" Drove my poor wife crazy too... better take her out for lunch today... :blush:

Thank you SO much!
Jerry
Last Edit: 02 Feb 2015 01:15 by Askjerry.
More
02 Feb 2015 02:24 #55560 by andypugh
andypugh replied the topic: SPINBOX DATA to G-Code Variable

Askjerry wrote: FEATURES = 12
...
M66 E0 L0


I know you got there, but to clarify for anyone else reading this thread...

You can (in versions > 2.6) read HAL pins in via the FEATURES=12 and #<_hal[...]> format.

OR

You can in any version of LinuxCNC Net the spinbox to a motion.analog-in-NN pin and read it with M66.

But these are tow completely different ways to do approximately the same thing. M66 is more trouble but has the advantage that it reads the value in the box at the time that the G-code gets there, whereas the other way synchs the values in a slightly unpredictable way.
The following user(s) said Thank You: cncnoel
More
02 Feb 2015 04:14 - 02 Feb 2015 04:16 #55567 by Askjerry
Askjerry replied the topic: SPINBOX DATA to G-Code Variable
All I know is that I was trying the M66 route as well... and still having issues.

Following your link and doing the AXIS upgrade to 2.6.5... that fixed the problem for me immediately. I'm testing some routines now... I won't be feeding values on-the-fly as I don't know how the timing etc will work. (As you stated.) I'll most likely have a header where I set up local variables...
(Some Bogus program)
O <get_the_job_done> SUB
(Set Variables)
#1000 = #<_hal[pyvcp.some_pin_goes_here]>            (Travel Set )
(Do some task)
G90 G1 X#1000 F05
(Some task accomplished)
O <get_the_job_done> ENDSUB

The first one I'll do will be a routine to PECK DRILL... set spinbox #1 for the full depth, and spinbox #2 for the depth per pass... click the button and go. This way i can drill deep holes wherever I want... without needing to write G-Code each time.

Thanks again for the help!!!
Jerry
Last Edit: 02 Feb 2015 04:16 by Askjerry.
More
03 Feb 2015 22:34 - 03 Feb 2015 22:42 #55649 by Askjerry
Askjerry replied the topic: SPINBOX DATA to G-Code Variable
I decided to try my first routine... I do quite a bit of Peck Drilling, G83. So I thought it might be nice to move the machine into position, then conversationally drill a hole... without needing to write G-Code each time. At first it wasn't working right... then I used your idea of running the HAL Configuration... it needed to have a "-f" appended to the HAL pin.

So here is the code...
(G83 Peck Drilling Routine)
O <peck-drill-rtn> SUB
(MSG, PECK DRILLING)
G90
G20
M3
G83 Z #<_hal[pyvcp.peck-z-f]> R #<_hal[pyvcp.peck-r-f]> Q #<_hal[pyvcp.peck-q-f]> F 3 
M5
(MSG, Completed OK.)
O <peck-drill-rtn> ENDSUB

And here is the interface I came up with...


Likely I'll modify it more... but it is working well. The pyVCP components are in a TABLE to get the format I have now... I may change the sliders to dials... not sure... still experimenting. :dry:

Thanks again ArcEye!
Jerry
Last Edit: 03 Feb 2015 22:42 by Askjerry. Reason: spelling
Time to create page: 0.111 seconds
Powered by Kunena Forum