Home Parallel Port Serial Port Serial Info Parallel Info USB .NET Webboard I/O Today API Project Link

 Microcontroller interfacing in visual basic programming.

Control and interface 8051 Microcontroller Project Chapter 1

Thai version Click here
   As my above-mentioned in interfacing Serial Port for Microcontroller ,
Please go to see as thus this link .
    Interfacing to serail port in 8051 Microcontroller programming

    Continue to this project , I 'm going to present in take as above-mentioned method to apply for communicate with RS-232 system in PC Serial Port  Which will be part of microcontroller programming and PC programming that i used Visual  Basic ,including circuit diagram and PCB picture which i used testing
So, I 'm going to separate the article to 2 chapter as it has long character and protect mix article.

   Regrading equiment in electrical hardware will be basic microcontroller wring circuit which has plus in RS-232 interfacing that i used IC L232 and LED display connect to between Serial Port and PC .
Regrading the micocrocontroller which has a internal memmory in itself that you can write your program which had complie to direct micocrocontroller.   

  

 

Picture 1 : Board for this Project

   We will be program as usual in Visual Basic for interface and communicate between PC and microcontroller.  

8051 Microcontroller Programming .

                    ORG             0000H

 ; Defind value setting for Timer in using genarate Baud Rate in transfer data.     

                     MOV IE,#00000000B

                     MOV TMOD,#00100000

                     MOV TL1#,0FDH

                     MOV TH1,#0FDH

 ; Defind value setting for SCON Register that select mode 1 and receive data setting to REN=1 

                     MOV SCON,#01010000B

                     SETB TR1

                     MOV P0,#00000000B   ;; Set value to parallet port P0 all bit is 0

Start to Main Program

INDEX:         ACALL SUB_RXD   ; Get data from Serial Port which sent from PC

                     ACALL LEDOFF       ; Function for command to microcontroller in send value to defined port is off all bit

                     ACALL LED1           ; Function for command to microcontroller in send value to defined port P0.0

                     ACALL LED2          ;Function for command to microcontroller in send value to defined port P0.1

                     ACALL LED3          ;Function for command to microcontroller in send value to defined port P0.2

                     ACALL LED4          ; Function for command to microcontroller in send value to defined port P0.3

                     ACALL LED5          ; Function for command to microcontroller in send value to defined port P0.4

                     ACALL LED6          ; Function for command to microcontroller in send value to defined port P0.5

                     ACALL LED7          ; Function for command to microcontroller in send value to defined port P0.6

                     SJMP INDEX          ;Goto Main Program

; Function for receive data from Serial Port

RXD :           JNB RI,$

                     CLR RI

                     MOV A,SBUF

                     RET

LEDOFF:      CJNE A,#30H,NEXT    ;Compare condition ,If it is TRUE then to do next step.

                     MOV P0,#00000000B  ; Will be send value from parallel port P0 to off all LED.

                     ACALL SUB_TXD       ; Go to step in sent data to PC ,If it has command completed.

                     SJMP  INDEX             ; GoTo Main Program

; Function for control LED2-LED7 in display that data sending will be parallel singal. 

LED1:           CJNE A,#31H,NEXT    ; Compare condition ,If it is TRUE then to do next step.

; This will be send value to parallel port number P0.0 which is going to convert value from 0 to 1 that LED1 On and convert 1 to 0 LED off.

                     CPL  P0.0      ; Boolean command = Not using control bit status of ports. 

                     ACALL SUB_TXD       ; Goto step in PC sending data which can know command completed.

                     SJMP  INDEX             ;Goto main program

; Function for control LED2-LED7 in display that data sending will be parallel singal. 

LED2:           CJNE A,#32H,NEXT 

                     CPL  P0.1

                     ACALL SUB_TXD

                     SJMP  INDEX

LED3:           CJNE A,#33H,NEXT

                     CPL  P0.2

                     ACALL SUB_TXD

                     SJMP  INDEX

LED4:           CJNE A,#34H,NEXT

                     CPL  P0.3

                     ACALL SUB_TXD

                     SJMP  INDEX

LED5:           CJNE A,#35H,NEXT

                     CPL  P0.4

                     ACALL SUB_TXD

                     SJMP  INDEX

LED6:           CJNE A,#36H,NEXT

                     CPL  P0.5

                     ACALL SUB_TXD

                     SJMP  INDEX

LED7:           CJNE A,#37H,NEXT

                     CPL  P0.6

                     ACALL SUB_TXD

                     SJMP  INDEX

NEXT:           RET  

; Function data sending to Serial Port for talk to PC program get command completed

TXD :           MOV SBUF,#43

                     JNB TI,$

                     CLR TI

                     RET

                     END 

                

     I would like to talk with you in function or command which can write more method .For this project should be not the best progrmming .
Next step ,you are take the program which has wrote complete to burn in microcontroller .
But in PC program part which write in Visual Basic ,I 'm going to talk in next chapter that you can Click Below Link .....

Visual Basic Interface Microcontroller 8051 by Serial Port 

 

  Benefit for you from this article
   1) Understand basic in 8051 microcontroller to control hardware
   2) Know commands in programming with microcontroller
   3) You can apply this knowledge to control electric devices or control other device.

   Document Referrent

   1. 8051 Tutorial Serial Communication

   2. http://www.smartdata.com.au/8051/serial.txt 

 



Copyright (c) 2000 thaiio.com all rights reserved.  Contact webmaster :webmaster@thaiio.com