toggle2nist description
When is-on changes state it always drives both outputs to false. then only one toggle is allowed on in pin per attached truth table.
Looks like i'm not allowed to attach my truth table so I'll try to explain it. If in is false when is-on goes false, off goes true.If in is true when is-on goes true, on goes true.
toggle2nist description.xlsx
Here I'll try to build a table but I see the html screws up the spacing.
toggle2nist
is-on | in | on | off | output |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 | |
0 | 0 | 0 | 1 | note: no change |
0 | 1 | 0 | 2 | note: no change |
1 | 1 | 0 | 0 | |
1 | 0 | 1 | 0 | |
1 | 1 | 1 | 0 | no change |
Please Log in or Create an account to join the conversation.
component toggle2nist "toggle button to nist logic";
description
"""
toggle2nist can be used with a momentary push button connected to a
toggle component to control a device that has seperate on and off inputs
and has an is-on output.
If in changes states via the toggle output
If is-on is true then on is false and off is true.
If is-on is false the on true and off is false.
""";
pin in bit in;
pin in bit is_on;
pin out bit on;
pin out bit off;
variable int old_in;
variable int to_state=0;
function _ nofp;
license "GPL";
;;
FUNCTION(_) {
if (in!=old_in) /* a toggle has occurred */ {
if (is_on) { /* turn OFF if it's on */
on=0;
off=1;
to_state=0;
}
else if (!is_on) { /* turn ON if it's off */
on=1;
off=0;
to_state=1;
}
}
else {
/* reset pins when we see the desired state */
if (to_state==is_on) {
on=0;
off=0;
}
}
old_in=in;
}
toggle2nist code ....
I hope these help.
Giorgio
Please Log in or Create an account to join the conversation.
I think a better description for my understanding would be:
A reset condition occurs whenever "is-on" changes state. When in the reset condition both outputs are false.
If in the reset condition "is-on" is false, a change of state of "in" changes "on" to true.
If in the reset condition "is-on" is true, a change of state of "in" changes "off" to true.
Further changes in output will not occur until unit is reset by change of state of "is-on"
Please Log in or Create an account to join the conversation.
toggle2nist can be used with a momentary push button connected to a
toggle component to control a device that has seperate on and off inputs
and has an is-on output.
If in changes states via the toggle output
If is-on is true then on is false and off is true.
If is-on is false the on true and off is false.
sorry if my comment I was upset a little ... but ... if then else or and not I think is boolean basic math not only c code ... more English is not my language .... so use the code it seems to me better.
Anyhow ... now you are solved the question??
regards
giorgio
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
I found that after pausing, 1st depress of the run/step button, the unit finishes the line of Gcode it is on, pauses, depressing it again would advance 1 step, pressing it again would not step, but make is-on change state then the further presses did nothing. pressing resume/pause at this point does resume properly.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
I found that after pausing, 1st depress of the run/step button, the unit finishes the line of Gcode it is on, pauses, depressing it again would advance 1 step, pressing it again would not step, but make is-on change state then the further presses did nothing. pressing resume/pause at this point does resume properly.
Ok is more clear for me .... because I have the same problem ... (very rarely but I have) ... so the next week I try to understand the problem better.
Reagrds
giorgio
Please Log in or Create an account to join the conversation.
I used: forum.linuxcnc.org/47-hal-examples/13201...-hold-resume-buttons
I found that after pausing, 1st depress of the run/step button, the unit finishes the line of Gcode it is on, pauses, depressing it again would advance 1 step, pressing it again would not step, but make is-on change state then the further presses did nothing. pressing resume/pause at this point does resume properly.
I'll have to take a look at it, the code was provided by someone else and I only use Run and Pause/Resume no single step.
# External Program Pause/Resume Button
net pause-resume-btn and2.3.in0 and2.4.in0 <= hm2_5i20.0.gpio.029.in_not
net pause-on toggle2nist.0.is-on and2.3.in1 <= halui.program.is-paused
net run-status and2.4.in1 <= halui.program.is-running
net pause-sig or2.5.in0 <= and2.3.out
net resume-sig or2.5.in1 <= and2.4.out
net toggle-ok toggle.0.in <= or2.5.out
net togglesig toggle2nist.0.in <= toggle.0.out
net toggleon halui.program.pause <= toggle2nist.0.on
net toggleoff halui.program.resume <= toggle2nist.0.off
JT
Please Log in or Create an account to join the conversation.
Jensor
Please Log in or Create an account to join the conversation.