Showing posts with label interfacing. Show all posts
Showing posts with label interfacing. Show all posts

RFID-Based Automatic Vehicle Parking System

Tuesday, 25 June 2013
RFID-Based Automatic Vehicle Parking System 

 Radio-frequency identification (RFID) is an automatic identification method wherein the data stored on RFID tags or transponders is remotely retrieved. The RFID tag is a device that can be attached to or incorporated into a product, animal or person for identification and tracking using radio waves. Some tags can be read from several metres away, beyond the line of sight of the reader.

RFID technology is used in vehicle parking systems of malls and buildings (refer Fig. 1). The system normally consists of a vehicle counter, sensors, display board, gate controller, RFID tags and RFID reader. Presented here is an automatic vehicle parking system using AT89S52 microcontroller.

RFID system fundamentals
Basically, an RFID system consists of an antenna or coil, a transceiver (with decoder) and a transponder (RF tag) electronically programmed with unique information. There are many different types of RFID systems in the market. These are categorised on the basis of their frequency ranges. Some of the most commonly used RFID kits are low-frequency (30-500kHz), mid-frequency (900kHz-1500MHz) and high-frequency (2.4-2.5GHz).


Fig. 2: Internal diagram of a typical RFID antenna
RFID antenna. Fig. 2 shows the internal diagram of a typical RFID antenna. The antenna emits radio signals to activate the tag and read/write data from/to it. It is the conduit between the tag and the transceiver, which controls the system’s data acquisition and communication.

Antennae are available in a variety of shapes and sizes. These can be built into a door frame to receive tag data from persons or things passing through the door, or mounted on an inter-state tollbooth to monitor the traffic passing by on a freeway. The electromagnetic field produced by the antenna can be constantly present when multiple tags are expected continually. If constant interrogation is not required, a sensor device can activate the field.

Often the antenna is packaged with a transceiver and decoder to act as a reader (interrogator), which can be configured either as a handheld or a fixed-mount device. The reader emits radio waves in the range of 2.5 cm to 30 metres or more, depending upon its power output and the radio frequency used. When an RFID tag passes through the electromagnetic zone, it detects the reader’s activation signal. The reader decodes the data encoded in the tag’s integrated circuit (silicon chip) and communicates to the host computer for processing.


Fig. 3: Internal structure of typical RFID tag
Tags (transponders). Fig. 3 shows the internal structure of a typical RFID tag. It comprises a microchip containing identifying information about the item and an antenna that transmits this data wirelessly to the reader. At its most basic, the chip contains a serialised identifier or licence plate number that uniquely identifies that item (similar to bar codes). A key difference, however, is that RFID tags have a higher data capacity than their bar code counterparts. This increases the options for the type of information that can be encoded on the tag; it may include the manufacturer’s name, batch or lot number, weight, ownership, destination and history (such as the temperature range to which an item has been exposed). In fact, an unlimited list of other types of information can be stored on RFID tags, depending on the application’s requirements.

RFID tag can be placed on individual items, cases or pallets for identification purposes, as well as fixed assets such as trailers, containers and totes. There are different types of tags with varying capabilities:
1. Read-only tags contain such data as a serialised tracking number, which is pre-written onto these by the tag manufacturer or distributor. These are generally the least expensive tags as no additional information can be included when they move through the supply chain. Any update to the information has to be maintained in the application software that tracks the stock-keeping unit’s movement and activity.


Fig. 4: Block diagram of RFID-based automatic vehicle parking system
2. Write-once tags enable the user to write data once in the production or distribution process. The data may include a serial number or lot or batch number.

3. Full read-write tags allow new data to be written to the tag—even over the original data—when needed. Examples include the time and date of ownership transfer or updating the repair history of a fixed asset. While these are the most costly of the three tag types and impractical for tracking inexpensive items, future standards for electronic product codes (EPCs) appear to be headed in this direction.

