PDA

View Full Version : i need help please...



gidah
- 2nd October 2006, 05:59
i could not send "A" to my pic16F627 using visual basic 6.please help me..

this is my picbasic pro code:
DEFINE OSC 4
DEFINE HSER_BAUD 1200
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_CLROERR 1

MDATAR1 VAR BYTE
LOOP VAR WORD
LOOP1 VAR WORD

TRISB = %00000010
PORTB = 0

hserout ["ONLINE",13] 'send "ONLINE to vb
MAIN:
hserin 3000,MAIN,[WAIT("A")] 'wait signal "A" from vb

SERVOON:
PORTB.4 = 1
PORTB.5 = 1
PAUSE 1000
PORTB.5 = 0
PAUSE 1000
PORTB.5 = 0
LOOP1 = 100

SERVOON1:
PULSOUT PORTB.0, 100 ' SERVO MOTOR CLOCKWISE
PAUSEUS 19000
LOOP1 = LOOP1 - 1

IF LOOP1 = 0 THEN GOTO SERVOOFF
GOTO SERVOON1

SERVOOFF:
PAUSE 4000
PORTB.5 = 0
PORTB.4 = 1
PAUSE 1000
PORTB.4 = 0
PAUSE 1000
PORTB.5 = 1
LOOP = 100
SERVOOFF1:
PULSOUT PORTB.0, 190
PAUSEus 18100 'SERVO MOTOR A.CLOCKWISE
LOOP = LOOP - 1

IF LOOP = 0 THEN GOTO MAIN
GOTO SERVOOFF1

END


my vb6 code:
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 'reveice "ONLINE"
If Text1.text<>"" Then
MSComm1.Output = "A" 'send signal "A" to pic
else
msgbox"No Data Receive"
End If
End Sub

Private Sub Form_Load()
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If

mister_e
- 2nd October 2006, 06:26
Before i spend my time looking at your code... how do you connect your PIC to your PC?

What happen if you use MicroCode Studio Serial communicator?

a while back i posted a nifty-mini-terminal VB program here....
Download it here (http://www.picbasic.co.uk/forum/attachment.php?attachmentid=303&d=1117969258)

It come from the following thread
http://www.picbasic.co.uk/forum/showthread.php?t=1833

gidah
- 3rd October 2006, 04:53
i used usb to serial converter to connect my pic to my notebook.

mister_e
- 3rd October 2006, 05:52
you need a MAX232 or else inverter between your PIC and you COM port.