Architecture and system

Concepts

The Waspmote's architecture is based on the Atmel ATmega1281 microcontroller.

When Waspmote is connected and starts the bootloader, there is a waiting time (62.5 ms) before beginning the first instruction, this time is used to start loading new compiled programs updates. If a new program is received from the USB during this time, it will be loaded into the FLASH memory (128 kB) substituting already existing programs. Otherwise, if a new program is not received, the last program stored in the memory will start running.

The structure of the codes is divided into 2 basic parts: setup and loop. Both parts of the code have sequential behaviour, executing instructions in the set order.

The setup is the first part of the code, which is only run once when the code is initialized. In this part it is recommended to include the initialization of the modules which are going to be used, as well as the part of the code which is only important when Waspmote is started.

The part named loop runs continuously, forming an infinite loop. Because of the behavior of this part of the code, the use of interruptions is recommended to perform actions with Waspmote.

A common programming technique to save energy would be based on blocking the program (either keeping the micro awake or asleep in particular cases) until any of the interruptions available in Waspmote show that an event has occurred. This way, when an interruption is detected the associated function, which was previously stored in an interruption vector, is executed.

To be able to detect the capture of interruptions during the execution of the code, a series of flags have been created and will be activated to indicate the event which has generated the interruption (see chapters "Interruptions" and "Energy system").

When Waspmote is reset or switched on, the code starts again from the setup function and then the loop function.

By default, variable values declared in the code and modified in execution will be lost when a reset occurs or there is no battery. To store values permanently, it is necessary to use the microcontroller's EEPROM (4 kB) non-volatile memory. EEPROM addresses from 0 to 1023 are used by Waspmote to save important data, so they must not be over-written. Thus, the available storage addresses go from 1024 to 4095. Another option is to make use of the SD card.

Timers

Waspmote uses a quartz oscillator which works at a frequency of 14.7456 MHz as a system clock. In this way, every 68 ns the microcontroller runs a low level (machine language) instruction. It must be taken into account that each line of C++ code of a program compiled by Waspmote includes several instructions in machine language.

Waspmote is a device prepared for operation in adverse conditions with regards to noise and electromagnetic contamination, for this reason, to ensure stable communication at all times with the different modules connected through a serial line to the UARTs (communication modules and USB) a maximum transmission speed of 115200 bps has been set for the communication modules and the USB port, and 4800 for the GPS, so that the success rate in received bits is 100%.

Watchdog

The ATmega1281 microcontroller has an internal Enhanced Watchdog Time - WDT. The WDT precisely counts the clock cycles generated by a 128 kHz oscillator. The WDT generates an interruption signal when the counter reaches the set value. This interruption signal can be used to wake the microcontroller from the Sleep mode or to generate an internal alarm when it is running in on mode, which is very useful when developing programs with timed interruptions.

The WDT allows the microcontroller to wake up from a low consumption Sleep mode by generating an interruption. For this reason, this clock is used as a time-based alarm associated with the microcontroller's Sleep mode. This allows very precise control of small time intervals: 16 ms, 32 ms, 64 ms, 128 ms, 256 ms, 500 ms, 1 s, 2 s, 4 s, 8 s. For intervals over 8 s (Deep Sleep mode), the RTC is used and not the microcontroller.

More information about the interruptions generated by the Watchdog can be found in the "Energy system" chapter.

Related API libraries: WaspPWR.h, WaspPWR.cpp

All information about their programming and operation can be found in the Interruptions Programming Guide.

All the documentation is located in the Development section in the Libelium website.

RTC Watchdog for reseting Waspmote

One of the alarms of the RTC (Alarm 2) is connected to a Watchdog reset circuit that is able to reset the microcontroller of Waspmote when the alarm is generated. This Watchdog has been implemented for reseting Waspmote if it gets stuck. That periodical reset avoids erratic behaviour. This is highly recommended for applications that need to be very robust and can never stop working. The use of the Watchdog feature enssures us that our Waspmote will never stop working.

The Watchdog feature requires the physical watchdog switch to be put in "enable" position.

Related API libraries: WaspRTC.h, WaspRTC.cpp

All information about the RTC programming and operation can be found in the RTC Programming Guide.

All the documentation is located in the Development section in the Libelium website.

RTC

As shown in the "Hardware" chapter, Waspmote has a real time clock (RTC) running a 32.786 kHz which allows to set an absolute time.

Alarms can be programmed in the RTC specifying day/hour/minute/second. This allows total control when the mote wakes up to capture values and perform actions programmed on it. Also, the RTC allows Waspmote to function in the maximum energy saving modes (Deep Sleep and Hibernate) and to wake up just at the required moment.

The RTC allows the microcontroller to be woken from a low consumption state by generating an interruption. For this reason, it has been associated to the microcontroller's Deep Sleep and Hibernate modes, making it possible to put the microcontroller to sleep, and wake it up by activating an alarm in the RTC. Sleeping intervals can go from 1 s to minutes, hours or even days.

More information about the interruptions generated by the RTC and Deep Sleep and Hibernate modes can be found in the "Energy system" chapter.

Related API libraries: WaspRTC.h, WaspRTC.cpp

All information about the RTC programming and operation can be found in the RTC Programming Guide.

All the documentation is located in the Development section in the Libelium website.

Last updated