Yesterday I finally got the code to read the temperature sensor value working. Today I’ve build a experimental setup with a small peltier. On the hot side I used an old Pentium 2 heat sink. On the cold side a piece of scrap aluminium with the temperature sensor attached to it.
The temperature controller working:
The temperature sensor mounted:
On the next picture u can see how the peltier is squeezed between the aluminum and the heat sink:
The heat sink is of an old P2 processor.
Component list:
Name: | Value: |
R1, R2, R3, R4, R5, R6, R7 | 180 Ohm |
R9, R11, R12 | 1 KOhm |
R13, R14 | 4k7 |
C1, C2, C3, C4 | 100nF |
7Seg1, 7Seg2 | 7-Segment display CC |
T1 | High power darlington |
T3, T4 | BC547 |
VR1 | 7805 |
IC1 | PIC16F628 |
IC2 | TC74A0 |
The code:
Device 16F628A Config WDT_OFF, PWRTE_ON, MCLRE_OFF, INTRC_OSC_NOCLKOUT, LVP_off ALL_DIGITAL = true '**************************************************************** Symbol digit1 = PORTB.5 Symbol digit2 = PORTA.1 Symbol digitA = PORTA.0 Symbol digitB = PORTA.7 Symbol digitC = PORTA.2 Symbol digitD = PORTB.6 Symbol digitE = PORTB.3 Symbol digitF = PORTA.6 Symbol digitG = PORTB.2 Symbol peltier = PORTB.4 Symbol SCL = PORTB.0 Symbol SDA = PORTB.1 Dim getal1 As Byte Dim getal2 As Byte Dim getal As Byte Dim index As Byte Dim temperatuur As Byte Symbol gewenst = 10 '**************************************************************** init: Clear I2Cin SDA,SCL,$90,[$00] '**************************************************************** main: While 1 = 1 GoSub sensorIn getal1 = temperatuur / 10 getal2 = (temperatuur - (getal1 * 10)) GoSub dispUit If temperatuur < gewenst Then Low peltier Else High peltier EndIf Wend '**************************************************************** sensorIn: I2Cin SDA, SCL,$91,[temperatuur] Return '**************************************************************** dispUit: ' A ' F B ' G ' E C ' D For index = 0 To 1 If index = 0 Then getal = getal1 High digit1 EndIf If index = 1 Then High digit2 getal = getal2 EndIf Select getal Case 0 High digitA High digitB High digitC High digitD High digitE High digitF Low digitG Case 1 Low digitA High digitB High digitC Low digitD Low digitE Low digitF Low digitG Case 2 High digitA High digitB Low digitC High digitD High digitE Low digitF High digitG Case 3 High digitA High digitB High digitC High digitD Low digitE Low digitF High digitG Case 4 Low digitA High digitB High digitC Low digitD Low digitE High digitF High digitG Case 5 High digitA Low digitB High digitC High digitD Low digitE High digitF High digitG Case 6 High digitA Low digitB High digitC High digitD High digitE High digitF High digitG Case 7 High digitA High digitB High digitC Low digitD Low digitE Low digitF Low digitG Case 8 High digitA High digitB High digitC High digitD High digitE High digitF High digitG Case 9 High digitA High digitB High digitC High digitD Low digitE High digitF High digitG EndSelect DelayMS 2 Low digitA Low digitB Low digitC Low digitD Low digitE Low digitF Low digitG Low digit1 Low digit2 Next Return '**************************************************************** End
If I have some time in the future maybe I will write a program of a PID controller.