"PID-style" loop for optimising bi-directional error - Page 1
Forum section: electronics / projects

author: tom66
author_rank: Super Contributor
timestamp: January 19, 2016, 03:12:37 am
content: I'm already well versed with control loop design for simple relationships between variables. For example in a PID controller, typically a step change in error value results in a change in output value.However, for a recent project at my university I'm faced with the output value change either increasing or decreasing for increasing input, and I am trying to maximise the output value. This is similar to a MPPT controller for solar power. However, the difference from a traditional MPPT system is that I need to regulate the value, not simply maximise the value at all times.Essentially, I am investigating a regenerative braking system for a DC motor. A model car of a mass of several kg is accelerated to roughly 20 mph then decelerated by braking the motor. A boost converter circuit (under full software control) steps the low motor voltage up to the higher battery voltage within a small range, in the process this energy extraction causes the motor to decelerate. The parameter of interest is deceleration, I am intending to regulate the deceleration of the car (by means of speed measurement & onboard accelerometer.) This parameter needs to be regulated because attempting to decelerate too rapidly will cause wheel slip and loss of traction, increasing the stopping distance. At the same time, I want to maximise the energy extracted, as a secondary parameter.To achieve a specific deceleration a naive algorithm would simply increase current until the target deceleration was reached. However, this algorithm falls over when the resistance of the motor armature, cables, and transistor losses (via body diodes) are taken into account. If the current is too high, the motor voltage will drop significantly and the power extracted will be small. The motor may decelerate reasonably quickly, but we would fail to extract much energy. A high motor voltage and low current may in fact decelerate the car more reliably, and allow for the extraction of more useful energy to recharge the battery.So, the system design should try to meet deceleration target whilst maximising generated motor power for any given deceleration. The control outputs are current - or more directly the duty cycle of the boost converter - and the inputs are motor voltage, boost converter current, regen current, and motor speed.I would be interested in hearing what other's experiences are with error loops that have such conflicting goal settings...

author: Phoenix
author_rank: Frequent Contributor
timestamp: January 19, 2016, 03:40:52 am
content: Have you got the equations/models that describes your relationships yet - that would be the first place to start. You can then analyse different operating points for stability.I.e a simple model of a DC motor is a voltage behind a series resistance. Greatest power is extracted when the load impedance (boost converter) matches the series resistance.The boost operating point to reach this peak could be calculated from the motor's constant K as a function of speed to get the back EMF voltage - then regulate the boost converter to the duty cycle which gives half the back EMF as the terminal voltage (assuming relatively stiff battery voltage).

author: filssavi
author_rank: Frequent Contributor
timestamp: January 19, 2016, 08:05:27 am
content: Tour problem is in this case a bad choice of variables, PID controllers are inherently lineare, tour problem is not, so you cant just adapt PID algorithm to what you want to do.If wou want to keep your variable, you'll have to resort to non linear contro la (big step up in difficoltà if you ask me)Another thing that might work if youcant do anything else (but it' very very ugly) is if your transfer function is picewise linear, to use multiple PID's one for every linear pice and then select the correct one at the end (extra care is needed to make shure that the controllers don'cause the exit to jerk while switching them out/inEDIT: to complement the last paragraph you could use gain scheduling (wikipedia for more details) and change gain based on uour transfer function

author: Marco
author_rank: Super Contributor
timestamp: January 19, 2016, 11:47:46 am
content: Quote from: tom66 on January 19, 2016, 03:12:37 amAFAICS for a simple permanent magnet DC motor for a given deceleration there is only a single boost current which will achieve it, so nothing to optimize. With a separately excited DC motor the extra variables you have to play with might change that, dunno.

author: penfold
author_rank: Frequent Contributor
timestamp: January 19, 2016, 01:17:31 pm
content: If you can model as many parameters as you can, you can probably add some kind of normalisation block to a PID controller to linearise and correct certain drift of parameters.Te biggest problem would be if the control action reverses and increasing power decreases acceleration, you could use a modified form of bang bang control which monitors the direction of the parameter of interest and can reverse off/on action, to make it effective you would need some kind of online parameter identification method to give yourself a bit of noise immunity.

