Micro-controller to PC Communication

This project demonstrates communication in between Micro-controller to PC and vise versa.

On controller board seven push buttons correspond to 6 LED and also with six virtual bulbs on PC and one for reset to SW off all bulbs. Whenever any push button pressed corresponding LED and on PC screen bulb glow Up.

By reset SW all LED and bulb on screen can be SW off at once. One reset button on PC screen also serves same purpose.

For proper communication baud rate as 9600 an 11059200 Hz crystal is used. The heart of the main

Control board is ATMEL AT89C2051 Micro-controller and its software, Software is written and debug in BASCOM-51.A free Demo Software BASCOM-51usefull up to 2K bytes code, can be down loaded from www.mcselec.com from Holland.  

 IC of MAXIM Co MAX 232 is used for the communication to Micro-controller to PC. Only 3 wires can be used for communication cable. Six 47 ohms resistors are added to limit the current of LED.

Schematic Diagram of Micro-Controller to PC Communication

Schematic Diagram of Power Supply

A standard regulator L7805 of TO220 casing is used for the controller supply.

a diode is added to protect by reverse supply feeding. Both side of regulator 

is filtered by 2200 u F 16 Volts and 220 u F 10 V capacitors. and two nos .01 u F capacitors are added for stability. 

Micro-controller Code

  Rem This module is presented only to serve as an sample for the

 Rem AT89C2051 development. Author provides this module as is and

 Rem doesn’t guarantee its functionality or suitability for any

 Rem particular purpose

 Rem Pl. E-Mail any question and suggestion to syedpervez@yahoo.com

 Rem ****   Micro-Controller to PC Communication.     ****

 Rem **** Update on 25-10-2005  ****

 Rem Controller send a string of 6 bytes

 Rem with added characters ";" in the start

 Rem and "ok" at the end, pc receive this string

 Rem and sort-out the information of on-off Bulbs

 Rem in vb program.

 Rem Reset command is transparent for both pc or

 Rem controller to switch off all LED simultaneously.

 Rem sw status information stays in a array of 6 bytes

 Rem and updated whenever a SW is pressed.

 

 $regfile = "89c2051.dat"

 

 $romstart = &H0                                              ' code starting address

 $crystal = 11059200                                          ' CPU 11.0592 for 9600 baud

 $baud = 9600

 $timeout

 

 Dim Num As Byte

 Dim Count As Byte

 

 

 Dim My_data(6) As Byte                          'declare arrays of 6 byte

 

 Gosub Clear                                               'initially clear all arrays

 

 Do

 

 Debounce P3.2 , 0 , Clear , Sub               'clear all arrays

 Debounce P3.3 , 0 , Ar1 , Sub                  'place "1" if pressed

 Debounce P3.4 , 0 , Ar2 , Sub                         '-----do-----

 Debounce P3.5 , 0 , Ar3 , Sub

 Debounce P3.7 , 0 , Ar4 , Sub                         '-----do-----

 Debounce P1.0 , 0 , Ar5 , Sub

 Debounce P1.1 , 0 , Ar6 , Sub                         '----do-------

 

 Print ";";                                                     'indicate the start of information

 

 For Num = 1 To 6

 Printhex My_data(num);                           'just transfer whatever array have

 Waitms 5

 Next

 

 Print "ok"                                                   'shows the end of string

 

 Input My_data(7) Timeout = 1000

 

 If My_data(7) = 1 Then Gosub Clear

 

 'Waitms 10

 

 Loop

 

 Ar1:

 My_data(1) = 1                                           'place "1" in the corresponding array

 Reset P1.7                                                   ' which ever PB. switch is pressed

 Return

 Ar2:

 My_data(2) = 1

 Reset P1.6

 Return

 Ar3:

 My_data(3) = 1

 Reset P1.5

 Return

 Ar4:

 My_data(4) = 1

 Reset P1.4

 Return

 Ar5:

 My_data(5) = 1

 Reset P1.3

 Return

 Ar6:

 My_data(6) = 1

 Reset P1.2

 Return

 

 Clear:

 

 For Count = 1 To 6

 My_data(count) = 0                                           'clear all arrays by placing zero

 Next

 Set P1.2

 Set P1.3

 Set P1.4

 Set P1.5

 Set P1.6

 Set P1.7

 Return

 

 End

Download all the files, document PDF , Capture ORCAD schematic Diagram, Micro-Controller Code basic and hex file in one ZIP File                 DOWN LOAD

Basic Compiler BASCOM-51 can be download by their web site http://www.mcselec.com.

and AT89C2051 Data sheet can be download by ATMEL web site http://www.atmel.com

 

 

 

     

Hosting by WebRing.