toggle2nist description

More
08 Feb 2017 15:14 - 09 Feb 2017 22:59 #87570 by jensor
jensor created the topic: toggle2nist description
I don't know why the man page for toggle2nist does not give a complete description for understanding toggle2nist. I ran some tests with it to find out exactly how it behaves.
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-oninonoffoutput
00000
0101
0001note: no change
0102note: no change
1100
1010
1110no change
Last Edit: 09 Feb 2017 22:59 by andypugh. Reason: trying to incorporate truth table
More
08 Feb 2017 22:17 #87611 by k-1
k-1 replied the topic: toggle2nist description
at these link ...

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
More
09 Feb 2017 13:44 - 09 Feb 2017 13:45 #87658 by jensor
jensor replied the topic: toggle2nist description
Thank you for your comments, Giorgio however I am not skilled in the programming language in your response.
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"
Last Edit: 09 Feb 2017 13:45 by jensor.
More
09 Feb 2017 15:43 - 09 Feb 2017 15:53 #87666 by k-1
k-1 replied the topic: toggle2nist 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.


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
Last Edit: 09 Feb 2017 15:53 by k-1.
More
09 Feb 2017 21:12 #87705 by BigJohnT
BigJohnT replied the topic: toggle2nist description
More
09 Feb 2017 22:58 #87723 by jensor
jensor replied the topic: toggle2nist description
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.
More
09 Feb 2017 23:00 #87724 by andypugh
andypugh replied the topic: toggle2nist description
I tried to put in tags for you, but they don't seem to work.
More
10 Feb 2017 10:40 #87753 by k-1
k-1 replied the topic: toggle2nist description

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
More
10 Feb 2017 21:15 #87779 by BigJohnT
BigJohnT replied the topic: toggle2nist description

jensor wrote: 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
More
11 Feb 2017 00:34 #87787 by jensor
jensor replied the topic: toggle2nist description
The file you posted is identical to what I have and for Run/Pause works flawlessly. However the Run/Step function sometimes works perfectly, other times gets hokey and you have to hit the Run/Pause alternately with Run/Step to get it to step.

Jensor


File Attachment:

File Name: jog-run-pause.hal.txt
File Size:5 KB
Attachments:
Time to create page: 0.095 seconds
Powered by Kunena Forum