Volatile is probably least documented keyword in most tutorials and books. Probably this is main cause of most misuses and bugs related to it. If you already are programming microcontrollers, you probably know that volatile is always used on global variables that are accessed from interrupt service routines. Otherwise code won’t work.
After few requests I decided to drop few lines about volatile keyword. This keyword is commonly used to tag memory type. We hear “volatile memory”, “non-volatile memory” when talking about computer hardware. As quick reminder – “non-volatile memory” is type of memory that stores its contents even when power is off. Such type of memory is EEPROM, Flash, FRAM. This is easy from hardware perspective. But what volatile keyword means in C or C++ code? This is an indicator (called qualifier) to compiler that tells that this variable may be changed during program flow even if it doesn’t look like to be. This means that compiler must treat this value seriously and keep optimizer away from it. Continue reading
GPS modem is a device which receives signals from satellite and provides information about latitude, longitude, altitude, time etc. The GPS navigator is more famous in mobiles to track the road maps. The GPS modem has an antenna which receives the satellite signals and transfers them to the modem. The modem in turn converts the data into useful information and sends the output in serial RS232 logic level format. The information about latitude, longitude etc. is sent continuously and accompanied by an identifier string.
The connection of GPS modem with AVR microcontrollers shown in the circuit diagram. The ground pin of max 232 and serial o/p of GPS modem is made common. Pin2 of MAX232 is connected to pin 3 of GPS modem and pin 3 of max 232 is connected to pin 2 of modem. This type of connection is called a serial cross cable. Continue reading
Connecting a button as an input to a micro-controller is a relatively easy task, but there are some problems. The main problem is that buttons bounce, i.e. when you press (or release) a button it will often change level a couple of times before it settles at the new level. So if you, for example, connect the button to a pin with an external interrupt enabled, you will get several interrupts when you press the button once. This behavior is normally not wanted. Even if the button’s didn’t bounce (with filtering hardware for example) we still want to capture the event of a pushed button and take some action one time for every button press, so we need to keep track of the state of the button as well.
One technique, used in this tutorial, to handle this is to check (poll) the button(s) periodically and only decide that a button is pressed if it have been in the pressed state for a couple of subsequent polls. Continue reading
In a past tutorial, we saw how to control a servo using AVR. This tutorial will aim at interfacing a DC geared motor with the ever popular ATMEGA series. For the sake of simplicity we will just learn a way to interface DC motor and not controlling it’s speed. DC Motors are small, inexpensive and powerful motors used widely in robotics for their small size and high energy out. A typical DC motor operates at speeds that are far too high speed to be useful, and torque that are far too low. Gear reduction is the standard method by which a motor is made useful .Gear’s reduce the speed of motor and increases the torque.
Choosing a DC Motor depends upon the application. Continue reading