EccentricDyslexic
New member
- Joined
- Oct 7, 2013
- Messages
- 2
- Programming Experience
- Beginner
Hi peeps,
i have had my automated brewery up and running for a couple of years but have always had issues with maintaining the mash tun at the required temperature. Currently i use the following code-
PrivateSub tmrRIMs_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrRIMs.Tick
Dim nextCheck AsInteger = 200
SelectCaseTrue
Case RIMS_CurrentTemp <= (desiredtemp - 1.7) ' CONSTANT ON
nextCheck = 1000
heaterIsOn =
True
Case RIMS_CurrentTemp >= (desiredtemp - 1.6) AndAlso RIMS_CurrentTemp < (desiredtemp - 0.6)
If heaterIsOn Then
nextCheck = 400
heaterIsOn =
False
Else
nextCheck = 600
heaterIsOn =
True
EndIf
Case RIMS_CurrentTemp >= (desiredtemp - 0.5) AndAlso RIMS_CurrentTemp < (desiredtemp - 0.2)
If heaterIsOn Then
nextCheck = 500
heaterIsOn =
False
Else
nextCheck = 500
heaterIsOn =
True
EndIf
Case RIMS_CurrentTemp >= (desiredtemp - 0.1) AndAlso RIMS_CurrentTemp < (desiredtemp + 0.1) ' TARGET TEMP
If heaterIsOn Then
nextCheck = 750
heaterIsOn =
False
Else
nextCheck = 250
heaterIsOn =
True
EndIf
Case Else'temp is too high
nextCheck = 1000
heaterIsOn =
False
EndSelect
setHeaterState(heaterIsOn)
tmrRIMs.Interval = nextCheck
As you can see, it is very simple and herein is where the problem is. I want to change this code so it functions as a errrr function with a variable passed to it between 0 and 100 to relate to how much time per second in percentage time the heater ellement is powered on. ie 0% = off 60% = on for 600ms/off for 400ms and of course 100% means on all the time.
Then i want to implement a PID sub every second to monitor the temperature of the flow of fluid past the element (downstream) and see how close it is to the desired temperature and make adjustments to the function above to keep the flow at the temperature i set it to.
I would really appreciate some help doing this from you guys, firstly i think it would be good to work with this piece of code so that it functions as a errrr function with an input of 0 - 100%.
Thanks in advance peeps!
Steve
i have had my automated brewery up and running for a couple of years but have always had issues with maintaining the mash tun at the required temperature. Currently i use the following code-
PrivateSub tmrRIMs_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrRIMs.Tick
Dim nextCheck AsInteger = 200
SelectCaseTrue
Case RIMS_CurrentTemp <= (desiredtemp - 1.7) ' CONSTANT ON
nextCheck = 1000
heaterIsOn =
True
Case RIMS_CurrentTemp >= (desiredtemp - 1.6) AndAlso RIMS_CurrentTemp < (desiredtemp - 0.6)
If heaterIsOn Then
nextCheck = 400
heaterIsOn =
False
Else
nextCheck = 600
heaterIsOn =
True
EndIf
Case RIMS_CurrentTemp >= (desiredtemp - 0.5) AndAlso RIMS_CurrentTemp < (desiredtemp - 0.2)
If heaterIsOn Then
nextCheck = 500
heaterIsOn =
False
Else
nextCheck = 500
heaterIsOn =
True
EndIf
Case RIMS_CurrentTemp >= (desiredtemp - 0.1) AndAlso RIMS_CurrentTemp < (desiredtemp + 0.1) ' TARGET TEMP
If heaterIsOn Then
nextCheck = 750
heaterIsOn =
False
Else
nextCheck = 250
heaterIsOn =
True
EndIf
Case Else'temp is too high
nextCheck = 1000
heaterIsOn =
False
EndSelect
setHeaterState(heaterIsOn)
tmrRIMs.Interval = nextCheck
As you can see, it is very simple and herein is where the problem is. I want to change this code so it functions as a errrr function with a variable passed to it between 0 and 100 to relate to how much time per second in percentage time the heater ellement is powered on. ie 0% = off 60% = on for 600ms/off for 400ms and of course 100% means on all the time.
Then i want to implement a PID sub every second to monitor the temperature of the flow of fluid past the element (downstream) and see how close it is to the desired temperature and make adjustments to the function above to keep the flow at the temperature i set it to.
I would really appreciate some help doing this from you guys, firstly i think it would be good to work with this piece of code so that it functions as a errrr function with an input of 0 - 100%.
Thanks in advance peeps!
Steve