I have a 400 PPR encoder that i have working with a ky-040 encoder node. Its the only node i have been able to get reliable readings from. But the only down side is when the encoder stops the CW/CCW direction output remains active. I’ve tried lots of things and now trying to find a way to use the counter to stop the outputs when stationary. any suggestions?
The background on what im doing is using an encoder to read the rotation direction only. I’m not interested in counting revolutions or angles. it rotates slow so cheaper encoders work with other nodes but miss the small movements.
the machine can eventually rotate indefinitely in any direction so a pot will not work.
It makes sense the way the encoder works. It has no way to know how long to wait between updates before deciding encoder is stopped, which is what you are now trying to do by saying we must have stopped if we have not updated in the last second (delay-T).
What you have above looks like it should work (assuming puls… is pulse-on-change). Does it not turn flip-flop back on if you move encoder in the same direction it was moving before? Is there some other problem with it?
If it is not turning flip-flop back on after a time with no movement, you might be able to use ‘gate’ nodes so you can use the pulse-on-change output to set the appropriate flip-flop:
If you want to detect “stopped” in less than one second, just change delay-T to a number between 0 and 1 (i.e. 0.5 for 1/2 second).
If this doesn’t seem to work consistently, try adding a defer node between encoder and pulse-on-change. That will make sure appropriate gate is enabled before pulse is sent to it. (You could instead put defer between pulse-on-change and gate, but then you would need 2 defer nodes.)
Thanks again gweimer
the gate node worked much better (without the defer)
the problem now is the over sensitivity of the encoder…
regardless of how slow and careful its rotated there is at least a single pulse (bounce) in the opposite direction when it stops.
I must have done something right as the encoder now works with other encoder nodes so have been able to get a reasonable result with this sketch. i will try a 100PPR encoder at some stage, but for now this works