How to get accurate RPM using a Raspberry pi board with Simulink?

3 views (last 30 days)
I'm using a Raspberry pi 2 model B with three photo interrupter sensors (https://www.waveshare.com/photo-interrupter-sensor.htm) to get the RPM of three different BLDC motors. I want to use Simulink as control interface. To get the RPM of each motor, I made a basic matlab function, that computes the motor speed when a sensor detects an obstacle (the obstacle is in fact a disk encoder with 20 holes). However, when I run the model and take some measures, the reading is not accurate at all. It does'nt measure the motor's real speed and the simulation is limited on speed (500RPM max). I guess is a problem with timing, but I don't have much experience dealing with timing in Simulink. Any tips or advice would be really appreciate. Thanks!
Below is the block diagram in Simulink:

Answers (1)

MULI
MULI on 23 Sep 2024
Hi Jorge,
I understand you are facing an issue with timing for the RPM measurement in Simulink. To improve accuracy and handle timing problems, consider the following suggestions:
Reduce Sample Time:
  • Simulink uses discrete time steps, so if the sample time is too large, it may miss fast sensor changes.
  • Reduce the step size in your Simulink model to capture state changes more accurately.
Debouncing:
Accumulate State Changes:
  • Instead of calculating RPM after every single state change, try accumulating several state changes and then average the time. This will make the RPM readings more stable.
Implementing these changes can improve the accuracy and reliability of your RPM measurements in Simulink.

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!