Is a PD controller correct choice

dpatel20

Member
Join Date
May 2016
Location
England
Posts
4
Hi -

I know the following isn't about PLCs but I've seen some great info about PID controllers here, so was hoping for some help. I am absolutely beginner in all of this...

I am making a self balancing bicycle (something like this: https://www.youtube.com/watch?v=kEctw-TUCcs) and will use a PID controller to control the PWM to the flywheel motor.

I believe that I need only a PD controller and that I will not help here as there is no steady-state error. Would you agree?

However, one concern I have with the use of D is, since this is a rapidly changing system (the PV - angle - will change quickly due to falling and then the correction by the flywheel), won't this cause a very high PWM (since de/dt will be high)? As I understand it, D causes dampening to reduce overshoot from P. To dampen the effects of the P, I understand I need a suitable D (relatively large)...but then doesn't the derivative also kick in as the error increases? So, the D will now cause a high PWM output, thereby causing potentially some overshoot.


Also, can you give some hints on tuning the PID for this? I have tried the difficult manual method without much success. I'm not sure how to apply some of the other methods I've read about in such a system since measuring variables is very difficult.
 
I agree that PD is typical in controlling such "servo" systems with much inertia. Integral action is more useful for long-term trim in process control like chemical plants. But, I doubt basic feedback control will be sufficient for your process, which is trying to make an unstable system stable via active control.

You most likely will also need "anticipatory" action, termed "feed-forward" or "open-loop control". These are algebraic equations that look at disturbance variables to the system and apply control output before a set-point error is realized. If you add the proper dynamics (lead/lag), they are differential equations. Feedback control is like trying to keep a car in its lane by looking straight down at a lane line, whereas feed-forward would be looking ahead, seeing the lane curve and start turning the wheel a little early. Another example, think of Space X trying to land a tall, skinny booster on a barge in heaving seas. Feed-forward inputs might be approaching waves, tilting rate of the platform, approaching air gusts, ... Even if you have only the controlled variable as an input, there are additions to PID that act similarly. Look at Delta Computer's RMC motion controllers, which have enhanced derivative terms.
 
The first thing you need to understand and account for is, even in the small signal sense, this is a non-linear system. A given set of PID tuning values will only be valid for a very small range of angles. So you either have to scale your PID output based on the angle of the bike or you will have to perform what is referred to as gain scheduling, which means to change the PID gains as the bike angle changes. Ideally I think gain scheduling may be the better plan. However, that will require you to make up a mathematical model of your system so you have something to calculate the gains from.

Also, what are you intending to use to command the motor? Is it a speed command or a torque command? Keep in mind that the restoring force is supplied by the acceleration of the wheel and for any given bike angle there will be a wheel acceleration required counteract the disturbance force due to angle. So ideally the output of your controller will be a torque command, not a velocity command. If it has to be a velocity command you should integrate the output of your controller prior to sending it to the motor controller so the result of the control action is acceleration of the wheel.

I don't think you will be able to get by without the derivative gain. I think this will end up evaluating to an integrating system. Without the derivative gain you won't be able to keep the thing stable as you go past center. Also, having the damping present as the error changes is a good thing, not a bad thing.

You are going to have a hard time tuning this manually. You may ultimately get it to work but it won't be easy.

Keith
 
I believe that I need only a PD controller and that I will not help here as there is no steady-state error. Would you agree?
Yes, agreed.

However, one concern I have with the use of D is, since this is a rapidly changing system (the PV - angle - will change quickly due to falling and then the correction by the flywheel), won't this cause a very high PWM (since de/dt will be high)?
Yes, if PWM is your controller's output. You'll be limited by the max PWM your motor can receive. The bike's angle is a function of gravity, which is second order force (an acceleration). Thus, the more time angle of the bike is increasing (or decreasing) the higher the rate angle change (think speed of angle change).

...but then doesn't the derivative also kick in as the error increases?
D kicks in as the 'rate of error change' increases. D won't act at all on a constant or steady state error regardless of how large.

Also, can you give some hints on tuning the PID for this?
If you can't find anything (I'd be surprised) on a bike controller, look up inverted pendulum. Very similar classic controller.
 
Thanks all for your responses. I guess I've got my work cut out to get this to work!

Keith - I am controlling the voltage using the PWM. Is that incorrect?
 
If it has to be a velocity command you should integrate the output of your controller prior to sending it to the motor controller so the result of the control action is acceleration of the wheel.
Typo. Should be:
differentiate the output of your controller
 
Originally posted by danw:

Typo. Should be:
differentiate the output of your controller

No, I meant integrate.

