Page 1 of 1

Encoder troubles

Posted: Thu May 14, 2026 12:32 pm
by Zhmil1789
Hello,

I tried to control a servo with an encoder, and I have some troubles. I cannot find where I made a mistake. I will be thankful if someone checks my project.

Best regards,
Zhmil1789

Re: Encoder troubles

Posted: Thu May 14, 2026 3:27 pm
by BenR
Hello,

You need to either poll the encoder at a high rate or you need to enable edge driven interrupts to catch when the encoder moves.

Here's an example of each method, the edge driven approach is much more suitable if you can use that as the interrupt only fires when the encoder moves.

encoder_timer.fcfx
(16.56 KiB) Downloaded 21 times
encoder_edge.fcfx
(17.37 KiB) Downloaded 23 times

Re: Encoder troubles

Posted: Fri May 15, 2026 5:59 am
by Zhmil1789
Hello Ben,

Thank you for the examples. Unfortunately neither encoder_timer.fcfx nor encoder_edge.fcfx work on my Flowcode 10. The servo still does not move in simulation.

Is there anything different I need to do in Flowcode 10 to make the encoder work with a servo?

Best regards,
Zhmil1789

Re: Encoder troubles

Posted: Fri May 15, 2026 9:55 am
by BenR
Your maths to do the servo motion from the encoder count looks a little off, what are you trying to acheive there?

Maybe for now just try connecting the servo angle to the encoder count and see how you get on there.