Shop OBEX P1 Docs P2 Docs Learn Events
Basic stamp 2P "talks" too fast, so Basic Stamp 2 can't keep up. — Parallax Forums

Basic stamp 2P "talks" too fast, so Basic Stamp 2 can't keep up.

CuriousOneCuriousOne Posts: 931
edited 2013-04-26 12:30 in BASIC Stamp
bs2pp.jpg
Hello.

I'm doing simple project of communicating two basic stamp modules via RS-485, as written in "STAMP2: Communication and control projects" book. The problem is, that I have only two modules, BS2 and BS2P, and when built device as in book, it does not works. I've checked wiring, code many times, no luck. Then I decided to swap the modules, and check with oscilloscope their output. As you can see on attached screenshot, (using same horisontal resolution for both modules, BS2P is blue and BS2 green), BS2P outputs much shorter pulses than BS2, so I think, this is the reason why they can't synchronise. Below is the code for both (TX/RX) modules:

TX:
' {$STAMP BS2p}
' {$PBASIC 2.5}
btnwk VAR Byte
INPUT 2
OUTPUT 0
HIGH 0
IF (IN2<>1) THEN loop1
SEROUT 1,16468,1,["H"]
loop1:
BUTTON 2,0,255,0,btnwk,1,preloop2
GOTO loop1
preloop2:
SEROUT 1,16468,1,["L"]
loop2:
BUTTON 2,1,255,250,btnwk,1,loop_again
GOTO loop2
loop_again:
SEROUT 1,16468,1,["H"]
GOTO loop1:

RX:
' {$STAMP BS2}
' {$PBASIC 2.5}
string VAR Byte
OUTPUT 2
OUTPUT 0
LOW 0
loop1:
SERIN 1,16468,60000,loop1,[string]
IF(string<>"H") THEN is_low
HIGH 2
GOTO loop1
is_LOW:
LOW 2
GOTO loop1

What I can do to make them work? how to slow down BS2P? insert PAUSE?
690 x 354 - 60K

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-26 06:59
    Read the manual, specifically the section on SERIN / SEROUT. The Baud constant is different for different models of the Stamp and those chapters of the manual have tables that give the proper values for each model.
  • CuriousOneCuriousOne Posts: 931
    edited 2013-04-26 10:11
    What will be the right choice?

    speed up BS2, or slow down BS2P ?
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-26 10:17
    You need to adjust the Baud constant in the BS2p program to match what the BS2 program expects. Please read the relevant sections (on the SERIN / SEROUT statements) of the Stamp Manual.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-04-26 12:02
    Mike is correct. As long as your Baud rates are set the same all should work fine.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-04-26 12:30
    NWCCTV wrote: »
    Mike is correct. As long as your Baud rates are set the same all should work fine.

    Not to be confused with what he has now, which are that the baud parameters are the same values, but they shouldn't be for the models of BASIC Stamp he's using.
Sign In or Register to comment.