Count Pulses from Hall Effect Sensor

Hi. The original discussion started here.

As the conversation went on, we decided that the package was not usable, and decided to count pulses from the sensor with this timed-counter node.

Now, I am trying to count the pulses, and update a text on the UI according to that. If timed counter counts no pulses, it will say "Bozuk" (it means faulty), when there are more than x amount of pulses, it will say "Normal", before the button press, and after 2nd press, it must show "-", since the button will also start the pump. How can I do this? I tried something like this:

[{"id":"14dab897.d647d7","type":"ui_switch","z":"4cdd06f6.faf528","name":"","label":"Başlat/Durdur","tooltip":"","group":"843bc78a.c5b078","order":7,"width":5,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"mi-power_settings_new ","oncolor":"yellow","offvalue":"false","offvalueType":"bool","officon":"mi-power_settings_new ","offcolor":"black","x":560,"y":520,"wires":[["e116c5af.573e28","7791562c.bacb98","29119598.39809a","6e4f0412.b1ff3c","5880552a.38fb4c"]]},{"id":"6e4f0412.b1ff3c","type":"function","z":"4cdd06f6.faf528","name":"","func":"var b0 = msg.payload;\n\nif(b0 === false)\n{\n    msg.payload = \"-\";\n}\nelse if(b0 === true)\n{\n    msg.payload = null;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":560,"wires":[["e1cb428a.02369"]]},{"id":"e1cb428a.02369","type":"ui_text","z":"4cdd06f6.faf528","group":"843bc78a.c5b078","order":12,"width":3,"height":1,"name":"","label":"Motor:","format":"{{msg.payload}}","layout":"row-center","x":850,"y":680,"wires":[]},{"id":"1f23bddb.087d42","type":"debug","z":"4cdd06f6.faf528","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":760,"wires":[]},{"id":"8dd3e3e9.58d9a","type":"function","z":"4cdd06f6.faf528","name":"","func":"var m0 = msg.count;\n\nif(m0 > 1)\n{\n    msg.payload = \"Normal\"\n}\nelse if(m0 <= 1)\n{\n    msg.payload = \"Bozuk\";\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":680,"wires":[["e1cb428a.02369","1f23bddb.087d42"]]},{"id":"d5ebaf98.67cc4","type":"debug","z":"4cdd06f6.faf528","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":500,"y":760,"wires":[]},{"id":"5880552a.38fb4c","type":"timed-counter","z":"4cdd06f6.faf528","name":"","timelimit":"10","timeunit":"1000","withhold":true,"fixedtimeout":false,"pertopic":false,"x":300,"y":680,"wires":[["8dd3e3e9.58d9a","d5ebaf98.67cc4"]]},{"id":"d057eca6.64926","type":"rpi-gpio in","z":"4cdd06f6.faf528","name":"","pin":"37","intype":"tri","debounce":"25","read":false,"x":70,"y":680,"wires":[["5880552a.38fb4c"]]},{"id":"843bc78a.c5b078","type":"ui_group","z":"","name":"logo","tab":"43cae785.290cd8","order":3,"disp":false,"width":8,"collapse":false},{"id":"43cae785.290cd8","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

Still can't get it working. Can someone help me?

How much of what you have shown in the flow is working, and which bits are not working?

As far as I understand, this entire flow works only once when I press the button. It should work at all times in the way I described above.

I deleted this part for now, because of the other problem I had. I'll import it back, and reply to you again after the other one.

The status is "-", when the switch is off. This part is working.

The status becomes "Bozuk" (faulty), when I don't move the magnets inside of it. This part is working. It only works at the start, for once.

The status becomes "Normal", when I move the magnets inside of it. This part is working. It gets stuck. It doesn't go back to "Bozuk", when I stop moving the magnets. It should keep counting, then change the status according to that, but it is not working like that.

Edit: It is also saying "Bozuk" (faulty), when the switch is off. I need to get rid of this too. It should only be "-", when the switch is off.

Edit 2: I tried this node between the switch and the timed-counter:

[{"id":"19745fad.345a3","type":"trigger","z":"4cdd06f6.faf528","name":"","op1":"1","op2":"msg.count == 0;","op1type":"num","op2type":"env","duration":"3","extend":false,"units":"s","reset":"0","bytopic":"all","topic":"topic","outputs":1,"x":140,"y":840,"wires":[["1c7132.e0936ece","e1398380.8a45a"]]}]

Nothing changed. Stuck in "Normal" state.

Can someone help me fix this?

Personally I would use a Trigger node for detecting moving or stationary. Configure it to send "Normal", then wait for maybe 1 second and then send "Bozuk". Set Extend Delay so that provided pulses keep coming in then it does not send "Bozuk" until the pulses stop. On startup use an Inject node to send "Bozuk" to the display directly so that it is initialised correctly.
If you like that idea get that bit going then we can think about the button.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.