Accurate serin usage?


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2009
    Posts
    29

    Default Accurate serin usage?

    I have a project running with a 12f675 that ive been working on for a while using an rs232 input. My problem is that it isnt totally reliable, close, but not perfect. I have a 4 digit string coming through rs232 and accept this data via the code below...

    Code:
    serin 3,2,digit1
    serin 3,2,digit2
    serin 3,2,digit3
    serin 3,2,digit4
    To make sure that I am getting a value that isnt corrupted, I try to check everthing in a range and go back to main to get more serial data if it doesnt look right with the following code...

    Code:
    check3:
    if digit1 = 48 then goto main
    if digit1 = 46 then goto main
    if digit4 = 46 then goto main
    if digit1 < 46 then goto main
    if digit1 > 57 then goto main
    if digit2 < 46 then goto main
    if digit2 > 57 then goto main
    if digit3 < 46 then goto main
    if digit3 > 57 then goto main
    if digit4 < 46 then goto main
    if digit4 > 57 then goto main
    if digit1 = 47 then goto main
    if digit2 = 47 then goto main
    if digit3 = 47 then goto main
    if digit4 = 47 then goto main
    return
    Often, the display keeps old data that is behind the rs232 stream by a few seconds, im sure because it isnt seeing what it likes and continues to loop thought the serin's until it gets something that it see's as appropriate. Is there a better way to do this?

    Thanks

  2. #2
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default

    Is the decimal point always in the same place in your data?

    What I do is to trap a known character in a known location in the data stream and then I am able to work out where in the data stream I am. If you are generating the data stream youself then you can include a start character that you trap.

    Steve

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 usage?
    By champion in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 24th January 2007, 00:57
  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. 16F628A Serin timeout and Timer1
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th March 2006, 23:20
  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 : 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