Книжная полка Сохранить
Размер шрифта:
А
А
А
|  Шрифт:
Arial
Times
|  Интервал:
Стандартный
Средний
Большой
|  Цвет сайта:
Ц
Ц
Ц
Ц
Ц

Using the Arduino platform in robotic development

Покупка
Основная коллекция
Артикул: 806347.01.99
Доступ онлайн
174 ₽
В корзину
Учебное пособие содержит полное и систематизированное изложение материала, включенного в учебную программу курсов: "Разработка микроконтроллерных устройств на базе Arduino", "Компьютерное управление исполнительными механизмами", "Проект 3-го курса". Адресовано студентам, обучающимся по программам бакалавриата и магистратуры по специальностям "Мехатроника и робототехника" и "Электроэнергетика" Института радиотехнических систем и управления Южного федерального университета. Пособие включает в себя введение в микроконтроллеры и их применение, основы использования этих устройств, начальные этапы работы с платами микроконтроллеров, инструменты моделирования. Предназначено для начинающих в этой области, в дополнение к курсам, перечисленным выше. Включает упражнения и варианты для индивидуальных заданий.
Кульченко, А. Е. Using the Arduino platform in robotic development : учебное пособие / А. Е. Кульченко, М. Ю. Медведев ; Южный федеральный университет. - Ростов-на-Дону ; Таганрог : Издательство Южного федерального университета, 2022. - 134 с. - ISBN 978-5-9275-4254-3. - Текст : электронный. - URL: https://znanium.ru/catalog/product/2039096 (дата обращения: 22.11.2024). – Режим доступа: по подписке.
Фрагмент текстового слоя документа размещен для индексирующих роботов
 

 

МИНИСТЕРСТВО НАУКИ И ВЫСШЕГО ОБРАЗОВАНИЯ 

РОССИЙСКОЙ ФЕДЕРАЦИИ 

Федеральное государственное автономное образовательное  

учреждение высшего образования 

«ЮЖНЫЙ ФЕДЕРАЛЬНЫЙ УНИВЕРСИТЕТ» 

Инженерно-технологическая академия 

 
 
 

А. Е. КУЛЬЧЕНКО 

М. Ю. МЕДВЕДЕВ 

 

 

USING THE ARDUINO PLATFORM  

IN ROBOTIC DEVELOPMENT 

 

 
 

Учебное пособие 

 
 
 
 
 
 
 

                                              
 
 

 
 

Ростов-на-Дону – Таганрог 

Издательство Южного федерального университета 

2022 

 

 

УДК 811.1(075.8) 
ББК  81.2 Англ-92          
         К906 

Печатается по решению кафедры электротехники и мехатроники 

Института радиотехнических систем и управления Южного 

федерального университета (протокол № 7 от 13 апреля 2022 г.) 

Рецензенты: 

старший разработчик ООО «Люксофт Профешнл» (г. Санкт-Петербург), 

кандидат технических наук В. А. Крухмалев   

профессор кафедры систем автоматического управления Института 

радиотехнических систем и управления Южного федерального 
университета, доктор технических наук, профессор А. Р. Гайдук 

 

Кульченко, A. E. 

К906       Using the Arduino platform in robotic development : учебное посо
бие / А. Е. Кульченко, М. Ю. Медведев ; Южный федеральный университет. – Ростов-на-Дону ; Таганрог : Издательство Южного федерального университета, 2022. – 134 с. 

ISBN  978-5-9275-4254-3 

 
Учебное пособие содержит полное и систематизированное изложение 

материала, 
включенного 
в 
учебную 
программу 
курсов: 
"Разработка 

микроконтроллерных устройств на базе Arduino", "Компьютерное управление 
исполнительными механизмами", "Проект 3-го курса". Адресовано студентам, 
обучающимся по программам бакалавриата и магистратуры по специальностям 
"Мехатроника 
и 
робототехника" 
и 
"Электроэнергетика" 
Института 

радиотехнических систем и управления Южного федерального университета. 
Пособие включает в себя введение в микроконтроллеры и их применение, 
основы использования этих устройств, начальные этапы работы с платами 
микроконтроллеров, 
инструменты 
моделирования. 
Предназначено 
для 

