Custom User Button_Momentary

More
6 years 1 day ago #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.
Code:
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 to join the conversation.

  • BeagleBrainz
  • New Member
  • New Member
More
6 years 1 day ago #187749 by BeagleBrainz
Replied by BeagleBrainz on topic Custom User Button_Momentary
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.

Please Log in to join the conversation.

More
6 years 1 day ago #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.

Please Log in to join the conversation.

  • BeagleBrainz
  • New Member
  • New Member
More
6 years 1 day ago #187775 by BeagleBrainz
Replied by BeagleBrainz on topic Custom User Button_Momentary
So the button output doesn't track the button state ?

Please Log in to join the conversation.

More
6 years 1 day ago #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. ☹️

Please Log in to join the conversation.

  • BeagleBrainz
  • New Member
  • New Member
More
6 years 1 day ago #187784 by BeagleBrainz
Replied by BeagleBrainz on topic Custom User Button_Momentary
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 ?
Code:
BUTTON_n_CODE = %halcmd setp pin 1 / some wait function / halcmd setp pin 0

Please Log in to join the conversation.

More
5 years 11 months ago #187962 by phillc54
I just pushed a toggle command for the custom user buttons:
Code:
BUTTON_n_CODE = toggle-halpin my-hal-pin-name

Please Log in to join the conversation.

Time to create page: 0.114 seconds
Powered by Kunena Forum