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
Encoder troubles
-
Zhmil1789
- Posts: 8
- http://meble-kuchenne.info.pl
- Joined: Sun Mar 01, 2026 6:50 pm
- Has thanked: 7 times
Encoder troubles
- Attachments
-
- encoder.fcfx
- (13.75 KiB) Downloaded 27 times
-
- Screenshot 2026-05-14 072740.png (202.23 KiB) Viewed 97 times
-
BenR
- Matrix Staff
- Posts: 2204
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 603 times
- Been thanked: 800 times
Re: Encoder troubles
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: Encoder troubles
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
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
-
BenR
- Matrix Staff
- Posts: 2204
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 603 times
- Been thanked: 800 times
Re: Encoder troubles
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.
Maybe for now just try connecting the servo angle to the encoder count and see how you get on there.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel