Read linear encoder using raspberry pi and simulink
1 view (last 30 days)
Show older comments
Hello there :)
I've already managed to read out acceleration data using the raspberry pi and simulink (created my own driver block for this using c code). The next step is to get a positional reference from the following linear encoder:
The encoder has a linear resolution of 0.25 mm, which generates 40.000 pulses/second when using a maximum speed of 10 m/second (the platform is moved by hand, so it should be less than this in average).
I've tested the encoder using simulink with the given simulink blocks (GPIO read), but it's not possible to get a sample time of 25 us.
Another approach that I've tested: Create a device driver block using c-code and the wiringPi library and interrupts. This works, as I can use a slower sample time in simulink and interrupts are running with a higher sample time on the raspberry pi, but still not fast enough (I'm not able, when moving a vertical platform up and down, to get back to the initial value with what the encoder started).
Do you have any possible solutions for me? I was thinking about using an arduino board just for reading the encoder, because I'm already reading out two acceleration sensors with the raspberry pi and simulink.
Thanks in advance.
Best regards,
Niko
0 Comments
Accepted Answer
Axel
on 26 May 2016
Edited: Axel
on 26 May 2016
Dear Niko,
i had the same problem as you now have. The performance of the Raspberry Pi is just not good enough to manage all the interupts from the encoder signal. I didn't tried it with an arduino, but i think you will run into the same problem with it.
A simple solution is to use just a decoder IC with an SPI interface for analysing the signal which is coming from the encoder. With this solution you dont have to take care about the problem with the high frequencies of the encoder signal. You're just reading the counter from the decoder IC via SPI.
I hope this approach can help you.
Best Regards
Axel
3 Comments
Mihir Pingle
on 10 Jul 2020
Hello I have bought the counter click board that you have mentioned here but how to interface it with simulink?Can you please share the working simulink model if you have one?
More Answers (0)
See Also
Categories
Find more on Raspberry Pi Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!