character return from PIC to VB


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2008
    Location
    devon
    Posts
    15

    Default character return from PIC to VB

    Hi, I'm testing the serial communication between a 16F876 and a VB6 application. I read HSERIN then send it straight back out as HSEROUT. But I don't always receive the character I sent. eg:
    Sent to PIC Recieved back to VB
    1 ±
    2 ²
    3 3
    4 '
    5 5
    6 6

    I'm obviously not using the correct code table but I'm not sure what character set to use. Can anyone help?
    Ta

  2. #2
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86

    Default

    can you post your code?

  3. #3
    Join Date
    Jul 2008
    Location
    devon
    Posts
    15

    Default

    Here is the PIC code. I am sending the data as a string from a TextBox in Visual Basic. By the way, the "END" is returned as "ÅND" if this gives any further clues!

    @ DEVICE HS_OSC,LVP_OFF,WDT_OFF,PROTECT_OFF,BOD_OFF,PWRT_OF F
    'declare variables
    define OSC 20
    DEFINE HSER_BAUD 19200 'serial
    DEFINE HSER_RCSTA 90h 'serial
    DEFINE HSER_TXSTA 24h 'serial
    DEFINE HSER_CLROERR 1 ' automatic clear overrun error
    DEFINE HSER_EVEN 1
    DEFINE HSER_BITS 7

    trisb = %11000000 ' set port b 0-5 o/ps 6&7 i/ps
    RCIF VAR PIR1.5
    SERIALDATA VAR BYTE
    portb.0 = 0
    portb.1 = 0
    portb.2 = 0
    portb.3 = 0

    PAUSE 100

    MAIN:
    portb.0 = 0
    IF RCIF THEN
    pause 100
    sound portb.0,[60,10]
    HSERIN [SERIALDATA] 'RCIF is reset by reading HSERIN
    HSEROUT [SERIALDATA,"E","N","D"]
    ENDIF
    GOTO MAIN

    end

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802

    Default

    Have you test the code with a simple program like terminal and give the numbers by hand and slowly ?

    What about you VB code?

    Ioannis

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358

    Default

    Your Crystal, Trimming Capacitors or a hundred other things could be affecting the Oscillator frequency. Looks like it's slightly off for your fast baud rate.

    Drop your communications down to 2400 and work up from there. You'll discover there will be a point where unacceptable errors start creeping in.

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818

    Default

    See what this does:
    Code:
    HSEROUT[IDEC,SERIALDATA,"END"10,13]
    It should display Decimal digits, no modifyer should display ASCII, and HEX . . .Have not tried it, modifyer might make a mess out of the string "END"

    Actually there should be a comma after END... - Melanie

    Code:
    HSEROUT[IDEC,SERIALDATA,"END",10,13]
    Last edited by Archangel; - 29th April 2009 at 10:26.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    Jul 2008
    Location
    devon
    Posts
    15

    Default

    Thanks for the quick replies.
    After trying the PBP Serial Comm I realised I had not configured the Port correctly in VB ie Was 19200,N,8,1 should be 19200,E,7,1 as in the PBP code config.
    Simple mistake made by a now wiser person!

Similar Threads

  1. Serial VB 2005 pic 16f877a problems
    By Snap in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 8th July 2013, 00:52
  2. Comm example: Pic to Pic
    By Chadhammer in forum Code Examples
    Replies: 4
    Last Post: - 14th November 2006, 23:26
  3. VB sending serial data to PIC
    By Tissy in forum Serial
    Replies: 7
    Last Post: - 8th March 2006, 18:31
  4. USB, PIC18F2550 and VB
    By Tissy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th November 2005, 18:37
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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