Quantcast
Channel: AVR ATmega Projects Archives - Projects Tutorials Code Library for Atmels Atmega32 AVR
Viewing all 1082 articles
Browse latest View live

How to interface RFID with AVR ATmega32 microcontroller

$
0
0

RFID is most arguably a evolutionary wireless technology which boosted working of embedded devices up to great mark. And there is plenty of systems and devices working based on this technology. This article is focused to teach you how to interface RFID with AVR microcontroller. Before moving on to that interfacing part let’s begin with what RFID exactly is and how it works?How to interface RFID with AVR ATmega32 microcontroller
Radio Frequency identification describes the system in which the identity of an individual or object is transmitted by means of a unique serial number through radio waves. Usually RFID system consists of two basic components they are

  • Tag
  • Reader

RFID tags consists of a simple Microchip which stores 12 byte unique ID and an antenna through which the unique ID is read by the reader. Whereas Reader is nothing but a specifically designed hardware module that senses the tag whenever it brought within a specific range say for example 10cms. The reader emit radio waves and receive signals back from the tag which comes with different operating frequency and sensing distance.
When a RFID tag is brought within the specific range of the reader the unique ID is sensed. After reading the ID from the tag is read by the reader and then that unique id is passed onto a controller/processor. The controller in turn performs specific action using that ID based on the written code

SCHEMATIC DESIGN OF RFID INTERFACE WITH AVR:Schematic How to interface RFID with AVR ATmega32 microcontroller

RFID module works at RS232 logic levels hence ATmega32 is connected to RFID module by means of a level converter IC MAX232. The unique ID from the RFID tag is converted into serial mode by means of the reader module and then transmitted to controller via MAX232. The baud rate is set to 9600bps for data transmission. The code was written in such a way when a card/tag comes in the proximity of RFID reader, the microcontroller reads the code and sends it to the LCD module for displaying
For more detail: How to interface RFID with AVR ATmega32 microcontroller


How to Establish A PC-Micro controller USART communication

$
0
0

Introduction

USART is one of the primitive inter-device communication protocols. It is not used in modern computers. But still, a few mother boards come with the module necessary for an USART communication. Here, in the case of PCs, the port is known as COM port and it follows RS232 protocol. It is no different from USART except for the voltage levels and some additional signals. Commonly MAX232 IC is used to translate the voltage level. MAX232 is a simple voltage translator buffer that converts +12/-12V of RS232 to 5/0V for USART. Other specifications are similar for USART and RS232. To know more about USART read this article from Wikipedia.How to Establish A PC-Micro controller USART communication

USART module in ATmega8

USART means Universal Synchronous Asynchronous Transmitter and Receiver. USART communication has provisions for full duplex communication, i.e. simultaneous transmission and reception. Synchronous means that a single clock source would be shared by end devices to facilitate communication. Asynchronous means, there would be no synchronized clock source b/w the end devices. But to receive a serial incoming data there is always a need for sampling. In addition to that, the symbol rate (i.e. the baud rate) should be known. That’s why each USART or UART module has an internal baud rate generator module. In earlier micro controllers, no separate baud rate generation unit was there. They used one of the internal timer counter for baud rate generation.
The frame (i.e. number of bits in each transmission) can consist of 5,6,7,8 or 9 data bits. Start bit starts the data transmission. There is one/two stop bit also included. There may be an even/odd parity bit included or there may not be any parity bits. The USART data register (Known as UDR for AVR micro controllers) is a double buffer register. It consists of transmitter buffer and receiver buffer. Both of them share the same I/O address. But when Data written to UDR, the data is saved to the transmitter buffer and serially shifted out from the TXD pin. And when UDR is read, the content in the receiver buffer is read which stores the serial incoming bits from the RXD pins.

Minimal settings to enable USART in ATmega8

USART module in ATmega8 have got 5 registers (4 8-bit, 1-16bit) associated with it. They are

  • 1.  UCSRA  : USART Control and Status Register A. In this Register, three Bits indicates the status of transmission  and reception. Only two bits are enough for basic programming. These are:

a) TXC- Transmission Complete
b) RXC- Reception Complete
These bits are checked before reading or writing data to UDR (USART Data Register)

  • 2. UCSRB  : Control and Status Register B. This register is very important to enable the USART Transmitter and Receiver. The bits associated are

a) TXEN: Transmitter Enable Bit. This enables the USART transmitter.
b) RXEN: Receiver Enable Bit. This enables the USART receiver.

  • 3. UCSRC  : This is the most important control register for USART. Let’s have a look.

USART Control and Status Register C –UCSRC

Bit

7

6

5

4

3

2

1

0

Bit Name URSEL UMSEL UPM1 UPM0 USBS UCSZ1 UCSZ0 UCPOL
Read/Write

RW

RW

RW

RW

RW

RW

RW

RW

Initial value

1

0

0

0

0

1

1

0

The UCSRC Register shares the same I/O location as the UBRRH Register. When doing a write access of this I/O location, the high bit of the value written, the USART Register Select (URSEL) bit, controls which one of the two registers that will be written. If URSEL is zero during a write operation, the UBRRH value will be updated. If URSEL is one, the UCSRC setting will be updated.

 Bit 7 – URSEL: Register Select

This bit selects between accessing the UCSRC or the UBRRH Register. It is read as one when reading UCSRC. The URSEL must be one when writing the UCSRC.

Bit 6 – UMSEL: USART Mode Select

This bit selects between Asynchronous and Synchronous mode of operation.

UMSEL Bit Settings

UMSEL

Mode

0

Asynchronous Operation

1

Synchronous Operation
Bit 5:4 – UPM1:0: Parity Mode

These bits enable and set type of Parity Generation and Check. If enabled, the Transmitter will automatically generate and send the parity of the transmitted data bits within each frame. The Receiver will generate a parity value for the incoming data and compare it to the UPM0 setting. If a mismatch is detected, the PE Flag in UCSRA will be set.

UPM Bit Settings

UPM1

UPM0

Parity Modes

0

0

Disabled

0

1

Reserved

1

0

Enabled, Even parity

1

1

Enabled, Odd Parity

Bit 3 – USBS: Stop Bit Select

This bit selects the number of stop bits to be inserted by the Transmitter. The Receiver ignores this setting.

USBS Bit Settings

USBS

Stop Bit(s)

0

1-Bit

1

2-Bit
Bit 2:1 – UCSZ1:0: Character Size

The UCSZ1:0 bits combined with the UCSZ2 bit in UCSRB sets the number of data bits (Character Size) in a frame the Receiver and Transmitter use.

UPM Bit Settings

UCSZ2*

UCSZ

UCSZ

Character Size

0

0

0

5-Bit

0

0

1

6-Bit

0

1

0

7-Bit

0

1

1

8-Bit

1

0

0

Reserved

1

0

1

Reserved

1

1

0

Reserved

1

1

1

9-Bit

*UCSZ2 Belongs to UCSRB
  • 4. UBRR: As mentioned earlier, writing information to UBRR is tricky. Whether we write the data to UBRRH and UCSRC, The same I/O location is used. The only thing makes the destiny differ is the MSB of the data to be written. If the MSB of the data byte is 1, Then the destiny is UCSRC, Else It is destined to be written at UBRRH. And, the Address of the UBRRL is not adjacent to UBRRH. So, although the combination of UBRRL and UBRRH is of 16bits, we cannot write a 16bit data (Like an integer variable) directly to the UBRR register. We need to write the Higher byte to the UBRRH and strip off the MSB from it before writing. And we would have to write the Low byte separately.
  •  UDR : The UDR is the storage of the data during the transmission or reception of the data. It is a double buffered register. So it can support a full duplex transmission. Here is what I found In Atmel’s ATmega8 datasheet:

