AVR Microcontrollers
AVR Microcontrollers
net/publication/273379962
CITATIONS READS
6 2,362
4 authors, including:
Some of the authors of this publication are also working on these related projects:
Geometrically nonlinear vibration of composite shells with cutout and different boundary conditions on inner and outer contours. View project
All content following this page was uploaded by Pawel Olejnik on 10 March 2015.
Abstract: Nowadays, microcontrollers are commonly used in many fields of industrial applications
previously dominated by other devices. Their strengths such as: processing power, low cost, and small
sizes enable them to become substitutes for industrial PLC controllers, analog electronic circuits,
and many more. In first part of this article an overview of the Atmel AVR microprocessor family
can be found, alongside with many scientific and industrial applications. Second part of this article
contains a detailed description of two implementations of ATmega644PA microprocessor. First one is
a controller with PID regulation that supports a DC motor driver. Second one is a differential equation
solver with 4-th order Runge-Kutta method implemented. It is used for solving a torsion pendulum
dynamics. Finally, some general conclusions regarding the two presented implementations are made.
Keywords: Atmel, AVR, ATmega, microcontroller, torsion pendulum, PID control, DC motor, PWM control
15
An Overview of ATmega AVR Microcontrollers Used in Scientific Research and Industrial Applications
trollers. Examples of scientific and industrial applications are a LCD screen and could be changed by the user via the atta-
described below. ched keypad.
In paper [3], ATmega161 was used as a controller with A comparative analysis of efficiency in generating PWM
embedded system for an Uninterruptable Power Supply (UPS) signals by three different microcontrollers (8-bit ATmega328P,
system. This system was capable of receiving commands via 16-bit SAB80C167 and 32-bit PIC32MX320F128H) is presen-
internet and send back information regarding UPS status. ted in [8]. Test was carried out for two duty cycle values and
Microcontroller also managed data communication with auxi- four different frequencies. Length of code needed to generate
liary memory unit via the I2C communication protocol. In a PWM signal was compared as well as the time needed to
certain determined cases the embedded system sends email reestablish the signal generation after reboot was measured.
messages to a list of defined addresses through SMTP protocol. ATmega328P achieved shortest reboot time and required the
Proposed solution allows for long distance monitoring and con- least amount of code for the assigned task. It can be conclu-
trol of the UPS. Low cost and high reliability enables the use ded that for simple PWM control, the 8-bit microcontroller
of mentioned microcontroller in serial produced UPS systems. has the advantage of easier programming and fast response.
An application of the microcontroller as a data gathering Another usage example of the ATmega microprocessor wor-
device was presented in [4]. Here the ATmega328 acts as a real- king as an electric motor controller is shown in [9]. The paper
-time health vital signs monitoring system. Measurements are describes a spherical robot capable of moving under water.
transmitted using an XBee communication system. The system The propulsion is realized by three water jet thrusters. Each
is designed to collect the body temperature and heart rate. thruster consists of one DC motor for generating propulsive
The described device has a memory card installed in the case force and two servomotors for changing its direction. In this
of loss of communication through the XBee radio. Data can application ATmega2560 is used via the RS-232 communica-
be transmitted in real-time and it is simultaneously stored on tion protocol as a unit controlling rotation of six separated
a removable memory card. This solution increases the reliabi- DC electric motors.
lity of data collection. It also enables a complete history of the Another device based on ATmega microcontroller used for
data to be stored and read separately without using the XBee underwater exploration is described in [10]. Quoted article
radio. The whole device is compact enough to be installed in describes a Poseidon MK6 Rebreather. Classical open-loop
a wrist mounted chassis. underwater breathing system disposes once used air into water.
An industrial application of an ATmega128 working as On the other hand, the Rebreather collects the exhaled air in
a microcontroller was presented in work [5]. The microproces- a flexible bag (counter-lung). Carbon dioxide is chemically
sor acts as a central controller of DXDF40 automated powder filtered in the so-called scrubber, and metabolized oxygen is
packaging machine. During the bag forming the microcontrol- substituted with fresh oxygen from a small tank. Whole con-
ler is responsible for packaging film feeding speed (measured trol system for the Rebreather is based on four ATmega 8-bit
by number of impulses from a rotary encoder) and packaging microcontrollers connected into a network. The control system
material tension control (basing on analog measurement from is responsible for the breathing gas composition, validation of
a potentiometer). Length of material can be set to a constant the multiple sensor signals and performing automatic predive
value or can be controlled by an input from a color tag sensor. checks. In the case of a failure, several warning systems like
Speed of filling and volume of powder in the package is also flashing LEDs and vibration motor are included. System para-
controlled. Sealing temperature (in the horizontal and vertical meters can be displayed on a custom LCD display. Rebreather
seals) is controlled by a PID algorithm by means of an analog can communicate with a PC via the IrDA data transmission.
measurement from K-type thermocouple. Furthermore, there It enables easy firmware upgrades and diving data exchange.
are incorporated: master motor control, production counting, ATmega microprocessors can be applied as regulators in
system status display, system failure alarm etc. Described con- complex dynamical systems. In papers [11] and [12] the micro-
troller fulfils all requirements concerning speed and precision. processors can be found as main controllers for Unmanned
An ATmega16 based wireless home appliance control system Aerial Vehicles (UAV). ATmega168-20U controls the flight of
was presented in [6]. User can turn on and off up to 15 diffe- a tri-rotor flying robot. Using signals from two MEMS gyrosco-
rent devices using a set of relays. PWM regulation was applied pes (ADC voltage conversion) it determines the pitch, roll and
for changing fan’s DC motor speed or to regulate intensity of yaw angles of rotation. Later calculations have led to proper
connected lights. The system is controlled by a Radio Frequ- regulation of the speed of three PWM regulated brushless DC
ency (RF) remote controller. The controller is compatible with motors. Thanks to that, the tri-copter can fly and hover stably.
a Sim300 GSM modem. This solution enables the system to Similar implementation is shown in work [12]. An ATme-
send notifications concerning status of powered devices thro- ga644PA microprocessor is used there as a main regulator of
ugh the mobile phone network to a defined telephone number. the four-rotor flying machine’s hovering state. The quadrocop-
Same information can be shown on a LCD screen. ter aerial vehicle is controlled by a microprocessor located on
Another useful implementation of an ATmega type micro- the ATB 1.03 start-up board. Commands are sent by pressing
controller in industrial manufacturing is presented in [7]. the appropriate buttons on the remote control supplied with
ATmega8535 is used as a process controller of Pulse Electric the board. The signals informing about the current quadrocop-
Field (PEF) pasteurization. The pasteurized apple juice is ter’s state are retrieved from a KAmodMEMS2 3-axis accelero-
subjected to a high voltage in range from 20 kV to 100 kV. meter (LIS35DE MEMS Motion Sensor) and a KAmodGYRO
This process is conducted in room temperature, contrary to 3-axis gyroscope (L3G4200D MEMS Motion Sensor). The con-
classical pasteurization process which is conducted in tem- trol unit processes the data and then sends specific duty cycles
peratures ranging from 76 °C to 88 °C. Consequently, more that are transferred to the rotational velocities of four three-
vitamins and micro elements do not decay during the process, -phase BLDC motors. The motors are sourced from the ESC
which gives better nutrition values to the pasteurized juice. Quattro-SQ20A4U driver. It combines four high performance
The electronic circuit responsible for generating appropriate 20 A ESCs and a 5 V/3 A UBEC, where the ESC is based
voltage is controlled by the PWM signal from the microcon- on standard PWM control signal. The UART communication
troller. ATmega8535 is also responsible for regulating the dura- with a PC computer was applied for realization of real-time
tion of the process. The process parameters are displayed on data acquisition.
16 P O M I A R Y • A U T O M A T Y K A • R O B O T Y K A N R 1 / 20 1 5
Wojciech Kunikowski, Ernest Czerwiński, Paweł Olejnik, Jan Awrejcewicz
2. ATmega644PA as a PID controller for speed of the transmission belt on which the oscillating body
a DC motor of mass was placed (the physical system (3) under control)
an incremental encoder (4) was used. The ATB is powered by
a 15 V power supply (6). The DC motor is controlled by a RN12
In the two subsequent sections of the article the described algo- driver (2). Its power and logical electric circuits are sourced
rithms were implemented on the Atnel Testing Board (ATB) by MATRIX 60 V and 30 V power supply (7), respectively.
1.03 [13]. It is equipped with ATmega644PA – an 8-bit micro- For the purpose of GI333 encoder’s output noise cancelation,
processor with 64 kB of Flash memory, 2 kB EEPROM, 4 kB in the dedicated measuring circuit a M74HCT14N Schmitt
SRAM and three programmable timers (two 8-bit and one Inverter has been used. It allowed to damp any voltage peaks
16-bit). The system used in this study operates under the con- causing appearance of incorrect (redundant) pulses to be coun-
trol of 16 MHz external timing source. ted by the microcontroller. To enable compatibility between the
microcontroller and the RN12 driver, a L293D integrated circuit
was implemented. It served as an amplifier for the PWM signal.
A control algorithm pictured by the closed-loop control sys-
tem shown in Fig. 2 calculates the adequate duty cycle of the
PWM signal based on the reference speed and the number of
pulses produced by the encoder in some predefined time inte-
rval (30 ms). In consequence, 9.7 kHz frequency PWM signal
having well-modulated pulse width is sent to the RN12 regu-
lator, which generates appropriate voltage for the DC motor.
The PWM signal’s resolution is 10-bit so the variable describing
its duty cycle can be tuned from 0 to 1023.
The classical discrete PID controller takes the form:
, (1)
17
An Overview of ATmega AVR Microcontrollers Used in Scientific Research and Industrial Applications
18 P O M I A R Y • A U T O M A T Y K A • R O B O T Y K A N R 1 / 20 1 5
Wojciech Kunikowski, Ernest Czerwiński, Paweł Olejnik, Jan Awrejcewicz
19
An Overview of ATmega AVR Microcontrollers Used in Scientific Research and Industrial Applications
Ph.D. student of Mechanics at the Faculty Ph.D. student of Mechanics at the Faculty
of Mechanical Engineering at the Lodz of Mechanical Engineering at the Lodz Uni-
University of Technology. In July 2014, he versity of Technology. In July 2014, he com-
defended his thesis in Mechatronics titled pleted Master’s degree in Mechatronics by
“Fuzzy logic in angular velocity control writing the thesis „Modeling and parameter
algorithms of DC motors”. Currently, under identification of vibrations of a double tor-
the leadership of Paweł Olejnik, Ph.D. D.Sc. sional pendulum with friction”. Currently he
His planned Ph.D. thesis is to be in the field is continuing research in the field of Applied
of Applied Mechanics. His research inte- Mechanics. Research interests: classical
rests cover: theory of control, mechatronics, mechanics, theory of control, mechatro-
system modeling, numerical simulations. nics, CAD design, system modeling, nume-
rical simulations.
Paweł Olejnik, Ph.D. D.Sc. Eng. Prof. Jan Awrejcewicz, Ph.D. D.Sc. Eng.
[email protected] [email protected]
In 2000 he completed Master’s degree in He received the M.Sc. and Ph.D. degrees in
computer physics at the Faculty of Tech- the field of Mechanics from the Lodz Univer-
nical Physics, Computer Science and Applied sity of Technology in 1977 and 1981, respec-
Mathematics of Lodz University of Techno- tively. He received bachelor’s degree in Phi-
logy. Then, he took a research and teaching losophy in 1978 from the University of Lodz,
job in the Department of Automation, Bio- and D.Sc. degree in Mechanics from Lodz Uni-
mechanics and Mechatronics at Lodz Uni- versity of Technology in 1990. He is an author
versity of Technology. In 2002 he defended or co-author of 538 publications in scientific
his doctoral thesis in Mechanics under the journals and conference proceedings, mono-
leadership of Professor Jan Awrejcewicz with a graphs, text books, edited volumes, confe-
distinction of self-made experimental station rence proceedings, journal special issues,
exploring of a two degrees of freedom system other books and short communications or
with friction. He received D.Sc. degree in Applied Mechanics from Lodz Uni- unpublished reports. He is now the Head of Department of Automatics and
versity of Technology in 2013. He is an author of scientific publications con- Biomechanics, and the Head of Ph.D. School on ‘Mechanics’ associated with
cerned on the use of computational techniques for solving problems of dyna- the Faculty of Mechanical Engineering of Lodz University of Technology.
mical analysis of discontinuous systems, experimental research on laboratory In 1994 he earned the title of Professor from the President of Poland, Lech
stations, control of dynamical systems, virtualization of mechatronic systems. Wałęsa. He is a contributor to research journals and to conferences. His
papers and research cover various disciplines of mathematics, mechanics,
biomechanics, automatics, physics and computer oriented sciences
20 P O M I A R Y • A U T O M A T Y K A • R O B O T Y K A N R 1 / 20 1 5