Functionally, the controller is attempting to generate a restoring FORCE to bring the bike back to vertical. The only way a rotating wheel can generate a force is through acceleration. If the output of the controller is a force (acceleration) command and the motor controller takes a velocity command the user would need to integrate the force/acceleration command to generate the changing velocity command necessary to result in an acceleration.

Originally posted by dpatel20:

Keith - I am controlling the voltage using the PWM. Is that incorrect?

No, that isn't incorrect. You just need to know what it is you are working with so you know how to use it. I assume the motor is a permanent magnet DC motor. So motor velocity is proportional to motor voltage. However, the motor response is a linear first order system of it's own. Said another way, the motor won't instantly achieve the speed that the voltage to the motor would seem to indicate it would. I think your velocity command changes will be small enough per iteration that this won't factor in too much but realize it is there.

Also, as stated above, your control output will likely be a restoring force to bring the bike back to level. Imagine that the bike can magically hang at a given angle that is not vertical but doesn't move. The P portion of your controller will try to generate a restoring force to bring the bike back to vertical. If you use this output directly as the command to the motor you will end up with a fixed motor speed that will not generate a restoring force. If you integrate this command you will end up with a constant acceleration, which will generate a restoring force. Take some time to make sure you understand where your forces are coming from and how they will act on the system. This all assumes there isn't some other quality of the wheel that will generate a restoring force simply due to rotation.

Also, as AGill pointed out, do some research on the inverted pendulum problem. If you ignore swing-up, the bike balancing problem is pretty similar to the inverted pendulum problem.

Keith
 
Last edited:
Keith -

Yes, I recognised the problem was an inverted pendulum (with a reaction wheel) and have taken time to understand the equations of motion, etc. But having read your post I have to say I am now confused!

My understanding: the reaction wheel generates a torque as it accelerates and conservation of momentum means the bike will 'turn' in response - thereby correcting the bike angle. Since, the flywheel torque = motor torque, then controlling the motor torque is key. Torque=KI. In my implementation, I cannot control current but can control voltage. Now, this is where I'm confused - if I understood correctly, as the voltage increases so does the speed (so, there's acceleration). As the reaction wheel accelerates there is torque thereby causing an increase in motor current.

But I am unclear how my controller should be...

In my set up, I am taking the angle of the bike as the PV and use the PID to generate a value for the PWM - with the view that as the voltage increases motor speed increases, it accelerates the reaction wheel and causes torque. My thinking here is that the greater the change in angle, the greater the PWM change - which means greater acceleration - and, hence, generates more corrective torque.

From your post, though, I get the impression this is wrong/over simplified or I'm missing something fundamental?
 
You are going to very quickly outpace my ability to help you with this. There are others on this forum that may be able to take you farther. I can only speak about this in generalities.

I think you are very close with what you are thinking. However, to make sure you are getting the output you want it may help to think of this system in a static sense.

Imagine holding the bike at a 5 degree angle with your hand and turning on your controller. What should the motor do? Based on what I THINK you said in your post the controller would generate an output and the motor would accelerate to a velocity determined by the 5 degree angle and then hold that velocity. What you would feel is a quick push against your hand in the direction to move the bike back to a balanced position and then nothing. In addition, you wouldn't have much control over that pulse magnitude. The pulse strength would be based on the motor transfer function.

What SHOULD happen is the controller generates an output just like before but that output should cause the motor to continuously accelerate until it is at maximum speed (assuming the 5 degree angle remains where it is). All the while it is accelerating you should feel a force pushing the bike against your hand trying to get it to stand up.

Do you see the difference between the two descriptions? A constant force request cannot result in a constant velocity.

Keith
 
That makes sense and I understand the difference between the two now. And I really appreciate the help.

I'll have to think about the scenario you mention.

Thanks.
 

Similar Topics

Hello! If someone can help me with the following problem. I can't change the phone number. Do I really need the interface (AL-232CAB - Programming...
Replies
0
Views
32
I have Woodward Controller EASYGEN-3500XT and Phoenixcontact make IO CAN-CUPLER part no: 2702230, Analog Input card: 2861412, Analog Output Card ...
Replies
0
Views
23
Hello I have a s7-1200 and I would like to read the tags present in this controller with my controllogix controller. The two controllers don't use...
Replies
5
Views
126
Everything was working fine, but suddenly CPU went into error mode, and the ERR and TER LEDs lit up. Now I can't download or connect with the PLC...
Replies
0
Views
39
I am running CCW 13 trying to upload to a micro 820 vers.12 I get an output message OPC server is unable to load project controller. Please help!
Replies
5
Views
227
Back
Top Bottom