Short Brief On Arduino
The hardware of the Arduino has evolved slowly since its introduction in 2005. Because Arduino as a concept is very much a combination of hardware and software. Arduino is an open-source single-board microcontroller. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments. The hardware consists of a simple open hardware design for the Arduino board with an Atmel AVR processor and on-board input/output support. The software consists of a standard programming language compiler and the bootloader that runs on the board.
Programming For Arduino
Arduino programs are written in C/C++, although users only need define two functions to make a runnable program: Arduino has two important functions: setup() and loop().The setup() function performs whatever one-time initializations need to be made. The loop() function is then called repeatedly. The calling of the setup() and loop() functions is handled automatically behind the scenes.
So , this code for arduino
will be in C
Super Loop A super loop is a program structure comprised of an infinite loop, with all the tasks of the system contained in that loop.
All mirco-controllers use this technique in executing the program (void loop() , while(1)) .
Why RTOS ?
as in superloop style , you can’t assign priority to a task you want , all tasks have the same priority . let me show you , you’re driving a car , playing the music and switching the AC on .If you’re typing your code in a superloop , you won’t get the brakes in time and the accident will happen. unlike priority based systems , if you want to get the brakes , you’ll get it in time -as it has high priority- , that’s what RTOS does. RTOS stands for Real Time Operating System.There’re many vendors of it but the common one is micro C OS . there’s also DuinOS for Arduino -Which I’m going to talk about.[divider scroll_text=””]
DuinOS is a small multithreading real time operating system (RTOS), based on the FreeRTOS kernel, for Arduino compatible boards. . Uses priorities in tasks. You can create and suspend whatever you like from tasks. you can create multiple tasks and pass it to the loop() function.
Assuming that you used arduino IDE before and you named the directory into “arduino”
1- Open a terminal and type this command
svn checkout http://duinos.googlecode.com/svn/trunk/ duinos-read-only
2- Go to the place where you downloaded the source code. copy arduino.DuinOS folder into arduino working directory -/arduino/hardware/arduino/cores-
3- Copy boards.txt file from duinos-read-only/hardware to arduino/hardware/arduino
[message_box title=”Note” color=”blue”]You’ll find an already file called boards.txt , change it to whatever you want[/message_box]
4- Copy keywords.txt from duinos-read-only/lib to arduino/lib
[message_box title=”Note” color=”blue”]you’ll find an already file called keywords.txt , change it to whatever you want[/message_box]
5- Open Arduino IDE and choose the appropraite board (you’ll fine the name of your board with + DuinOS next to it)
The source code comes with two examples that demonstrates how it uses the priorities with tasks. copy the contents of examples of the source code into arduino/examples and start the IDE . Go to file > examples > MoreComplexBlinking. Burn it on the board and see what’s happening.
So when you need to define a task in duinOS , here’s an example for togglong a LED
switching between tasks is done through nextTask(); call in loop() function.
Well, this was a brief introduction about how to use RTOS(DuinOS) on an Arduino board. For further informations check refrences.[divider scroll_text=””]