Data from G-Code to pyvcp panel

More
21 Apr 2018 06:46 - 21 Apr 2018 06:51 #109370 by Askjerry
I have create a new control panel (don't I always?) which has an LED graphic assigned to pyvcp.goin-home that I would love to send data from my G-Code to the panel. (Look at the SAFE GO HOME button near the bottom.)


I have sent data FROM my panel into G-Code.... I have that process down pat... no problem.

For example, my PECK DRILL routine has lines to pull the depth to drill, etc...
G83 Z #1001 R #1000 Q #<_hal[pyvcp.peck-q]> F#<_hal[pyvcp.peck-f]>

So I thought that in my G-Code I could do something like
#<_hal[pyvcp.goin-home]> = 1
And it would pass the BIT value "1" to light up the LED... then later send...
#<_hal[pyvcp.goin-home]> = 0
To turn it off.

So what am I missing???

pyvcp ==> G-Code = No Problem
G-Code ==> pyvcp = Problem

From G-Code use WHAT??? to make pyvcp.goin-home either a 1 or 0.

Can it be done? If so... I can have indicators on screen to inform the operator of various things.

Thanks,
Jerry
Attachments:
Last edit: 21 Apr 2018 06:51 by Askjerry. Reason: Clean up.

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

More
21 Apr 2018 10:13 #109379 by rodw
Gerry, this thread describes how to send data back from gcode to a python handler for a Gmoccappy screen.
forum.linuxcnc.org/plasma-laser/32691-settings-from-g-code-file

Hope it helps.
The following user(s) said Thank You: Askjerry

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

More
21 Apr 2018 16:34 - 21 Apr 2018 16:38 #109400 by Askjerry
Replied by Askjerry on topic Hummmmm
Most of what he was saying was way over my head... but I learned a VERY IMPORTANT thing about LinuxCNC.
I had thought that the motion.analog-out-00 through motion.analog-out-03 were only available IF the pins were actually assigned to a parport pin. The truth is, they are not... they will return values even if not predefined in HAL.

That is AWESOME as it means I can recover the number sent and act accordingly...

For those of you who do not know what float, s32, u32, or bit are... this is the reference you need to read...
linuxcnc.org/docs/2.4/html/hal_basic_hal.html#sec:Hal-Data

For me, it would be awesome to send a value like "5" to the system, then pick that apart as binary 0000101 and have LEDs tied to the appropriate outputs, or have a <multilabel> display text based on the u32 (positive only) value received. The analog-out-03 that I will use outputs a float type number, (Positive and negative with decimal.)

For a <multilabel> text box, I need positive only, no decimal points... u32 type... so float will not work.

We are in luck however... there is a conversion we can add to HAL called CONV_FLOAT_S32.
Reference: linuxcnc.org/docs/2.6/html/man/man9/conv_float_s32.9.html

For binary bits... there is no direct conversion (that I could find... but I did find CONV_S32_BIT which would convert the number above into a series of bits that could be examined. It is a double step process... but it is doable.
Reference: linuxcnc.org/docs/html/man/man9/conv_s32_bit.9.html

This means that I can have up to four outputs from my G-Code sending data back to the pyVCP (or GLADE) control panel...
  • motion.analog-out-00
  • motion.analog-out-01
  • motion.analog-out-02
  • motion.analog-out-03

So thank you rodw for pointing me in that direction!
Last edit: 21 Apr 2018 16:38 by Askjerry. Reason: Colors and stuff

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

More
21 Apr 2018 21:52 - 21 Apr 2018 21:53 #109406 by rodw
Gerry, Glad I could help.

If you just wanted a binary input, M64/M65 is a better option as they control a digital input (on or off)
You can increase the number of analog and digital inputs in hal when motion is loaded. This is mentioned in the M64/M65 and M67/M68 docs but syntax is here:
linuxcnc.org/docs/html/config/core-components.html#sec:motion

The example I linked to you folded multiple analog settings into the one analog input that is parsed in the screen handler. eg
if number starts with 2 then setting2 = the value to the right of the leading digit
elseif number starts with 3 setting3 = the value to the right of the leading digit
elseif number starts with 4 setting4 = the value to the right of the leading digit
etc
This is a good option when you want to control an analog value from both a screen control and gcode but its not in real time so you should follow the gcode M67/M68 with a G4 P0.1 to delay for bit so it can "stick"

The other approach is to write a component and parse the analog value in real time as shown in this example.
forum.linuxcnc.org/plasma-laser/32700-co...hc-from-within-gcode
Use this approach when you want to control a setting from gcode in real time (in this case turn the Torch Height Control on and off).

So now you've got a whole series of tutorials to produce :)
Last edit: 21 Apr 2018 21:53 by rodw.

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

More
21 Apr 2018 22:59 - 21 Apr 2018 23:00 #109410 by rodw

For me, it would be awesome to send a value like "5" to the system, then pick that apart as binary 0000101 and have LEDs tied to the appropriate outputs,


Hmm, I just found a component exists that does exactly this..

linuxcnc.org/docs/html/man/man9/bitslice.9.html
Last edit: 21 Apr 2018 23:00 by rodw.

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

More
21 Apr 2018 23:33 #109411 by Askjerry
I appreciate that... if I am not mistaken...

Still a two-step process... I was looking at float --> s32 --> bit where this is float --> u32 --> bit.

I have done the reverse of this converting a series of bits to a u32 for image manipulation...
forum.linuxcnc.org/22-pyvcp/34297-multi-...-axis-home-indicator

It does open a door for all sorts of interactive displays where the G-Code can do more than drop those annoying message boxes that need to be closed. Now I can use graphics and/or <multiline> to achieve my goals.

I had tested the digital-out-00 through digital-out-03 function as well... I like the analog out as it provides much more data capability per resource. If I only use analog-out-03 for example... that's 8 individual bits that I can play with which leads to a lot of possibilities.

Definitely gives me things to experiment with.

Thanks,
Jerry

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

More
22 Apr 2018 13:14 #109426 by Todd Zuercher
An other option is to use a custom M-code to setp a halpin value.

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

More
22 Apr 2018 15:48 - 22 Apr 2018 15:58 #109430 by Askjerry
True. In theory, the command could set the value directly.

This was for a project with the Austin Hackerspace... there will be some setup routines that I want to relay feedback on the display. For example, I created a bolt hole circle routine that asks how many holes, at what radius, and at what depth, and at what peck depth. This is all done on-screen from the pyvcp panel. The text will display the instructions for how it works. When the click the button to start the process, the G-Code will kick back a number which will cause the instructions to change to a warning that the process is starting. By breaking into bits... I could assign buts 0-3 to one panel, 4-7 to another... four messages per panel.


If I use a second output... ANALOG-OUT-02 I could capture the actual number to a spinbox or similar... The effect is an interactive panel that tells you how the function works, warns you that it is starting up, then gives you a countdown to how many holes are left to go... and finally, returns to the instructions screen.

Overkill... yeah... but I'm just showing off my coding skills and making a nice demo piece. B)
Attachments:
Last edit: 22 Apr 2018 15:58 by Askjerry. Reason: Cleaning up

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

Time to create page: 0.181 seconds
Powered by Kunena Forum