Society of Robots - Robot Forum

General Misc => Robot Videos => Topic started by: liam.sr on February 12, 2010, 04:40:19 PM

Title: GBOT (Ground Bot) with PID Controller
Post by: liam.sr on February 12, 2010, 04:40:19 PM
Hello,

This is the GBOT with a PID controller using the ZX-40A microcontroller from zbasic.net. ZX-40A is based on the ATMEGA644 AVR chip. Inputs include 2 IR range sensors (GP2D12). Outputs include 2 PWM signals to the Pololu motor driver (VNH2SP30).  

The GBOT maintains a setpoint distance of 10-inches from a target and maintains that distance, no matter what. The control system was originally coded with P-control only, but the GBOT tended to overshoot and oscillate. So then I added PID control.  See video to see P-control vs. PID control.

The SocietyofRobots website was helpful in understanding the range sensors.  Thanks very much.

Ground Bot Tracker with PID Control (http://www.youtube.com/watch?v=uTh2DBWAbPs#)

Here's a closeup view:
(http://)
Title: Re: GBOT (Ground Bot) with PID Controller
Post by: madsci1016 on February 12, 2010, 04:47:14 PM
I would be interested to see a PD vs PID comparison, as many believe the I is not worth the processor power required for simple control systems.
Title: Re: GBOT (Ground Bot) with PID Controller
Post by: liam.sr on February 14, 2010, 10:35:04 PM

The effect of Integral control was very subtle and would not be discernible on video.  The GBOT object was to hold a setpoint of 10 inches.  If I keep moving the target and maintain a 1 inch error from the setpoint, the Proportional compensation is too small to correct the error, and the relative velocity is zero so Derivative control does nothing.  The Integral is needed to correct that 1 inch steady state error.  There is plenty of computational power (i.e., processing speed) on the ZX-40A microcontroller (www.zbasic.net (http://www.zbasic.net)) to handle the I-control, but more importantly, it was worthwhile to understand and implement the I-control for future projects that really need it.  Appreciate the comments.
Title: Re: GBOT (Ground Bot) with PID Controller
Post by: apc3161 on February 28, 2010, 02:52:16 PM
Would you please post your source code for the PID?

I've read about it before, but have never seen any source code where its been implemented. I would love to have yours as a template because it seems to work great.

Awesome job btw.
Title: Re: GBOT (Ground Bot) with PID Controller
Post by: liam.sr on February 28, 2010, 03:29:43 PM

I'd be happy to put together pseudo-code because the source code is proprietary.  The most difficult part of the project was putting together the hardware from scrap and Home Depot parts with minimal tools and space.  The 2nd most difficult part was quelling the IR range sensor noise.  Programming the PID controller was not too difficult.  Tuning Kp, Ki & Kd was difficult, but you see the immediate effects once you download your code and run the bot.  Here's some pseudo-code:

main
   let t = current time
   let x = IR range sensor distance
   let s = setpoint distance
   let ilim = Integral-control limiter

   error = s - x
   vel = x/(t-told)

   P = Kp * error
   I = I + Ki * error * t
   D = Kd * vel

   if I>ilim, then reset I=ilim or zero or other

   K = P + I + D

   motor_throttle(K)
   
   told = t

end main
Title: Re: GBOT (Ground Bot) with PID Controller
Post by: apc3161 on March 03, 2010, 03:21:45 PM
thanks!