USART Data Register–UDR

Bit

7

6

5

4

3

2

1

0

UDR (Read)

RXB[7:0]

UDR (Write)

TXB[7:0]

Read/Write

RW

RW

RW

RW

RW

RW

RW

RW

Initial value

1

0

0

0

0

1

1

0

The USART Transmit Data Buffer Register and USART Receive Data Buffer Registers share the same I/O address referred to as USART Data Register or UDR. The Transmit Data Buffer Register (TXB) will be the destination for data written to the UDR Register location. Reading the UDR Register location will return the contents of the Receive Data Buffer Register (RXB). For 5-bit, 6-bit, or 7-bit characters the upper unused bits will be ignored by the Transmitter and set to zero by the Receiver.
The transmit buffer can only be written when the UDRE Flag in the UCSRA Register is set. Data written to UDR when the UDRE Flag is not set, will be ignored by the USART Transmitter. When data is written to the transmit buffer (with the Transmitter being enabled) then the transmitter will load the data into the Transmit Shift Register, when the Shift Register is empty. Then the data will be serially transmitted to the TxD pin.
The receive buffer consists of a two level FIFO. The FIFO will change its state whenever the receive buffer is accessed. Due to this behavior of the receive buffer do not use Read-Modify- Write instructions (SBI and CBI) at this location. Be careful when using bit test instructions (SBIC and SBIS), since these also will change the state of the FIFO.

The target settings for this experiment are:

  •   a.   Both transmission and reception will be enabled.
  •   b. There would be 8 data bits
  •   c. There would be 2 stop bits
  •   d. There would be no parity bits
  •   e. The transmission would be asynchronous
  •   f. The baud rate for the transmission would be 1200 baud
  •   g.  The UBRR value for the baud rate is calculated as per the formula given in the datasheets. The formula is

Schematic How to Establish A PC-Micro controller USART communicationFor more detail: How to Establish A PC-Micro controller USART communication

AVR HVSP Fuse Resetter

$
0
0

description
in working w/ 8 or 14 pin avr devices, i would sometimes want to use the RESET pin as io as the io pin count is low. but doing so will disable further programming via SPI. i do not need a full blown HV programmer, just a way to revert these devices to factory default fuse settings so that i can use SPI to flash them again. it is also handy as sometimes by mistake i may burn wrong fuse value and brick my devices.AVR HVSP Fuse Resetter
this project is created so that if i could revert the RESET fuse change and flash via SPI again. it employs the high-voltage serial programming (hvsp) available for such devices. note that this is not to be confused w/ the high-voltage parallel programming used for 20pin+ devices (i.e. tiny2313, mega8, etc).
features
* reads device signature and hi-low fuses for hi-voltage serial programmable attinys
* reset hi-low fuses to factory default on target devices
* layout to drop-on attiny13, attiny25/45/85 8 pin devices targets
* attiny24/44/84 targets needs additional breadboard and jumper wires
* standalone operations, fuses values show on 7 segment display
* cannot reset fuse for attiny2313 and atmega devices as they requires hi-voltage parallel programming
parts list
* attiny2313
* 4×7 segment LED display
* 1k resistor x 2
* 2n2222 NPN transistor or equivalent
* 78L05
* mini breadboard 170 tiepoints
* +12V battery source
project fuse setting
avrdude -c usbtiny -p t2313 -V -U lfuse:w:0xe4:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
opearation
* place 8 pin target device on breadboard
* for 14 pin targets, jumper wire to breadboard
* apply 12V power
* display shows device name upon identification
* press and release button to cycle display content
* displays device name, fuse hi bits, fuse low bits and fuse extended bits
* long press and release button to reset fuse to factory default

Step 4: Breadboard Layout and SchematicSchematic AVR HVSP Fuse Resetter

[2016-11-29] I had replace the schematic w/ a correct one done by a builder R. Schenk. Thanks R.
* some components shown above are restricted by drawing software (fritzing), see actual photo, the physical layout fits a lot nicer
* the two green pins are to be connected to a 12V power source. i use an A23 12V battery but i can only find a 2xA23 battery holder. you may use whatever is available to you.
* the six red pins are approximate locations for an ISP programmer hookup, you will need to connect the 2nd pin (from left) to pin 1 (RESET, blue wire) of the tiny2313 during programming. in-circuit programming is a hit and miss, as our programming pins are connected to many devices. for the least, you need to remove the led module before attempting to program isp fashion. if fails, you need to remove 2313 and have it programmed off circuit.
For more detail: AVR HVSP Fuse Resetter

AVR uartConfig – an atmega and arduino eeprom config library

$
0
0

Update to version 2014-06-13
AVR uartConfig is a small footprint library you can use to config your micro eeprom through uart communication.
AVR uartConfig - an atmega and arduino eeprom config library
AVR uartConfig is a set of tools running on Windows, Linux and Mac, made up or:

  • a avrgcc firmware library
  • a commandline utility
  • a gui tool

Applications
This library prevent you to wire up a disply and buttons to configure your micro eeprom. For example is it usefull to setup PID parameters of your robot by uart/bluetooth uart, or for other small devices that doesn’t came with an output/input interface.
How does it works
Firmare side you have to setup an eeprom structure which contains all the variable you want to save on your eeprom and later you can read.
The same eeprom structure is replicated in the commandline utility config file.
So every times you want to write/read an element of your micro eeprom, you can run commandline utility which serialize your input value, prepare it to be written on eeprom, and then ask the firmware to write this parameter on eeprom.
To read a value, the commandline utility just ask firmware to return a specific eeprom byte interval, then it deserialize the value recived.
Serialization and Deserialization functions provide the way to “convert” the commandline input as a valid atmega eeprom variable input, and viceversa.
All the conversion are made client (commandline) side, firmware side we have a small footprint library.
To make this works we have setup the same struct on firmware and command line side.
Firmware Library

  1. include the library in your main file
  2. setup eestruct on firmware and commandline config file read EESTRUCT file for further info
  3. init your eestruct eerpm (optional)
  4. in the main loop get a character from uart, and use avruartconfig main check function to check if the character you get is a library command main function also need a pointer to the eestruct variable and eeprom variable

Firmware Library, Arduino Notes
Import avruartconfig library in your libraries folder.
Make sure your serial connection is not resetting your arduino every times the serial port is open, look here for info: http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection
Commandline Utility
Using the commandline tool you can setup you atmega. Commandline utility implements the setup procol client side. Setup eestruct configuration files, read EESTRUCT file for further info.
The command line utility makes use of libconfig, so to build it, you need to add libconfig library to your linker (-lconfig for the library, -L../lib/_select_os to select the library directory).
Check that you have execution permission on commandline binary.AVR uartConfig - an atmega and arduino eeprom -config library
For more detail: AVR uartConfig – an atmega and arduino eeprom config library

100mA Ammeter using AVR Microcontroller

$
0
0

In this project we are going to make a low range ammeter using ATMEGA8 microcontroller. In ATMEGA8, we are going use 10bit ADC (Analog to Digital Conversion) feature to do this. Although we have few other ways to get the current parameter from a circuit, we are going to use resistive drop method, because it’s the easiest and simplest way to get current parameter.

