Digital thermometer on attiny2313. How the ATTINY thermometer works

There are a lot of thermometer diagrams for AVR on the Internet, but as always, you want something of your own... And you should also stretch your brains. This thermometer was one of my first projects.

What I wanted:

  • minimum sizes (within reasonable limits)
  • minimum cost
  • simplicity of design
  • high repeatability
  • versatility (more on that later)

What happened:

After looking at similar designs and smoking a description of the tinny that was at hand (ATtiny2313), I came to the conclusion that it is possible to somewhat simplify the existing designs and slightly improve their characteristics.

The diagram shows the second option for turning on the temperature sensor if it does not want to work via a single-wire bus (which is very rare). Please note that the pull-up resistor on pin 11 must be exactly 4.7 kOhm. Decreasing or increasing can lead to unstable operation of the sensor if switched on in a single-wire circuit.

As you can see, this circuit differs from similar ones in the absence of transistors for controlling the segments. Thus, the circuit has been simplified by 4 transistors and 4 resistors, compared to similar circuits. Here some will say: “this is not possible - there is a lot of load on the ports!!!”. Read on this controller " DC Current per I/O Pin - 40.0 mA". We have 8 segments in each symbol, 5 mA each - it turns out 40 mA !!!.

Now let's look at the graphs from the same description:

It is clear from the graphs that the current can reach 60 mA and even 80 mA per pin. Well, let’s not get carried away - 5 mA per segment (40 mA per symbol) is enough for us! The limiting resistors are selected to produce a current of approximately 5 mA per segment. In my circuit there are 470 Ohms. The brightness of the segments is excellent!!! So, I got carried away by the theory.

Practice!!!

I drew the printed circuit board based on their considerations “as small as possible, but as simple as possible.” That's why it turned out to have several jumpers...

In the picture there is a place for quartz - this is for a little versatility - I had several AT90S2313 pieces that do not have an internal oscillator. The crank is used in the SOT-89 housing. Protective zener diodes BZX79-C5V1 in DO-35 housing. The capacitors in the power filter are 10mkF * 16V tantalum (no others were found), size 3528 (SMD-B). I usually don’t install them, but instead - 1mkF * 50V size 1206. No power-related glitches were noticed.

blank board made by "laser iron"

assembled board: view from the side of the conductors (stabilizer is missing)

view from the elements side (indicator not sealed)

The project was assembled in pieces, some from ready-made projects from the Internet, some added by me... The original idea was a dynamic display. The problem was that while communicating with the DS18B20 temperature sensor, moments arose when the “scanning” of the indication stopped. Therefore, the indicator update was done not by interruptions, but in the main program loop, and was also inserted here and there in the procedure for communicating with the sensor... The advantage of this method was the high update frequency, which eliminated the flickering problem.

I almost forgot - fuses for normal operation of the thermometer:

So, we flashed it, turned it on... Hmm... it works!!!

So, as we can see, we got a fairly simple (how much simpler???) device, which in size does not exceed the size of the indicator. In addition, the accuracy is also high: according to the sensor description - “±0.5°C accuracy from -10°C to +85°C”. As practice has shown, the accuracy is much higher - about ±0.1°C. I checked 10 copies with a laboratory thermometer that had passed metrological control...


26.04.2014
sPlan is a convenient tool for drawing electronic circuits. It has a simple and intuitive interface. The program includes...

A very convenient program for reading pdf Foxit Reader
26.04.2014
Foxit Reader - Compact and fast program for reading PDF files. Can serve as an alternative to the popular PDF viewer - Adobe Reader....


22.04.2014
Proteus VSM is a microcontroller device simulator program. Supports MK: PIC, 8051, AVR, HC11, ARM7/LPC2000 and other common processors....


01.04.2014
The project site, which has been in a frozen state for a long time, is again starting to work with renewed vigor, with new articles and...

Proteus 7.7 SP2 + Crack v1.0.2 + RUS
22.04.2014
Proteus VSM is a microcontroller device simulator program. Supports MK: PIC, 8051, AVR, HC11, ARM7/LPC2000 and other common processors....

Splan 7.0.0.9 Rus + Portable + Viewer Final
26.04.2014
sPlan is a convenient tool for drawing electronic circuits. It has a simple and intuitive interface. The program includes...

DIY digital soldering station (ATmega8, C)
27.05.2012
Composition: ATmega8, LM358, IRFZ44, 7805, bridge, 13 resistors, one potentiometer, 2 electrolytes, 4 capacitors, three-digit LED seven-segment...

I immediately disclaim all responsibility for the time, money, details, etc. you spent... If something doesn’t work for you, then blame it on your crooked hands.....

