IndianEngineer

ProjectsectsBazaar.in

Microcontrollers & Use in Embedded Technology

Its fun programming and working with microcontrollers. With microcontrollers you can create a piece of hardware which acts according to your wish (obviously with some limitations !). Examples are you can flash a LED, drive a 7 segment display, print text on a LCD, receive signals from a remote control, control electrical appliances of your room, build a robot that follows a line on the floor and avoids obstacles coming in between, frequency meter and infinitely many more..

BSNL JTO

BSNL JTO COACHING

Basically a Microcontroller is a mini computer with CPU, Memory, I/O lines etc. Microcontrollers are much better for smaller embedded systems than their ancestors i.e. microprocessors, if you are developing a system using microprocessor, then your hardware or circuit will be more complex whereas if you choose a microcontroller, your hardware becomes simple because all the necessary peripherals such as RAM, ROM, TIMERS, I/O ports etc are embedded in a microcontroller. Therefore it is also called a mini computer on a chip. Now we will start with interfacing various devices to microcontrollers (Assuming you have basic knowledge of 8051 architecture and assembly programming and also C). I have chosen 8051 microcontroller due to its simplicity in architecture and assembly language, and learning 8051 chip is much easier than other microcontrollers if you don’t have any prior knowledge on microcontrollers. For more detailed information of hardware architecture and assembly language of 8051 microcontroller you can refer hardware manual and instruction set from ATMEL’s homepage.

Most of the projects and tutorials published here are based on Atmel’s AT89S52 microcontroller, it is a 8- bit microcontroller with 8051 architecture, comes in a 40 pin DIP, contains all necessary peripherals required for a hobby project. Now for a microcontroller to be operational the minimum hardware you need is a crystal oscillator, power supply, power on reset etc. So I have come up with a very simple development board to carry on the projects and interfacing tutorials published here. (Note: This development board is not compulsory; you can also rig up the circuits in breadboard since most of the circuits are simple). You can construct the development board on a general purpose circuit board. (Soon I will be publishing PCB layout for this).

8051 Development Board.

We will start with interfacing microcontroller with LED’s, Displays, Motors, Relays etc.

· Interfacing LED(s)

· Interfacing 7 segment Display

· Interfacing multiple 7 segment displays

· Basics of PWM

· Interfacing Relays

· Interfacing 4×4 keyboard

· 8051 Serial port

· many more to come…

In order set up your simple home lab, you need

· keil or any other assembler/compiler.

· ISP programmer circuit

· ISP programmer software

· Target hardware (your development board or circuit).

April 11, 2010 Posted by | Microcontroller's | , | 2 Comments

8051 Development Board

I have designed a development board for practicing 8051 microcontrollers. The development board is simple one containing minimum hardware required for a 8051 chip to function. The 8051 chip used in this development board is 89S52. The AT89S52 comes in a 40 pin PDIP package. It consists 8kB in system programmable flash memory for code storage, 256 bytes of RAM, 32 I/O lines, three 16 bit timer/counters, one full duplex serial port and many more. For further details you can refer the datasheet.

Figure below shows the circuit diagram of the development board. Click on the image to enlarge. I have connected pull up resistors for all the ports in the circuit diagram, but pull ups are compulsory only for port 0. You can neglect pull ups connected for other ports since they are connected to pull ups internally.

This circuit can be easily constructed in a general purpose circuit board. One can neglect the seven segment display and 8 LEDs if they wish to build it separately. I will be publishing the PCB files for this board soon. Keep visiting.

Some Images of my 8051 development board built on breadboard. This is my first version of my board so the 7 segment display is not present.

Image notes: 1] The marvel chip Atmel’s 89S52    2] ISP port for downloading programs    3] Pull up resistor network    4] connectors to connect I/O pins to any other circuits/interface boards    5] 11.0592 Mhz crystal    6] Power connector    7] 7805 voltage regulator    8] Power indication LED    9] 8 LEDs connected to Port 0

April 11, 2010 Posted by | Microcontroller's | , , | Leave a comment

8051 serial port

The only one communication hardware present in atmel 89S52 version of 8051 microcontroller is the serial port. The serial port or UART transfers data bit by bit. In mode 1, 8 bits can be sent with one start and stop bit in a frame.

Communicating with the PC:

We can communicate with PC by using the serial port available in 8051. In order to communicate with the PC, we need a level converter because the serial port of the pc uses RS232 voltage levels which is much higher voltage than the TTL logic used by the microcontroller (+12v for logic 0 and -12v for logic 1). A dedicated IC from MAXIM i.e. Max232 is readily available in the market. It converts the TTL signals from the microcontroller to RS232 level and the other way round. Max232 contains 2 channels, works with single 5V supply and uses the principle of charge pump to convert the voltage levels.

