The microcontroller based voting machines made the process of voting and counting the voted lot easier than before. Previously the votes were marked in paper which are then stored safely in a box and inside a well secure room for days. The process of separating the votes and counting them manually may take a lot of days. But after finding the electronic voting machine the votes can be marked without using papers, which makes the voting process eco-friendly. Moreover it makes the counting process faster and the results can be announced in a comparatively shorter period of time. There should be a controller inside the Electronic Voting Machine (EVM) which controls the process and there should be storage medium where the details of the vote are stored. There should be a ballet unit which is been used in such a way that the one who came to cast the vote can do only one vote.
A microcontroller is a device which has an inbuilt processor surrounded by few dedicated hardware modules. Once the microcontroller initializes them they start operating on their own. In case of an ADC it will do the sampling and digital to analog conversion all by itself and keep the converted data in its buffer so that the microcontroller can read that later. The advantage of this kind of implementation is that the microcontroller is free to do other tasks during that time and hence increase the overall efficiency. That was the case of hardware modules or peripherals inside a microcontroller which increases the processing efficiency of the built in processor. The efficiency can increase even more if the external hardware attached to the microcontroller can also does lot more tasks by their own without depending the microcontroller.
The Boot-Loader is a code which executes when a microcontroller is powered ON or reset. It basically sets an environment for the application code to execute. It is the Boot-Loader that sets the hardware and loads the application code from any storage medium or received through external communication and let the application to execute. Thus a Boot-Loader has to perform the following basic function : Initialize the controller peripherals, Initialize the devices in the board, Allow an option for the user to select from the available applications to load, Load the selected application, Let the application code to execute. Apart from the above mentioned functions some Boot-Loaders can perform many other functions and there are Boot-Loaders which don’t perform all these functions like provide option to select the required application etc. The Boot-Loader codes in microcontrollers are actually very small and simple compared to the Boot-Loaders in advanced devices like PC. In most of the microcontroller the functionality of a Boot-Loader is limited only to set the initial clock and other settings for the microcontroller, load an application binary from the serial port etc.
In any microcontroller the Boot-Loader is the first code which executes before the application code does. The major function of the Boot-Loader is to load the application code into the flash memory of the microcontroller and execute it. In AVR microcontroller the Self Programming Mode (SPM) helps the Boot-Loader to load a particular application from where the application binary is stored.The Boot-Loader may receive the code binary from other memory chips, SD-cards or through the serial port of the microcontroller in case of serial programming. It is then with the help of the SPM that the microcontroller write the binary code into the application flash section. In this particular project the operation of a Boot-Loader code using the SPM is demonstrated by re-writing flash memory with the code binary which has already been flashed into the built-in EEPROM of the ATMEGA16. The hardware used in this project includes ATMEGA16 as microcontroller, USBASP as the programmer and the software used are AVR STUDIO4 as IDE and AVR-BURNO-MAT as the burner software.
The Self Programming Mode (SPM) is a feature which enables a microcontroller to program its own flash memory. Using the SPM a microcontroller can program itself with an SPM code. The SPM is commonly used with the microcontroller Boot-Loader codes which help to program the microcontroller serially. In AVR microcontroller the SPM is available only for the code running in the BLS of the flash memory. With the help of the SPM a code in BLS can rewrite the application flash memory entirely or a part of it. It can even rewrite its own code in the BLS section. The SPM is a key factor of the Boot-Loader code since the major function of the Boot-Loader is to load an application code into the application flash section. The Boot-Loader may receive the code binary from other memory chips, SD-cards or through the serial port of the microcontroller in case of serial programming.
In almost all the microcontroller codes the peripheral initialization functions like uart initialization, spi initialization are written along with the different application codes. These initialization functions are actually repetitions of the original initialization functions. The same is the case with the external hardware initialization like LCD initialization, GSM modem initialization etc. Suppose the case in which the application codes required are stored in a memory chip or SD memory card so that there is an option to select between the applications. If all the application codes have the same functions for peripheral and external hardware initialization that will simply increase the size of the code only and the size of the memory required to store the codes. It will take too much time for the Boot-Loader to load such a large size application and there will be flash memory shortage issues due to the large code size. These issues can be solved by doing the initialization of the peripherals and the external hardware in the code running from the BLS itself.
In the AVR microcontroller the flash memory is divided into two parts, namely Application Section and Boot Loader Section. A code can be programmed into either the Application Section or the Boot loader Section (BLS). The code programmed into the Application section runs normally and is used for common applications, whereas the code running in the BLS is provided with some special features. The code running in the BLS section can execute Self Programing Mode (SPM) instructions which are blocked for the code running in the Application section. Using SPM instructions the code from the BLS can rewrite the code in the application section or the code in the BLS itself. The BLS section is normally used for storing the Boot-loader code for the microcontroller. The Boot-Loader code can be used for initializing the peripherals in the microcontroller, initialize the devices connected to the microcontroller, select the application to load and execute from a storage medium, load the selected application to the application section, jump to the application section and execute the application.
This project explains how to interface the SD card with an AVR microcontroller. In this project an ATMEGA16 microcontroller is used. The microcontroller runs on 5V power supply with a built in crystal frequency of 8 MHz. A 2GB SDSC card from Transcend is used in this particular project, but the code will work with most of the SD cards. The SD card is formatted with FAT32. The ultimate aim of this project is to read a file from the FAT32 file system of the SD card.The SD card has been formatted as FAT32 before interfacing. The generalized code for the FAT32 is written to interface the SD card. Explanations of the FAT32 file system and how to access files from these file system is explained in this project.This project explains the SD card interfacing with an AVR microcontroller and circuit working in detail. Read more to find out how this project works and do it yourself!!!
GPS modem is a device which receives signals from satellite and provides information about latitude, longitude, altitude, time etc. The GPS navigator ismore 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.This article shows how to interface the GPS modem with ATmega16 and extract the location (latitude and longitude) from the GPGGA string and display it on LCD. The connection of GPS modem with AVR microcontroller (ATmega 16) is 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.
Some high end applications require multiple or critical calculations to be done by the microcontroller. This may lead to cases when the controller enters intowrong or infinite loops. As a result of this, the system either hangs up or gets crashed. The solution to overcome these situations is to automatically reset the system whenever such a situation arises.The Watchdog Timer is a hardware or software generated timer interrupt which reboots/resets the system in the situations mentioned above. The watchdog timers are also used in cases when you intentionally require resetting the system without any physical interference.The AVR microcontroller has an in-built watchdog timer. This article explains the working of watchdog timer in ATmega16. The Watchdog Timer is a special timer which can be enabled in any section of the code and when enabled it ensures that a certain number of instructions execute within a pre-defined time frame. This time frame or the time delay can be configured/set using the registers of the watchdog timer.
ADC is an electronics device that converts the analog signals to digital number proportional to the magnitude of voltage. The ADClike ADC0804, ADC0809 etc., give 8-bit digital output. The controller device needs eight pins to receive the 8-bit data (For more details about ADC refer to Using Inbuilt ADC of AVR). Some applications need higher resolution ADCs, (10 or higher bits digital data output) for data accuracy. Using parallel ADCs is one option for such applications. However using parallel ADC will increase the size of the hardware as a 10-bit parallel ADC will have 10 output lines. Also you might have to use controller with higher number of pins. The other option is to use serial ADC, which needs smaller number of pins. Since the data is transmitted serially, the data transfer rate of the serial ADC is low as compared to parallel ADC. They can serve as a very good alternative in applications where speed of data transfer in not a critical point. This article explores interfacing of serial ADC0831 with ATmega16.
For understanding the human needs a system must be able to take input from user. The devices which can be used to take input for a system are keypad, touch [[wysiwyg_imageupload::]]screen, etc. In the article LED blinking, the microcontroller drives the LED or in embedded language the microcontroller was set to give o/p, this article gives brief information of getting an input from user at a particular pin of microcontroller. In order to take input from an external source on any of the pins of the AVR microcontroller, the pins need to be configured as input pin. This configuration informs the controller that the corresponding pins are used to take input. Read more to find out how the circuit is constructed and how the IC can be programmed to work in the desired manner.
This article explores the TWI interfacing between two ATmega32 controllers. Readers are advised to go through TWI Communication and TWI registers[[wysiwyg_imageupload::]]of ATmega32 before going further. Generally modes 1 & 3 and modes 2 & 4 are used together. This article explains the use of these four modes by an experiment.To establish the communication between two ATmega32 using TWI interface. First the Master starts by sending data then the slave transmits complement of the received data to the master. When the Master receives the complemented data, it shifts the original data to left. This process of transmitting and receiving continues. As the data value reaches 0x80 the whole process is repeated. At the starting, value of the original data is 0x01. The received value is displayed on PORTB at both the ends.
Servo motors find huge applications in industries in the field of automation, control & robotics. The servo motors are well known for their precise control and work [[wysiwyg_imageupload::]]on the principle of servo mechanism. The servo motors can be made to run at precise angle using PWM. The PWM (pulse width modulation) is the basic working principle behind a servo motor (For more details about PWM refer Phase correct PWM mode). This article explores the interfacing of servo motor with ATmega16. Also to know more about servo mechanism see Interfacing Servo Motor with 8051. There are different types of servos available in the market. This article bounds its scope to interfacing a commonly available servo, widely used by hobbyist with ATmega16. Such a servo consists of three wires positive supply, ground and a control signal. Unlike other motors, Servo motors don’t require any driver. When a PWM signal is applied to its control pin the, the shaft rotates to a specific angle depending on the duty cycle of the pulse.
Keypad is most widely used input device to provide input from the outside world to the microcontroller. The keypad makes an application more users interactive. [[wysiwyg_imageupload::]]The concept of interfacing a keypad with the ATmega16 is similar to interfacing it with any other microcontroller. The article of Interfacing keypad with 8051 can be referred for detailed description of the methodology used here. This article explains the interfacing of a 4×3 keypad with AVR microcontroller(ATmega16) and displaying the output on a LCD. The algorithm and detailed explanation for keypad interfacing is given in above mentioned article. The brief steps to interface the keypad with AVR are written below:1. Configure the row pins or column pins.2. Make all output pins to low and input pins to high.3. Keep monitoring the port value, where the key pad is connected.
ATmega16 has 32 I/O pins to communicate with external devices. Before interfacing with external devices, these pins must be cofigured as input or output pin. [[wysiwyg_imageupload::]]This article demonstrates the basic I/O operation of ATmega 16 using LEDs. All the four ports can be configured to read an input from some external device or to give output to any external device as per the application. For e.g., a switch is connected to a particular pin, that pin should be configured as input to read the values from the switch (external Device in this case) and if you are connecting a LED to any pin of the port then that particular pin should be configured as output to transmit the signal to the LED (external device in this case). A single port can be configured such that some of the pins of the same port are input and some are output. Read on more to understand how LED interfacing is done with the help of an AVR.
When an interrupt occurs, the normal flow of instructions is suspended by the microcontroller and the code corresponding to the interrupt, which has occurred, is executed. Once the code corresponding to the interrupt is executed completely the execution again begins from the same instruction where it was stopped. Following is what happens when…
The previous article explains serial communication using 8-bit data transfer. AVR microcontroller also supports serial data transfer with frame size of 5, 6, 7 and 9 [[wysiwyg_imageupload::]]data bits. The size of data frame can be adjusted according to application. For example, consider a system that needs to transmit only ASCII codes as data. In this case data frame size of 7-bits is sufficient because data length of ASCII code is equal to 7-bit. This will makes system more efficient by saving time of one clock period in each data frame transmission. This article explains serial transfer of data with different frame size. A test program is written for 6-bit data communication between Microcontroller and PC. In this experiment the input is taken from the user through a keyboard. The corresponding data is sent to microcontroller via PC’s COM port. The microcontroller receives data and returns it again to PC’s COM port. The HyperTerminal is used to configure COM port to make it compatible for this experiment.
At times we come across applications or situations wherein we need to generate square waves with the microcontroller. The square wave can be generated by [[wysiwyg_imageupload::]]programming a pin which toggles between 0 and 1 with a certain time delay. Alternatively, the inbuilt feature of AVR timers can be used in square wave generation. The advantage of using AVR timers in wave form generation is that the output pin toggles automatically when the timer condition are fulfilled. This article focuses on usage of AVR timer for simple square wave generation. It is better to use CTC mode instead of Normal mode because in CTC mode, frequency can be easily adjusted. ?When the Timer is triggered, register TCNTn counts the value constantly as timer started. Each timer has an OCRn (Output Compare Register), which is continuously compared with TCNTn register. In CTC mode whenever match occurs, OCFn (Output Compare Flag) will set to 1. If continuous wave form generation is required, OCFn must be reset again. Alternatively, if OCIEn (Output Compare interrupt) and Global interrupt flags in SREG are set, OCFn will reset automatically after interrupt execution.
Pulse Width Modulation is well known technique for controlling power electronics devices like SCR, IGBT etc. PWM is also used in motor speed controlling.[[wysiwyg_imageupload::]] Square wave generation by using AVR timers is explained in previous article. The AVR timers have feature of PWM wave generation as well .This article describes PWM generation capability of AVR timers. There are four in-built PWM channels in ATmega16. The PWM outputs are received on pins OC0, OC1A, OC1B and OC2. Readers can refer the previous article which gives explanation of these pins. The Phase correct PWM mode can be selected by assigning bits WGM0[1:0]=01. This mode is based on dual slope operation. In dual slope operation, TCNTn counts from bottom value to maximum value and maximum value to bottom value. The OCRn register compares the value with the TCNTn register constantly during up-counting and down-counting. On compare match PWM output pin (OCn) behaves according to inverting or non-inverting mode which can be selected by programming of COMn [1:0] bits.