100mA Ammeter using AVR Microcontroller

Digital Ammeter using AVR Microcontroller

In this method we are going to pass the current which needed to be measured in to a small resistance, by this we get a drop across that resistance which is related to current flowing through it. This voltage across resistance is fed to ATMEGA8 for ADC conversion. With that we will have the current in digital value which will be displayed on a 16×2 LCD.

For that we are going to use a voltage divider circuit. We are going to fed the current through the complete resistance branch. The midpoint of branch is taken to measurement. When current changes there will be drop change in the resistance which is linear to it. So with this we have a voltage which changes with linearity.

Now important thing to note here is, the input taken by the controller for ADC conversion is as low as 50µAmp. This loading effect of resistance based voltage divider is important as the current drawn from Vout of voltage divider increases the error percentage increases, for now we need not worry about loading effect.

Components Required

Hardware: ATMEGA8, power supply (5v), AVR-ISP PROGRAMMER, JHD_162ALCD (16*2LCD), 100uF capacitor, 100nF capacitor (4 pieces), 100Ω resistor (7 pieces) or 2.5Ω (2 pieces), 100KΩ resistor.

Software: Atmel studio 6.1, progisp or flash magic.

Circuit Diagram and Working Explanation Schematic 100mA Ammeter using AVR Microcontroller

[See this tutorial to understand how to interface LCD with AVR Microcontroller]

The voltage across R2 and R4 is not completely linear; it will be a noisy one. To filter out the noise, capacitors are placed across each resistor in the divider circuit as shown in figure.

In ATMEGA8, we can give Analog input to any of FOUR channels of PORTC, it doesn’t matter which channel we choose as all are same. We are going to choose channel 0 or PIN0 of PORTC. In ATMEGA8, the ADC is of 10 bit resolution, so the controller can detect a minimum change of Vref/2^10, so if the reference voltage is 5V we get a digital output increment for every 5/2^10 = 5mV. So for every 5mV increment in the input we will have a increment of one at digital output.

For more detail: 100mA Ammeter using AVR Microcontroller

Joystick Interfacing with AVR Microcontroller

$
0
0

In this tutorial we are going to interface a joystick module with atmega8 microcontroller. A JOY STICK is an input module used for communication. It basically makes easy the user machine communication. A joystick is shown in below figure.

Joystick Interfacing with AVR Microcontroller

Joystick Interfacing with AVR Microcontroller

The joystick module has two axis – one is horizontal and other is vertical. Each axis of joystick is mounted to a potentiometer or pot or variable resistance.  The mid points are brought down as Rx and Ry. These pins carry as output signal pins for JOYSTICK.  When the stick is moved along horizontal axis , with the supply voltage present , the voltage at Rx pin changes.

The voltage at Rx increases when moved forward, the voltage at Rx pin decreases when moved backward. Similarly, the voltage at Ry increases when moved upward, the voltage at Ry pin decreases when moved downward.

So we have four directions of JOYSTICK on two ADC channels. At normal cases we have 1Volt on each pin under normal circumstances. When the stick is moved the voltage on each pin goes high or low depending on direction. So four directions as ( 0V,5V on channel 0) for x- axis; ( 0V,5V on channel 1) for y- axis.

We are going to use two ADC channels of ATMEGA8 to do the job. We are going to use channel 0 and channel 1.

Components Required

Hardware: ATMEGA8, power supply (5v), AVR-ISP PROGRAMMER, LED (4 pieces), 1000uF capacitor, 100nF capacitor (5 pieces), 1KΩ resistor (6 pieces).

Software: Atmel studio 6.1, progisp or flash magic.

Circuit Diagram and Working ExplanationSchematic Joystick Interfacing with AVR Microcontroller

The voltage across JOYSTICK is not completely linear; it will be a noisy one. To filter out the noise a capacitors are placed across each resistor in the circuit as shown in figure.

As shown in figure there are four LEDs in the circuit. Each LED represents each direction of JOYSTICK. When the stick is moved in a direction, then the corresponding LED glows.

Before going any further we need to talk about ADC of ATMEGA8,

In ATMEGA8, we can give Analog input to any of FOUR channels of PORTC, it doesn’t matter which channel we choose as all are same, we are going to choose channel 0 or PIN0 of PORTC.

In ATMEGA8, the ADC is of 10 bit resolution, so the controller can detect a sense a minimum change of Vref/2^10, so if the reference voltage is 5V we get a digital output increment for every 5/2^10 = 5mV. So for every 5mV increment in the input we will have a increment of one at digital output.

For more detail: Joystick Interfacing with AVR Microcontroller

4×4 Keypad Interfacing with ATmega32 Microcontroller

$
0
0

In this tutorial we are going to interface a 4×4 (16 key) keypad with ATMEGA32A microcontroller. We know that keypad is one of the most important input devices used in electronics projects. Keypad is one of the easiest ways to give commands or instructions to an electronic system.

4x4 Keypad Interfacing with ATmega32 Microcontroller

4×4 Keypad Interfacing with AVR Microcontroller (ATmega32)

Components Required

Hardware: ATMEGA32, power supply (5v), AVR-ISP PROGRAMMER, JHD_162ALCD (16*2LCD), 100uF capacitor, 100nF capacitor, 10KΩ resistor (8 pieces).

Software: Atmel studio 6.1 or Atmel studio 6.2, progisp or flash magic.

Circuit Diagram and Working ExplanationSchematic 4x4 Keypad Interfacing with ATmega32 Microcontroller

In circuit PORTB of ATMEGA32 is connected to data port LCD. Here one should remember to disable the JTAG communication in PORTC ot ATMEGA by changing the fuse bytes, if one wants to use the PORTC as a normal communication port. In 16×2 LCD there are 16 pins over all if there is a back light, if there is no back light there will be 14 pins. One can power or leave the back light pins. Now in the 14 pins there are 8 data pins (7-14 or D0-D7), 2 power supply pins (1&2 or VSS&VDD or gnd&+5v), 3rd pin for contrast control (VEE-controls how thick the characters should be shown), and 3 control pins (RS&RW&E).

In the circuit, you can observe that I have only took two control pins , this give the flexibility, the contrast bit and READ/WRITE are not often used so they can be shorted to ground. This puts LCD in highest contrast and read mode. We just need to control ENABLE and RS pins to send characters and data accordingly.

The connections which are done for LCD are given below:

PIN1 or VSS to ground

PIN2 or VDD or VCC to +5v power

PIN3 or VEE to ground (gives maximum contrast best for a beginner)

PIN4 or RS (Register Selection) to PD6 of uC

PIN5 or RW (Read/Write) to ground (puts LCD in read mode eases the communication for user)

PIN6 or E (Enable) to PD5 of uC

PIN7 or D0 to PB0 of uC

PIN8 or D1 to PB1 of uC

PIN9 or D2 to PB2 of uC

PIN10 or D3 to PB3 of uC

PIN11 or D4 to PB4 of uC

PIN12 or D5 to PB5 of uC

PIN13 or D6 to PB6 of uC

PIN14 or D7to PB7 of uC

