Categories: Practical Electronics, Microcontroller circuits
Number of views: 21376
Comments on the article: 0

Types and arrangement of AVR microcontrollers

 


AVR - This is the name of the popular family of microcontrollers that the company produces. Atmel. In addition to ABP under this brand are issued microcontrollers and other architectures like ARM and i8051.


What are AVR microcontrollers?

Microcontrollers AVR

There are three types of microcontrollers:

  1. AVR 8-bit.

  2. AVR 32-bit.

  3. AVR xMega

For more than a decade, the most popular is the 8-bit family of microcontrollers. Many hams began to study microcontrollers from him. Almost all of them learned the world of programmable controllers by doing their simple crafts, such as LED flashing lights, thermometers, clocks, as well as simple automation, such as controlling lighting and heating appliances.

Microcontrollers AVR 8-bit, in turn, are divided into two popular families:

  • Attiny - the name shows that the youngest (tiny - young, young, youngest), basically have 8 pins or more. The volume of their memory and functionality is usually more modest than in the following;

  • Atmega - More advanced microcontrollers have more memory, pins and various functional units;

Microcontrollers Attiny

The most powerful subfamily of microcontrollers is xMega - these microcontrollers are available in cases with a huge number of pins, from 44 to 100. So much is necessary for projects with a large number of sensors and actuators. In addition, the increased memory capacity and speed allow you to get high performance.

Microcontroller Atmega

Decoding: Pin (eng. Pin - needle, pin) is the output of the microcontroller or, as they say, the leg. Hence the word "pinout" - i.e. information about the purpose of each of the legs.


What are microcontrollers for and what are they for?

Microcontrollers are used almost everywhere! Almost every device in the 21st century works on a microcontroller: measuring instruments, tools, household appliances, watches, toys, music boxes and postcards, as well as much more; enumeration alone will take several pages of text.

The developer can use the analog signal from the bottom of it to the input of the microcontroller and manipulate data on its value. This work is performed by an analog-to-digital converter (ADC). This function allows the user to communicate with the microcontroller, as well as to perceive various parameters of the surrounding world using sensors.

AVR microcontroller on breadboard

In common AVR microcontrollers, for example, Atmega328which in 2017 is the heart of many circuit boards Arduinobut about them later. Used 8 channel ADCwith bit depth 10 bit. This means you can read the value from 8 analog sensors. And digital sensors are connected to the digital outputs, which may be obvious. However, a digital signal can be only 1 (unit) or 0 (zero), while an analog signal can take an infinite number of values.

Digital and analog signals

Explanation:


Capacity Is a value that characterizes the quality, accuracy and sensitivity of the analog input. That doesn’t sound very clear. A bit of practice: a 10-bit ADC, record analog information from a port in 10 bits of memory, in other words, a smoothly changing digital signal is recognized by a microcontroller as a numerical value from 0 to 1024.

A 12-bit ADC sees the same signal, but with higher accuracy - in the form from 0 to 4096, which means that the measured values ​​of the input signal will be 4 times more accurate. To understand where 1024 and 4096 came from, simply raise 2 to the power of the ADC bit depth (2 to the power of 10, for 10 bit, etc.)

To control the load power, there are PWM channels at your disposal, they can be used, for example, to adjust the brightness, temperature, or engine speed. In the same 328 controller there are 6 of them.

In general, the structure of the AVR microcontroller is depicted in the diagram:

Microcontroller AVR Structure

All nodes are signed, but still some names may not be so obvious. Let's look at their notation.

  • ALU - arithmetic-logical device. Needed to perform the calculation.

  • General Purpose Registers (RON) - Registers that can receive data and store them while the microcontroller is connected to power, are erased after a reboot. Serve as temporary cells for data operations.

  • Interruptions - something like an event that occurs due to internal or external influences on the microcontroller - timer overflow, external interrupt from pin MK, etc.

  • Jtag - an interface for in-circuit programming without removing the microcontroller from the board.

  • Flash, RAM, EEPROM - types of memory - programs, temporary working data, long-term storage independent of the power supply to the microcontroller according to the order in the names.

  • Timers and Counters - the most important nodes in the microcontroller, in some models their number can be up to a dozen. They are necessary in order to report the number of measures, respectively, time intervals, and the counters increase their value for any of the events. Their work and its mode depend on the program, however, these actions are performed in hardware, i.e. parallel to the main text of the program, they can cause interruption (by timer overflow, as an option) at any stage of code execution, on any line of it.

  • A / D (Analog / Digital) - ADC, we have already described its purpose.

  • WatchDogTime (Watchdog Timer) - an RC oscillator independent of the microcontroller and even its clock generator, which counts a certain period of time and generates a MK reset signal if it worked, and wakes up if it was in sleep mode (power saving). Its operation can be disabled by setting the WDTE bit to 0.


