Serin to Vb


Closed Thread
Results 1 to 10 of 10

Thread: Serin to Vb

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Posts
    7

    Default Serin to Vb

    Hi,

    I am testing the serin function with a vb program that I have written.
    When I send 123456789 for example I then only get back 13579 and I am losing 2468 all the even nubers? I am using the pic16f84a and the code is like this

    include "16f84a.inc"


    B0 var Byte

    Srt:Pause 1000
    serout portb.7,N2400,["Hello 123",13,10]
    goto wait1

    wait1: Serin portb.6,N2400,B0

    loop: Serout portb.7,N2400,[B0]
    Goto wait1

    Can any one help
    Please !

    Thanks

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by Johansch View Post
    When I send 123456789 for example I then only get back 13579 and I am losing 2468 all the even nubers?
    Probably because, when your program receives "1", it sends out "1", but at the same time, it can't receive "2" because it's busy sending "1". Then it's done sending "1", "2" has already past by but "3" gets received. Then "3" gets sent, but now "4" is on the way. But "4" gets missed because "3" is being sent out.

    Try 'pacing' your sending program. Send the characters with a bit of a delay.
    Or receive a bunch of characters at a time using the STR instead of a single byte at a time.

  3. #3
    Join Date
    Jun 2007
    Posts
    7

    Default

    Hi skimask,

    Thanks for your replay!
    Ok I have tried both timing and STR function, but no luck all I want to do is to loop the data back that I have send to the pic. I am new to micro programming, so maybe I am not placing the timing in the right place?
    Do you maybe have a example for me?

    Thanks

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Sounds like a problem in the VB code.

    How do you have it setup?
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373

    Default

    B0 var Byte

    Srt:Pause 1000
    serout portb.7,N2400,["Hello 123",13,10]
    goto wait1

    wait1: Serin portb.6,N2400,B0

    loop: Serout portb.7,N2400,[B0]
    Goto wait1

    Can any one help
    Please !

    Create an array like
    B var byte[16]
    array_count var byte
    Then use serin with a time out. I don't have the book so you need to do a little tweaking.

    Receive:
    array_count = 0
    get_byte:
    Serin portb.6,N2400,500,send_char,B[array_count] ;wait for char for 500 ms, then send received chars.
    send_char:
    if array_count = 0 then get_byte
    Serout...blah blah
    goto Receive

    Ron

  6. #6
    Join Date
    Jun 2007
    Posts
    7

    Default

    I don't think vb is the problem. I have treid 3 different serial vb examples and all off them is the same, but here is the code

    Private Sub Command2_Click()
    MSComm1.Output = Text3.Text + vbCr
    End Sub


    Private Sub Form_Load()
    MSComm1.PortOpen = True

    End Sub


    Private Sub Timer1_Timer()
    Dim stemp As String

    MSComm1.InputLen = 0
    If MSComm1.InBufferCount Then
    With frmMain
    stemp = stemp + MSComm1.Input

    List1.AddItem stemp

    Text1.Text = stemp & vbCrLf
    Text2.Text = stemp

    End With
    End If

    End Sub

    Johan

  7. #7
    skimask's Avatar
    skimask Guest

    Default

    Well, what happens if you just forget about vB for awhile, and just use Hyperterminal (or whatever)...
    In other words, can you make it work the other way around, the PIC echo's everything the PC sends to it....

Similar Threads

  1. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 22:03
  2. serin question?
    By sachymo in forum General
    Replies: 5
    Last Post: - 27th July 2008, 10:04
  3. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02
  4. USB, PIC18F2550 and VB
    By Tissy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th November 2005, 18:37
  5. SerIn and SerOut
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 21st July 2004, 15:54

Members who have read this thread : 0

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