Shop OBEX P1 Docs P2 Docs Learn Events
BS2 serial filter / speed question — Parallax Forums

BS2 serial filter / speed question

VonSzarvasVonSzarvas Posts: 3,343
edited 2006-11-29 21:30 in BASIC Stamp
Hello, I am hoping for some advice.

I would like to solve a hardware problem I have, and can see how to do it logically, but would like to ask if technically the BS2 would be up for the job!

I have 2x 57600 (baud) devices. One streams out some bytes, one receives. I would like to put the stamp in between them and filter the bytes.

More specifically:

Device 1: Only TX, no handshaking etc. Sends a 30 byte string once every second, ending in CR LF.

Device 2: Only RX, no handshaking etc. Needs to be sent bytes 10-16 from each 30 byte string (plus the CR LF), as it arrives.


1. Can I connect different devices to the TX/RX ports on the BS2, without problem (like echo across the devices or whatever...)

2. Would the BS2 be fast enough to cope? If some buffering code is required, any pointers to a sample would be very much appreciated. I have read in some places that 9600 is the max, but then other places suggest more is OK. Maybe for this "simple" task, I can go to 57600 baud.....?

I am hoping to manage this with just the BS2-1C module, rather than adding other components.

Many thanks, Max.

Post Edited (Maxwin) : 11/29/2006 8:57:13 AM GMT

Comments

  • VonSzarvasVonSzarvas Posts: 3,343
    edited 2006-11-29 10:42
    I noticed I should have mentioned the BS2SX-IC module rather than the BS2-IC.

    I add the sample code I was thinking about for the BS2SX-IC...

    iodata VAR BYTE(30)

    DO
    SERIN 0,23, [noparse][[/noparse]STR iodata \30] 'Wait for 30 bytes on Pin 0, then store in array "iodata"
    SEROUT 1,23, [noparse][[/noparse]iodata(10),iodata(11),iodata(12),CR,10] 'output the required bytes on Pin 1

    LOOP


    Would this work???


    // Note, I would re-transmit / SEROUT iodata(10) to iodata(16) in the actual program.

    Post Edited (Maxwin) : 11/29/2006 11:11:40 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-29 15:37
    Maxwin,
    ·
    ·· For something at 57.6Kbps and requiring processing time I would have to say I would recommend using an SX Microcontroller for the job.· You could program it in SX/B to make it easier.·
    ·
    ·· Your example code wouldn’t work for two reasons…First you don’t have 30 bytes to create an array to store the data.· That doesn’t count any other variables you would need.· On a BS2p you could use the SPSTR command to stuff the incoming data into Scratch Pad RAM where you would have room.· But 57.6Kbps is just too fast for the BASIC Stamp to handle a 30 byte packet.· I will follow-up and see if the BS2p can do it using SPSTR, but I know the SX can do it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • VonSzarvasVonSzarvas Posts: 3,343
    edited 2006-11-29 20:53
    Thank you for the advice Chris.

    I have downloaded the SX documentation, and indeed it seems to be the way forward.

    I will order a Tech Kit in the morning and see what I can do!

    Hopefully there will be a simple circuit showing how to connect the rs232 socket to the SX28. But if I get stuck, I will check the SX forum.

    I can see a huge benefit also in price - so I am very glad I asked the original question here!

    Thanks again, Max.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-29 21:10
    Max,
    ·
    ·· If the devices are TTL Serial (non-inverted) you can connect them directly to any I/O pins you wish to use for serial data.· Typically the RA port is used for serial I/O.· If the devices are RS-232 levels then you would need line drivers, such as a MAX232 to shift the levels.· There is sample source code for the SX for serial transmission.· You can also use SX/B to buffer the string and send out the parts of it you want.· If you get to that point please post a follow-up in the SX Forum.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-29 21:30
    Max,
    ·
    ·· By the way, I confirmed it….57.6Kbps isn’t possible for packets of data…I think you can send single bytes but not 30, even SPSTR.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.