Other features of the tag include:
Data capacity. The capacity of data storage on a tag can vary from 16 bits to several thousand bits. Of course, the greater the storage capacity, the higher the price of the tag.

Form factor. The tag and antenna structure can come in a variety of physical form factors and can either be self-contained or embedded as part of a traditional label structure (termed as ‘smart label,’ it has the tag inside what looks like a regular bar code label).

Passive and active. Passive tags have no battery and broadcast their data only when energised by a reader. It means these must be actively polled to send information. Active tags broadcast data using their battery power. This means their read range is greater than passive tags—around 30 metres or more, versus 5 metres or less for most passive tags.

The extra capability and read range of active tags, however, come at a cost. These are several times more expensive than passive tags. Today, active tags are much more likely to be used for high-value items or fixed assets such as trailers, where the cost is minimal compared to item value and very long read ranges are required. Most traditional supply chain applications, such as the RFID-based tracking and compliance programmes emerging in the consumer goods retail chain, use the less expensive passive tags.

Frequency range. Like all wireless communications, there are a variety of frequencies or spectra through which RFID tags communicate with readers. Again, there are trade-offs among cost, performance and application requirements. For instance, low-frequency tags are cheaper than ultra-high-frequency (UHF) tags, use less power and are better able to penetrate non-metallic substances. These are ideal for scanning objects with high water content, such as fruit, at close ranges.

UHFs typically offer longer range and can transfer data faster. But these use more power and are less likely to be effective with some materials.

Electronic product code (EPC) tags. EPC is an emerging specification for RFID tags, readers and business applications. It represents a specific approach to item identification, including an emerging standard for the tags—with both the data content of the tag and open wireless communication protocols.

RF transceiver. RF transceiver is the source of RF energy used to activate and power the passive RFID tags. It may be enclosed in the same cabinet as the reader or it may be a separate piece of equipment. When provided as a separate piece of equipment, the transceiver is commonly referred to as an RF module. RF transceiver controls and modulates the radio frequencies that the antenna transmits and receives. The transceiver filters and amplifies the backscatter signal from a passive RFID tag.

How this vehicle parking system works
Fig. 4 shows the block diagram of the RFID-based automatic vehicle parking system.

To get started with RFID-based automatic vehicle parking system, the vehicle owner has to first register the vehicle with the parking owner and get the RFID tag. When the car has to be parked, the RFID tag is placed near the RFID reader, which is installed near the entry gate of the parking lot. As soon as the RFID tag is read by the reader, the system automatically deducts the specified amount from the RFID tag and the entry gate boomer opens to allow the car inside the parking area. At the same time, the  parking counter increments by one. Similarly, the door is opened at the exit gate and the parking counter decremented.

The system also offers the facility to recharge the amount for each RFID tag. No manual processing is involved. In addition, the system provides security.

Circuit description
Fig. 5 shows the circuit of the RFID-based automatic vehicle parking system. The circuit can be divided into different sections:

Fig. 5: Circuit of the automatic RFID-based automatic vehicle parking system

Power supply. Connector CON1 (refer Fig. 8), diodes D1 through D4, capacitor C1, and voltage regulator ICs 7805 (IC1) and 7812 (IC2) form the power supply section of the automatic vehicle parking system. CON1 is a three-pin connector that provides 15V AC or DC power supply to the circuit. In case of 15V AC, diodes D1 through D4 form a bridge rectifier to rectify the AC supply. Capacitor C1 filters out the ripples from the rectified output. ICs 7805 and 7812 provide regulated +5V and +12V, respectively, to the circuit. +5V is used to operate the microcontroller, LCD, RFID and IR sensor circuit and +12V operates the motor.

AT89S52 microcontroller. AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8kB Flash memory. It is compatible with the industry-standard 80C51 instruction set and pin-out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional non-volatile memory programmer. Other features include 256 bytes of RAM, 32 input/output lines, watchdog timer, two data pointers, three 16-bit timers/counters, a six-vector two-level interrupt architecture, a full-duplex serial port, on-chip oscillator and clock circuitry.

