Close

Simulink Communication

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/22/2022 at 21:040 Comments

The tachometer block only uses one encoder/interrupt pin, therefore it can't acquire the direction of the wheel.  The fastest way to slow down the wheel from say 120 rpm to 0 rpm in the CW direction is to command the motor to spin as fast as possible in the CCW direction.  This is how my code works in C/C++ and the motor exhibits an underdamped/critically damped response.  However because I can't acquire direction information with the tachometer the system has to command the motor to spin slower, leading to an overdamped response.  In order to accurately model and test the dynamics of the motor and control system I tried using the two pin Encoder Arduino Block.

Unfortunately when using the encoder block it was discovered that Simulink can't maintain communication with the Arduino and change values of the parameters at the same time.  

This coupled with the fact that Interrupts only work in "External IO Mode" make testing the control system in Simulink an arduous task.  Also, when I tested the systems response to a sinusoidal input it lost connection after 30 seconds.

******Ordinarily I would not bother using Simulink to complete this project.  It hasn't added any value in terms of getting better control parameters or acquiring a deeper understanding of the motor dynamics.  However a lot of recruiters in the field I want to join want new hires with experience turning Simulink code into C/C++ code and implementing it onto a system 

Discussions