Hello everyone,
For my project I need to make a PID position control.
I can use any equipment to demonstrate it.
I was thinking of servo motor position control, where it would maintain the same position and if I would try to move it with fingers it would always go back to its original position that I set.
I need advice on how to demonstrate this and what equipment to get and where to find a similar PID code that I could apply to this.
Thank you.
A hobby servo has a built in controller that, probably, utilizes a PID for position control. It alone will do what you want in terms of holding a position once the position is set. You have no control over the PID coefficients, you send it a position angle an it will go to and hold the the position if possible. You can couple a potentiometer to a motor (DIY servo) and write your own PID or use one of a number of PID libraries to control the motor using the potentiometer for feedback to close the loop. Then you have control over the PID coefficients and can demonstrate their effects on the control output. Choose your motor first and then you can spec a motor controller and power supply. You absolutely cannot power a motor from the Arduino supply, a driver and external power supply are required.
Textbook position control is normally achieved by cascading three controllers
- Current/torque/acceleation
- Speed
- Positioni
I have gotten decent results by using a h-bridge with current control and feeding it a pwm signal from a PID controller using integral calculations and a cycle time of 400 us taking signals from an encoder
Perhaps instead of a forcing the hobby servo to move maybe move something else like a pot ?
You'll need something on the servo to give you feedback however, another pot for instance.
PID between the two pot measurements (... just let the hobby servo do it's own internal control)
Or if you're feeling up to the challenge, stick a camera on a servo and do some image processing, make the servo/camera mount track a laser (lots of examples of this online)
This has to be a very basic project.
Practically to make it out of Arduino beginners kit.
So having the battery and servo motor along with other equipment that comes with the beginners kit, that would be enough?
I don't know what level you're at but PID isn't exactly basic.
You can kludge together something that works following tutorials and so on - but as for understanding it, which I assume is the goal, a knowledge of topics that aren't 'very basic' (depending on your exposure) is required.
As has been pointed out by groundfungus, a servo has it's own internal control system that will be at least proportional (P), but you're not going to convince me that simply hooking up a servo and trying to move it is a demonstration of PID - that is, as a learning exercise 
What level of course is this? More theory or more practical? We can tailor our answers appropriately if we know.
I don't know the beginners kit, does it include two potentiometers?
It includes two potentiometers.
It is more practical. I understand a theory behind PID, just need to apply it. And I decided that the best way to demonstrate position control with PID is through servo motor. Am I wrong in that assumption? Is there any other easier way?
As has been said, plugging in a hobby servo will show position control in action. Who knows if it is full PID, or more than that or leas.
It won't show that you understand PID.
If your course let's you get away with that then congrats.
(Heck, even using arduinos PID library won't show you understand it.... But that's another discussion.)
OK, so... You've got two pots ... So...
Yeah?
If you understand PID, you should be going:
'ah, yes, OK I see what to do next'.
'I need to somehow mechanically connect the servo shaft to one of the pots'
'Hrrrm, that could be tricky with the resources I have on have'
(Is it?)
'I wonder if instead I could hack the signal from the servo directly'
And so on...
vladovu:
For my project I need to make a PID position control.
I can use any equipment to demonstrate it.
Just thought since you understand PID theory you could make a simulation all in code, no need for expensive hardware like wire and breadboard.
Have a running 'position' variable with dynamics (a moving window average filter will do) initialised at 0. Have a set point running 0,0,0 then boom '1' - i.e. a step input.
Program and apply PID then plot results for different parameters.
Also try a moving average with second order dynamics and go for instability.
Can be done in any language, but I'd suggest matlab/simulink as this is all built in...
vladovu:
I understand a theory behind PID, just need to apply it. And I decided that the best way to demonstrate position control with PID is through servo motor. Am I wrong in that assumption? Is there any other easier way?
If the PID integrated into a servo motor is sufficient for your demonstration, you only have to connect a pot and servo to your Arduino - see StarterKit example.
If you want to demonstrate PID parametrization, the servo built-in PID is of little use. Then a geared DC motor and H-bridge were required, and some position (plus supply current...) feedback, before you can start implementing your own configurable PID regulator on the Arduino. Eventually you can find something easier to construct.
What is wrong with connecting the servo shaft to a pot as I suggest?
Run a step input in code, if you're keen send the actual positions over serial to something that can plot them...
The internal PID of the actual servo is just a part of the system dynamics in that case.