Shop OBEX P1 Docs P2 Docs Learn Events
Serin & Serout with handshaking — Parallax Forums

Serin & Serout with handshaking

alnajjar1alnajjar1 Posts: 110
edited 2011-02-24 23:13 in BASIC Stamp
I am trying to get the BS2 to control a solid state audio player (QuickWave). I attached the pdf for how to interface serially to the QuickWave in case you are interested. I tested the device using my PC with HyperTerminal and it works.

I cannot get the BS2 to talk to the device at all. I have P0 connected to Pin2 (RX) and P1 to pin3(TX) and grnd to pin5.The cable works and I get continuity all the way through. I wrote a simple routine to test and I am sure I am doing something wrong with the code which is also attached.

Any help would be most appreciated...

AlQuikwave EM3028B.pdfBS2 to QuickWave.bs2

Comments

  • Spiral_72Spiral_72 Posts: 791
    edited 2011-02-24 08:01
    I'm working with a similar project now. Bear in mind I'm learning:

    Does your terminal program see anything from the BS2??

    I know that the following code works 100% right out of my code for a BS2px at 9600 baud, 8 bit, No parity, INVERTED, using P16 (The programming pin)

    Waits for a "SVA" token from the host, then receives a n-digit number, truncated by a non-numeric byte:
    SERIN 16,16780,[WAIT("SVA"),DEC SVA]

    Sends the "SVA" string to the host
    SEROUT 16,16780,["SVA OK"]

    Sends a single byte of data to the host
    SEROUT 16,16780,[inches]

    Your port settings will be different though. Either 16468 (which you have) or 84
  • Spiral_72Spiral_72 Posts: 791
    edited 2011-02-24 08:07
    From your PDF:

    The serial interface consists of a female DB9 serial port supporting
    both RS-232 (default setting) and RS-485. To support RS-485, you
    must move the internal jumper J2 to the “485” setting.

    Do you have your jumper set for RS232???



    On the DB9 connector, three pins are used for RS-232: pin 2 for
    RX, pin 3 for TX, pin 5 for ground. Two pins on the same connector
    are used for RS-485: pin 1 for negative, pin 9 for positive.

    I assume it's wired correctly? From your description it is.


    The hardware protocol is fixed at 9600 baud, eight data bits, no
    parity and one stop bit (9600, 8N1). Other protocols may be supported
    by special request.

    This is how mine is setup, except the TX/RX pins are different.
  • Spiral_72Spiral_72 Posts: 791
    edited 2011-02-24 08:20
    I would NOT try to use the programming port like I did. The BS2px (and yours too I think) will echo all data it receives back to the host.

    My guess is the jumper, the wiring, or the 16468 should be an 84. In my limited experience, your code looks good.
  • alnajjar1alnajjar1 Posts: 110
    edited 2011-02-24 09:40
    It seems you know much more that you say about serial.

    Well:

    1. the jumper is set to RS232
    2. I am using 16468 but will try 84 this evening.
    3. the cable is straightforward and connected as described.

    I am also concerned but timing issues since it is mentioned in the Parallax Syntax Ref.

    thanks for your help and will report back tonight on progress...

    Al
  • Desy2820Desy2820 Posts: 138
    edited 2011-02-24 18:59
    I'm not an expert, nor do I have any experience with this player. Please take the following suggestions with a large grain of salt.

    Make sure that the Stamp's TX is connected to the player's RX. The Stamp's RX connects to the player's TX. I know the manual refers to a straight-thru cable, but this only applies if using the programming port or a PC. To connect directly to a Stamp pin, you need to cross pins 2 and 3 so that a transmit pin connects to a receive pin. A null-modem adapter may quickly solve the problem.

    To help protect the Stamp, you may also want to include a 220 ohm in-line resistor at each pin. These will limit current flow in the event of a wiring or programming error, preventing excessive current. If you're using a Homework Board (HWB), these resistors are already in place for you. Stamp--->Resistor--->player.

    I'm also not clear if the player will work with logic-level RS232. "Standard" RS232 requires negative and positive voltages---some devices will work fine with 0-5 volts, some won't---YMMV. You may need something like a MAX232 line driver between the stamp and player to boost the voltages up to a true RS232 signal level.

    FYI, the Stamp's programming port borrows voltage from the PC for its negative voltage, so you can't get true RS232 from there either.

    If you continue to have difficulty, you may want to call the distributor/dealer and clarify if the player will work at logic RS232 or if it requires true RS232 signal levels.

    I hope this helped--somewhat.
  • skylightskylight Posts: 1,915
    edited 2011-02-24 23:13
    @ allnajar1

    ' test serial communication with QuickWave audio player
    ' to play file 001: send "A", then followed by Binary, you should receive "a", then send "F" (will get "f" back),
    ' then send "1" (get "1" back), then send "0" (get "0" back), then send "0" and finally get another "1" back.
    ' this is weird "handshaking"! the sequence above actually works in HyperTerm.

    In your BS2 program you are only sending: A F 0 0 1 above says you should be sending A F 1 0 0 (1 ?) , you have missed the first 1, perhaps this is the problem?
Sign In or Register to comment.