Go Down

### Topic: Arduino PID Library (Read 107055 times)previous topic - next topic

#### Datapolo

#60
##### Oct 16, 2009, 12:57 pm
Sounds brill! Look forward to using it.

Mike

#### pacofvf

#61
##### Oct 25, 2009, 12:50 amLast Edit: Oct 25, 2009, 03:13 am by pacofvf Reason: 1
Before everything... It's just an advice,I don't want to look pretentious...
I don't understand why you have problems making your PID faster....maybe because I've never used it . Sometimes the measurement is not at the same frequency than the Computing frequency, maybe you can't achieve the maximum speed because you are not using timer interrupts, and almost every PID ready-to-use software made by big companies uses timer interrupts. When you use timer interrupts the only limit is the clock speed and the timer's pre-escalator, ahh one last thing, the common acronyms are:
Set Point, (SP)
input: PV (Present Value)
output: MV(manipulated variable)
error
dt : (delta t) that's what you call calc period
Kp
Ki,Ti (I prefer Ki than Ti, where Ki=Kp/Ti)
Kd,Td (same with Kd, Kd=Kp*Td)

EDIT: PV: process variable

#### retrolefty

#62
##### Oct 25, 2009, 01:50 am
Quote
input: PV (Present Value)

I was taught that PV = Process Variable

Lefty

#63
##### Oct 25, 2009, 02:44 am
Quote
I was taught that PV = Process Variable

Ditto.

#### pacofvf

#64
##### Oct 25, 2009, 03:11 am
Of course you are right, PV is process variable,  there is a present value, but that is not it.   LOL

#### br3ttb

#65
##### Oct 26, 2009, 07:23 pm
Quote
I don't understand why you have problems making your PID faster

the issue isn't with when the computation occurs, it's with how long the computation takes when it's excecuted.  the computation fires at whatever interval the user desires (set by the SetSampleTime function)  the interrupt idea is interesting.  I'll have to look into that.

what I was talking about when I said "faster" was the computation itself.  the fewer processor cycles it takes to perform its calculation, the more time the arduino has to do other things.  and, just as a point of pride, I want the pid to be as efficient as possible.

as far as abbreviations, some are certainly more common than others, but they do vary from manufacturer to manufacturer.  off the top of my head:
Process Variable: PV, ME
SetPoint: SP, SV
Controller Output: CO,  CV, OUT, OT, OP.

dt is commonly used.  I settled on SampleTime (which is also commonly used) because I felt it was easier to understand.

at any rate, give the library a shot!  I'd love to hear any more suggestions you might have.

Brett

#### pacofvf

#66
##### Oct 26, 2009, 11:56 pm
I've just looked at the source, and it looks very well, I can see that you have done something to prevent windup, I also preffer the Ideal form of the PID algorithm, everything is done efficiently (computing time-speaking), maybe millis() is taking too much, I don't see where else the code could be made more efficient, I will try to do it with interrupts and I will let you know if it works better, also I'm going to implement a kalman filter, so maybe that will be my first contribution to the arduino project, for those who don't know what I'm talking about, a kalman filter must be used with accelerometers and many other sensors..

#### SteNull

#67
##### Feb 05, 2010, 09:02 am
Thanx for an splendid lib, just the interrupt part missing for me to be 100% satisfied  8-) and maybe a Tracking value/Tracking active.

By the way PV is often referred as "Process Value" in engineering terms

#### SteNull

#68
##### Feb 18, 2010, 09:13 am
oh! and i wanna ad one more thing to my wish list, Master/Slave config for cascade regulation.

#### Flotec

#69
##### Feb 22, 2010, 06:25 pm
There is no problem to run it in master slave configuration. Just run it twice with different inputs. We have used this successfully.

#### SteNull

#70
##### Feb 22, 2010, 08:20 pm
ok nice. I had some ideas that master needed feedback from slave.

#### jeff_witz

#71
##### Feb 24, 2010, 01:44 pm
Last year I have trained a student during 3 month in order to make a complex regulation, for this purpose we have developed and implemented the Broïda method that allows to identity PID coefficient by measuring the response of the open loop system to square by measuring an amplitude and two time (at 0.28*deltaA* and 0.40*deltaA) it gives parameters depending of the kind of PID you want (with or without overshoot). This method seems to work up to the 6th order.
What do you think about coding this into the arduino platform ?
I think it can works on a lot of cases !

#### LanceKifer

#72
##### Jun 10, 2010, 05:05 pm
I am having trouble getting this PID to work with my application.

I am doing a research project where I am required to have a trough fill with water to sub - millimeter accuracy. I have determined the best way for me to do this is to use a laser pointing horizontally across the trough with a photodiode on the other side that the laser will be pointed at. When the water level becomes high enough the light beam will be broken and the voltage reading from the photodiode will drop.
I have a test circuit built (just the photodiode and a LED). With no obstruction between the LED and photodiode I get .013V from the photodiode, and that drops to .03V when you put an obstruction between the two.

So I edited the example code to this
Code: [Select]
`#include <PID_Beta6.h>/******************************************************** * PID Simple Example * Reading analog input 0 to control analog PWM output 3 ********************************************************///Define Variables we'll be connecting todouble Setpoint, Input, Output;//Specify the links and initial tuning parametersPID myPID(&Input, &Output, &Setpoint,5,1,1);void setup(){  //initialize the variables we're linked to  Input = analogRead(0);  Setpoint = 100;  //turn the PID on  myPID.SetMode(AUTO);    Serial.begin(9600); }void loop(){  Input = analogRead(0);  Serial.print("Output value: ");  Serial.println(Output);  myPID.Compute();  analogWrite(3,Output);}`

I have this hooked up to an oscilloscope and I can see that the voltage will pulse, but I only see that happen right when I turn the Arduino on.
I am brand new to PID and Arduino, I spent all day reading with no luck.
Can anyone give me some advice on how to get this to work? I can't get the right tuning parameters or even know what they mean entirely or approximate values to use.
I am also unsure about the setpoint... does everyone else just randomly enter in values for these until they get the appropriate results or is there some method of finding the tuning parameters I need?

#### pwillard

#73
##### Jun 10, 2010, 07:59 pmLast Edit: Jun 10, 2010, 08:01 pm by pwillard Reason: 1

Setting PID values correctly is truly an art/science that does seem to get the experts some nice paychecks...

Your application seems more like an ON OFF design from what I can tell... the PID library works best if the feedback about what you are trying to measure/control is changing as it get close to set point.  Like a temperature reading, for example.

A PID tries to adjust it's output based on the input error...   but in your case... it sort of like playing 1...2...3... RED LIGHT!  if you have ever played that game... you might know what I mean...

You have an action with inertia... water feed.... and you want it to stop at an instant in time with little warning...  which sounds pretty hard to do to me...

I'm not claiming to be a PID expert though... maybe I can be corrected by one of the guru's here...

#### KenH

#74
##### Jun 13, 2010, 07:39 pm
You are wanting to fill with very much accuracy - does the tank drain any during this time?

You might consider measuring the level, then as the level approaches setpoint, start slowing the fill, until as setpoint is reached, the fill rate is at zero.  This method would use a PID controller.

BTW, this deserves a thread of it's own.

Good luck and have fun.

Ken H>

Go Up