The outputs of the microcontroller are rather weak, meaning that the current through them is usually up to 20-40 milliamps, which is enough to light up the LED and LED indicators. For a more powerful load, current or voltage amplifiers are needed, for example, the same transistors.


What do you need to start studying microcontrollers?

First you need to purchase the microcontroller itself. The role of the first microcontroller can be any Attiny2313, Attiny85, Atmega328 and others. It is better to choose the model that is described in the lessons that you will be engaged in.

Attiny2313

The next thing you need is programmer. It is needed to download firmware to the memory of MK, it is considered the cheapest and most popular USBASP.

Programmer

A little more expensive, but no less common programmer AVRISP MKII, which you can do yourself - from a regular board Arduino

Programmer AVRISP MKII

Another option is to flash them through USB UART adapter, which is usually done on one of the converters: FT232RL, CH340, PL2303 and CP2102.

USB-UART Adapter

In some cases, AVR microcontrollers with USB hardware support are used for such a converter; there are not too many such models. Here are some:

  • ATmega8U2;

  • ATmega16U2;

  • ATmega32U2.

USB hardware-based AVR microcontroller

Only one “but” - the UART bootloader must first be loaded into the memory of the microcontroller. Of course, for this, you still need a programmer for AVR microcontrollers.


Interesting: Bootloader - This is a normal program for a microcontroller, but with an unusual task - after its launch (connecting to power), it expects for some time that firmware can be loaded into it. The advantage of this method is that you can flash any USB-UART adapter, and they are very cheap. The disadvantage is that the firmware takes a long time to load.

For work UART (RS-232) interface in the AVR microcontrollers allocated a whole register UDR (UART data register). UCSRA (RX, TX transceiver bit settings), UCSRB and UCSRС - a set of registers responsible for the interface settings as a whole.


How can I write programs?

In addition to the programmer, for writing and downloading the program you need an IDE - development environment. You can of course write code in notepad, pass through compilers, etc. Why is it necessary when there are excellent ready-made options. Perhaps one of the most powerful is the IAR, but it is paid.

The official Atmel IDE is AVR Studio, which was renamed Atmel studio on version 6. It supports all AVR microcontrollers (8, 32, xMega), automatically detects commands and helps to enter, highlights the correct syntax and much more.With its help, you can flash MK.

The most common is C AVR, so find a tutorial on it, there are tons of Russian-language options, and one of them is Khartov V.Ya. “AVR microcontrollers. Workshop for beginners. "

Microcontroller programming

The easiest way to learn AVR

Buy or do it yourself Arduino board. The arduino project is designed specifically for educational purposes. It has dozens of boards with various shapes and number of contacts. The most important thing in arduino is that you are buying not just a microcontroller, but a full-fledged debug board soldered to a high-quality textolite printed circuit board, covered with a mask and mounted SMD components.

The most common are Arduino Nano and Arduino UNO, they are essentially identical, except that the "Nano" is about 3 times smaller than the "Uno".

Arduino uno

A few facts:

  • Arduino can be programmed in a standard language - “C AVR”;

  • his own - wiring;

  • standard development environment - Arduino IDE;

  • to connect to a computer, you just need to connect the USB cable to the micro-USB socket on the Arduino nano board, install the drivers (most likely this will happen automatically, except when the converter on the CH340, I didn’t have drivers on Win 8.1, I had to download it, but it It didn’t take much time.) Then you can upload your “sketches”;

  • “Sketches” is the name of the programs for arduino.

Experiments with Arduino UNO

conclusions

Microcontrollers will be an excellent help in your amateur radio practice, which will allow you to discover the world of digital electronics, design your own measuring instruments and home automation equipment.

See also at i.electricianexp.com:

  • PIC microcontrollers for beginners
  • Microcontroller programming for beginners
  • Connecting and programming Arduino for beginners
  • Programmable microcontrollers in JavaScript: which one to choose, characteristics ...
  • What are microcontrollers - purpose, device, software

  •