pyVCP button to control generic digital out

More
5 years 9 months ago #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
5 years 9 months ago #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
5 years 9 months ago - 5 years 9 months ago #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: 5 years 9 months ago by Todd Zuercher.

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

More
5 years 9 months ago #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?

Todd Zuercher wrote: 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
5 years 9 months ago - 5 years 9 months ago #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!
Last edit: 5 years 9 months ago by chris@cnc.

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

More
5 years 9 months ago #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.

Time to create page: 0.215 seconds
Powered by Kunena Forum