
This project was published in Elektronika dla Wszystkich 08/2011 (polish magazine for electronics hobbyists) and is available as AVT2985
How It Works?:
In the picture 1 the schematic of mini thermometer is presented. Main part of this project is microcontroller U1 (ATTINY2313). It works with internal oscillator, without internal frequency divider. In result the clock frequency was set to 8MHz. There are no quartz resonator so PCB is smaller and XTAL pin can be used as input port PA0. This input is connected directly to switch S2. Microcontroller has to: read results of temperature measurement from two sensors, calculate values suitable for LED display, read state of buttons S1 and S2. Capacitor C1 (100nF) is placed close to the microcontroller and is responsible for supply voltage filtration. The same task have capacitors C2 (10uF) and C3 (10uF), which are necessary to properly work of voltage regulator U3 (78L05). This project is very simple, because DS18B20 is used as temperature sensor. This sensor is a 12-bits digital thermometer and it can work in area of -55 to 125 Celsius degree. Time needed for temperature conversion is less than 750ms. Temperature readout is completely digital, and for the connection with microcontroller the 1-Wire bus is used.Construction:
View of printed circuit board from the bottom side may be seen here. Figure in a mirror image is available here. The board is designed as a one-sided, and almost all items are SMD. An exception is the LED display, buttons and connectors. Mounting is not complicated but requires little skill in soldering of SMD components. Figure here will be very useful for soldering the printed circuit board (from bottom side). For mounting the top side of PCB very useful will be schematic available here.At the beginning, it is good to solder all SMD elements, because there are no protruding parts on the other side and mounting is simpler. It should be noted that the GND passes in one place through the button (the button has 2 pairs of shorted outputs). If becomes necessary to abandon the buttons instead of the switch S1, jumper must be soldered. The disadvantage of the small PCBs is lack of the programming connector, so if change the program will be necessary, you will need to solder a wires to microcontroller's pins. The power connector, as in the case of GP1, can be replaced by wires soldered directly to the board. Pinout of the GP1 is shown in Figure 2 Pins 1 and 2 of this connector is as follows: the power supply and the ground. Control output (OUT) is available at pin 3. Each of the sensors must be connected by three wires: power, ground and data. The data pin of first sensor should be connected to pin 5, and the second sensor to pin 6 of GP1 connector. The thermometer can be powered with voltages of range 7-12V by the voltage regulator 78L05. Nothing stands in the way to skip the voltage regulator, and connect 5V supply voltage directly to the circuit.
Programming:
The program controlling the operation of the thermometer was written in the well known program BASCOM AVR. It occupies around 70% of the available memory of the microcontroller and can be successfully compiled in the demo version of BASCOM AVR. The program is not complicated, in brief looks like this: all the time processor runs in an infinite loop, waiting for the setting of one of the timing flags (Timer0 interrupt). Every 4ms the procedure of LED display multiplexing is called, which in due time a jump to the temperature reading (to avoid display blinking).
Przerwanie0:
Timer0 = 131
Set F4ms
Incr Dziel(1)
If Dziel(1) = 25 Then
Dziel(1) = 0
Set F100ms
Incr Dziel(2)
If Dziel(2) = 10 Then
Dziel(2) = 0
Set F1s
End If
End If
Return
The main loop is shown below:
Do
If F4ms = 1 Then
Reset F4ms 'co 4ms
Wysw = T
Gosub Wyswietl_zmierz
End If
If F100ms = 1 Then
Reset F100ms 'co 100ms
If Pind.2 = 0 Then Kanal = 1
If Pina.0 = 0 Then Kanal = 0
End If
Loop
End
The display procedure and temperature measurement is shown below:
Wyswietl_zmierz:
Incr Mux
If Mux = 5 Then Mux = 0
Portd.3 = Not Minus
For I = 1 To 3
Wysw_pomoc = Wysw Mod 10
Ww = Wysw_pomoc
W(i) = Lookup(ww , Tabela)
Wysw = Wysw / 10
Next I
If W(3) = 40 Then W(3) = 255 'wygaszenie zera wiodącego
Select Case Mux
Case 0:
Portb = W(3)
Reset Portd.6
Case 1:
Set Portd.6
Portb = W(2) And &B11011111
Reset Portd.5
Case 2:
Set Portd.5
Portb = W(1)
Reset Portd.4
Case 3:
Set Portd.4
Portb = 255
Gosub Temp
'Case 4:
End Select
Return
Tabela:
Data 40 , 235 , 50 , 162 , 225 , 164 , 36 , 234 , 32 , 160
The rest of the procedure depends on the variable Mux. For values 0-2, one of 3 digits are displayed. In this moment the anode, corresponding to previous digit, is switched off, PortB is set to coded value of next digit, and anode corresponding to next digit is switched on. An exception is the digit of W(2) where additional operation (And &B11011111) provides adding a decimal point after the second character. For the Mux = 3 the temperature measurement procedure is called, and the state Mux = 4 is the phase of waiting for the temperature measurement.
Temperature measurement procedure is shown below:
Temp:
If F1s = 1 Then
Reset F1s
1wreset Pind , Kanal
1wwrite &HCC , 1 , Pind , Kanal
1wwrite &HBE , 1 , Pind , Kanal
T = 1wread(2 , Pind , Kanal):
Minus = T.15
T = Abs(t)
T = T * 10
T = T / 16
1wreset Pind , Kanal
1wwrite &HCC , 1 , Pind , Kanal
1wwrite &H44 , 1 , Pind , Kanal
End If
Return
The circuit can be converted into a thermostat little effort. We resign then from the two-channel temperature measurement and negative temperatures. To control output (Portd.3) optotriac and triac (for AC receivers) can be connected. DC receiver can by controlled by MOSFET transistor, connected to the control output. In the main loop you will need to make the changes shown below:
If F4ms = 1 Then
Reset F4ms
If Ust = 0 Then Wysw = T Else Wysw = Tu
Gosub Wyswietl_zmierz
End If
If F100ms = 1 Then
Reset F100ms
If Pind.2 = 0 Then
Incr Tu
Autoret = 20
End If
If Pina.0 = 0 Then
Decr Tu
Autoret = 20
End If
If Autoret > 0 Then
Ust = 1
Decr Autoret
Else
Ust = 0
End If
H = Tu + 10
L = Tu - 10
If T > H Then Set Portd.3
If T < L Then Reset Portd.3
End If
Photos:
Parts List:
Thermometer Parts:
Attachments:
PCB Design: | ||
AB AB AB | Board (bottom side,thermotransfer method) | 10.7 kB |
AB AB AB | Board (bottom side, mirrored) | 10.7 kB |
AB AB AB | Board (bottom side, few per page, thermotransfer method) | 157.0 kB |
AB AB AB | Mounting (top side) | 8.7 kB |
AB AB AB | Mounting (bottom side) | 13.7 kB |
AB AB AB | Description Layer (top overlay) | 53.3 kB |
AB AB AB | Description Layer (bottom overlay) | 100.5 kB |
Documentation: | ||
AB AB AB | Thermometer Schematic | 117.4 kB |
Programing: | ||
AB AB AB | Thermometer Source Code (BASCOM-AVR) | 3.1 kB |
AB AB AB | Thermostat Source Code (BASCOM-AVR) | 3.4 kB |
AB AB AB | Thermometer Output file (BIN BASCOM-AVR) | 1.4 kB |
AB AB AB | Thermostat Output file (BIN BASCOM-AVR) | 1.6 kB |
AB AB AB | Thermostat Output file (HEX) | 4.6 kB |
AB AB AB | Thermometer Output file (HEX) | 4.1 kB |
AB AB AB | Fusebits Configuration (burn-o-mat) | 12.5 kB |
Questions and Comments:
comments powered by Disqus
July 19, 2018
Power supply was presented ...
More …
June 20, 2018
Triac Module was presented...
More …
More news …
Power supply was presented ...
More …
June 20, 2018
Triac Module was presented...
More …
More news …
Recommended Sites