Custom User Button_Momentary

More
30 Oct 2020 00:27 #187740 by EW_CNC
Hi,
For the downdraft on my plasma table I would like to have one custom user button to open all vent air valves at once.
I have it set up using two custom user buttons. One to set signal true and one button to set signal false.
BUTTON_10_IMAGE          = 
BUTTON_14_NAME           = Open\Valve
BUTTON_14_CODE           = %halcmd sets button-on 1
BUTTON_10_IMAGE          = 
BUTTON_15_NAME           = Close\Valve
BUTTON_15_CODE           = %halcmd sets button-on 0
Is it possible to use a custom user button as a momentary true button as in PyVCP "A button is used to control a BIT pin. The pin will be set True when the button is pressed and held down, and will be set False when the button is released"? Or as a checkbutton to control a hal pin? Or is there a way to do it in hal?
Earl W

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

More
30 Oct 2020 03:01 - 30 Oct 2020 03:01 #187749 by BeagleBrainz
Ok you have 2 buttons lets call them On & Off and output called Vent.

You press & release On and Vent goes true.

You then press & release Off and Vent goes false.

But if you press either button twice in a row there is no change to Vent ?

This might be what you are looking for.
linuxcnc.org/docs/2.8/html/man/man9/flipflop.9.html

I'm not exactly sure of the implementation in HAL.
Last edit: 30 Oct 2020 03:01 by BeagleBrainz.

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

More
30 Oct 2020 10:22 #187771 by phillc54
The problem is that once the pin is set then you need to reset it, this may be a good reason to implement a "toggle" as a special function code. It shouldn't be too difficult.
The following user(s) said Thank You: BeagleBrainz

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

More
30 Oct 2020 10:52 #187775 by BeagleBrainz
So the button output doesn't track the button state ?

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

More
30 Oct 2020 11:07 #187780 by phillc54
They are pretty basic at the moment, so if you use halcmd setp pin 1 to set a pin then that pin won't be reset until you do another halcmd setp pin 0. I didn't envisage toggling bit pins when I originally did it. ☹️
The following user(s) said Thank You: BeagleBrainz

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

More
30 Oct 2020 11:35 - 30 Oct 2020 11:57 #187784 by BeagleBrainz
Even a "one shot" function could work. Similar to the HAL component. Pressing the button produces a pulse of a certain length ?

Could the command code run a script that sets the pin, waits a 1ms, then resets the pin ? Or multiple commands ?

I guess I should learn some python one day.

Or multiple commands ?
BUTTON_n_CODE = %halcmd setp pin 1  / some wait function / halcmd setp pin 0
Last edit: 30 Oct 2020 11:57 by BeagleBrainz.

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

More
01 Nov 2020 01:44 #187962 by phillc54
I just pushed a toggle command for the custom user buttons:
BUTTON_n_CODE = toggle-halpin  my-hal-pin-name
The following user(s) said Thank You: EW_CNC, snowgoer540, BeagleBrainz

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

Moderators: snowgoer540
Time to create page: 0.130 seconds
Powered by Kunena Forum