Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/29/04 09:54
Read: times


 
#69460 - Why it does not work?
Hi friends
I am trying to connect VB frontend panel with uC P89C51RD2.with the following program for my

project.


In VB FrontEnd Panel, after selecting Port COM 1, Connect, When I click on LED 1, I get Return=1

instead of "C" from the uC. The LED which is connected to the p2.0 is also not respoding.

Where is the catch?

VB FRONTEND

General Declarations
Dim valLED1 as boolean

Private Sub Form_Load()
with Combo1
.AddItem "Com 1"
.AddItem "Com 2"
end with
Text1.text= "9600,n,8,1"
End Sub

'************************

Private Sub Command2_Click()
On Error GoTo ErrLabel
MSComm1.Settings=Text1.text 'setting Baud Rate,Parity,Data bit. stop bit (9600,n,8,1)
MSComm1.CommPort=Combo1.ListIndex + 1 'Selecting COM Port
MSComm1.RThreshold = 1 ' Event-Driven
MSComm1.PortOpen = True ' opening the selected port for communication
MSComm1.InputLen = 0 ' Buffer MSComm
Exit Sub

ErrLabel:
If Err.Number=8002 then
MsgBox "Select Com port"
if end
End Sub

'********************

Private Sub Command1_Click()
MSComm1.Output = "1" ' 1 Ascii = 31(Hex) for LED1
valLED1 = not valLED1 ' this will set the value of valLED1 to True or False
End Sub


'***********************

Private Sub MSComm1_OnComm()
Select case MSComm1.CommEvent 'this will work if there is any event happen on com

port
Case ComEvReceive 'if data received from com port then it wil further

proceeds
Dim Buffer as Variant 'declare a variable to store value received from ComPort
Buffer = MSComm1.Input ' retrieving and storing the value from Serial port
Label2.Caption = "Return = " & Buffer
On Error GoTo ErrLabel

If Buffer = "C" Then ' if C is received from MicroController through serial

port
If valLED1 = True Then
Shape1.FillColor = &HFF& 'changing the color of shape
Else
Shape1.FillColor = &HFFFFFF
End If
End If
End Select
ErrLabel:
Exit Sub
End Sub






******************************************************************************************


Microcontroller program for this interface


ORG 0000H


MOV IE,#00000000B
MOV TMOD,#00100000B
MOV TL1,#0FDH
MOV TH1,#0FDH

MOV SCON,#01010000B
SETB TR1

MOV P2,#00000000B


INDEX:




ACALL RXD
ACALL LED1




SJMP INDEX

RXD:
JNB RI,$
MOV A,SBUF
CLR RI
RET

LED1: CJNE A,#31H,NEXT
CPL P2.0
ACALL TXD
SJMP INDEX

NEXT: RET

TXD: MOV SBUF,#43H
JNB TI,$
CLR TI
RET
END


HARDWARE: P89C51RD2 DEVELOPMENT >SERIAL PORT CONNECTED TO PC SERIAL COM PORT1,P2.0 IS CONNECTED

TO LED



Thanks

rashu


List of 8 messages in thread
TopicAuthorDate
Why it does not work?            01/01/70 00:00      
   Which bit doesnt work?            01/01/70 00:00      
      RE: Which bit doesnt work?            01/01/70 00:00      
      RE: Which bit doesnt work?            01/01/70 00:00      
         RE: Which bit doesnt work?            01/01/70 00:00      
   RE: Why it does not work?            01/01/70 00:00      
      RE: Why it does not work?            01/01/70 00:00      
   RE: Why it does not work?            01/01/70 00:00      

Back to Subject List