In the circuit you can see that we have used 8bit communication (D0-D7) however this is not a compulsory, we can use 4bit communication (D4-D7) but with 4 bit communication program becomes a bit complex. So from mere observation of above table we are connecting 10 pins of LCD to controller in which 8 pins are data pins and 2 pins for control.

 For more detail: 4×4 Keypad Interfacing with ATmega32 Microcontroller

RFID Based Voting Machine

$
0
0

We know in offices, shopping malls and in many other places where only the person with authorization card is allowed to enter the room. These systems use RFID communication system. RFID is used in shopping malls to stop theft as the products are tagged with RFID chip and when a person leaves the building with the RFID chip an alarm is raised automatically. The RFID tag is designed as small as part of sand. The RFID authentication systems are easy to design and are cheap in cost. Some schools and colleges nowadays use RFID based attendance systems.

RFID Based Voting Machine

RFID Based Voting Machine using AVR Microcontroller

In this project we are going to design a voting machine which only counts authenticated votes. This is done by using RFID (Radio Frequency Identification) tags.  Here we are going to write a program for ATMEGA for allowing only authorized RFID tag holders to vote. (Also check this simple voting machine project)

Components Required

Hardware: ATMEGA32, power supply (5v), AVR-ISP PROGRAMMER, JHD_162ALCD (16x2LCD), 100uF capacitor (connected across power supply), button (five pieces), 10KΩ resistor (five pieces), 100nF capacitor (five pieces), LED (two pieces), EM-18(RFID reader module).

Software: Atmel studio 6.1, progisp or flash magic.

Circuit Diagram and ExplanationSchematic RFID Based Voting Machine

In circuit PORTA of ATMEGA32 is connected to data port of LCD. Here one should remember to disable the JTAG communication in PORTC to ATMEGA by changing the fuse bytes, if one wants to use the PORTC as a normal communication port. In 16×2 LCD there are 16 pins overall if there is a black light, if there is no back light there will be 14 pins. One can power or leave the back light pins. Now in the 14 pins there are 8 data pins (7-14 or D0-D7), 2 power supply pins (1&2 or VSS&VDD or gnd&+5v), 3rd pin for contrast control (VEE-controls how thick the characters should be shown), 3 control pins (RS&RW&E)

In the circuit, you can observe that I have only took two control pins, this give the flexibility of better understanding, the contrast bit and READ/WRITE are not often used so they can be shorted to ground. This puts LCD in highest contrast and read mode. We just need to control ENABLE and RS pins to send characters and data accordingly.

The connections which are done for LCD are given below:

PIN1 or VSS to ground

PIN2 or VDD or VCC to +5v power

PIN3 or VEE to ground (gives maximum contrast best for a beginner)

PIN4 or RS (Register Selection) to PD6 of uC

PIN5 or RW (Read/Write) to ground (puts LCD in read mode eases the communication for user)

PIN6 or E (Enable) to PD5 of uC

PIN7 or D0 to PA0 of uC

PIN8 or D1 to PA1 of uC

PIN9 or D2 to PA2 of uC

PIN10 or D3 to PA3 of uC

PIN11 or D4 to PA4 of uC

PIN12 or D5 to PA5 of uC

PIN13 or D6 to PA6 of uC

PIN14 or D7 to PA7 of uC

In the circuit, you can see we have used 8bit communication (D0-D7). However this is not a compulsory and we can use 4bit communication (D4-D7) but with 4 bit communication program becomes a bit complex, so I preferred 8 bit communication.

So from mere observation of above table we are connecting 10 pins of LCD to controller in which 8 pins are data pins and 2 pins for control.

Before moving ahead, we need to understand about the serial communication. The RFID module here sends data to the controller in serial. It has other mode of communication but for easy communication we are choosing RS232. The RS232 pin of module is connected to RXD pin of ATMEGA.

 For more detail: RFID Based Voting Machine


RFID Based Toll Plaza System

$
0
0

We know in offices, shopping malls and in many other places where only the person with authorization card is allowed to enter the room. These systems use RFID communication system. RFID is used in shopping malls to stop theft as the products are tagged with RFID chip and when a person leaves the building with the RFID chip an alarm is raised automatically. The RFID tag is designed as small as part of sand. The RFID authentication systems are easy to design and are cheap in cost. Some schools and colleges nowadays use RFID based attendance systems.

RFID Based Toll Plaza System

RFID Based Toll Plaza System using AVR Microcontroller

In this project we are going to design a RFID based toll plaza system for security purposes. So this system open gates and allow people only with the authorized RFID tags. The authorized tags holder ID’s are programmed in to the ATMEGA Microcontroller and only those holders are allowed to leave or enter the premises.

Components Required

Hardware: ATmega32 microcontroller, power supply (5v), AVR-ISP Programmer, JHD_162ALCD (16×2 LCD module), 100uF capacitor (connected across power supply), button, 10KΩ resistor, 100nF capacitor, LED (two pieces), EM-18 (RFID reader module), L293D motor driver IC, 5V DC motor.

Software: Atmel studio 6.1, progisp or flash magic.

Circuit Diagram and Working ExplanationSchematic RFID Based Toll Plaza System

In the toll plaza circuit shown above, PORTA of ATMEGA32 is connected to data port of LCD. Here we should remember to disable the JTAG communication in PORTC to ATMEGA by changing the fuse bytes, if we wans to use the PORTC as a normal communication port. In 16×2 LCD, there are 16 pins over all if there is a back light, if there is no back light there will be 14 pins. We can power or leave the back light pins. Now in the 14 pins there are 8 data pins (7-14 or D0-D7), 2 power supply pins (1&2 or VSS & VDD or gnd & +5v), 3rd pin for contrast control (VEE-controls how thick the characters should be shown), 3 control pins (RS & RW & E).

In the circuit, you can observe that I have only took two control pins. This gives the flexibility of better understanding. The contrast bit and READ/WRITE are not often used so they can be shorted to ground. This puts LCD in highest contrast and read mode. We just need to control ENABLE and RS pins to send characters and data accordingly.

The connections which are made for LCD, are given below:

PIN1 or VSS to ground

PIN2 or VDD or VCC to +5v power

PIN3 or VEE to ground (gives maximum contrast best for a beginner)

PIN4 or RS (Register Selection) to PD6 of MCU

PIN5 or RW (Read/Write) to ground (puts LCD in read mode eases the communication for user)

PIN6 or E (Enable) to PD5 of Microcontroller

PIN7 or D0 to PA0

PIN8 or D1 to PA1

PIN9 or D2 to PA2

PIN10 or D3 to PA3

PIN11 or D4 to PA4

PIN12 or D5 to PA5

PIN13 or D6 to PA6

PIN14 or D7 to PA7

In the circuit, you can see we have used 8bit communication (D0-D7). However this is not a compulsory and we can use 4bit communication (D4-D7) but with 4 bit communication program becomes a bit complex, so I preferred 8 bit communication.

So from mere observation of above table we are connecting 10 pins of LCD to controller in which 8 pins are data pins and 2 pins for control.

Before moving ahead, we need to understand about the serial communication. The RFID module here sends data to the controller in serial. It has other mode of communication but for easy communication we are choosing RS232. The RS232 pin of module is connected to RXD pin of ATMEGA.

For more detail: RFID Based Toll Plaza System

Microcontroller Based Electronic Voting Machine

$
0
0

