Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

pic 16f917 with PID?

Status
Not open for further replies.

alexsoad

New Member
is pic16f917 a good choise for implementing a PID regulator for a Line Follower Robot?

thank you very much!
 
You can implement PID in most PIC's with ADC feedback. Are u looking for a hardware PID?
 
I did one a couple of months back...but it was my 1st go at it. Turned out to be a PID with a 2nd order differential to make things work as desired.

I was operating at a max freq of about 50hz. Using a 1ms ISR routine to alter the PWM based on the PID calc.

What I found was in order to reduce oscillations caused by the integral accelerating the solution to the tgt I needed a 2nd order differential to look ahead and prevent overshoot.

Here are the oscilloscope traces showing the PWM PID control signal and the results of the control signal

https://img268.imageshack.us/f/surgecontrol1.png/

Further I add a Time dimension to the feedback loop (call it PIDt).
In order to achieve the desired control sensitivity I decrease the number of updates of the PWM signal down to about 25% of maximum to reduce the rate of corrections based on the expected latency of the valve being controlled.

So as the target error decreases so does the update of the PWM corrections. Eventually this trends toward the steady state solution with no more PWM updates being required for a given set of parameters - a flat line of control with no oscillations.

Therefore for a big error signal PWM corrections happen every period. For a small error PWM corrections happen every 4 periods.

Lastly I added a tgt buffer zone equivalent to the LSB of the 8 bit ADC I used. So if the signal is within 1 LSB of the tgt, no corrections are attempted. In my case 1 LSB amounted to 0.2psi. This achieves a potential steady state solution that is within tolerance and eliminates small oscillations about the tgt.

I used a 16f886.
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top