I am quite new in ladder logic - trying to learn something about. However, now I got stuck on implementating of rotary encoder (something like KY-040).
I made this:
Where IN3 and IN4 contacts are connected to DT and CLK pins of encoder, OUT variable is interger type.
If I understood how rotary encoders works correctly, my program should detect change (rising or falling edge) on IN3 or IN4 contacts, then add or substract value 1 depending on which contact detected change first, and immediately block other pin detection until both contacts has the same values again to avoid negating value by opposite contact signal.
Problem is, that this works only if I turn encoder shaft really slow. When I turn it faster, output value starts to behave messy, substracts value instead of adding and so on. I thought it might be because scanning time is set to 50ms and it is too slow, but problem remains even after changing it to 5ms.
Did anyone successfully tried to implement this device into Open PLC ladder logic program? Or can anyone help me with it?