Whenever we go to vote for elections we come to see electronic voting machines. In this project we are going to design and develop a simple voting machine by using ATmega32A microcontroller. Although we can use the controller to get more than 32 people voting machine, to keep everything simple we are going to make a voting machine for a size of four people.We will have four buttons for four people and whenever a button is pressed, a vote goes for the corresponding person and the number of votes each person gets shown on LCD.

Microcontroller Based Electronic Voting Machine

AVR Microcontroller Based Electronic Voting Machine

Components Required

Hardware:

ATMEGA32

Power supply (5v)

AVR-ISP PROGRAMMER

JHD_162ALCD (16×2 LCD)

100nF capacitor (five pieces), 100uF capacitor (connected across power supply)

button(five pieces),

10KΩ resistor (five pieces).

Software:

Atmel studio 6.1

progisp or flash magic.

Circuit Diagram and Working ExplanationSchematic Microcontroller Based Electronic Voting Machine

As shown in the above electronic voting machine circuit, PORTA of ATMEGA32 microcontroller is connected to data port LCD. Here one should remember to disable the JTAG communication in PORTC of ATMEGA by changing the fuse bytes, if one wants to use the PORTC as a normal communication port. In 16×2 LCD, there are 16 pins over all if there is a back light, if there is no back light there will be 14 pins. One can power or leave the back light pins. Now in the 14 pins there are 8 data pins (7-14 or D0-D7), 2 power supply pins (1&2 or VSS&VDD or gnd&+5v), 3rd pin for contrast control (VEE-controls how thick the characters should be shown), 3 control pins (RS&RW&E).

In the circuit, you can observe that I have only taken two control pins as this give the flexibility of better understanding. The contrast bit and READ/WRITE are not often used so they can be shorted to ground. This puts LCD in highest contrast and read mode. We just need to control ENABLE and RS pins to send characters and data accordingly.

For more detail: Microcontroller Based Electronic Voting Machine

How to interface RFID with AVR ATmega32 microcontroller

$
0
0

RFID is most arguably a evolutionary wireless technology which boosted working of embedded devices up to great mark. And there is plenty of systems and devices working based on this technology. This article is focused to teach you how to interface RFID with AVR microcontroller. Before moving on to that interfacing part let’s begin with what RFID exactly is and how it works?How to interface RFID with AVR ATmega32 microcontroller
Radio Frequency identification describes the system in which the identity of an individual or object is transmitted by means of a unique serial number through radio waves. Usually RFID system consists of two basic components they are

  • Tag
  • Reader

RFID tags consists of a simple Microchip which stores 12 byte unique ID and an antenna through which the unique ID is read by the reader. Whereas Reader is nothing but a specifically designed hardware module that senses the tag whenever it brought within a specific range say for example 10cms. The reader emit radio waves and receive signals back from the tag which comes with different operating frequency and sensing distance.
When a RFID tag is brought within the specific range of the reader the unique ID is sensed. After reading the ID from the tag is read by the reader and then that unique id is passed onto a controller/processor. The controller in turn performs specific action using that ID based on the written code

SCHEMATIC DESIGN OF RFID INTERFACE WITH AVR:Schematic How to interface RFID with AVR ATmega32 microcontroller

RFID module works at RS232 logic levels hence ATmega32 is connected to RFID module by means of a level converter IC MAX232. The unique ID from the RFID tag is converted into serial mode by means of the reader module and then transmitted to controller via MAX232. The baud rate is set to 9600bps for data transmission. The code was written in such a way when a card/tag comes in the proximity of RFID reader, the microcontroller reads the code and sends it to the LCD module for displaying
For more detail: How to interface RFID with AVR ATmega32 microcontroller

How to Establish A PC-Micro controller USART communication

$
0
0

Introduction

USART is one of the primitive inter-device communication protocols. It is not used in modern computers. But still, a few mother boards come with the module necessary for an USART communication. Here, in the case of PCs, the port is known as COM port and it follows RS232 protocol. It is no different from USART except for the voltage levels and some additional signals. Commonly MAX232 IC is used to translate the voltage level. MAX232 is a simple voltage translator buffer that converts +12/-12V of RS232 to 5/0V for USART. Other specifications are similar for USART and RS232. To know more about USART read this article from Wikipedia.How to Establish A PC-Micro controller USART communication

USART module in ATmega8

USART means Universal Synchronous Asynchronous Transmitter and Receiver. USART communication has provisions for full duplex communication, i.e. simultaneous transmission and reception. Synchronous means that a single clock source would be shared by end devices to facilitate communication. Asynchronous means, there would be no synchronized clock source b/w the end devices. But to receive a serial incoming data there is always a need for sampling. In addition to that, the symbol rate (i.e. the baud rate) should be known. That’s why each USART or UART module has an internal baud rate generator module. In earlier micro controllers, no separate baud rate generation unit was there. They used one of the internal timer counter for baud rate generation.
The frame (i.e. number of bits in each transmission) can consist of 5,6,7,8 or 9 data bits. Start bit starts the data transmission. There is one/two stop bit also included. There may be an even/odd parity bit included or there may not be any parity bits. The USART data register (Known as UDR for AVR micro controllers) is a double buffer register. It consists of transmitter buffer and receiver buffer. Both of them share the same I/O address. But when Data written to UDR, the data is saved to the transmitter buffer and serially shifted out from the TXD pin. And when UDR is read, the content in the receiver buffer is read which stores the serial incoming bits from the RXD pins.

Minimal settings to enable USART in ATmega8

USART module in ATmega8 have got 5 registers (4 8-bit, 1-16bit) associated with it. They are

  • 1.  UCSRA  : USART Control and Status Register A. In this Register, three Bits indicates the status of transmission  and reception. Only two bits are enough for basic programming. These are:

a) TXC- Transmission Complete
b) RXC- Reception Complete
These bits are checked before reading or writing data to UDR (USART Data Register)

  • 2. UCSRB  : Control and Status Register B. This register is very important to enable the USART Transmitter and Receiver. The bits associated are

a) TXEN: Transmitter Enable Bit. This enables the USART transmitter.
b) RXEN: Receiver Enable Bit. This enables the USART receiver.

  • 3. UCSRC  : This is the most important control register for USART. Let’s have a look.

USART Control and Status Register C –UCSRC

Bit

7

6

5

4

3

2

1

0

Bit Name URSEL UMSEL UPM1 UPM0 USBS UCSZ1 UCSZ0 UCPOL
Read/Write

RW

RW

RW

RW

RW

RW

RW

RW

Initial value

1

0

0

0

0

1

1

0

The UCSRC Register shares the same I/O location as the UBRRH Register. When doing a write access of this I/O location, the high bit of the value written, the USART Register Select (URSEL) bit, controls which one of the two registers that will be written. If URSEL is zero during a write operation, the UBRRH value will be updated. If URSEL is one, the UCSRC setting will be updated.

 Bit 7 – URSEL: Register Select

This bit selects between accessing the UCSRC or the UBRRH Register. It is read as one when reading UCSRC. The URSEL must be one when writing the UCSRC.

Bit 6 – UMSEL: USART Mode Select

This bit selects between Asynchronous and Synchronous mode of operation.

UMSEL Bit Settings

UMSEL

Mode

0

Asynchronous Operation

1

Synchronous Operation
Bit 5:4 – UPM1:0: Parity Mode

These bits enable and set type of Parity Generation and Check. If enabled, the Transmitter will automatically generate and send the parity of the transmitted data bits within each frame. The Receiver will generate a parity value for the incoming data and compare it to the UPM0 setting. If a mismatch is detected, the PE Flag in UCSRA will be set.

