Lesson 1. Introduction. General information about Arduino.

Arduino Uno

As a professional microcontroller programmer, I do not think Arduino controllers are a good element for developing complex systems. But I quite appreciated the simplicity of developing projects in this system, the simplicity of learning, writing programs, the convenience of using ready-made hardware modules.

List of lessons     Next lesson

On the Internet, there are a large number lessons about programming  in the Arduino system. Most of them are reduced to primitive programs that perform sequential actions from other people's functions.

It immediately catches the eye that the programs are written extremely unprofessional.

  • The signals of the hardware devices that are connected to the controller are not well processed. For example, the simplest elements are buttons. There is a bounce of the buttons, they can be connected by long wires, sensitive to interference. In a reliable system, it is mandatory to use digital signal filtering from buttons or dry contact sensors. As a rule, in the examples of lessons, the state of the button signals is simply read.
  •  Reliable microcontroller programs require cyclic resetting of variables, monitoring of data integrity.
  •  A good style of programming microcontrollers implies structural programming. These are not formal words. You can develop beautiful, structured programs in assembler, but you can create a chaotic set of operators in C ++.
  •  Perhaps the most important is multitasking. Almost in all lessons - the sequential actions of the program. We looked at the state of the button, then lit the LED, caused some strange function ... The result is achieved simply, but the result is somehow flawed.

If you take, for example, my program of controller for the refrigerator on the Peltier element. How to do it on this principle? How to perform all the necessary actions with simple sequential operations? This program is written in assembler for PIC controller. It performs many parallel operations:

  • With a period of 10 ms, it scans three buttons, provides digital filtering of button signals, eliminates bounce.
  • Every 2 ms regenerates the data of the LED seven-segment LEDs and LEDs.
  • Generates control signals and reads data from two DS18B20 temperature sensors with a 1-wire interface. It is necessary to generate a new read or write bit for each sensor every 100 μs.
  • Every 100 μs reads the analog values of the output current, output voltage, and supply voltage.
  • Averages the values of the output current and voltage in each 10 ms, calculates the power on the Peltier element.
  • Constantly operates a complex system of regulators:
    • Stabilization of current, voltage, power on the Peltier element;
    • PID (proportional integral differential) temperature controller.
  • Processes protective functions, checks data integrity.
  • Provides reading and writing internal EEPROM.
  • And, of course, the overall management of the system, the logic of work.

All these operations must be performed cyclically with different cycle periods. And you can not skip anything or suspend anything. Such a program can not be implemented by a simple sequence of actions.

In my programming lessons Arduino I'm going to pay attention to the above problems. I'm going to teach practical programming. Programming Arduino controllers that work with real objects.

At the same time, I focus lessons on nonprofessional programmers, on people who want to learn how to program controllers.

Despite frightening expressions - digital filtering, multitasking, it's much easier than it seems. It's just necessary to strictly handle all possible situations, do not close their eyes to them.

Rather, it will be programming and electronics lessons, since the use of microcontrollers without additional hardware does not make sense. Something they must control.

In each lesson, I will strive to create a complete module that can be used in future projects. Ideal is the creation of a similarity of the operating system, in which the drivers (functions) of all external hardware are used. I managed to create such a system on PIC controllers for managing complex filling equipment. It includes an environment for performing parallel tasks and drivers for working with stepper motors, sensors, buttons, a display, and so on. I hope, it will turn out on Arduino.

 

General information about Arduino.

Arduino is the name of hardware and software tools for creating simple electronic systems of automation and robotics. The system has a completely open architecture and is aimed at non-professional users.

The software part of Arduino consists of an integrated software environment (IDE), which allows you to write, compile programs, and also upload them to hardware.

The hardware consists of electronic boards with a microcontroller, associated elements (voltage stabilizer, quartz resonator, blocking capacitors, etc.), a port for communication with a personal computer, connectors for input / output signals, and so on.

Arduino Uno

Due to the simplicity of the development of devices, the Arduino system has become extremely widespread. In one Yandex, up to 150 thousand requests "Arduino" per month. Despite the simplicity of project development, using Arduino, quite complex systems can be created, especially after the appearance of high-performance controllers.

The Arduino boards use Atmel AVR microcontrollers with a bootloader stitched into them. Using the bootloader, the program is written into the microcontroller from a personal computer without the use of hardware programmers.

For programming Arduino uses the language C / C ++, with some features.

There is a huge number of clones of the Arduino hardware. Most of them are full analogues of branded Arduino, often not inferior in quality.

List of lessons     Next lesson

Leave a Reply

Your email address will not be published. Required fields are marked *