Serin vs Serin2


Closed Thread
Results 1 to 13 of 13

Thread: Serin vs Serin2

  1. #1
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697

    Default Serin vs Serin2

    Hi, which is the fastest to use, Serin or Serin2? This project needs speed rather than functionality so im wondering if its worth using serin this time

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


    Did you find this post helpful? Yes | No

    Default

    I do not think there is much of a speed difference between the two.
    Dave
    Always wear safety glasses while programming.

  3. #3


    Did you find this post helpful? Yes | No

    Default DEBUG probably fastest

    The handbook says DEBUG is the smallest and fastest serial I/O command.

    Why not try that?

    HTH
    Brian

  4. #4
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    These are software UARTS using the bit-banging technique.
    The speed is the same because the speed is tied to the baud rate
    you receive the data.

    Best regards,

    Luciano

  5. #5
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    ahh. that makes sense. im using 9600N at the moment. how do i know how high i can go? are there chip specific restrictions?

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


    Did you find this post helpful? Yes | No

    Default

    19200 according to the manual is the top end for SERIN/OUT2. You will need an OSC faster than 4MHz though.

    Look at appendix A
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    oh. do you know the fastest for a chip using 4MHz?

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


    Did you find this post helpful? Yes | No

    Default

    At 4MHz the recommended is less than 9600. 9600 will work at 4MHz if all is stable.

    There is some debate, but I do not like the internal OSC for serial, I use a crystal resonator (the ones with three pins, built in caps) seem to be very stable.
    Dave
    Always wear safety glasses while programming.

  9. #9
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    ahh, i cant go any higher then. i use an external oscillator anyway because thats the way i was shown how to do it. everything seems to be working fine now. i had a bug that looked like the serin command wasnt running fast enough but i turned out to be the wait() part.

    the way ive solved it has created another question. the chips must wait for 250 and their own unique ID before doing something. that bit works fine but i want to be able to send a command that resets their ID no matter what it is.

    the code im using now is
    serin2 porta.2,16468,2000,nocmd,[wait(250,address),cmd,val]

    can i tell it to do something if it gets 251 and anything *aswell*? if not then i have a backup plan but i would rather do it that way

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Master View Post
    ahh,

    the code im using now is
    serin2 porta.2,16468,2000,nocmd,[wait(250,address),cmd,val]

    can i tell it to do something if it gets 251 and anything *aswell*? if not then i have a backup plan but i would rather do it that way
    If I understand what you want the answer is yes. After the TIMEOUT for the 250 ends you could have it WAIT for 251.
    Code:
    serin2 porta.2,16468,2000,nocmd,[wait(250,address),cmd,val]
    
    serin2 porta.2,16468,2000,nocmd,[wait(251,?????),cmd,val]
    
    serin2 porta.2,16468,2000,nocmd,[wait(252,?X?X?X),cmd,val]
    Something like that
    But this will eat up speed. Maybe decrease the TIMEOUT?
    Dave
    Always wear safety glasses while programming.

  11. #11
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    hmm, i see what thats doing. the timeout is designed to turn the outputs off if there is no data for 2 secs. the serin really does need to wait for 250,address all the time. just waiting for 250 then using an if-then statement to check the address takes enough time to cause problems.

    i suppose the only way to do it is to send a long string from the PC that includes 250 and every address that i might use (about 1 to 40 should do)

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


    Did you find this post helpful? Yes | No

    Default

    Yes, the timeout will let the program move on if the wait character is not seem. With out the time out, the program could "wait" forever.

    Depending on what you are doing you could decrease the timeout and check often, or use interrupts.

    Or to maybe speed things up-- wait for "X" and write "address" value to a VAR(doing that already).

    Then have some if / thens / else deciding what to do. This way the serial transmissions are short.
    Kind of like you said but the long string is not needed.

    Sorry if I am confusing things
    Dave
    Always wear safety glasses while programming.

  13. #13
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    that idea about putting the address into a variable and using if-then is how i had it in the first place. the trouble i had is that it would fire when the string gets sent out and try to read the first bunch of bytes. if the address didnt match it would return to serin but by that time the rest of the data has already passed.

    there is only 1 string that gets sent out of the PC but that string has the values for all the chips in it

Similar Threads

  1. Serin to Serin2 ??
    By Gixxer in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th January 2008, 03:56
  2. serin and serin2??? need to understand
    By tkly36 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th April 2006, 05:13
  3. Serin / Serin2 / Debugin Differences
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 19th January 2006, 06:32
  4. SERIN SERIN2 Timeout
    By markedwards in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd June 2005, 18:59
  5. serin and serin2
    By rastan in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 3rd January 2005, 13:10

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