View previous topic :: View next topic |
Author |
Message |
planix
Joined: 20 May 2006 Posts: 5
|
interesting question about pid control |
Posted: Sun Aug 06, 2006 6:09 am |
|
|
I have been there for a long time and i have learned a lot of things with this forum. firstly thanks all for every thing you post.
Here comes my question.
I'm trying to improme my line following robot i have been using 6 line sensors (3 left from the orgin and 3 right) and 2 motors( left and right) with 2 sensors(actually they are small dc motors connected via belts to drive motors. and i have been reading adc from them. )
I have studied pid algors. and but all of those examples and codes are read from only 1 sensor.
the big question is how can i control the robots drive motors with 6 sensors and 2 motor speed sensors using pid or pi or something like that?
thanks again for every thing.
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sun Aug 06, 2006 9:35 am |
|
|
At 'heart', this is the question of 'how do I do multiple things on a single processor'. The 'key' normally for most embedded applications, is a 'state machine', where you loop round some process 'flow', and each time round the loop, at some critical point you branch to do different things. Now without knowing the timings involved for your PID, and for the sensors, it is hard togive a real answer, but instead I'll try to draw a 'structure' layout, of what has to happen:
Code: |
loop: Wait here to synchronise to the PWM
Read the selected ADC
Select the next ADC
(now you read, before you select, to avoid having to wait for the
ADC conversion, which will carry on while you go round the loop).
If ADC read, was for 'position', update the required movement
fed to the corresponding PID algorithm.
If instead ADC read, was for a servo, update it's PID coefficients,
and calculate new required PWM values.
Go back to 'loop'.
|
Now the 'state' in this version, is the read ADC channel, which you change each time round the loop, so you read the six position sensors, and then the two servo sensors in turn. In each loop you only perform one set of arithmetic, corresponding to which sensor was read (you will need to be careful, and use fast (int) arithmetic, to keep the loop time short).
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
planix
Joined: 20 May 2006 Posts: 5
|
|
Posted: Sun Aug 06, 2006 10:14 am |
|
|
thank you for your answer this outline will really help me
thankx again. |
|
![](templates/subSilver/images/spacer.gif) |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
Re: interesting question about pid control |
Posted: Sun Aug 06, 2006 6:02 pm |
|
|
planix wrote: | ...with 2 sensors(actually they are small dc motors connected via belts to drive motors. and i have been reading adc from them. ) |
Planix,
Can you shed some more light on these sensors? Do you somehow use the DC motors as RVDT? Do you use them as shaft position feedback (instead of an encoder)?
Thanks!
~K |
|
![](templates/subSilver/images/spacer.gif) |
planix
Joined: 20 May 2006 Posts: 5
|
|
Posted: Sat Aug 12, 2006 1:55 am |
|
|
two of these dc motors connected to other driver motors via shaft/drive belt. as you know dc motors generate voltage if you turn them and the 2 small motors are turned by driver motors i mean the motors which moves robot.
the light sensors are fairchild' s qrd1114
i have worked after i asked my question and i am nearly solve my problem 6 light sensors are lowerd down to 1 with some kind of alg. i will post my full code and isis simulations when i finish my project ;) |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Sat Aug 12, 2006 6:43 pm |
|
|
This looks to me like three PID loops. Each motor would have a loop, with an input of the desired ground speed, feedback from the motor sensor, and a PWM output to the motor. Then the third PID loop would have the six light sensors as feedback and the difference of motor ground speeds as output. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
|