UPM Bit Settings

UPM1

UPM0

Parity Modes

0

0

Disabled

0

1

Reserved

1

0

Enabled, Even parity

1

1

Enabled, Odd Parity

Bit 3 – USBS: Stop Bit Select

This bit selects the number of stop bits to be inserted by the Transmitter. The Receiver ignores this setting.

USBS Bit Settings

USBS

Stop Bit(s)

0

1-Bit

1

2-Bit
Bit 2:1 – UCSZ1:0: Character Size

The UCSZ1:0 bits combined with the UCSZ2 bit in UCSRB sets the number of data bits (Character Size) in a frame the Receiver and Transmitter use.

UPM Bit Settings

UCSZ2*

UCSZ

UCSZ

Character Size

0

0

0

5-Bit

0

0

1

6-Bit

0

1

0

7-Bit

0

1

1

8-Bit

1

0

0

Reserved

1

0

1

Reserved

1

1

0

Reserved

1

1

1

9-Bit

*UCSZ2 Belongs to UCSRB
  • 4. UBRR: As mentioned earlier, writing information to UBRR is tricky. Whether we write the data to UBRRH and UCSRC, The same I/O location is used. The only thing makes the destiny differ is the MSB of the data to be written. If the MSB of the data byte is 1, Then the destiny is UCSRC, Else It is destined to be written at UBRRH. And, the Address of the UBRRL is not adjacent to UBRRH. So, although the combination of UBRRL and UBRRH is of 16bits, we cannot write a 16bit data (Like an integer variable) directly to the UBRR register. We need to write the Higher byte to the UBRRH and strip off the MSB from it before writing. And we would have to write the Low byte separately.
  •  UDR : The UDR is the storage of the data during the transmission or reception of the data. It is a double buffered register. So it can support a full duplex transmission. Here is what I found In Atmel’s ATmega8 datasheet:

USART Data Register–UDR

Bit

7

6

5

4

3

2

1

0

UDR (Read)

RXB[7:0]

UDR (Write)

TXB[7:0]

Read/Write

RW

RW

RW

RW

RW

RW

RW

RW

Initial value

1

0

0

0

0

1

1

0

The USART Transmit Data Buffer Register and USART Receive Data Buffer Registers share the same I/O address referred to as USART Data Register or UDR. The Transmit Data Buffer Register (TXB) will be the destination for data written to the UDR Register location. Reading the UDR Register location will return the contents of the Receive Data Buffer Register (RXB). For 5-bit, 6-bit, or 7-bit characters the upper unused bits will be ignored by the Transmitter and set to zero by the Receiver.
The transmit buffer can only be written when the UDRE Flag in the UCSRA Register is set. Data written to UDR when the UDRE Flag is not set, will be ignored by the USART Transmitter. When data is written to the transmit buffer (with the Transmitter being enabled) then the transmitter will load the data into the Transmit Shift Register, when the Shift Register is empty. Then the data will be serially transmitted to the TxD pin.
The receive buffer consists of a two level FIFO. The FIFO will change its state whenever the receive buffer is accessed. Due to this behavior of the receive buffer do not use Read-Modify- Write instructions (SBI and CBI) at this location. Be careful when using bit test instructions (SBIC and SBIS), since these also will change the state of the FIFO.

The target settings for this experiment are:

  •   a.   Both transmission and reception will be enabled.
  •   b. There would be 8 data bits
  •   c. There would be 2 stop bits
  •   d. There would be no parity bits
  •   e. The transmission would be asynchronous
  •   f. The baud rate for the transmission would be 1200 baud
  •   g.  The UBRR value for the baud rate is calculated as per the formula given in the datasheets. The formula is

Schematic How to Establish A PC-Micro controller USART communicationFor more detail: How to Establish A PC-Micro controller USART communication

AVR HVSP Fuse Resetter

$
0
0

description
in working w/ 8 or 14 pin avr devices, i would sometimes want to use the RESET pin as io as the io pin count is low. but doing so will disable further programming via SPI. i do not need a full blown HV programmer, just a way to revert these devices to factory default fuse settings so that i can use SPI to flash them again. it is also handy as sometimes by mistake i may burn wrong fuse value and brick my devices.AVR HVSP Fuse Resetter
this project is created so that if i could revert the RESET fuse change and flash via SPI again. it employs the high-voltage serial programming (hvsp) available for such devices. note that this is not to be confused w/ the high-voltage parallel programming used for 20pin+ devices (i.e. tiny2313, mega8, etc).
features
* reads device signature and hi-low fuses for hi-voltage serial programmable attinys
* reset hi-low fuses to factory default on target devices
* layout to drop-on attiny13, attiny25/45/85 8 pin devices targets
* attiny24/44/84 targets needs additional breadboard and jumper wires
* standalone operations, fuses values show on 7 segment display
* cannot reset fuse for attiny2313 and atmega devices as they requires hi-voltage parallel programming
parts list
* attiny2313
* 4×7 segment LED display
* 1k resistor x 2
* 2n2222 NPN transistor or equivalent
* 78L05
* mini breadboard 170 tiepoints
* +12V battery source
project fuse setting
avrdude -c usbtiny -p t2313 -V -U lfuse:w:0xe4:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
opearation
* place 8 pin target device on breadboard
* for 14 pin targets, jumper wire to breadboard
* apply 12V power
* display shows device name upon identification
* press and release button to cycle display content
* displays device name, fuse hi bits, fuse low bits and fuse extended bits
* long press and release button to reset fuse to factory default

Step 4: Breadboard Layout and SchematicSchematic AVR HVSP Fuse Resetter

[2016-11-29] I had replace the schematic w/ a correct one done by a builder R. Schenk. Thanks R.
* some components shown above are restricted by drawing software (fritzing), see actual photo, the physical layout fits a lot nicer
* the two green pins are to be connected to a 12V power source. i use an A23 12V battery but i can only find a 2xA23 battery holder. you may use whatever is available to you.
* the six red pins are approximate locations for an ISP programmer hookup, you will need to connect the 2nd pin (from left) to pin 1 (RESET, blue wire) of the tiny2313 during programming. in-circuit programming is a hit and miss, as our programming pins are connected to many devices. for the least, you need to remove the led module before attempting to program isp fashion. if fails, you need to remove 2313 and have it programmed off circuit.
For more detail: AVR HVSP Fuse Resetter

AVR uartConfig – an atmega and arduino eeprom config library

$
0
0

Update to version 2014-06-13
AVR uartConfig is a small footprint library you can use to config your micro eeprom through uart communication.
AVR uartConfig - an atmega and arduino eeprom config library
AVR uartConfig is a set of tools running on Windows, Linux and Mac, made up or:

  • a avrgcc firmware library
  • a commandline utility
  • a gui tool