Connectors CON2 through CON4. CON2 and CON3 are two-pin connectors that connect the 12V DC motors to the circuit for controlling the entry and exit gate boomers. CON4 is a ten-pin dual-in-line female connector that connects the RFID reader module to the circuit.

L293D motor driver. H-bridge DC motor driver L293D (IC5) operates the DC motors to open the door or barrier for entry into and exit from the parking lot. Two high-current motor drivers can be used in place of L293D and 12V DC motors to control the entry and exit gates, respectively.

LM358 op-amp. Dual-operational amplifier LM358 (IC4) is used as a voltage comparator to compare the output of the IR sensors with a fixed threshold voltage in order to know whether the IR beam is interrupted or not.

IR transmitter and receiver. Two IR transmitter-receiver pairs are used. The IR LEDs are connected in forward-biased condition to the +5V power supply through 220-ohm resistors. These emit IR light, which is interrupted when an object comes into its way to the IR receiver. The IR receiving photodiodes are connected in reverse-biased condition to +5V power supply through 1-mega-ohm resistors. When the IR light falls on the photodiodes, their resistance changes and so does their output. This output is compared with a fixed voltage to give a digital output to the microcontroller in order to judge the entry and exit of the vehicles.

LCD display. LCD1 is a two-line, 16-character, alpha-numeric liquid crystal display. Data lines D0 through D7 of the LCD are connected to port 2 of AT89S52 (IC3). Reset (RS) and enable (E) control lines are connected to port pins P3.6 and P3.7, respectively. Control lines control data flow from the microcontroller to LCD1.

When power is switched on, LED1 glows to indicate the presence of power in the circuit and LED2 glows to indicate the presence of RFID reader. Simultaneously, the ‘Automatic RFID Car Parking’ message is displayed on LCD1 along with a short beep from piezobuzzer PZ1. Transistor BC547 drives the buzzer. Pin details of 7805, 7812 and BC547 are shown in Fig. 6.

When a car crosses the IR LED1-D1 pair installed at the entry gate, the gate boomer does not open until an RFID tag is placed near the RFID reader. After the tag is placed near the reader, the gate boomer opens for three seconds and closes automatically. If the initial recharge amount was Rs 900, the LCD display shows ‘Vehicle1 Amount’ in the first line and ‘Deducted 100’ in the second line, followed by ‘Balance Amount’ in the first line and ‘800’ in the second line. It is then followed by display of ‘Number of Cars’ in the first line and ‘001’ in the second line. If the parking lot is full, the message “Parking is Full, Sorry for Inconvenience” is displayed on LCD1.

When a car leaves the parking area and crosses the IR beam between IR LED2 and D2 at the exit gate, the vehicle count decreases by one. The LCD shows the number of cars in the parking lot along with “Thanks for Visiting” message.

Software
The program (parking.c) for the microcontroller is written in C and compiled using Keil software to generate the hex code. The program coding starts with ‘#include’ and ‘#include’ header files. The microcontroller port pins are defined using ‘sbit’ function for interfacing with the surrounding peripherals. The entry gate motor is controlled using ‘sbit START_POINT=P1^3;’ code.

The LCD is initialised using the following code:

void lcdinit(void)
{
lcdcmd(0x38);
DelayMs(250);
lcdcmd(0x0E);
DelayMs(250);
lcdcmd(0x01);
DelayMs(250);
lcdcmd(0x06);
DelayMs(250);
lcdcmd(0x80);
DelayMs(250);
}

Construction and testing

An actual-size, single-side PCB layout for the RFID-based automatic vehicle parking system is shown in Fig. 7 and its component layout in Fig. 8. Burn the hex code into the AT89S52 microcontroller using a suitable programmer and then mount the microcontroller on the PCB. Install IR LED1-D1 pair at the entry gate such that these face each other. Similarly, install IR LED2-D2 pair at the exit gate.




