i need help please...


Closed Thread
Results 1 to 4 of 4
  1. #1
    gidah's Avatar
    gidah Guest

    Default i need help please...

    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

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    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

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

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    gidah's Avatar
    gidah Guest

    Default

    i used usb to serial converter to connect my pic to my notebook.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    you need a MAX232 or else inverter between your PIC and you COM port.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts