Welcome,
Guest



Attached is an Excel document I made to simulate some data and PID control. It's a handy way to view how the above PID algorithm functions, along with bias tuning.
use a quality charcoal in that Weber Smokey Mountain such as KINGSFORD. This is all I ever use for dutch oven cooking in camp. NOTE each briquet is good for 25degrees F Unfortunately Kingsford Charcoal is not readily available here in Australia (I'd buy it if I could). That said, the charcoal I use seems to do the job just fine.Hopefully blowing air across the charcoal won't create a gray haze on the food product? Regarding air flow  it will be a very subtle flow of air; ideally no more than the air flow of a fully opened port. Although I'll probably knock around some ash while prototyping!
Attachments:



Graham, to you have any example code that calls this library that you can share? I am gonna try and adapt this for some solder reflow oven control.
On a side note: I went with a pellet auger system for my smoker/grill. https://pbs.twimg.com/media/BDU091sCUAEAfjQ.jpg:large 


Hi Ohararp, great to see you about again!
Below is the latest version of the PID Module .. it's pretty straight forward once you start using it. The PID Tuning Tool (attachment from earlier) helps to calculate the tuning requirements for the "P" "I" "D" biasing. After initialising the module, call the function "Calculate" and pass the "SetPoint" (desired value) and "InputValue" (the actual value). The function will return an error correction value that has PID biasing applied. You need to apply this to the control (whether it be a duty cycle or something else). A point to note; this PID module works with a set time interval for samples/corrections. Not overly important, but if you want it to behave exactly as the tuning tool depicts then the interval needs to be fixed. And with that in mind  raw data is highly recommended with the tuning tool. Log some results for the oven at the same interval your program will sample at. Induce some errors (open the door etc) and get some raw data for how the environment behaves in there. Afterwards you will be able to tune the PID algorithm a lot easier. Hopefully that is a good start point, naturally I'd like to hear more! Stay in touch. Module PID
'  '
'  PID library with fixed calculation time interval  '
'  '
' Graham Mitchell
' www.digitaldiy.com
' With help from Pascal and Basic code by D.Rossel
'Public Sub Init(Kp, Ki, Kd, MinOutput, MaxOutput As Float)
' Initialises the PID engine
' Kp = the "proportional" bias
' Ki = the "integrated value" bias
' Kd = the "derivative" bias
' MinOutput = the minimal value the output value can have (should be < 0)
' MaxOutput = the maximal value the output can have (should be > 0)
'Public Sub Reset()
' Reinitialises the PID engine without change of settings
'Public Function Calculate(Setpoint, InputValue As Float) As Float
' To be called at a regular time interval (e.g. every 100 msec)
' Setpoint: the target value for "InputValue" to be reached
' InputValue: the actual value measured in the system
' Functionresult: PID function of (SetPoint  InputValue),
' a positive value means "InputValue" is too low (< SetPoint), the process should take action to increase it
' a negative value means "InputValue" is too high (> SetPoint), the process should take action to decrease it
Dim PID_Kp, PID_Ki, PID_Kd As Float
Dim PID_Integrated As Float
Dim PID_Prev_Input As Float
Dim PID_MinOutput, PID_MaxOutput As Float
Dim ErrAbs, PID_Prev_AbsError As Float
Dim PID_First_Time As Boolean
Function AbsReal(val1 As Float) As Float
Result = Val1
If Result < 0 Then
Result = Result
EndIf
End Function
Public Sub Reset()
PID_Integrated = 0.0
PID_Prev_Input = 0.0
PID_First_Time = true
End Sub
Public Sub Init(Kp, Ki, Kd, MinOutput, MaxOutput As Float)
PID_Kp = Kp
PID_Ki = Ki
PID_Kd = Kd
PID_MinOutput = MinOutput
PID_MaxOutput = MaxOutput
PID_Integrated = 0.0
PID_Prev_Input = 0.0
PID_First_Time = true
PID_Prev_AbsError = 0
End Sub
// returns 1 for positive, 0 for negative
Function Sign(pVar1 As Float) As Byte
result = 1
If pVar1 < 0 Then
result = 0
EndIf
End Function
Public Function Calculate(Setpoint, InputValue As Float) As Float
Dim TheErr, ErrValue, DiffValue As Float
// calculate the error
TheErr = SetPoint  InputValue
// calculate proportional value 
ErrValue = TheErr * PID_Kp
// minimise integration lag
If Sign(TheErr) <> Sign(PID_Integrated) Then
PID_Integrated = 0
EndIf
// calculate integrated value
PID_Integrated = PID_Integrated + (TheErr * PID_Ki)
// limit it to output minimum and maximum
If PID_Integrated < PID_MinOutput Then
PID_Integrated = PID_MinOutput
End If
If PID_Integrated > PID_MaxOutput Then
PID_Integrated = PID_MaxOutput
End If
// calculate derivative value
If PID_First_Time Then
PID_First_Time = false
PID_Prev_Input = InputValue
End If
DiffValue = (InputValue  PID_Prev_Input) * PID_Kd
PID_Prev_Input = InputValue
// check if error becomes smaller (stop differentiation)
ErrAbs = AbsReal(TheErr)
If ErrAbs < PID_Prev_AbsError Then
DiffValue = 0
EndIf
PID_Prev_AbsError = ErrAbs
// check if error has resolved (remove residual)
If ErrAbs = 0 And PID_Prev_AbsError = 0 Then
DiffValue = 0
PID_Integrated = 0
Result = 0
Exit
EndIf
// calculate total
Result = ErrValue + PID_Integrated  DiffValue
// limit it to output minimum and maximum
If Result < PID_MinOutput Then
Result = PID_MinOutput
End If
If Result > PID_MaxOutput Then
Result = PID_MaxOutput
End If
End Function Any improvements are more than welcome!! BTW  Nice smoker! Looks like it has plenty of room. I hear the pallet systems are a breeze to use  here in Australia I was looking at 1.5+K for an entry level BBQ similar to that .. hence my "I should probably try DIY first..." approach 


Graham, I put a big blog writeup on my IR reflow oven. It's a bit of a rehash of some similar projects. I opted to go with an atmega 328 on this project and leveraged some preexisting pid arduino code to make it go smoother. Details can be found at http://ohararp.com/wp/infrawavereflowovencontroller/