начинающих в этой области, в дополнение к курсам, перечисленным выше. 
Включает упражнения и варианты для индивидуальных заданий. 

УДК 811.1(075.8) 
ББК  81.2 Англ-92          

 

ISBN  978-5-9275-4254-3 
 

© Южный федеральный университет, 2022 
© Кульченко А. Е., Медведев М. Ю., 2022 
© Оформление. Макет. Издательство  

 Южного федерального университета, 2022

CONTENT 

CHAPTER 1. INTRODUCTION ....................................................................... 5 
1.1. The microcontroller ..................................................................................... 5 

1.2. Microcontrollers vs microprocessors ........................................................... 6 
1.3. How do microcontrollers work? .................................................................. 6 

1.4. What does a microcontroller consist of ? ..................................................... 7 

1.5. Microcontroller features .............................................................................. 9 
1.6. Types of microcontrollers .......................................................................... 10 

1.7. Applications for microcontrollers .............................................................. 11 
1.8. Selecting a microcontroller for a project .................................................... 13 

1.9. Programming languages ............................................................................ 13 
1.10. Developer Hardware ................................................................................ 14 
1.11. ARDUINO Platform ................................................................................ 15 

1.12. Performance of the Arduino platform ...................................................... 20 

CHAPTER 2. GETTING STARTED WITH ARDUINO ................................. 22 
2.1. The device of a typical Arduino board ....................................................... 22 

2.2. Running the example program on Arduino ................................................ 23 
2.3. Installing libraries using the Package Manager .......................................... 25 
2.4. Program structure ...................................................................................... 27 

CHAPTER 3. SYNTAX ................................................................................... 29 

3.1. Data types and keywords ........................................................................... 29 
3.2. Scope and constants ................................................................................... 32 

3.3. Operators ................................................................................................... 33 
3.4. Conditional operators ................................................................................ 34 

3.5. Increment and commenting ....................................................................... 37 

3.6. Conditional operators ................................................................................ 39 
3.7. Logical operators ....................................................................................... 44 

3.8. Logical operator NOT (!)........................................................................... 47 

3.9. Ternary conditional operator ..................................................................... 48 
3.10. Conditional switch and break statements ................................................. 49 

3.11. One – dimensional arrays ........................................................................ 51 

Content  

 

3.12. Structures ................................................................................................. 55 
3.13. Pointers .................................................................................................... 58 
3.14. A Class..................................................................................................... 62 

CHAPTER 4. SIMULATION ........................................................................... 66 
4.1. Online Arduino Tinkercad Emulator .......................................................... 66 

4.2. Alternative emulator – Wokwi ................................................................... 70 

CHAPTER 5. PERIPHERY .............................................................................. 76 
5.1. Analog input .............................................................................................. 76 

5.2. Analog output ............................................................................................ 84 

5.3. Digital inputs/outputs ................................................................................. 86 
5.4. I2C Interface .............................................................................................. 91 

5.5. SPI Interface .............................................................................................. 96 

CHAPTER 6. LIBRARIES ............................................................................. 103 
6.1. Arduino Standard Libraries ...................................................................... 103 

6.2. Arduino EEPROM ................................................................................... 103 
6.3. Arduino FIRMATA ................................................................................. 105 

6.4. Arduino SERVO ...................................................................................... 106 

6.5. Arduino SoftwareSerial ............................................................................ 108 
6.6. Arduino IRremote .................................................................................... 109 

CHAPTER 7. DATA VISUALIZATION ON A PC ....................................... 116 
7.1. Plotter in Arduino IDE ............................................................................. 116 
7.2. Data visualization using Processing IDE .................................................. 117 
7.3. Data visualization using Qt for Python ..................................................... 123 

CHAPTER 8. PRACTICAL TRAINING........................................................ 125 
8.1. Task 1 ...................................................................................................... 125 

8.2. Task 2 ...................................................................................................... 126 

8.3. Task 3 ...................................................................................................... 129 
8.4. Task 4 ...................................................................................................... 131 

BIBLIOGRAPHY........................................................................................... 133 

 

CHAPTER 1. INTRODUCTION 

1.1. The microcontroller 

