PID Control of DC motors using Simulink hardware support for arduino

4 views (last 30 days)
I'm trying to create a Control System using Symulink that helps syncronizing the motion of two DC motors using Simulink hardware support for arduino from MATLAB R2019a. I used two encoder wheels and two optointerruptes, whose signal I expected to process in order to get the rotation angle of the motors.
The subsystems MOTOR are configured as follows:
The INX pins correspond to IN pins of an L293D H bridge. The pins ENA, ENB are the enable pins accordingly. The ENCA, ENCB pins read the pulsating signal from the optointerrupters. By counting the number of pull-ups or pull-downs of the pulsating signal of the optointerrupters, I expected to characterize the motion of the motors as a function of time.
My idea was to set the motion of a motor to fixed velocity using a fixed PWM argument for the enB input in MOTORB. Then, using a PI control, I expected to adjust the motion of the MOTORA to that of the MOTORB. My model is included in the figure. Both counters are set to trigger at both edges.
In the socpes I was able to see the results of my model when run in extenal mode on an arduino 2560 R3, using FixedStepDiscrete solver with automatic step:
Apparently, the control system works, because the two outputs of the COUNTA and COUNTB are very similar. However, when I monitor the PWM input for the MOTORA, I get a completelly different result. The motors do not behave nearly similar. In fact, whereas the MOTORB behaves like shown in actuallity, the MOTORA performs a chaotic motion that in no way resembles the motion depicted above. How is that possible? How can I modify my model to accuratelly measure the motion of the motor using the optointerrupters? How can I modify the model in order to obtain a result similar to that of the picture above but in the real life?

Answers (0)

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!