Encoder troubles

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Zhmil1789
Posts: 10
http://meble-kuchenne.info.pl
Joined: Sun Mar 01, 2026 6:50 pm
Has thanked: 9 times

Flowcode v10 Encoder troubles

Post 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
Attachments
encoder.fcfx
(13.75 KiB) Downloaded 69 times
Screenshot 2026-05-14 072740.png
Screenshot 2026-05-14 072740.png (202.23 KiB) Viewed 278 times

BenR
Matrix Staff
Posts: 2207
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 605 times
Been thanked: 803 times

Re: Encoder troubles

Post 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 28 times
encoder_edge.fcfx
(17.37 KiB) Downloaded 30 times

Zhmil1789
Posts: 10
Joined: Sun Mar 01, 2026 6:50 pm
Has thanked: 9 times

Re: Encoder troubles

Post 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

BenR
Matrix Staff
Posts: 2207
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 605 times
Been thanked: 803 times

Re: Encoder troubles

Post 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.

medelec35
Valued Contributor
Posts: 2288
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 712 times
Been thanked: 775 times

Re: Encoder troubles

Post by medelec35 »

Hello.
Is your issue that you get a compile error as well as simulation issues?
The Servo component is not currently supported on the PICO for any version of Flowcode.
See this topic

It helps to look for issues if as much detail is give as possible.
For example compiler error, or encoder detection issues etc.
"I have some troubles" is very vague and not at all helpful.

We get you have simulation issues, but its always good to compile first, to check if components are compatible.
There are projects posted that can control a servo using timer interrupts ,that could be used as a get around.
I will see if I can find some links.
Martin

medelec35
Valued Contributor
Posts: 2288
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 712 times
Been thanked: 775 times

Flowcode v10 Re: Encoder troubles

Post by medelec35 »

Attached is controlling a Servo on a PIC using ADC.
It uses the timer interrupt to bit bang a pico pin.
As the interrupt is triggered every 10uS then you should get 151 steps
I have not tested it, but in theory it should work fine.

All you need to do is implement the encoder as per Ben's example.

You won't need to use this method when the servo is fixed.
I don't know if it will be fixed for both V10 & V11 or just V11?
Attachments
Servo PICO V1.2.fcfx
(14.64 KiB) Downloaded 28 times
Martin

Post Reply