A general-purpose microcontroller (hereinafter referred to as a 

microcontroller) is a special microcircuit designed to control various electronic 
devices. A typical microcontroller includes a processor, memory, and 
input/output (I/O) peripherals on a single chip. In the block diagrams, the 
microcontroller unit may be referred to as the MCU. Microcontrollers are used 
everywhere. They are used in industry, robotics, household appliances, medical 
devices, and other devices. These are miniature calculators for controlling the 
components of a more complex system. Microcontrollers can work without an 
operating system. The Figure 1.1 shows the appearance of the microcontroller. 
These microcircuits can have a different form factor, depending on the 
application. The same microcontroller can be produced in large DIP packages, as 
well as in compact tqfp.     

 

 

Fig. 1.1. Atmel microcontrollers 

Chapter 1. Introduction  

6 

1.2. Microcontrollers vs microprocessors 

Modern microcontrollers and processors differ in design and purpose. 

There is a statement that the difference between has become less clear, but this is 
fundamentally not true. The processor requires additional hardware components 
(RAM module, ROM module, modules for communication with external 
devices, etc.) and an operating system. Think about how your personal computer 
works. A microcontroller has lower performance than a microprocessor, but is 
generally more energy efficient. To start a modern microcontroller, it is enough 
to apply power, and it is ready to work. Sensors, drivers and actuators can be 
directly connected to the microcontroller. The basic condition for this is the 
observance of coordination by logical levels. While microprocessors are 
designed to perform calculations with maximum efficiency, communication with 
peripheral devices is carried out via internal buses. For this reason, 
microprocessors require special cooling. The microprocessor itself is installed on 
the motherboard. In other words, the microprocessor is not a stand-alone device. 
 

1.3. How do microcontrollers work? 

The microcontroller is integrated into the system to control a separate 

task of the device. It does this by interpreting the data it receives from its I/O 
peripherals using its CPU. The temporary information that the microcontroller 
receives is stored in RAM, where the processor gets access to it and uses 
instructions stored in its program memory to decrypt and apply incoming data. It 
then uses its peripheral I/O devices to communicate and perform the appropriate 
actions. 

Due to the convenience and accessibility, microcontrollers are used in 

many systems and devices. A single device can include dozens of 
microcontrollers that work together inside the device to perform certain tasks. If 
a microcontroller has a small cost, it is very advantageous to use several 
microcontrollers to solve isolated tasks. 

For example, in a modern car, there may be many microcontrollers that 

control various isolated systems, such as anti-lock braking system, traction 
control, fuel injection. In this case, all microcontrollers interact with each other 
via a special data bus, such as CAN. If more complex processing is required, 
then a more efficient microcontroller or microprocessor is installed. They send 

1.4. What does a microcontroller consist of ? 

7 

and receive data using their I/O peripherals and process that data to perform their 
assigned tasks. 

 

1.4. What does a microcontroller consist of ? 

The microcontroller consists of components: 
 Processor (CPU). It processes and responds to various instructions 

that control the operation of the microcontroller. This includes performing basic 
arithmetic, logic, and I/O operations. It also performs data transfer operations 
that transmit commands to other components of a larger embedded system.  
It also consists of separate blocks. The processor block diagram is shown in 
Figure 1.2. 

 Memory. The memory of the microcontroller is used to store data that 

the processor receives and uses to respond to instructions that are programmed to 
execute. The microcontroller has two main types of memory: Program memory, 
which stores long-term information about instructions executed by the CPU. 
Program memory is non-volatile memory, meaning it stores information over 
time without requiring a power supply. Data memory required for temporary 
storage of data during execution of instructions. The data memory is volatile, 
that is, the data stored in it is temporary and is stored only if the device is 
connected to a power source. 

 Peripheral input/output devices. Input and output devices represent 

the processor's interface with the outside world. They allow you to convert 
analog input signals into digital. Input ports receive information and send it to 
the processor in the form of binary data. The processor receives this data and 
sends the necessary instructions to the output devices that perform tasks external 
to the microcontroller. Peripheral devices can determine the scope of the 
microcontroller. 

Although the processor, memory, and I/O peripherals are the defining 

