And on the subject of PID, this ridiculous video makes the concept so=20 much [sarcasm]easier[/sarcasm] to understand... https://www.youtube.com/watch?v=3DrFBlcS2Sg0k Cheers, -Neil On 1/26/2015 10:52 AM, Neil wrote: > So I finally got around to implementing this and it works. I initially > used the Arduino PID library, got it working/tuned and then wrote my own > PID code for a PIC18F. I used integer math, then scaled down to get the > appropriate range. In my final tuning, I used (what I believe is > feed-forward) an offset -- I experimentally determined what constant > output value would just counteract the spring pulling on the servo and > added that to my PID output result. Works pretty nicely. > > Much thanks, > -Neil. > > > On 1/1/2015 7:36 PM, Neil wrote: >> I was continuously spitting out the raw A/D value from the control and >> feedback pots and can see that I have the resolution, and there there is >> some discrepancy between those two. Range is ~113 to ~870 (raw A/D >> values), and the difference is sometimes around 30 when the motor >> "stalls" for a bit . It seems like it wants to correct it, but can't, >> then every so often it gets enough oomph (I expect from the Integral >> component building up) to move, overshoots a bit and then repeats in the >> other direction. >> >> I am seeing (on the continuous serial dump) the LSB (in decimal) >> toggling by one digit, so I don't think it's noise (since the >> discrepancy is ~30). But I can add some IIR filtering easily anyway. >> >> Cheers, >> -Neil. >> >> >> >> On 1/1/2015 4:42 PM, Ruben J=F6nsson wrote: >>>> *Basic* tuning (ie: no oscillation, chatter and getting pretty close t= o >>>> setpoint) with the Ziegler-Nichols method was relatively easy, but it >>>> seems a bit "sticky" -- ie: very small changes to my control pot don't >>>> immediately take effect, and continuing to change the pot a bit more >>>> suddenly makes it "jump" to the correct position. >>> Could it be that you have too low resolution so very small changes to t= he pot >>> isn't registered? When you move it a bit more, you will get a step chan= ge. >>> >>> >>>> Also, just sitting >>>> with a fixed setpoint, it will move a bit every once in a while (like >>>> 5-10 seconds). >>> Could be noise in the signal from the motor position and/or pot. You no= rmally >>> will get one to a couple of bits jitter from the A/D converter if your = analog >>> circuit isn't well filtered and separated from the digital circuit. Per= haps >>> digital filtering could help. >>> >>> /Ruben --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .