Software > Software

PID algorithm

(1/4) > >>

[email protected]:
hey guys m tryin to build a linefollower based on d PID algorithm...
bt for some reason m nt gettin the expected result.....
plzz tell me if d algorithm ive made is wrng or thers some error.....
ive attached d code.....

What do You expect to get and what do You actually get?

[email protected]:
i expect it to follow d line ... but it jus goes straight...
n m using a 5 IR sensor array...

Your integrator doesn't appear to integrate, you don't have a gain for the derivitive. But, to start with I would turn I and D terms off anyhow - they will just make it hard to tune the controller.

With a gain of 1, your correction is going to change the pwm by just a few counts. How much does this actually change the speed of your motors?

For a starting point make the proportional gain big enough that when you sense the line at one extreme of your array the two motor speeds are different by a factor of two at least.

Are you also sure that high/low really corresponds to over the line / off the line?

Your error calculation in your loop function won't work correctly. You calculate the current position in the other function but then use a different uninitialized variable with the same name for working out the error.


[0] Message Index

[#] Next page

Go to full version