author: tom66
author_rank: Super Contributor
timestamp: January 19, 2016, 01:54:09 pm
content: Quote from: Marco on January 19, 2016, 11:47:46 amI put together a simple simulation in Python, but I may have got the physics wrong and it seems power is important (because you are removing energy from the system, the car has some KE and the motor is converting it.) But perhaps just using the torque equation to calculate deceleration may be simpler. I am not sure how well that will work though?Quote from: penfold on January 19, 2016, 01:17:31 pmYes the reversal is the main problem, if you short the motor you will extract zero watts but the car will decelerate quickly. And this is what the controller will drift to if the deceleration is no longer achievable (car is travelling too slowly)If I want to decelerate at 2m/s^2 then I can load the motor at around 3 amps or 2.1 amps, as an example, both of those will decelerate roughly the same as the total power regen by the motor is the same. However the 2.1A case produces more useful regen energy that the boost converter can use to recharge the battery as the resistive and diode losses are lower.I am not sure how well a bang-bang controller will work - it may simply cause a rather unpleasant amount of vibration.

author: station240
author_rank: Unknown
timestamp: January 19, 2016, 01:59:42 pm
content: Yes power VxI is key, as it is with MPPT trackers. Consider the calculations the reverse of accelerating the car with the motor in the first place.

author: Marco
author_rank: Super Contributor
timestamp: January 19, 2016, 02:10:29 pm
content: Quote from: tom66 on January 19, 2016, 01:54:09 pmI don't see how that is ever going to be the case, it will always decelerate more at 3 amps.

author: tom66
author_rank: Super Contributor
timestamp: January 19, 2016, 02:51:18 pm
content: Quote from: Marco on January 19, 2016, 02:10:29 pmI am assuming a motor armature resistance of 3 ohms which is based off a small motor for now. The use case motor will have a lower resistance, although ideally this system would be motor independent, inevitably it will be tuned to work with one specific motor. So at 3A the motor produces say 7V @ 3A = 21W, and at 2.1A it produces say ~10V @ 2.1A = 21W. In the 3A case the motor is dissipating an additional 9 watts of energy, which heats up the motor and is not usefully recovered. In the 2.1A case, the motor produces only 4 watts of waste heat.The 3A case does decelerate more because the total dissipated power is slightly higher (30W vs 25W), however, if I want to get the maximum energy out of the motor whilstregulating decelerationthen I will need to reduce current, which works against the power optimisation and deceleration optimisation terms. That's my problem with the PID controller. It will never move away from a goal to find a better goal elsewhere on the curve because it is a strictly linear process.To slow the car down, we need to remove kinetic energy from the car and convert that into electrical energy or heat, so the equation I have used is to work out the car's KE and subtract power*time energy, then recalculate speed from that. Convoluted, yea, but I couldn't think of a motor-independent way of doing it (I'd otherwise need to calculate the torque and deceleration from that which requires careful characterisation of the motor for which I do not have a datasheet.)

author: Siwastaja
author_rank: Super Contributor
timestamp: January 19, 2016, 03:28:14 pm
content: I think you are making this too complicated, or misunderstanding the motor theory. Generally, you would want to control torque (via the brake pedal, for example) for best control of traction, and motor current corresponds to the torque directly. You don't want to control power, because braking at low speeds will produce little power. Motor voltage is proportional to speed, and you want to ignore both speed and voltage, and dedicate your control to torque, and hence, motor current, only.Note that this is the motor current, not battery current.I don't see a point for a PID controller, unless you are doing a self-driving car. Adjust the current setpoint of a simple current-driven PWM controller through the brake pedal and you are done. I have done it this way.