http://www.shree-electronics.com/images/rs232_level_conv.gif  http://www.shree-electronics.com/images/rs232_level_conv.gif

The schematic :

http://www.shree-electronics.com/images/max232_pins.gif  http://www.shree-electronics.com/images/max232_pins.gif

http://www.shree-electronics.com/images/max232_ckt.gif  http://www.shree-electronics.com/images/max232_ckt.gif

Configuring HyperTerminal:

HyperTerminal is the tool usually used to test and communicate with the PC’s serial port. To set up HyperTerminal follow the steps given below.

1. Open HyperTerminal.

Start > All programs > Accessories > Communications > Hyper Terminal

2.Specify a name for the connection

Click OK

http://www.shree-electronics.com/images/hyper2.gif  http://www.shree-electronics.com/images/hyper2.gif

3.Configure the connection parameters

Select the port of your PC i.e.COM1, COM2 etc., click OK

http://www.shree-electronics.com/images/hyper3.gif  http://www.shree-electronics.com/images/hyper3.gif

Set baud rate as required, and change Flow control to none

http://www.shree-electronics.com/images/hyper4.gif  http://www.shree-electronics.com/images/hyper4.gif

The connected in the bottom shows the status of the connection.

http://www.shree-electronics.com/images/hyper6.gif  http://www.shree-electronics.com/images/hyper6.gif

Now your HyperTerminal is ready to communicate. You can disconnect or connect the connection by clicking on the icons shown in the image.

http://www.shree-electronics.com/images/hyper5.gif  http://www.shree-electronics.com/images/hyper5.gif

HyperTerminal displays only the character or data received, not the one you typed to send.

Testing the Level converter:

You are ready with level converter hardware and HyperTerminal, now its time for testing your level converter hardware. For testing purpose, just interconnect the Tx and Rx pins of the level converter, and type something in the HyperTerminal, you will see the echo.

Programming the 8051:

8051 USART uses dedicated buffer register SBUF, the mode and other settings of the serial port such as number of stop bits etc. is determined by the contents of SCON register. Timer 1 should be initialized to 8-bit auto reload, and its content determines the Baud rate of the 8051 serial port. Read datasheet to know more about different modes of UART.

Connecting the Microcontroller:

Connect the Tx and Rx pins of the 8051 (pin no. 10 and 11 i.e. P3.0 and P3.1 in 89S52)microcontroller to the level converter. Provide power for the 8051 microcontroller target board.

;*************************************************
;
;Program: UART_test
;Author: Srikanth
;Website: http://shree-electronics.com/
;Description: Prints string on the hyperterminal window
;
;*************************************************

org 0000h
ljmp main

main:
mov tmod,#20h      ;Timer 1 configured to 8 bit
;auto reload
mov th1,#-6        ;Baud rate set to 9600
mov scon,#50h      ;UART configure as 8 data bits
setb tr1           ;with 1 start and stop bit
up:
mov sbuf,#’s’      ;Store the char to be
;transmitted in SBUF refister
acall transmit     ;call transmit subroutine
mov sbuf,#’h’
acall transmit
mov sbuf,#’r’
acall transmit
mov sbuf,#’e’
acall transmit
mov sbuf,#’e’
acall transmit
mov sbuf,#’-‘
acall transmit
mov sbuf,#’e’
acall transmit
mov sbuf,#’l’
acall transmit
mov sbuf,#’e’
acall transmit
mov sbuf,#’c’
acall transmit
mov sbuf,#’t’
acall transmit
mov sbuf,#’r’
acall transmit
mov sbuf,#’o’
acall transmit
mov sbuf,#’n’
acall transmit
mov sbuf,#’i’
acall transmit
mov sbuf,#’c’
acall transmit
mov sbuf,#’s’
acall transmit
mov sbuf,#’.’
acall transmit
mov sbuf,#’c’
acall transmit
mov sbuf,#’o’
acall transmit
mov sbuf,#’m’
acall transmit

up1:
ajmp up1           ;Loop here

transmit:            ;Transmit subroutine
jnb ti, transmit   ;Wait for completion of
;transmission
clr ti             ;Clear transmit flag
ret

end

;*************************************************
;
;Program: UART_test_1
;Author: Srikanth
;Website: http://shree-electronics.com/
;Description: Prints the next char of the typed
; character on the hyperterminal window
;
;*************************************************

org 0000h
ljmp main

