PDA

View Full Version : serial connection n vb interface



gidah
- 18th September 2006, 08:24
hello..i using pic16f627 for my project.i not sure how to sent a signal to my pic by using vb6 code..this is my picbasic coding..

DEFINE OSC 4
define HSER_BAUD 1200
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h

MDATAR1 VAR BYTE
MDATAR1 = 1
hserout ["ONLINE",13]
MAIN:
hserin [WAIT("A"), DEC MDATAR1]
PORTB.4 = 1
PORTB.5 = 1
PAUSE 1000
PORTB.5 = 0
PAUSE 1000
PORTB.5 = 1

this is my vb coding:

Private Sub Command1_Click()
Dim str As String

MSComm1.CommPort = 5
MSComm1.Settings = "1200,n,8,1"
MSComm1.InputLen = 0
MSComm1.PortOpen = True
Do
Loop Until MSComm1.InBufferCount >= 6
str = MSComm1.Input
Text1.Text = "receive:" + str
Text2.Text = "sending: A2A"
MSComm1.Output = "A2A"
MSComm1.PortOpen = False
End Sub
Private Sub Form_Load()

If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
End Sub


when i run my vb programming..i can receive the word "ONLINE" on my screen means that the are a connection between pic and my vb.but i can't send signal from vb to pic to on my led..plz help me??...isn't my coding is right..i need help immediately..

mister_e
- 18th September 2006, 14:54
i don't know how much it will help, but in your PIC program, you should add
DEFINE HSER_CLROERR 1

with the other DEFINEs. And at the end of your program, you should add a GOTO somewhere or END

There's few weird thing on the VB side but it may work.

I have few PDF on VB if you want them drop me you e-mail in my PM box.

OR have a look on the Bruce website => http://rentron.com/VisualBasic.htm