Shop OBEX P1 Docs P2 Docs Learn Events
Critical SERIN show stopper in BS2 Rev G — Parallax Forums

Critical SERIN show stopper in BS2 Rev G

KwoodaKwooda Posts: 1
edited 2013-01-20 09:56 in BASIC Stamp
I have tried all day long to get SERIN to work on a BS2 Rev G. I have the following command:

SERIN 16, 84, [HEX2 command, HEX2 thrs, HEX2 tmins] ' 9600 bps 8-1-N non-inverted on DEBUG port

If I type the input manually, it works fine, because I cannot type at 9600 bps. But if I connect to a serial port and programmatically send a byte sequence, say "0A0130", only the command byte 0A is received and it sits waiting for the next two bytes. At 9600 bps, in fact, I have to insert a 40 ms delay between each byte on the sending end to get it to work. Unfortunately, where my Stamp is going to be used does not have any way for me to add such a delay. I have even tried 1200 bps with the same results, although it only needed 7ms between bytes, but it may as well be 700ms, as I need the Stamp to operate at full 9600 bps throughput.

Is there any way around this? This is a complete show stopper for me.

Comments

  • SapphireSapphire Posts: 496
    edited 2013-01-19 23:54
    Kwooda,

    Can you send your data as binary instead of hex representation of ASCII text? Reason being, the BS2 is slow at processing incomming serial data when there are formatters in the SERIN command (i.e. HEX2). If you eliminate them like this:
    SERIN 16, 84, [command, thrs, tmins]          ' 9600 bps 8-1-N non-inverted on DEBUG port
    

    then the processing time is reduced and you might be able to receive the data. Of course, you have to change your sending program to match this and send only one byte per variable.
  • stamptrolstamptrol Posts: 1,731
    edited 2013-01-20 05:26
    You may be able to get the system to work by fiddling with data structure and delays. But, if you need reliable data at 9600, my experience suggests that you move up to the BS2sx or the BS2px modules as they are much faster and can work well at 9600. As a bonus, you get much larger program memory and access to scratchpad memory as well.

    Having said that, I am a bit surprised that it wouldn't work at 1200, since the truck scales I work with operate at 4800 with the BS2 Stamp and data strings almost twice as long as your example.

    Cheers,
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2013-01-20 08:27
    Hi, the following maybe a faster way to receive the 6 bytes, they will need parsing after reception. I used 16468 for the baud connected to the programming port.
    values VAR Byte(6)
    
    SERIN 16,16468,[STR values\6]
    

    Jeff T.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-01-20 09:56
    As you've noticed, the BS2 is marginal at 9600 Baud and completely unreliable when using most of the input formatters. Unsoundcode's suggestion is sometimes a way to get by, but it's still marginal. As stamptrol suggested, often the only way to get reliable performance at 9600 Baud is to go to one of the higher speed Stamps like the BS2sx or BS2px. You can also use an external buffer like this one which allows for 32 bytes of buffering. It's difficult to use the input formatters with this buffer since you can't tell how much data is in the buffer.
Sign In or Register to comment.