For testing, switch on the circuit,  interrupt the infrared beam between IR LED1 and IR D1 with your hand or some other opaque object and then remove it, and place the tag near the reader. The LCD should show the message as described earlier in ‘How this vehicle parking system works’ section. An amount of Rs 100 should be deducted for every interruption of the IR beam. The card can be recharged by pressing the pushbutton switches (S2 and S3) provided in the circuit. Pressing switch S2 recharges the card with Rs 900 and pressing switch S3 recharges it with Rs 500.

Similarly, interrupt the IR beam at the exit gate. LCD1 should show the number of cars in the parking lot along with ‘Thanks for Visit’ message. No amount should be deducted at the time of exit.






www.efymag.com/admin/issuepdf/Const-2_Microcontroller%20Based%20Traffic%20Light%20System.zip


The maker is founder and CEO of HBeonLabs, Greater Noida
Read more ...

Part 1 of 3 USING AVR MICROCONTROLLERS FOR PROJECTS

Tuesday, 25 June 2013
Part 1 of 3
USING AVR MICROCONTROLLERS FOR PROJECTS
The AVR 8535 microcontroller and its new version ATmega8535 are versatile, high-performance but low-cost chips. This article series covers typical applications of this processor illustrating its power and cost-effectiveness in an embedded system.

The AVR family comprises several chips, all with almost the same instruction set. Of them, the 90S8515, 90S8535 and ATmega8535 chips are low-cost and readily available with the complete set of port pins. The ATmega8535-16 is more powerful and available for around Rs 250. Capable of running at 16 MHz and achieving almost 16 million instructions per second (MIPS), it is one of the fastest devices available in the market today.

Fig. 1: Pin configuration of ATmega8535


Fig. 2: A simple LED display circuit using ATmega8535

Using ATmega8535, you can build a microcontroller-based project with following features:
1. Four ports, of which one of them has eight analogue-to-digital converter (ADC) channels
2. ADC conversion time is as little as 60 microseconds. Imagine adding an external ADC to 8051 or any other microcontroller chip—that would have taken the cost to over four digits. And mind you, it is a 10-bit ADC, not just 8-bit.
3. If an 8MHz crystal is connected, each instruction executes in 1/8th of a microsecond. The 89C51 at 12MHz clock had its internal division by twelve, so it ran at just one microsecond. Thus, ATmega8535 chip is eight times faster with an 8MHz crystal. However, you can also use a higher-frequency crystal. The chip is basically a RISC processor that executes most instructions in one clock cycle itself.
4. The chip has RS-232 transmit and receive terminals much like the 8051 family, but it can support even higher baud rates.
5. It has quite a few internal registers, RAM, EEPROM and CODE memory (flash memory in excess of 4kB).
6. The instruction set is versatile, complete with several arithmetic, logic and transfer instructions and related jump instructions, etc.
7. An analogue comparator pin, which can compare an external analogue voltage and take control action.
8. Reset is possible through the software, and a watchdog is provided. Power-down or sleep modes are available.
9. An additional serial interface, known as the SPI bus, with three wires: data (2) and clock (1). These pins can be used for programming or loading the code from a PC through the printer port or serial port. For programming the internal flash memory locations, just 5V supply is enough.
10. Two PWM output pins, which are useful for power control applications.
11. Several timers as in other members of the 8051 family, but with much better time resolution.
12. Additional features like input capture and output compare.

Here, we shall delve into the chip’s operations with typical programs and circuits. All the development tools including ‘C’ compiler are available for free from the Internet.

The features of ATmega8535 make it the right candidate for various embedded control applications. Even a digital filter can be implemented on the device, provided you are fully conversant with its hardware and software features. You can download the databook of ATmega8535 from the ‘ATMEL.com’ Website to understand its features and work out simple applications.

The sample programs given here can be used to yield a powerful controller for many applications like a filter or motor controller.

Programming the chip

The AVR source code file with ‘.asm’ extension can be written using either the EDIT, Wordpad or notebook programs.