Applications
This library prevent you to wire up a disply and buttons to configure your micro eeprom. For example is it usefull to setup PID parameters of your robot by uart/bluetooth uart, or for other small devices that doesn’t came with an output/input interface.
How does it works
Firmare side you have to setup an eeprom structure which contains all the variable you want to save on your eeprom and later you can read.
The same eeprom structure is replicated in the commandline utility config file.
So every times you want to write/read an element of your micro eeprom, you can run commandline utility which serialize your input value, prepare it to be written on eeprom, and then ask the firmware to write this parameter on eeprom.
To read a value, the commandline utility just ask firmware to return a specific eeprom byte interval, then it deserialize the value recived.
Serialization and Deserialization functions provide the way to “convert” the commandline input as a valid atmega eeprom variable input, and viceversa.
All the conversion are made client (commandline) side, firmware side we have a small footprint library.
To make this works we have setup the same struct on firmware and command line side.
Firmware Library

  1. include the library in your main file
  2. setup eestruct on firmware and commandline config file read EESTRUCT file for further info
  3. init your eestruct eerpm (optional)
  4. in the main loop get a character from uart, and use avruartconfig main check function to check if the character you get is a library command main function also need a pointer to the eestruct variable and eeprom variable

Firmware Library, Arduino Notes
Import avruartconfig library in your libraries folder.
Make sure your serial connection is not resetting your arduino every times the serial port is open, look here for info: http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection
Commandline Utility
Using the commandline tool you can setup you atmega. Commandline utility implements the setup procol client side. Setup eestruct configuration files, read EESTRUCT file for further info.
The command line utility makes use of libconfig, so to build it, you need to add libconfig library to your linker (-lconfig for the library, -L../lib/_select_os to select the library directory).
Check that you have execution permission on commandline binary.AVR uartConfig - an atmega and arduino eeprom -config library
For more detail: AVR uartConfig – an atmega and arduino eeprom config library

ATmega8 Line Follower Robot (LFR) Project – Part 2/2

$
0
0

Now that the mechanical assembly part is over,and we have completed the construction of left and right (L&R) infrared sensor cards. Since the MCU (ATmega8) cannot drive the dc motors directly, a dedicated motor driver circuit is used. The motor driver circuit here is based on a simple 16-pin IC (L293D) which can drive two dc motors independently.
ATmega8 Line Follower Robot (LFR) Project
As can be seen in the circuit diagram, pins 4, 5, 13 and 12 of LM293 (U2) are connected to GND and the pin 16 (VSS) is connected to 5V. The ‘chip inhibit’ pins (1&9) act as the enable pins for the input-output pairs on left side and right side of the motor driver, respectively. Pin 8 (VC) receives the unregulated input supply (Vcc) from the LFR power supply circuit. It is noteworthy that this motor driver chip is PWM supporting, means that if you apply some voltage in the range 0V to 5V at any input, then it will be scaled up by a factor and will be available at the corresponding output.
The four input pins (2-7-10-15) receives motor drive instructions from the MCU. In short, U2 acts as the interface between the microcontroller (U3) and the dc motors (M1&M2) in which instructions from the microcontroller go into its input pins and the outputs are used to drive the robot motors.
LFR-Microcon-
troller Unit (MCU) Circuit Diagram

Here is the circuit of the MCU,wired around our favorite ATmega8 chip (U3). The first task is to resolve which pins of the MCU will be used for taking inputs from the infrared sensor cards and giving outputs to the motor driver circuit. As an exercise, I went for PC0 (left) and PC3 (right) of PORT C for the two inputs from two infrared sensor cards, and pins PB1 to PB4 of PORT B as outputs to motor driver circuit (actually only PB1 and PB4 are important at this time). The code is written using the C language so you need to be comfortable with the syntax of C language, concept of libraries, compiler, etc (IDE used is the AVR Studio 4). The final code (hex code) can be burned into the MCU using a suitable programmer (refer previous chapters of this avr tutorial).
ATmega8 Line Follower Robot (LFR) Project Schematic
Read More: ATmega8 Line Follower Robot (LFR) Project – Part 2/2


DC motor interfacing with AVR ATmega16/ATmega32

$
0
0

DC motor converts electrical energy in the form of Direct Current into mechanical energy.
In case of motor, the mechanical energy produced is in the form of rotational movement of the motor shaft.
The direction of rotation of the shaft of the motor can be reversed by reversing the direction of Direct Current through the motor.
DC motor interfacing with AVR ATmega16/ATmega32
The motor can be rotated at a certain speed by applying a fixed voltage to it. If the voltage varies, the speed of the motor varies.
Thus, the DC motor speed can be controlled by applying varying DC voltage; whereas the direction of rotation of motor can be changed by reversing the direction of current through it.
For applying varying voltage, we can make use of PWM technique.
For reversing the current, we can make use of H-Bridge circuit or motor driver ICs that employ the H-Bridge technique or other any other mechanisms.
For more information about DC motors and how to use them, H-Bridge circuit configuration, PWM technique, refer the topic DC Motors in the sensors and modules section.
For information about PWM in ATmega16 and how to use it, refer the topic PWM in AVR ATmega16/ATmega32 in the ATmega inside section.
Here we will be using ADC feature of AVR ATmega16.
For information about ADC in ATmega16 and how to use it, refer the topic ADC in ATmega16/ATmega32 in the ATmega inside section.
Here, we are going to interface DC motor with AVR ATmega16 microcontroller. In which we will control the DC motor speed by using POT connected to ADC of ATmega16 and direction by using a switch.
We are going to use L293D motor driver IC to control DC motor movement in both directions. It has in-built H-bridge motor drive.
–  As shown in above figure we have connected 1kΩ Potentiometer at ADC channel 0 of ATmega16 to change the speed of DC motor.
–  One toggle switch is connected to INT0 pin (2nd pin of PORTD) which control the motor rotating direction.
–  PORTC is used as an output control signal port.It provides control to motor1 input pins of the L293D motor driver which rotate motor clockwise and anticlockwise by changing their terminal polarity.

Programming steps

  • Enable ADC and map its output into 0-255 range.
  • Enable Global interrupt, INT0 external interrupt with the rising edge triggered mode.
  • Set Fast PWM mode of Timer0 with F­OSC/64 timer clock.
  • ADC value is given to the OCR0 register and in an interrupt routine, we are toggling motor direction.
  • Now continuously check for the interrupt for direction and read ADC value for speed control.
  • A switch will produce interrupt which causes to change in motor direction. By varying potentiometer, variable ADC values can be given to OCR0 register to achieve speed variation.

DC motor interfacing with AVR ATmega16/ATmega32 Schematic
 
Read More: DC motor interfacing with AVR ATmega16/ATmega32

RFID Based Toll Collection System

$
0
0

We know in offices, shopping malls and in many other places where only the person with authorization card is allowed to enter the room. These systems use RFID communication system. RFID is used in shopping malls to stop theft as the products are tagged with RFID chip and when a person leaves the building with the RFID chip an alarm is raised automatically. The RFID tag is designed as small as part of sand. The RFID authentication systems are easy to design and are cheap in cost. Some schools and colleges nowadays use RFID based attendance systems.

RFID Based Toll Collection System

In this project we are going to design a RFID based toll collection system for security purposes. So this system open gates and allow people only with the authorized RFID tags. The authorized tags holder ID’s are programmed in to the ATMEGA Microcontroller and only those holders are allowed to leave or enter the premises.

Components Required

Hardware: ATmega32 microcontroller, power supply (5v), AVR-ISP Programmer, JHD_162ALCD (16×2 LCD module), 100uF capacitor (connected across power supply), button, 10KΩ resistor, 100nF capacitor, LED (two pieces), EM-18 (RFID reader module), L293D motor driver IC, 5V DC motor.

Software: Atmel studio 6.1, progisp or flash magic.