Recently I was building a computer with completely passive cooling. In order to conveniently monitor the processor temperature, it was necessary to quickly assemble a thermometer. All sorts of programs like "Everest", "Aida", and others were not suitable for me for one simple reason: I wanted to control the temperature even when the monitor was turned off. Or even with the monitor completely turned off. It was decided to assemble a thermometer based on a DS18B20 digital sensor, a cheap AVR microcontroller, and a seven-segment indicator. At first I wanted to repeat the thermometer circuit according to one of the options proposed on the Internet. But after analyzing the diagrams posted on the Internet, I came to the conclusion that I would have to invent my own “bicycle.”

The designs presented on the Internet had a number of disadvantages, namely:
* low speed of dynamic display (50...100 hertz), due to which it becomes uncomfortable to look at the indicator; if you quickly glance at it, it seems that the numbers are “moving”;
* not all designs adequately measured the entire temperature range (from -55 to +125); for example, there were designs that did not measure temperatures below zero degrees, or incorrectly measured temperatures above 100 degrees;
* there was no checksum check (CRC);
* the common pins of the segments were connected to one leg of the microcontroller without key transistors, OVERLOADING THE MICROCONTROLLER PORTS.

If the MK ports are overloaded, the brightness of the indicator may decrease, and the legs of the microcontroller may also burn. A few years ago I assembled a thermometer using an ATtiny2313+DS18B20 using a diagram from the Internet. The circuit was without key transistors. At a temperature of 18 degrees, the number “1” glowed brightly, and the number “8” glowed noticeably dimmer, I hope everyone understands why everything happens this way. Therefore, I promised myself not to overload the MK legs in the future. By the way, here’s a photo of that thermometer, assembled according to a diagram from the internet; I think it doesn’t need any comments:

I also wanted to make a few improvements:
* display the degree symbol on the indicator (tenths of a degree were not so critical to me);
* clock the microcontroller from an external quartz, since the “1-Wire” protocol that the sensor uses is critical to the formation of time intervals (time slots), so I did not want to pray for the stability of the built-in clock generator;
* introduce a checksum check into the program, if the checksum does not match, display on the indicator: "Crc";
* add a diode to the circuit (to protect the circuit from power reversal);
* when power is applied, all segments are illuminated for 1 second (the so-called segment test);
* implement DS18B20 checksum verification.

I wrote the project in the AVR Studio 5 environment, found the functions for working with the sensor somewhere on the Internet, and rewrote the rest in my own way, abundantly commenting on the source code. At the end of the article there is a link to download the firmware and source code.

I used a seven-segment indicator for 3 familiar locations, segments with a common anode. Also in the archive (at the end of the article) there are firmwares for an indicator with a common cathode. I connected the common terminals of the segments to two terminals of the MK, connected in parallel. Thus, each common pin of the segment indicator uses 2 MK pins to increase the load capacity of the pins.

I used the ATtiny2313A microcontroller (you can also use ATtiny2313 or ATtiny2313L), using almost all free legs (except for the reset pin). If you assemble a thermometer on ATmega8, you can connect 3 or 4 legs in parallel to increase the load capacity of the ports.

Device diagram:

I am attaching photos of the assembled thermometer. There is no case yet, since the thermometer will be built into the PC case.

Indication.
The temperature sensor is not connected, or there is a short circuit on the data line:

Checksum error (CRC):

Temperature sensor connected, temperature from -55 to -10 degrees:

Temperature sensor connected, temperature from -9 to -1 degrees:

Temperature sensor connected, temperature from 0 to 9 degrees:

Temperature sensor connected, temperature from 10 to 99 degrees:

Temperature sensor connected, temperature from 100 to 125 degrees:

The dynamic display frequency is several kilohertz, so flickering is not noticeable to the eye even with a quick glance at the indicator.
For those who want to repeat the design, I compiled several firmware for different quartz: 4 MHz, 8 MHz, 10 MHz, 12 MHz, 16 MHz.
I also made firmware for indicators with a common anode (OA) and a common cathode (OC). All firmware is in the archive (see below).

UPD
Updated the firmware. Minor fixes, minor goodies. The main ones are stdint data types, flexible configuration of legs for segments. All changes are described in the source header.

A microcontroller circuit is proposed ATMega8 for measuring temperatures in the range from -55C to +127C with an accuracy of no worse than +-0.5C. A “dynamic” three-digit LED indicator is used as an indicator.

Fig.1 Schematic diagram