author: Marco
author_rank: Super Contributor
timestamp: January 19, 2016, 04:12:12 pm
content: Quote from: tom66 on January 19, 2016, 02:51:18 pmWhat is your goal exactly? To extract maximum energy with only an upside limit on deceleration? At that point rolling resistance is going to start playing a role as well.If you just want to decelerate at a specific rate then you don't have an optimization problem, it only happens at a single current.

author: tom66
author_rank: Super Contributor
timestamp: January 19, 2016, 04:16:01 pm
content: Quote from: Marco on January 19, 2016, 04:12:12 pmGoals are:* Decelerate at a fixed rate (to be determined by user command on throttle control, "one-pedal" control)* Maximise power extracted at said fixed rateThere are also some constraints that I don't expect will be too difficult, but it is worth mentioning:* Continuous boost current limit ~4A (defined by inductor & diode)* Power will be limited when the battery is approaching 100% SOC

author: Marco
author_rank: Super Contributor
timestamp: January 19, 2016, 04:43:20 pm
content: The maximum power you can extract is the same as the minimum, it simply is what it is.Stop spinning your wheels for a moment

author: Siwastaja
author_rank: Super Contributor
timestamp: January 19, 2016, 05:18:19 pm
content: Inductor?? Diode?? It seems you are going horribly wrong. There is no separate inductor in a motor regen system at all. The motor is the inductor. You need to learn the basics on regen first; then you'll probably see that you are wasting time with your opening question! It seems you have a totally unnecessary power conversion stage which brings extra losses (+ weigh + cost) with no benefit whatsoever, also complicating the control.What type of motor do you use? You say DC; this means a brushed motor. Is it permanent magnet, sepex or series wound? First two are relatively easy to regen with; series wound will be rather problematic.You can find a lot of resources on motor control. Go for that first. You probably won't have any optimization, or even a PID controller at all! It is actually very easy, unless you have a series wound motor.

author: magtux
author_rank: Newbie
timestamp: January 19, 2016, 05:28:23 pm
content: Ha, my first post on the forum. I just got off doing this 2 weeks ago. The others are bang on. You don't need a complex non-linear controller. The motor torque (assuming PMDC) is directly proportional to current. You don't need to look at anything else. Also, I don't understand what you mean by maximizing power, it will be constant there is nothing for you to maximize. I suggest going through the characteristic curves for the motor that you are interested in and having a look, it is quite simple. If you have additional details about the motor, I may be able to let you know more.

author: cdev
author_rank: Super Contributor
timestamp: January 19, 2016, 11:08:04 pm
content: I've been looking for the thread on board suggestions and can't find it.We should have a board section on motion control in all its variations.

author: macboy
author_rank: Super Contributor
timestamp: January 20, 2016, 01:50:49 pm
content: Quote from: Siwastaja on January 19, 2016, 03:28:14 pmI completely agree, and this was my first thought too.... why control the voltage of a step up converter? Just determining the voltage to step up to is going to be very complicated, as it will depend on state of charge of the battery as well as many other variables.

author: rsee
author_rank: Contributor
timestamp: January 22, 2016, 03:42:23 am
content: Quote from: tom66 on January 19, 2016, 04:16:01 pmDefining a physical model of your system will really help, then you can look at what you need to control. The model will make it possible to analyze things like disturbance rejection and what you can do to improve it or if you even need to because maybe the system is stiff enough. Or adding command feed forward or maybe you need an observer. There are a lot of options to reduce the burden on your controller to fix everything with only feedback.To illustrate my point, do you know how the wind speed and wind resistance are going to impact your controller? What about the inertia of the wheels or even momentum of the vehicle? It'll be challenging to design a good controller without having a solid understanding of the physics and governing equations. You'll need the equations anyway if you hope to check your system for stability. That said, you don't need to make it needlessly complex either. If you can make a good assumption that the dynamics of the system respond much faster, maybe that part can be abstracted away (i.e. electrical systems generally respond faster than mechanical systems). For example, if you can make the assumption that you've commanded 1A and you get 1A at the output before the mechanical system responds, that would be ok to abstract away. Finally where your sensors are in your feedback will impact the stability of the system so be careful with that.