Te Controller v1-6
Te Controller v1-6
Symbol SetTempLED = 1 ' LED that flashes upon entering set temp
function
Symbol PowerLED = 2 ' LED that shows power is on to system
Symbol SetTempButton = pin0 ' set temp button to enter set temp function
Main:
low SetTempLED
high DispEnable
low DispClock
Sum = 0
For N = 1 to 32 ' sum 32 readings
ReadADC10 0, AD0_Val
Sum = Sum + AD0_Val
Next
DispDig10 = TE_Temp / 10
DispDig1 = TE_Temp % 10
gosub DispTemp
goto Main
'-----[ Subroutines ]-----
PropControl:
DutyCycle = PropGain * PropError MAX PWMMax
pwmout TEC_PWM_LED, PWMPeriod, DutyCycle
return
PropControlOff:
pwmout TEC_PWM_LED, 0, DutyCycle
return
TurnOffPeltier:
Low TEC_OnOff_LED
GoTo Main
TurnOnPeltier:
High TEC_OnOff_LED
GoTo Main
LED_Flash:
For N = 1 to 7
toggle SetTempLED
pause 250
Next
if SetTempButton = 0 then Set_Temp
goto Main
Set_Temp:
pause 1000
do
readADC10 1,AD1_Val
debug AD1_Val
if SetTempButton = 0 then LED_Flash
TempSetPoint = SetPoint_10 / 10
DispDig10 = TempSetPoint / 10
DispDig1 = TempSetPoint % 10
gosub DispTemp
loop
DispConfigure:
low DispEnable
spiout DispClock, DispData, 1, (%00000001)
high DispEnable
return
DispTemp:
low DispEnable
spiout DispClock, DispData, 1, (%00000000,DispDig1,DispDig10)
high DispEnable
return