| Electronics > Projects, Designs, and Technical Stuff |
| DC Motor PI Controller |
| (1/2) > >> |
| maurosmartins:
Hello all, I'm interested in implementing a PI speed controller for a small vehicle, so far I've collected the data for a step response and figured out a first order transfer function approximation for the system: with that information I've calculated the Kp and Ki gains using Ziegler Nichols method. I've simulated it in scilab xcos: with the following results: Now my doubts start (assuming the previous is ok) I'm using a STM32 microcontroller to implement the PI controller, I've set PWM in such a way that it accepts a value of 0 to 1000 units, the control signal of my controller looks nothing to it Do I have to adapt this control signal to my PWM range? can someone clarify what I'm doing wrong and what I should be doing? thanks in advanced, Best regards, Mauro. |
| XaviPacheco:
--- Quote from: maurosmartins on December 29, 2018, 06:32:35 pm --- Do I have to adapt this control signal to my PWM range? --- End quote --- Yes. As you're using a STM32, can you upload your embedded PI controller? I implemented one recently and it worked well. What are you using for feedback? |
| IanB:
--- Quote from: maurosmartins on December 29, 2018, 06:32:35 pm ---Do I have to adapt this control signal to my PWM range? can someone clarify what I'm doing wrong and what I should be doing? --- End quote --- It's conventional when creating feedback control loops to normalize variables. So you would take your speed measurement between zero and the maximum expected speed and scale this to a value between 0 and 1. Then you would take the PWM control range of the motor between no power and full power and scale this also between 0 and 1. Now your controller will operate on dimensionless variables, which will be much more convenient during simulation exercises and also during implementation. A secondary thing to keep in mind when doing speed control of motor vehicles is the concept of "jerk". Sudden changes in power input to the motor can be unpleasant for passengers, so you may wish to modify the control algorithm to smooth out such changes. Of course, if the vehicle has no passengers you don't need to worry so much, but there is still a possibility of excessive wear and tear on the drivetrain. |
| rstofer:
Not withstanding the excellent advice above, I don't think you are very far off. If Figure 4 is supposed to represent voltage to the motor, sure, I expect it to throttle back when the error decreases as it does when the RPM approaches the setpoint. The integral part of the equation doesn't really kick in until some long time relative to the motor spinning up to speed. Note t=0.2 on your various graphs. In fact, draw a vertical at 0.2 on all the graphs. You are starting to get close to the setpoint and the voltage is throttling back. |
| max_torque:
Speed control in the real world for a vehicle becomes a compromise! In the real world, things like gradients, head and tail winds, corners, varying battery voltages, requirements for min/max accel rates etc all play a part. The basic "stready state" gains to get to a set speed are really not the issue! You also need to consider how accurately you want your vehicle to follow the requested speed target? ie +- 1mph, or +- 0.001mph etc. That makes a huge difference! |
| Navigation |
| Message Index |
| Next page |