Button Toggle

More
2 years 1 month ago #311037 by Project_Hopeless
Are Toggle and Toggle2inst separate independent functions?  Most of the examples I come across for toggling buttons use both. 

Is there a simple button toggle for a Mesa output using one or the other?

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

More
2 years 1 month ago #311044 by Benb
Replied by Benb on topic Button Toggle
Attached is a Function Block Diagram (FBD) and netlisting for toggling halui machine on/off. Since we are using FBD, signal names are insignificant in this case.  n.1 means net 1 ... etc. Hope this helps
 
#
# Load realtime Components and their counts
loadrt and2         count= 4
loadrt not            count= 4
loadrt or2            count= 2
loadrt toggle       count= 1
#
# Add functions to threads
addf and2.0                   servo-thread 
addf and2.1                   servo-thread 
addf and2.2                   servo-thread 
addf and2.3                   servo-thread 
addf not.0                      servo-thread 
addf not.1                      servo-thread 
addf not.2                      servo-thread 
addf not.3                      servo-thread 
addf or2.0                      servo-thread 
addf or2.1                      servo-thread 
addf toggle.0                 servo-thread 
#
# Set parameters
setp toggle.0.debounce                           5 
#
# Connect hal signals to hal component Pins
net gui.pb                     or2.1.in1  
net halui.mc.is-on         halui.machine.is-on  not.2.in  
net halui.mc.off             and2.3.out  halui.machine.off  
net halui.mc.on             and2.1.out  halui.machine.on  
net mc.pnl.pb                or2.0.in0  
net n.1                          or2.0.out  or2.1.in0  
net n.2                          toggle.0.in  and2.0.in0  and2.3.in1  or2.1.out  
net n.4                          toggle.0.out  not.0.in  
net n.5                          and2.2.in0  not.1.in  not.0.out  
net n.6                          not.3.in  not.2.out  and2.1.in1  
net n.7                          and2.0.in1  not.1.out  
net n.8                          not.3.out  and2.2.in1  
net n.9                          and2.0.out  and2.1.in0  
net n.10                        and2.2.out  and2.3.in0  
net pendant.pb             or2.0.in1  

 

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

More
2 years 1 month ago #311084 by Benb
Replied by Benb on topic Button Toggle
Actually in your case a simple single toggle component will do the trickt, just replace the hal signals input-togl and output-togld with your mesa input&output addresses:

loadrt toggle count= 1
addf toggle.0 servo-thread
setp toggle.0.debounce 5.0

net input-togl toggle.0.in
net output-togld toggle.0.out
The following user(s) said Thank You: tommylight

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

More
2 years 1 month ago - 2 years 1 month ago #311098 by Project_Hopeless
Replied by Project_Hopeless on topic Button Toggle
I got a button to toggle but still not quite understanding how it works.

I followed this guide.

Big John T. Toggle

So my version that works
Code:
loadrt toggle count=1 addf toggle.0 servo-thread net flood-toggle toggle.0.in <= pyvcp.drive-disable net flood-control toggle.0.out => hm2_7i96s.0.ssr.00.out-01


I don't understand how flood-toggle and flood-control are linked.  Is there a simpler way to get button "drive-disable" to toggle ouput hm2_7i96s.0.ssr.00.out-01 ?
Last edit: 2 years 1 month ago by Project_Hopeless.

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

More
2 years 1 month ago #311106 by Benb
Replied by Benb on topic Button Toggle
The LinuxCNC Toggle component replicates a toggling pushbutton functionality. In the case of BJT example. The pyvcp is a push button widget on the screen that used to turn ON and OFF the flood valve.

So, initially the flood is OFF when you press the pyvcp widget the flood will turn ON if you press the same pyvcp widget button the flood will turn OFF and so forth.

In nut shell one push button is used to turn on and off the flood valve.

This is probably the simplest way to turn an output ON/OFF with only one push button (ui or hardwired). If you use hardwired push button add 20 ms debounce.

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

More
2 years 4 weeks ago #311136 by Project_Hopeless
Replied by Project_Hopeless on topic Button Toggle
My quest is more about understanding how the HAL structure works in this case.

I re-wrote the HAL below and changed to "generic-1" and "generic-2" and it still works.
Code:
loadrt toggle count=1 addf toggle.0 servo-thread net generic-1 toggle.0.in <= pyvcp.drive-disable net generic-2 toggle.0.out => hm2_7i96s.0.ssr.00.out-01

I thought I could write it in one line like so.    
Code:
pyvcp.drive-disable => toggle.0.out => hm2_7i96s.0.ssr.00.out-01

Trying to understand why "generic-1" and "generic-2" are necessary.
 

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

Time to create page: 0.361 seconds
Powered by Kunena Forum