Shop OBEX P1 Docs P2 Docs Learn Events
Bit blasting (pulseout) RS-232 serial data.... — Parallax Forums

Bit blasting (pulseout) RS-232 serial data....

StampUSRStampUSR Posts: 48
edited 2005-09-08 01:40 in BASIC Stamp
Has anyone sent RS-232 data using pulseout/bit-blastin? If so is there any example code available to get me started?

Can't use SEROUT as it doesn't support the comm parameters I must use.

Thanks!

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-09-07 19:19
    Hello,

    ·· This might be a job more suited to an SX chip.· You could build a custom serial interface.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • StampUSRStampUSR Posts: 48
    edited 2005-09-07 19:29
    Chris,

    The SX by itself won't work for me, not enough code space. I am trying to add a feature to an existing app. on a Stamp.

    Thanks!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-09-07 19:36
    Correct...That's what I was suggesting...Use the SX to build a customer serial interface...to the Stamp Module.· Not as a stand-alone device.· Quite often features that we want to add to the Stamp Modules can be added using a co-processor, usually the SX.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • StampUSRStampUSR Posts: 48
    edited 2005-09-07 19:50
    "Correct...That's what I was suggesting...Use the SX to build a customer serial interface...to the Stamp Module. Not as a stand-alone device. Quite often features that we want to add to the Stamp Modules can be added using a co-processor, usually the SX."

    The hardware is done and 'out in the world.' If possible I want to add another feature as a software only upgrade to it. A co-processor isn't going to get that done for me. Even if I did integrate a co-processor SX I'd still have to write the bit blasting routines for it since SX/B also doesn't support the comm parameter I am looking to send. Since that is the case I'd rather just do the bit blasing in the Stamp if it is possible and have it work within my existing hardware.

    Thanks!
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-09-07 20:17
    I don't think it is possible. "Bit-Blasting" at 2000 Basic Instructions Per Second will probably not meet the needs of RS-232 timing. The RS-232 spec is 'loose' (allowing 10% inaccuracies in the baud clock) but it's not that loose.

    Others have built PIC co-processors to do this, and I believe there's even an 8-pin AVR solution.

    What are the comm parameters you 'must' use?

    If you have an installed base, what comm parameters are they using now?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-09-07 20:32
    StampUSR -

    I now have to ask the obvious question, that no one has yet bothered to ask. What communications parameter are you hoping to use that's so elusive? It's got to be 9-bit word length or something real odd.

    Regards,

    Bruce Bates

    Post Edited (Bruce Bates) : 9/7/2005 8:47:15 PM GMT
  • StampUSRStampUSR Posts: 48
    edited 2005-09-07 21:28
    ""I don't think it is possible. "Bit-Blasting" at 2000 Basic Instructions Per Second will probably not meet the needs of RS-232 timing. The RS-232 spec is 'loose' (allowing 10% inaccuracies in the baud clock) but it's not that loose."

    I'm running the BS2PX so it is closer to 19k instructions per second. Don't know if that is fast enough either though, that is why I asked. Before sending it would calculate out all the pulses ahead of time (and store that) then just run a loop to send the pulses either reading from scratchpad or from EEPROM.

    "Others have built PIC co-processors to do this, and I believe there's even an 8-pin AVR solution."

    That would be more difficult then just moving to a PIC for everything.

    "If you have an installed base, what comm parameters are they using now?"

    Whatever they need to use as long as it is either 8N1 or 7E1. The parameters/baud rate are configurable by the user as needed to fit the devices they are using it with. That is why a coprocessor makes things more difficult... it isn't one set parameter all the time. It needs to be adjustable based on how they configure it at run time.

    Some devices are hard coded to other parameters then 8N1, 7E1.... I'm trying to be able to support working with them.


    Thanks.

    Post Edited (StampUSR) : 9/7/2005 9:32:33 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-07 21:35
    I'm with Chris on this one: use an SX chip to build a buffer/translater between the BASIC Stamp and the other system. Al Williams' book shows how to do this -- you'd just have to modify the code to match your odd serial requirement.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • StampUSRStampUSR Posts: 48
    edited 2005-09-07 21:41
    "- you'd just have to modify the code to match your odd serial requirement."

    Again, that doesn't solve the problem. The parameters I'm using aren't fixed at compile time. They are configurable by the user for whatever they need it to be with regards to baud rate and selectable between 8N1 and 7E1.... and I'm hoping to extend that.

    So I guess the obvious answer to my question is that there is no example code for bit blasting RS232 with a Stamp.

    Thanks.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-07 21:43
    Reading tokens from the EEPROM simply slows things down too much. Why could you not code the various routines into the SX and call them as required? If you didn't have to talk to both devices at once, you could actually do the whole thing in high-level SX/B (well you might have to code the 7E1 yourself).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • StampUSRStampUSR Posts: 48
    edited 2005-09-07 21:55
    "well you might have to code the 7E1 yourself)."

    Sorry, meant 7O1... the two that were supported by the Stamp already. I wanted to add support for parity with 8 data bits.

    "Why could you not code the various routines into the SX and call them as required?"

    I could probably send commands to the SX from the Stamp to configure it for the output it would use. But then I could just use an actual UART and get the same thing without having to code another processor.

    But either way is a new hardware design. I was trying to keep this in software if possible.

    Thanks.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-09-07 23:14
    StampUSR -

    What you're attempting is called "autobauding" and I can't think of any way to do it without an external device using a Stamp. Using an external device (an 8 pole dip switch and shift register) you can do it with 2 Stamp pins.

    Microchip has applications notes for doing "autobauding" in assembler with their PIC mirocontrollers, and I have to believe with the virtual UART available on the Ubicom SX chips that someone has done it there as well, although it would have to be done in SX assembler I suspect. The SX/B complier supports both Basic and assembler so that's still a go from that angle.

    Regards,

    Bruce Bates
  • StampUSRStampUSR Posts: 48
    edited 2005-09-08 01:09
    "What you're attempting is called "autobauding" and I can't think of any way to do it without an external device using a Stamp. Using an external device (an 8 pole dip switch and shift register) you can do it with 2 Stamp pins."

    No, I am not talking about autobauding. Like I have said they are configurable by the user.

    On bootup over an RS232 connection the stamp gives the user an option to enter a configuration menu (at a fixed known baud/parameter) with a timeout of a few seconds if no input/wrong input is received from the user. If the user enters the menu they have the option of setting the baud rate and comm port parameters among other things. When they exit the setup menu (or the initial timeout expires) the stamp then switches to whatever baud/parameters it is configured for and it does its normal run time actions.

    This is done/tested/working.

    I was looking for the bit-blasting to be able to offer more serial port options then just 7O1, 8N1 support.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-09-08 01:40
    StampUSR -

    Look at using a MAX3100 UART as your serial input device. The parameters can be set in that chip to nearly anything you want. The Stamp uses SHIFTIN to access the data. The MAX3100 also has a built in FIFO buffer which may be helpful at higher baud rates.

    Regards,

    Bruce Bates
Sign In or Register to comment.