This code enables control of brushed DC motors using two types of driver control schemes: (1) PWM-DIR and (2) IN2-IN2.
Below is a schematic of the overall system for both driver control schemes. The system is a single-input-single-output closed-loop proportional control system. The "plant" subsystem contains the lower-level functions that depend on if the motor driver is manipulated using PWM-DIR logic or IN1-IN2 logic.
PWM-DIR:
For this scheme, the PWM pin on the driver outputs a pulse-width modulated (PWM) voltage signal whose duty cycle varies between 0% and 100%. The Arduino PWM pins are controlled using 8-bit values, so in the Arduino code, a PWM value of 0 corresponds to 0% duty cycle whereas a PWM value of 255 corresponds to 100% duty cycle. The DIR pin receives a Boolean voltage value from the Arduino digital pin. This value changes the direction of the motor.
IN1-IN2:
This scheme is similar to PWM-DIR. Both IN1 and IN2 receive a PWM signal from the Arduino. However, IN1 turns the motor in one direction, whereas IN2 turns the motor in the opposite direction. The Simulink block diagram is designed such that when IN1 is on, IN2 is off, and vice versa.
引用格式
David Bombara (2024). Proportional control of a brushed DC motor in Arduino (https://www.mathworks.com/matlabcentral/fileexchange/104805-proportional-control-of-a-brushed-dc-motor-in-arduino), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
创建方式
R2021b
兼容 R2021b
平台兼容性
Windows macOS Linux标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!