As with all microprocessor or microcontroller programs, for the source code, one has to enter the program by mnemonics and assembler directives and then convert the same into a code list for the program. (Directives are assembler commands used to control the input, output and data allocation of the assembler. These are, however, not translated into op-codes directly.) This is done using the cross-assembler software ‘avrasm.exe.’


Fig. 3: Circuit diagram of AVR programmer (Pod)
To describe the modus of writing of an Assembly language program, a simple program (LED.ASM) for AVR processors is given below:


This program helps you understand:
1. Access to the output port (here port B, where LEDs are connected)
2. The different parts of a typical assembler program
3. Different conventions like use of semicolon, upper-/lower-case letters, etc

Explanatory notes for LED.ASM
1. In Assembly language, all the text on a line after a semicolon (;) is treated by the cross-assembler as comments and it does not use it for code formation.

2. Including the m8535def.inc processor-specific file in Assembly program means all the I/O register names, I/O register bit names, etc appearing in the datasheet can be used. Failure to include this file may result in a number of error messages. Ensure that this file is placed in the same directory as your source code file (LED.asm in this case). Else, give complete path for the m8535def.inc file.

3. Following conventions havebeen used in the program:
(a) Words in upper-case letters are used for command directive words of the Assembly language or predefined ports of the processor.
(b) Mnemonic words are written in lower case.

4. LIST directive turns on the listing output if it had been previously turned off. Similarly, NOLIST directive, if used, will turn off the listing output.

5. DEF directive is used to define a text-substitution label for a string. A label/name is easy to remember. Here, register R16 is replaced with ‘mp’ name. Thus whenever ‘mp’ is encountered in the source code, it will be automatically replaced with ‘R16.’

Fig. 4: Screenshot of AVR-Programmer


Fig. 5: Screenshot of AVR-Programmer showing activity window
6. ‘.org $0000’ defines the reset address. When power is switched on, the program starts from this location. A restart from the reset address can be activated by resetting the respective hardware pin of the chip (pin 9) or upon watchdog timer reaching its zero count. A relative jump command (rjump) at this reset location directs the program execution to label (main)—as long as the label is within 2k locations from the reset address (0000). Incidentally, ‘rjmp main’ is the first code-generating instruction.

7. It is essential to set up the stack pointer before being able to call any subroutine, since stack is required for saving the return address, where the next program execution is to start from. The program lines starting with ‘ldi R16,low(RAMEND)’ and ending with ‘out SPH, R16’ do just that.

8. The ‘ldi mp, 0b11111111’ and ‘out DDRB, mp’ lines set port-B pins as the output. The first line, interpreted as ‘load immediate (ldi) into register ‘mp’’, loads binary value ‘11111111’ into the ‘mp’ register. The second line transfers the contents of ‘mp’ (11111111) to the data direction register of port B (DDRB). DDRB is already defined in the m8535def.inc file. (If you want to set port-B pins as input, load binary ‘00000000’ into ‘mp’ and output it to DDRB.) Incidentally, ‘0b’ precedes a binary number. Similarly ‘0x’ precedes a hex number. Numbers without these prefixes denote decimal numbers by default. Hence you may replace ‘0b11111111’ with either ‘0xFF’ or simply ‘255’ to achieve the same results.

Fig. 6: Circuit for message display on the LCD

9. The rest of the program starting at label ‘loop:’ and ending with ‘rjmp loop’ achieves switching on and off of the LEDs with a delay. The delay subroutine starting at label ‘delay:’ and ending with return instruction ‘ret’ is called from within the loop.

Initially, ‘mp’ is loaded with hex value ‘00’ and output through port-B pins, making them low. Since the cathodes of all the eight LEDs are connected to these port pins via current-limiting resistors, the LEDs light up. Thereafter, the delay subroutine (Rcall delay) is called and ‘mp’ is loaded with hex value ‘FF’ and transferred to the port-B output to turn off the LEDs. The loop is repeated as long as the power is switched on.

