pyVCP button to control generic digital out

More
21 Jan 2021 21:43 #196150 by oddwick
Just curious if this is even possible. I have searched the forum and to be honest i am not really sure what to search for. what i am trying to do is create a pyvcp button to toggle a digital output. specifically with a mesa 7i96 using one of the general outputs to turn on and off an extraction fan. i can do it using an M code, but i would really like to do it with a button and toggle if possible. any ideas?

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

More
21 Jan 2021 22:28 #196160 by tommylight
It should be,
www.anderswallin.net/tag/pyvcp/
linuxcnc.org/docs/2.8/html/gui/pyvcp.html
First link, second example should do what you need, or checkbutton on the second link, but the latter is very small.

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

More
22 Jan 2021 03:31 - 22 Jan 2021 03:32 #196177 by Todd Zuercher
Yes it very much is possible. It's even possible to have both a custom m-code and a vcp button. In fact it can make it easier. If you set up an m-code, you can trigger it with a halui mdi command with the vcp button.

Without the M-code you have to use either a hal toggle component, or a toggle button in your vcp.
Last edit: 22 Jan 2021 03:32 by Todd Zuercher.

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

More
22 Jan 2021 19:40 #196265 by oddwick
hey thanks tommy, i got that far, i have some buttons that turn on the pump and flood, and that works pretty well. and that example is pretty much what i had going, but where i got lost there seems to be no attributes that i can set for motion.digital-out-NN. like with mist, there is halui.mist.on/halui.mist.off etc. that i can manipulate. how do i do that with digital-out?

Without the M-code you have to use either a hal toggle component, or a toggle button in your vcp.

is it better to use the m-code? that is what i use (o subs anyway) to do generic canned operations like parking head, probe touch off. but how would i actually toggle it or would the m code toggle it when its called? if i used a mdi command, can it process logic or access machine variables?

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

More
22 Jan 2021 20:23 - 22 Jan 2021 20:26 #196270 by chris@cnc
Hi,
not sure what do you want do with motion but i think you want enter some straight postion or switch on or off somthing.
I do also some off this and here my exmaple.
First button is for touching tool. I use a old style dial indicator and touch always 100mm top of the surface.
Second is for laser switch on and after find X and Y i set position. In my case not zero mounted.
And "Parkpositon" is drive to front or rearside.



Warning: Spoiler!
Attachments:
Last edit: 22 Jan 2021 20:26 by chris@cnc.

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

More
22 Jan 2021 21:00 #196275 by Todd Zuercher
A custom M-code can be pretty much any executable file, but is usually a Bash or Python script. In it's simplest form it may be just a bash script that executes a halrun command to setp the value of a hal input pin. The hal pin will then hold that value until it is changed by something else. (You have to remember though, you can't setp a hal input pin if it is already connected to an output.)

What might be the best approach will depend on the complexity of what you're trying to accomplish.

Unfortunately custom m-codes can't contain g-code, so o-sub logic and machine parameter variables aren't available. But you can do that by remapping an m-code.
The following user(s) said Thank You: tommylight

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

More
22 Jan 2021 21:08 #196278 by rodw
Its not often done, but it is possible to maintain a separate pin inside your screen handler that is set by a screen control or by analog or digital input. Its a long time since I've done it but it does work.

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

More
07 Feb 2021 16:13 #197926 by oddwick
so for what i am trying to do, that is a bit of overkill. basically i just need to hit button on screen and toggle one of the digital outputs on a 7i96. i would think that it would have been simpler than that. i can do it with the mist and flood, but i have two more that need to do the same thing to...

Now, when you say m code can be any executable, that really peaks my interest for other things. BUT, (there's always a but) you say that one cant pass machine parameters to it unless you remap it. could you elaborate?

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

More
07 Feb 2021 20:30 #197950 by rodw
This very old example with help from islander261 is extracted from a python screen handler file for Gmocappy
In this case an analog input is connected to a pin called command-from-file in the handler
Different numeric ranges sent by M67/M68 override the screen controls
So in your case you could connect the screen button to your fan and set it from gcode as well...

Warning: Spoiler!

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

More
09 Feb 2021 00:26 #198105 by andypugh
If you just want to link an onscreen button to a physical IO pin it is just a case of making the control in a PyVCP panel and (in HAL) connecting the pyvcp pin to the io pin.

It would be as simple as

net this-pin pyvcp.button -> hm2_7i96.0.gpio.000.out

Or similar.

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

Time to create page: 0.123 seconds
Powered by Kunena Forum