Shop OBEX P1 Docs P2 Docs Learn Events
Help with Serin — Parallax Forums

Help with Serin

DiablodeMorteDiablodeMorte Posts: 238
edited 2008-03-10 16:40 in BASIC Stamp
I need some help with the serin command. I'm trying to send 3 variables to a BS2 at 19200 Baud(Yes a little high for BS2). For some reason I am unable to get the two variables. I seem to be able to get the first variable, and maybe the second, but never the third. For the third I keep getting the first.

Anyhelp?

Here's my code:
SERIN 16, Baud, 200, No_Data, [noparse][[/noparse]SKIP 1,DEC2 command, DEC2 param, DEC2 param2]



and here's the string of data I'm sending the BS2:
@13,3,3$


and here's what I get back from the stamp:
#D0003|0013$


and here's the code from the stamp to send the above data back
SEROUT 16,Baud,[noparse][[/noparse]"#D",DEC4 param,"|",DEC4 param2,"$"]

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Current Projects:
Robot Control Via Skype API - Dev Stage(50% Complete) - Total(25%)
Robot Localization Via Xbee's - Research Stage
IR Tracking with Propeller - Research Stage

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-03-04 05:22
    DiablodeMorte -

    Not only is it "a little high for a BS-2", but the SERIN formatters are killing you. Reduce the baud rate, remove the formatters, or use a faster Stamp. There are no other choices that will produce the results you're seeking.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Programming can't be all that difficult, it's nothing but 1's and 0's
  • DiablodeMorteDiablodeMorte Posts: 238
    edited 2008-03-04 12:44
    @Bates·- Well thank god I just found my BS2p



    @everybody: Will a BS2p be fast enough or will I still need to remove formatters etc?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Current Projects:
    Robot Control Via Skype API - Dev Stage(50% Complete) - Total(25%)
    Robot Localization Via Xbee's - Research Stage
    IR Tracking with Propeller - Research Stage
  • DiablodeMorteDiablodeMorte Posts: 238
    edited 2008-03-10 02:59
    Update:

    I've replaced the BS2 with a BS2p and the results havn't been much better!

    Here's my Serin Code:
    SERIN 16, Baud, 200, Main, [noparse][[/noparse]WAIT("@"),DEC command, DEC param, DEC param2]
    



    I've changed it alittle from the original code and I hope it's better.
    I've also changed what my PC sends out, Now it's along the lines of:
    @13 3 5$
    



    I'm sending this data about every 50ms and I'm not getting a very smooth run, I only seem to get reliable data every so often. The Stamp seems to want to put the command(13) into one of the param variables, I don't have any idea why. Any suggestions?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Current Projects:
    Robot Control Via Skype API - Dev Stage(50% Complete) - Total(25%)
    Robot Localization Via Xbee's - Research Stage
    IR Tracking with Propeller - Research Stage
  • FranklinFranklin Posts: 4,747
    edited 2008-03-10 03:20
    SERIN must be waiting for the data before the data is sent or all bets are off. There is no buffer on the stamp. Sending and waiting for the @ is a good idea though. Try reducing the baud rate and see if the data becomes more stable.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-03-10 16:40
    Hi DiablodeMorte, I'm not sure you will be able to do what you want at 19200 even with the BS2px. Sometimes reducing the baud actually makes things run faster because of its reliability.

    Here's a·couple of things that you could try and will help anytime you are writing your own serial routines.

    I don't know which program you are using at the PC but if you have control of the strings you are sending it helps sometimes to send a line feed or carriage return after each data item, so your transmitted data might look like :-· "@"· LF "13"·LF "3" LF "5$" LF.

    If you are using the wait instruction at rates higher than 4800 it might help to place a pause in the string just after the header

    :-· "@"·LF· pause for 10 mS· "13"·LF "3" LF "5$" LF.

    Unfortunately all these suggestions slow things down a tad.

    things can get even more complex and difficult to handle when you are sending and receiving, get it to where it works at 4800 then try to see if it will run at a higher rate.

    Jeff T.
Sign In or Register to comment.