Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Robotics Chat


Robotics Chat Specific to discussions about robots and the making of.

Reply
 
Tools
Old 3rd March 2005, 07:55 AM   #1
Default P & PD control algorithms applied to PIC based line foll

Hello

I need to build a line follower, based on PIC16F84A. I was asked to depend on designing the program with P & PD trasnfer functions.

I need to know the algorithms that interpret P & PD transfer functions into flowcharts at least.

I use PIC Basic Pro to write PIC programs, so any flowchart, but right one will be easily done.

Thanks in advance
metal is offline  
Old 4th March 2005, 06:51 PM   #2
Default

Implementing a PID controller in code is fairly easy; you just need to translate the equasions into code.

Error signal e: e = setpoint - measured_location.

Proportional control: P is a constant that you detirmine through testing.

control_output = P*e.

Derivative control: You can aproximate the derivative by calculating the difference between the newest error sample and the previous error sample. derivative(e) = e - previous_e.
D is another constant that you detirmine through testing.

PD controller:
control_output = P*e + D*derivative(e)

Make sure you get the sign correct on P and D. The sign depends on the order you do the subtraction for e and derivative(e). P should cause a push towards the setpoint. D should oppose the direction of motion.
bmcculla is offline  
Old 14th March 2005, 03:13 AM   #3
Default

Hello

Thanks for this reply, I was going to abandon the whole idea, but you gave me a step forward to continue.

I am using PICBasic Pro compiler to write my program and PIC microcontroller, the two rear motors are those types found in toys.

If I want to use three infra-red transceivers as sensors for my robot
"Left - Middle - Right", considering the output of each sensor as logic 1 or logic 0, depending on whether the line exists beneath the sensor or not. Then, I will have eight possible states for these three sensors. Shall I consider these eight outputs the measured location, or not.

The setpoint, what is it practically in my robot, is it a predefined constant, a variable, or one of the measured locations that I will consider to be a reference for instance. I need more explaination please.


Now, when I get the error sample, how can I perform subtraction of the new and the previous value, to obtain derivative control part.

The control output is simply the direction of each rear motor, how can I sum P and D control parts to obtain PD control algorithm.

Thanks
metal is offline  
Old 14th March 2005, 07:42 PM   #4
Default

Using a PID controller with your sensors really doesn't make sense. You need a better position sensor for PID to be useful.

I think you're overcomplicating your solution. With your 3 sensors a simple algoritm should do a decent job of line following.

If the middle sensor is on turn both motors on.
If the Left sensor is on turn the right motor on.
If the Right sensor is on turn the left motor on.
bmcculla is offline  
Old 28th June 2009, 03:14 PM   #5
Default

bmcculla, very good explanation about implementation of Proportional and derivative. Can you please let me know about integral as well? Cheers

Last edited by mtariq85; 28th June 2009 at 03:15 PM.
mtariq85 is offline  
Old 28th June 2009, 03:37 PM   #6
Default

The integral part is only needed if you require precise position. The integral term will cause a small error to be amplified over time and result in zero error position. It is only useful in systems that require accuracy rather than fast response.

Mike.
Pommie is online now  
Old 28th June 2009, 04:48 PM   #7
Default

i mean how do we implement on microcontroller. Like as bmculla said

"Derivative control: You can aproximate the derivative by calculating the difference between the newest error sample and the previous error sample. derivative(e) = e - previous_e.
D is another constant that you detirmine through testing.

PD controller:
control_output = P*e + D*derivative(e)"


but whats about integral? i.e. if i want to implement PID? By the way i am working on inverted pendulum on cart so you think i can get away with PD only?
thanks
mtariq85 is offline  
Old 28th June 2009, 05:16 PM   #8
Default

I'd have thought that a Proportinal and Integral functions would have been more suited...Derivative is usually employed to reduce time lags in slow changing processes...

Least that's what I was taught at college....
__________________
Eccentric millionaire financed by 'er indoors

Last edited by Chippie; 28th June 2009 at 05:16 PM.
Chippie is offline  
Old 1st July 2009, 11:17 PM   #9
Default

Hi,


Another idea is to start with the Laplace form of a PID controller, then do a
bilinear Z transform on the Laplace, then convert that to a difference equation.
You end up with another form suitable for a micro controller.


BTW, here is a flow graph of a typical PID controller...does it really help any?
Attached Thumbnails
P & PD control algorithms applied to PIC based line foll-flowgraph01b.gif  

Last edited by MrAl; 2nd July 2009 at 01:21 AM.
MrAl is offline  
Old 2nd July 2009, 02:47 AM   #10
Default

Embedded.com - PID without a PhD

"PID without a PHD," a very good online explanation of PID control and how to implement it.
chuddleston is offline  
Reply

Tags
algorithms, applied, based, control, foll, line, pic

Thread Tools
Display Modes




All times are GMT. The time now is 02:51 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker