Speed control with DC Motor w/ Encoders PID Control L298N Driver
70 次查看(过去 30 天)
显示 更早的评论
I am trying to use Simulink/MATLAB to create a PID control with feedback to control the speed of a DC Motor. The DC Motor has two encoder outputs which is what's confusing me (Motor Link). I know that the encoders are for feedback but I'm uncertain about where these pins go. I'm also using an L298N Driver for PWM. I also have an Arduino Mega, which I'm not entirely sure if I'll need? I think I might need the Mega for the encoders but I'm hoping to only use one arduino component so are both an L298N and Mega necessary? Or does having both make the speed control much easier? How might the block diagram look in Simulink for the PID control with feedback from the encoders? Any resources and tips would be appreciated.
Thanks,
Dalton
回答(3 个)
Akshay Khadse
2019-3-28
编辑:Akshay Khadse
2019-3-28
Hi Dalton,
As per my knowledge, this motor contains a two channel quadrature encoder which has four connectors and the remaining two connectors are for the motor supply. In the following image, pins Motor+ and Motor- are for connecting motor supply voltage source while Sensor Voltage + and Ground is for connecting sensor input voltage. However, please note that the Motor- and Ground should not be connected together. The output can be sensed from pins Channel A and Channel B. This output will be in form of pulses.
In your Arduino program, you must maintain a counter variable because such incremental encoders don't provide an absolute value of angle or speed. You will need to poll these two channels and decide wether to increment or decrement the count. The calibration of this count would depend on the specifications of the encoder. Please read the following pages for more information on operation of encoders:
You can use a HCTL 2022 decoder IC to avoid this procedure and directly read the angle values. This will save you computational overhead but make the circuit more involved. Please refer the image attached to this post for circuit diagram from one of my projects.
Regarding the hardware requirements, you will need L298N to drive the motor and an Arduino Mega to implement a PID controller. Optionally, you may want to use an appropriate decoder IC.
0 个评论
Pradeep KS
2019-4-10
Hi Dalton,
In 19a release, there is a new block in Simulink Arduino support package to handle the Interrupts on the Arduino pins. Refer https://www.mathworks.com/help/supportpkg/arduino/ref/externalinterrupt.html for more details on how block works.
A reference example is given in the below link:
For your case, you need to connect Encoder Channel A and Channel B to 2 digital input pins on the Arduino hardware which supports Interrupt mode.
In the External Interrupt block, select the Digital input pin number and the triggerring mode (Rising or Falling). Connect the Interrupt block output to a function call subsytem which increments the counter every time you get a pulse from the Encoder.
0 个评论
Benedikt Müller
2021-6-24
Did you solved the project and got the motor to work? Just asking because I have a similiar project ongoing for my university
0 个评论
社区
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!