10. The internal R-C clock of ATmega8535 is 1 MHz by default. In the absence of ‘Rcall delay’ instruction, each of ‘ldi’ and ‘out’ instructions requires 1000 ns, while ‘rjmp’ instruction requires 2000 ns. Thus loop execution would take 4000 ns. This amounts to LED switching rate of 250 kHz.

Introduction of delay between switching on and off reduces this frequency to around 0.5 Hz by decrementing registers ‘r19’ and ‘r17’ from ‘255’ to ‘0,’ thereby making the elapsed time slower by 256×256 (which works out to around 0.5Hz rate).

After assembling the LED.asm source file, the program will have eight words. The LED.LST file stores the result of the assembly process in the form of a listing.

Once a program has been written using any editor, wordpad or notepad, it is assembled using the avrasm.exe AVR assembler, which is included in this month’s EFY-CD. Of course, the AVRSTUDIO 4.0 integrated development environment (IDE) is more versatile and user-friendly software for development, but the avrasm.exe assembler is simpler and direct.

Simply typing ‘avrasm -i LED.asm LED.lst LED.hex’ under the DOS prompt makes the cross-assembler generate code for the LED.hex file and also provide a text file giving both the code and the program together in LED.lst. Thus, you get the LED.lst listing file and the LED.hex Intel hex code file.