The schematic diagram of the device is shown in Figure 1. It seems to me that it is so simple that it does not need any explanation. Some strangeness in the arrangement of the indicator pins is explained by the desire to make a beautiful circuit without crossing lines and buses. Resistors and capacitors SMD- this is a sacrifice to the desire to make the device literally 5 mm larger than the indicator. By the way, the indicator was used without identification marks and was sold as a “dynamic” indicator. Most likely, this is some kind of left-handed Chinese craft, but it works well. When repeating the design, you should make sure that the pin numbers correspond to the required digits and segments. The circuit is powered from a 3...5V source.

Rice. 2 Bottom side of the board

Rice. 3 Top side of the board

On pictures 2 And 3 drawings of the tracks on the sides of the board are shown, and pictures 4 And 5 - placement of elements on these sides. As you can see, the elements are placed not only on both sides, but also part SMD-components are placed under non- SMD-components. Thanks to such tricks, the dimensions of the board are only 50x22 mm. In general, installation should not cause any problems.

Fig.4 Bottom mounting

Fig.5 Top mounting

Since the board is very simple, I didn’t make a high-quality drawing - I think that such a board can be reproduced even using traditional “varnish” technology, and for LUT it can be slightly corrected pictures 2 And 3 .

Firmwares are available in . Their 4 options : for indicators with a common anode and a common cathode, as well as for sensors DS18S20 or DS18B20. The name of the firmware files is such that it is easy to determine the correspondence, for example: mt_18S20_oa.hex- firmware for the sensor DS18S20 and indicator with common anode. When programming the microcontroller, you should set fuse-bits clocking mode from the built-in 8 MHz RC oscillator.

Note: if the sensor is actually installed on the board in the provided holes, it will be fictitious, since it will “catch” heat from the indicator and the microcontroller.


(12) | Views: 119051

On the radio market, I looked at a three-digit seven-segment radio. I purchased an Attiny2313 microcontroller in a SOIC package, DS18B20, an SMD resistor and an SMD capacitor. I drew a printed circuit board, drew a circuit based on the printed circuit board, wrote a program, uploaded it to the MK and:

And this is what happened:

A tint film is glued to the indicator (it was not possible to photograph the indicator properly without it).

The size can also be judged by the indicator used:

Scheme:

A few words about the diagram and the program. Compactness has not come without sacrifices. There are no current-limiting resistances in the circuit, which is not entirely good. To increase the load capacity, the indicator cathodes are connected to two terminals of the MK at once.
There is nothing original in the program. The template is prepared using the wizard from CVAVR, the rest of the parts are taken from my thermometer clock. I used the corrected DS18B20 library, or rather it is the sum of two libraries from CVAVR for DS1820/DS18S20 and DS18B20, i.e. Any of the above sensors can be used in a thermometer. More precisely, no more than 4 sensors in any combination.
Fuses: The MK is configured to operate from an internal RC oscillator at 4 MHz. CKSEL = 0010, SUT = 10, all others = 1.

Result:
I'm not sure that my version of a thermometer using a seven-segment indicator is the smallest.

Files:

- Printed circuit board in SL 5.0 format.

You do not have access to download files from our server - MK firmware.

You do not have access to download files from our server - Firmware sources.

You do not have access to download files from our server - Project for Proteus.

“Thermometer: it can’t be smaller” is the title of the article on the website arv.radioliga.com. I saw the diagram located on the indicated page a long time ago, but I became interested in it when one of the forum’s fellow citizens had questions with this “small” thermometer. To be more precise, I became interested not so much in the diagram as in the dimensions of the thermometer. The author has a thermometer assembled on a board measuring 50*22 mm.
Is there really no such thing as less?

On the radio market, I looked at a three-digit seven-segment radio. I purchased an Attiny2313 microcontroller in a SOIC package, DS18B20, an SMD resistor and an SMD capacitor. I drew a printed circuit board, drew a circuit based on the printed circuit board, wrote a program, uploaded it to the MK and this is what happened:

A few words about the diagram and the program. Compactness has not come without sacrifices. There are no current-limiting resistances in the circuit, which is not entirely good. To increase the load capacity, the indicator cathodes are connected to two terminals of the MK at once.
There is nothing original in the program. The template is prepared using the wizard from CVAVR, the rest of the parts are taken from my thermometer clock. I used the corrected DS18B20 library, or rather it is the sum of two libraries from CVAVR for DS1820/DS18S20 and DS18B20, i.e. Any of the above sensors can be used in a thermometer. More precisely, no more than 4 sensors in any combination.
Fuses: The MK is configured to operate from an internal RC oscillator at 4 MHz. CKSEL = 0010, SUT = 10, all others = 1.