SerIn Looping problem ???


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2008
    Posts
    38

    Default SerIn Looping problem ???

    Hi All,

    I'm trying to find out what happens to the "SerIn" command when no valid data is present on the RS232 line.


    For example:

    Code:
    Loop:
              SerIn pin1,T9600,SerialData     'get serial data from Pin1, 
                                              'store it in variable "SerialData"
    
              SerOut pin2,T9600,[SerialData]  'send the variable to a terminal to
                                              'view the variable value on screen.
    
              GoTo Loop                       'do it forever.

    If i press a key, i see the key appear on the screen.

    But, while no keys are pressed (and the program is still looping), what value does the variable "SerialData" become?
    I expected to see a column of say 0's to run down my screen, or at least the previous value of SerialData, but that doesnt happen.

    It doesn't appear to be 0 and think it might be a null (alt-255) or is it just an idle DC level until data arrives?

    What i'm trying to acheive is a condition that can tell the difference between 'active data' and 'no data'.

    Hope this made sense???
    Marty.

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


    Did you find this post helpful? Yes | No

    Default

    In your code the program is not looping. It is sitting there waiting for data. Once data arrives it will move on. Put a LED blinky after the SERIN and you will see what is going on.

    Now then, I will suggest you use SERIN2. You have more options and when you end up using hardware serial the syntax is the same.

    To see if data is coming in look at the SERIN2 section in the manual. You will find a way to wait for a given amount of time and a given character. If neither is present the code will then continue to the routine of your choosing.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Your program is not looping when there is no Data.

    It is suspended, sitting at SERIN waiting for valid Data to arrive. If Data never arrives, it will be there until the end of time or until you forget to pay your electricity bill (whichever comes first).

    SERIN has the ability to wait suspended like this for a TIMEOUT period, and if no Data arrives within that given period to jump out to a LABEL elsewhere into your program.

    Beat me to the answer Dave... bah... too slow... not enough coffee yet this morning...

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


    Did you find this post helpful? Yes | No

    Default

    Beat me to the answer Dave... bah... too slow... not enough coffee yet this morning...
    Middle of the night for me and to much Mountain Dew
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jul 2008
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Thanx Melanie (ladies first) & Dave, i didn't know that the SerIn behaved like that with lack of data.

    Ok, i'll go fiddle my code to accomodate that, and see what happens ;-)

    Thanx again.

  6. #6
    Join Date
    Jul 2008
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Hi again,

    For a quick test, i tried :

    Code:
    SerIn pin1,T9600,[1000],SerialData
    but nothing happens. (assuming a 1000ms timeout).

    Am i meant to be adding other code to accomodate the elapsed timeout? or does the SerIn just "let go" after 1000mS, and return back to any previous gosubs/code etc?


    Once again, the PBP Manual is "light" with information in most of it's commands, i'd love to see an entire re-write someday.

    Is there an ADVANCED PBP link/pdf i should be looking at these days???

    Regards,
    Marty.

  7. #7
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Loop:
    SerIn pin1,T9600,500 Jumpout,SerialData 'get serial data from Pin1,
    'store it in variable "SerialData"
    Jumpout:

    SerOut pin2,T9600,[SerialData] 'send the variable to a terminal to
    'view the variable value on screen.

    GoTo Loop 'do it forever.
    The added code in red, wait for 500 ms the data, then jump to label JUMPOUT executing the serout command.

    Al.
    All progress began with an idea

  8. #8
    Join Date
    Jul 2008
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Thanx AL, i discovered that just moments ago, and got it to work pretty much the same as you've indicated....

    Marty

Similar Threads

  1. Serin Problem with 12F629/PBP
    By Flyingms in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th March 2009, 14:59
  2. Serin Problem 16f819
    By jjohannson in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd March 2007, 22:50
  3. Serin serout problem
    By lerameur in forum mel PIC BASIC Pro
    Replies: 336
    Last Post: - 6th February 2007, 04:25
  4. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02
  5. serout and serin problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th April 2006, 19:44

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