Fig. 7: Actual-size, single-side PCB layout for AVR
programmer (Pod

Fig. 8: Component layout for the PCB in Fig. 7

Fig. 9: Actual-size, single-side PCB layout for
message display on LCD

Fig. 10: Component layout for the PCB in Fig. 9
http://adf.ly/R66qb
Alternatively, you can prepare a batch file as follows:
Upon DOS prompt, enter ‘copy con avr.bat.’ In the following line, type ‘Avrasm -i %1.asm %1.lst %1.hex.’ Pressing ‘F6’ key in the following line displays ‘Control-Z.’ Now pressing the ‘Enter’ key displays “1 file copied.”

Now the avr.bat file has been prepared. This simple batch file is invoked to assemble this (or any) program by typing ‘Avr LED’ upon the DOS prompt and pressing the ‘Enter’ key.

This assembles the program, and forms both the list file (that contains the code-cum-Assembly listing) and the hex file (the actual Intel-format hex file for use by the programmer).

Likewise, any other assembly program ‘xxx.asm’ can be coded into the hex file by simply typing ‘avr xxx’ on DOS prompt. ‘xxx’ denotes the name of the program. The ‘.asm’ is not to be typed.

In our LED.asm program, we have included the m8535def.inc file. This file is required along with the avrasm.exe cross-assembler. For other AVR processors like 90S8515, 90S8535 and at-Tiny 26, the files to be included are 8515def.inc, 8535def.inc and tn26def.inc, respectively.

The next task is to burn the code into the chip. Note that a chip previously programmed or erased is automatically erased when a new program is burnt into it using the device programmer as described below.

The AVR device programmer
The AT-PROG programmer software is used for programming ATmega8535. This menu-drive programming software is simple to use and invoked from command prompt.

The software uses a simple pod connected to the printer port of a computer. The circuit of the pod (shown in Fig. 3) is very simple. It just connects the IC to be programmed to the pins of the PC’s printer port.

This circuit is assembled on a small PCB with a D25 male-female plug at one end. The IC base is a 40-pin zero-insertion-force socket (ZIF). This enables easy insertion and removal of the IC to be programmed.

The AT_PROG.exe is a simple programming software that can be run under DOS prompt by typing AT-PROG. The files At-prog-hlp.htm, At-prog.exe, At-prog.cfg and At-prog.ini should be placed in one directory before running the AT-PROG. These files have been included in this month’s EFY-CD as part of this article.

The menu-driven window of the AT-PROG programmer has the following menu items:
1. File menu. This menu is used to select or open the LED.hex file, or whatever, which is to be programmed into the device.

Pull down the menu by clicking it. Under ‘Open’ option, enter the file name as ‘LED.hex’ and press ‘Enter.’ The IC to be programmed is selected from the AVR-Programmer window by clicking the edge of the small rectangular window and choosing the IC as shown in Fig. 4. Now connect the printer-port connector to the programming pod, whose circuit is shown in Fig. 3.
2. Write menu. On clicking the ‘Write’ menu, the ‘Activity’ window at the bottom whitens and shows ‘Connecting’  (refer Fig. 5). Then, the data is transferred to the IC and verified after programming, showing ‘ok’ in the same window.
3. Check menu. This menu is used to find out whether the IC is inserted in the socket and whether the connector connections are okay. It will indicate an error if the IC is not there or not responding.

In this mode of programming, the serial-peripheral interface (SPI) of the AVR chip is used. This interface has three wire connections:
(i) Master output and slave input (MOSI)
(ii) Master input and slave output (MISO)
(iii) Serial clock (SCLK)

Using these wires, the SPI interface does the serial transfer of data (i.e., our program codes) into the chip, which is configured as a slave. The data and clock are connected via MOSI and SCLK pins of the chip, respectively. Upon reception of each byte, the chip acknowledges it by sending a byte (53hex).

In ‘Check’ mode, the IC is enquired about its name by the computer (Master), which it replies with its signature code embedded in the chip memory by the manufacturer. Each IC has its specific signature code. Thus, by noting the code itself, what IC is being programmed will be known to the computer. So the small window under the device-select rectangular window can be clicked to show ‘autodetect’ the IC.
4. Options menu. In this menu, the speed of the clock used for transferring data from the computer can be selected as ‘slow,’ ‘normal’ or ‘fast.’ With present high-speed PCs, choose ‘normal’ or ‘slow.’ In the same menu, the ‘read signature bytes’ option is to be enabled and it is so by default.
5. Port menu. The port menu, which is next to the file menu, is useful if a different printer port is available. The program automatically selects the available printer port.

When the ‘Activity’ window shows ‘ok’ after clicking the ‘Write’ menu, remove the programmed chip from the programmer circuit board and fix it onto the target circuit for the LED.asm program (shown in Fig. 2). Now apply 5V and press the switch connected to Reset pin, if needed. (The circuit resets at power-on.) The LEDs start blinking fast and the waveform can be observed on the CRO for any of the pins at the output to the LEDs. It will be around 600 Hz.

Message display on the LCD module
Method I. Given below is the source code for message display on the LCD module along with suitable comments wherever needed.


This program displays ‘Electronics ForU’ on the LCD module (Fig. 6). The message may be displayed on the LCD in a single or two rows depending on the LCD module. In some LCD modules, the first eight characters are written consecutively, while for display of the next eight characters, the program needs to restart the cursor at address $C0. But Hitachi-make single-row types do not need to restart the cursor’s address after the eighth entry; the characters can be written consecutively up to ‘16,’ i.e., in a single row.

The program is named as ‘LCD_CHAR.asm’ and assembled into the ‘.hex’ file by typing ‘avr lcd_char’ and invoking the cross-assembler AVR. Now the lcd_char.hex file is generated. The AT-PROG programmer burns this code into the flash memory of the ATmega8535.

Note that while assembling this program using ‘avr lcd_char’ command, the definition file for IC ATmega8535 (m8535def.inc) should be in the same directory.

Method II. This message display program uses look-up table. In the message display program described in Method I, ‘Call lcdwr’ instruction was written for each character. Here, instead, if we enter all the bytes for ‘Electronics ForU’ in a table, they can be picked up one by one until the end and shown on the LCD screen. For the purpose, there is an instruction called load program memory (LPM).

The table, as also the name, is stored in the program memory. Here is the program along with necessary comments.


The actual-size PCB for programming and LCD message display are given in Figs 7 and 9, while their component layouts are shown in Figs 8 and 10, respectively.
 
Read more ...