main:
mov tmod,#20h      ;Timer 1 configured to 8 bit
;auto reload
mov th1,#-6       ;Baud rate set to 9600
mov scon,#50h     ;UART configure as 8 data bits
setb tr1          ;with 1 start and stop bit
up:
acall recieve     ;First recieve the char typed on
;hyperterminal
cjne a,#’z’,next  ;If typed char is not Z, then
mov a,#’a’-1      ;send next char of the typed one
next:
inc a
acall transmit
sjmp up           ;Loop

transmit:           ;Transmit subroutine
mov sbuf,a        ;Move the char to be transmitted
;into SBUF reg
jnb ti,$          ;Wait for transmission to be
;complete
clr ti            ;clear transmit flag
ret

recieve:            ;Recieve subroutine
jnb ri,$          ;wait for a char to be recieved
mov a,sbuf        ;save the recieved char
clr ri            ;clear recieve flag
ret

end

April 11, 2010 Posted by | Microcontroller's | | Leave a comment

ISP Flash Microcontroller Programmer Ver 3.0a

ISP Flash Microcontroller

Programmer

Ver 3.0a

Mohammad Asim Khan, asimkhan@sat.net.pk


Introduction

This ISP Programmer can be used either for in-system programming or as a stand-alone spi programmer for Atmel ISP programmable devices. The programming interface is compatible to STK200 ISP programmer hardware so the users of STK200 can also use the software which can program both the 8051 and AVR series devices.

Hardware

Figure 1 shows the circuit diagram of the in-system programmer interface, the power to the interface is provided by the target system. The 74HCT541 ic isolate and buffer the parallel port signals. It is necessary to use the HCT type ic in order to make sure the programmer should also work with 3V type parallel port.

http://www.kmitl.ac.th/~kswichit/IspPgm30a/isp1_sch.gif

Figure 1: Circuit Diagram of the ISP Programmer Interface

Figure 2 shows the circuit diagram of the stand-alone spi programmer, the power to the interface is provided by the PC USB port which can supply a max of 100mA current. Get a cheap USB cable, cut the
cable other end connector and attach a crimp shell connector to this end, red wire is 5V and black is 0V.

The printer port buffer interface is same as shown in figure 1. For the u-controller a 40 pin ZIF socket can
be used.
This programmer circuit can be use to program the 89S series devices and the AVR series devices which
are pin compatible to 8051, like 90S8515. For other AVR series devices the user can make an adapter
board for 20, 28 and 40 pin devices. The pin numbers shown in brackets correspond to PC parallel port
connector.

http://www.kmitl.ac.th/~kswichit/IspPgm30a/isp2_sch.gif

Figure 2: Circuit Diagram of the SPI Programmer

Software

The ISP-30a.zip file contains the main program and the i/o port driver. Place all files in the same folder.
The main screen view of the program is shown in figure 3.

Also make sure do not program the RSTDISBL fuse in ATmega8, ATtiny26 and ATtiny2313 otherwise further spi programming is disable and you will need a parallel programmer to enable the
spi programming. For the fuses setting consult the datasheet of the respective device.

For the auto hardware detection it is necessary to short pin 2 and 12 of DB25 connector, otherwise the
software uses the default parallel port i.e. LPT1.

Following are the main features of this software,

· Read and write the Intel Hex file

· Read signature, lock and fuse bits

· Clear and Fill memory buffer

· Verify with memory buffer

· Reload current Hex file

· Display buffer checksum

· Program selected lock bits & fuses

· Auto detection of hardware

Note:

The memory buffer contains both the code data and the eeprom data for the devices which have
eeprom memory. The eeprom memory address in buffer is started after the code memory, so it is
necessary the hex file should contains the eeprom start address after the end of code memory last address
i.e. for 90S2313 the start address for eeprom memory is 0x800.

The software does not provide the erase command because this function is performed
automatically during device programming. If you are required to erase the controller, first use the clear
buffer command then program the controller, this will erase the controller and also set the AVR device fuses
to default setting.

Download

ISP-Flash Programmer Software ISP-30a.zip

http://www.kmitl.ac.th/~kswichit/IspPgm30a/ISP-Pgm.gif

Figure 3: Main screen of the program ISP-Pgm Ver 3.0a

Contribution to Asim’s ISP Loader

ISP_programmer.zip Schematics and PCB Files including PDF layouts for all layers designed by Farshid Jafari Harandi from Iran using Eagle cadsoft. updated 8-Sep-2005

AT89ISP.rar Single side layout made by Amr Ahmed Abdel-Baset from Egypt.

prahlad.zip ppisppdf.zip Single Side PCB files in Post Script and PDF Format made by Prahlad J. Purohit from India.

ISP_PGM.zip Layout made by Mehrdad Mahboudy from Iran.

April 11, 2010 Posted by | Microcontroller Programmer | | 2 Comments