Close

Reading Encoders via Simulink

A project log for Remote Control Differential Drive Robot Car

A remote control differential drive robot car where the linear & angular velocities of the are controlled using a PID control system.

ghani-lawalGhani Lawal 02/18/2022 at 23:120 Comments

Tachometer and Encoder Simulink blocks (anything the requires an interrupt) only works in External Mode (Monitor and Tune), the can't be used in Connected I/O Mode

When using a pulses/rotation = 1920 for when the trigger is set to CHANGE, there appears to be aliasing in the calculated speed of the motor when the PWM command rises above 120. i.e PWM=[0:120] -> RPM = [0:100], PWM =[120:200] -> RPM=[0:50]

Therefore, when using Tachometer the trigger will be set to RISING and the pulses/rotation = 960.

Tried using the Encoder block that requires ports of quadrature encoder to be connected to both be connected to interrupt pins.  Appears to work.

***It seems that Simulink is unable to maintain communication with the Arduino when it is receiving messages from more than 2 interrupt pins at once.

Discussions