Shop OBEX P1 Docs P2 Docs Learn Events
SEROUT control of Kitsrus K108 I/O module....please help! — Parallax Forums

SEROUT control of Kitsrus K108 I/O module....please help!

ChrisOChrisO Posts: 10
edited 2005-02-05 23:17 in BASIC Stamp
Hello-

A while back I wrote asking for help using the BS2 to control a Kitsrus K108 serial I/O module. I am very new to using Stamps and appreciate the help.
Thanks to John Williams for his relpy....however, Looking at my BS2 manual, I am not totally clear how to use the template you sent to select baud, etc. (I know, thick newbie)...

Just to review my situation....the K108 uses simple ASCII commands to turn relays on and off--ie, "N1" followed by CR turns Relay 1 on, "F1", CR turns it off.

Kitsrus says that is the only data that needs to be sent. The K108 uses 9600, 8 data bits, 1 stop bit, no parity, no flow control.

I used a straight-through DB9 to connect the BOE to the K108 serial in, and my program basicially looked like this:

DO
SEROUT 16, 84, [noparse][[/noparse]"N1", CR]
PAUSE 1000
SEROUT 16, 84, [noparse][[/noparse]"F1", CR]
PAUSE 1000
LOOP

for example, to make Relay 1 turn on and off as a test.

While I have the BOE hooked to my PC via the USB-to-serial adapter, I can see the Rx light blinking, so I know the Stamp is outputting data.

I have tried using the ASCII numbers for the N, 1, and CR, and just about every other data formatting variation I can think of.
I have also tried baudmode 16468 (inverted 8bit no-parity).

I saw the note that when Tpin=16 is used, the data is inverted and driven regardless of baudmode......so I tried using I/O pin 1 and Vss hooked to DB9 pins 2 and 5, with Tpin=1 instead. Then I connected DB9 pins 1,4,6 and 7,8 to disable hardware handshaking.

Nothing.

Can anyone give me a Clue? [noparse]:)[/noparse] Thanks!

Chris

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-02-05 20:33
    Chris -

    These are just a few suggestions after a quick overview of the Kitsrus K108 documentation, as supplied on their web site. Have you tried using Hyperterminal to test the board to make sure there are no construction errors? This will help you to determne whether the problem is on the board, or in the Stamp program you've written.

    The board apparently sends out a "#" character to let you know it's there. You might want to add a dummy SERIN just to clear that character out in case it's causing a problem.

    I would stay away for pin port 16 since there are issues such as character echoing which may be causing a problem somewhere along the way. Your use of pin port 1 was a good idea. You may need a MAX232 (or other) level converter to bring the output pin voltage up to RS-232 specs. I only mention this since the documentation does make specific reference to TTL voltage levels. CMOS voltage levels as seen on the Stamp and other similar microcontrollers is lower than TTL levels, by definition. The exception on the Stamp is pin port 16, but there are other issues (noted above) which may cause problems in this application.

    Regards,

    Bruce Bates
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-02-05 23:17
    Chris,

    The reason I suggested the template is because it holds all the gory serial details -- and as you know, the devil is in the details. You may need to swtich to inverted mode; this is easily done with the template. Your baud definition would look something like this:

    Baud CON T9600 + Inverted

    Now ... you must be aware that the BS2 programming port echos everything it receives, and this may be causing your problems. If you request the status from the K108, the status message it sends is going to get echoed right back. If this becomes a problem then you should switch to standard IO pins for SERIN/SEROUT. If the unit is very close to the BASIC Stamp, you can make a direct connection between TX on the Stamp and RX on the KT108. If you're going to receive data from the KT108 then you should insert a 22K resistor between the KT108 TX pin and the Stamp RX pin.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.