In the RFID toll collection system circuit shown above, PORTA of ATMEGA32 is connected to data port of LCD. Here we should remember to disable the JTAG communication in PORTC to ATMEGA by changing the fuse bytes, if we wans to use the PORTC as a normal communication port. In 16×2 LCD, there are 16 pins over all if there is a back light, if there is no back light there will be 14 pins. We can power or leave the back light pins. Now in the 14 pins there are 8 data pins (7-14 or D0-D7), 2 power supply pins (1&2 or VSS & VDD or gnd & +5v), 3rd pin for contrast control (VEE-controls how thick the characters should be shown), 3 control pins (RS & RW & E).

In the circuit, you can observe that I have only took two control pins. This gives the flexibility of better understanding. The contrast bit and READ/WRITE are not often used so they can be shorted to ground. This puts LCD in highest contrast and read mode. We just need to control ENABLE and RS pins to send characters and data accordingly.

RFID Based Toll Collection System Schematic
Read More: RFID Based Toll Collection System
 

Auto No Break Power Supply Control

$
0
0

The major aim of this no break power supply project is to supply continuous energy supply to a load, by picking the supply from any spring out of the four like – generator, mains, inverter and solar robotically in the lack of any of the spring. The demand for power is raising day by day and regular electricity cuts are grounds to a lot of troubles in a range of areas such as- houses, hospitals and industries. A substitute arrangement for electricity supply is a must.

Auto No Break Power Supply Control
This project is brought to you by edgefxkits.com
In this controller for no break power supply project 4 keys are there to display the particular breakdown of that power source. When out of the four any of the keys is pushed it confirms the lack of that exact spring, keys are linked to micro-controller as incoming signals. 8051 family’s micro-controller is brought into use. The productivity of micro-controller is set to the transmit driver IC, which controls suitable transmit to uphold continuous power supply to the load. The output has to be monitored by means of a lamp taking electricity supply from mains originally. On malfunctioning of the mains power supply (which is activated by pushing the suitable button) the load obtains power supply from the subsequent existing source, like an inverter.
If the inverter too stops working it turn over to the subsequent existing power source and so on. The electricity status, as to which power source delivers the load is also exhibited on an LCD. As it’s not possible to give all four different power springs of supply, one spring with swap switches are given to obtain the similar utility.
The no break power supply can in addition be improved by means of other springs such as wind speed power also and then taking into thought for bring into play the best feasible power whose duty maintains low at that point of time.
Auto No Break Power Supply Control Schematic
Read More: Auto No Break Power Supply Control
 

Power factor measurement using Atmel AVR Micro-Controllers

$
0
0

To learn about the power factor measurement, you should have a basic knowledge of power factor. There are three types of loads.

  1. Resistive
  2.  Inductive
  3. Capacitive

Power factor measurement using Atmel AVR Micro-Controllers
When we apply AC voltage to resistive loads it will not change the current wave form. But inductive loads will force to lag the current waveform and in the case of capacitive loading it will force to lead the current waveform than voltage waveform.
You can see the waveforms of inductive load. The phase shift of 30 degree is present in the current waveform.
The power factor is basically the “angle cosine of that lagging current”. In simple words, current is lagging by voltage with some angle and if we take the cosine of that angle we will get power factor.

Zero Cross Detection:

Zero cross detection is a method which can enable us to measure the time between voltage and current. In this technique we get a high value (i.e. 1) whenever a zero will cross the system. There are many ways to implement it. But remember, this technique is the heart of this project so implementation must be accurate. In this project we implemented zero crossing using LM358 an 8 pin IC having dual amplifiers in it. In zero crossing, we have to get a “high” value during crossing of zero in waveforms. So to get  that  value  we  use  amplifier  as  a  comparator  which  will  compare  the  non  inverting reference value and then act accordingly.
We will use a 16×2 LCD to show our results and ATmega 8 or ATmega16 can be used for the project. In the simulation, take upper sine generator as output of Potential Transformer (PT) and lower sine generator as output of Current Transformer (CT). The reason behind using CT and PT is, we cannot give high voltage to the IC LM358. It will burn the IC badly. So first step down the voltage and step down the current at such extent that the highest peak of current and voltage is not more than 5V. If you have no idea of using CT and PT in the real systems then see the links below.
Power factor measurement using Atmel AVR Micro-Controllers Schematic
 
Read More: Power factor measurement using Atmel AVR Micro-Controllers

Using AVR Studio – My first C++ code

$
0
0

This is an extremely simple “Hello World” C++ code for the ATMega32 that you can follow using AVR Studio. You do not need any hardware such as the chip or even the ISP programmer cable because AVR Studio simulates the inputs and outputs, and you can see for yourself how the ports behave.

This is just a simple article to show how to install the software and use it. I used an old version of AVR Studio because my computer is old and I did not want to waste time downloading large files that would take ages to install.

Using AVR Studio - My first C++ code

Step 1: New Project

Select the “New Project” button.

Step 2: AVR GCC

Select “AVR GCC” and give the project a name, then press the “Next” button.

Step 3: ATMega32 Device

Select the “ATMega32” device and press the “Finish” button.

ATMega32 Port A Pinout

Here is the ATMega32 pin diagram. Ideally, you want to look over the documentation of this IC to understand its full capabilities. For this article, I shall be using the pins PA0 to PA7.

As these things go, it all boils down to being able make the pins produce +5 V and 0 V to blink LEDs. If you can start out learning that then you are half way there.

Once you have made some LEDs blink! Call yourself a genius and get a degree from Cambridge University. Well, it is not that simple, unless your dad is the Chairman of the Board, but at least it gets you part way there. 🙂

Hello World!

In this first program we use Port A, which consists of 8 physical pins, pin 33 to pin 40, as shown above. A data bit within the chip represents each physical pin. These bits are grouped together to make the Port A Data Register.

When you set a data bit to binary 1, the associated physical pin will produce 5 V. Hey, it is clever! When the data bit is set to binary 0, the physical pin produces zero volts.

If you set each bit to binary 1 in succession, one after the other, then each physical pin will produce 5 volts in the same succession. If there were LED lights connected to the pins, you would see each LED light up one after the other in succession.

Using AVR Studio - My first C++ code schematics

Luckily you do not need to build a circuit with LED lights to see what is happening at the pins in Port A. AVR Studio provides a simulated I/O View that lets you see each bit of Port A.

Code

  1: #include <avr/io.h>
  2: // Example by Peter J. Vis for ATmega32
  3: // This program will turn each pin
  4: // of the PortA ON,sequentially.
  5: 
  6: int main(void)
  7: {
  8: // Set all the Data Direction Register bits
  9: // to Logic 1 which means all bits in PortA
 10: // will be sending data out.
 11: 
 12: DDRA = 0b11111111;
 13:  for ( ; 1==1 ; ) // loop while 1 equals 1
 14:  {
 15: // Send a sequence of binary numbers to the
 16: // PortA. Binary 1 is shifted along to the
 17: // right in each bit.
 18: 
 19: 
 20:  PORTA = 0b10000000;
 21:  PORTA = 0b01000000;
 22:  PORTA = 0b00100000;
 23:  PORTA = 0b00010000;
 24:  PORTA = 0b00001000;
 25:  PORTA = 0b00000100;
 26:  PORTA = 0b00000010;
 27:  PORTA = 0b00000001;
 28:  }
 29: return 1;
 30: }

Read more: Using AVR Studio – My first C++ code


Viewing all 1082 articles
Browse latest View live