elements of a microprocessor, other elements are often included in it. The term 
peripheral I/O devices simply refers to auxiliary components that interact with 
memory and processor. There are many auxiliary components that can be 
attributed to peripheral devices. The presence of some peripheral I/O devices is 
elementary for a microprocessor because they represent the mechanism by which 
the processor is applied. 

Chapter 1. Introduction  

8 

 

Fig. 1.2. The block diagram of AVR MC 

A set of peripheral devices, their capabilities may differ depending on the 

model of the microcontroller, its cost. 

Microcontrollers include peripheral devices: 
Analog-to-Digital Converter (ADC) – An ADC is a circuit that converts 

analog signals into digital signals. This allows the processor in the center of the 
microcontroller to interact with external analog devices such as sensors. 

Digital-to-analog converter (DAC). The DAC performs the reverse 

function of the ADC and allows the processor in the center of the microcontroller 
to transmit its outgoing signals to external analog components. 

System bus. The system bus is a connecting wire connecting all the 

components of the microcontroller together. 

1.5. Microcontroller features  

9 

Synchronous-asynchronous transceiver. The serial port is one example of 

an I/O port that allows a microcontroller to connect to external components. It 
performs functions similar to USB, but differs in the way bits are exchanged. 

 

1.5. Microcontroller features 

The 
choice 
of 
microcontroller 
depends 
on 
the 
application. 

Microcontrollers range from simple 4-bit, 8-bit or 16-bit processors to more 
complex 32-bit or 64-bit processors. Microcontrollers can use types of volatile 
memory, such as random-access memory (RAM) and various types of nonvolatile memory, including flash memory, erasable programmable permanent 
memory (EPROM) and electrically erasable programmable permanent memory 
(EEPROM). For example, EEPROM is present in ATmega microcontrollers, but 
is absent in STM32 microcontrollers. 

When developing microcontrollers, the possibility of their use without 

additional computing components is taken into account. It offers some average 
amount of internal memory, the presence of ports for general I/O operations, so 
that microcontrollers can directly interact with sensors and other components. 

The architecture of the microcontroller can be based on Harvard 

architecture or von Neumann architecture. Architectures differ in the methods of 
data exchange between the processor and memory. In the Harvard architecture, 
the data bus and the instruction are separated, which allows simultaneous 
transmission. The von Neumann architecture uses a common bus for data and for 
instructions. 

Microcontroller processors can be based on computations with a complex 

instruction set (CISC) or computations with a reduced instruction set (RISC). 
CISC usually has about 80 instructions, and RISC has about 30, as well as more 
addressing modes. CISC may be easier to implement and uses memory more 
efficiently, its performance may decrease due to the greater number of clock 
cycles required to execute instructions. RISC often provides higher performance 
than CISC processors due to a simplified instruction set. 

Microcontrollers have peripherals for implementing communication and 

control functions. Such peripherals include analog-to-digital converters, display 
controllers, real-time clocks (RTC), universal synchronous/asynchronous 
receiver-transmitter (USART), timers, watchdog timer, universal asynchronous 
receiver-transmitter (UART) and universal serial bus (USB), SPI, I2C. Sensors 

Chapter 1. Introduction  

10 

that collect data about the environment are often connected to the 
microcontroller via the I2C or SPI interface. 

 

1.6. Types of microcontrollers 

The general-purpose microcontrollers include the Intel MCS-51, often 

referred to as the 8051 microcontroller, which was first developed in 1985; the 
AVR microcontroller, developed by Atmel in 1996; the programmable Interface 
Controller (PIC) from Microchip Technology; the MSP430 from Texas 
Instruments (has a von Neumann architecture used in energy-efficient 
applications) and various licensed Advanced RISC microcontrollers Machines 
(ARM). The most famous ARM microcontrollers are being developed by NXP 
Semiconductors, Renesas Electronics, Silicon Labs and Texas Instruments and 
STMicroelectronics. 

Figure 1.3 shows family of Atmel's line of microcontrollers. Atmel offers 

various models that differ in functionality and price. 

 

 

Fig. 1.3. The family of Atmel microcontrollers [1] 

Доступ онлайн
174 ₽
В корзину