Shop OBEX P1 Docs P2 Docs Learn Events
Transmitter to Receiver to PC — Parallax Forums

Transmitter to Receiver to PC

niconico Posts: 28
edited 2009-08-31 05:37 in BASIC Stamp
Hi,
I have a 27981 RF receiver and 27980 RF receiver. I'm able to transmit data to the receiver using bs2 with the following codes.

Transmitter
Main :

CmConstant CON 2260
CmConstant2 CON 2260
cmDistance VAR Word
cmDistance2 VAR Word

time VAR Word
time2 VAR Word

DO

PULSOUT 15, 5                                                               
PULSIN 15, 1, time
PULSOUT 14, 5                                                               
PULSIN 14, 1, time2

cmDistance = cmConstant ** time
cmDistance2 = cmConstant2 ** time2

DEBUG HOME, DEC3 cmDistance, CR
DEBUG DEC3 cmDistance2

PULSOUT 8, 1200
SEROUT 8,16468,[noparse][[/noparse]"!", DEC3 cmDistance, DEC3 cmDistance2]

PAUSE 100
LOOP




Receiver
cmDistance VAR Word
cmDistance2 VAR Word
DO

SERIN 7, 16468, [noparse][[/noparse]WAIT("!"),DEC3 cmDistance,DEC3 cmDistance2]

DEBUG HOME, DEC3 cmDistance, CR
DEBUG DEC3 cmDistance2

LOOP




Everything works fine using the above codes. However, when I'm going to send the data from the receiver to my PC using the SEROUT command, the readings are wrong.
Below is the edited receiver codes to send data to my pc. The debug window will show the correct readings using the above codes(cmDistance=006, cmDistance2=050). But, when using the below code to send data to my pc, the debug window will show the wrong readings(cmDistance=007058, cmDistance2=053007053)

cmDistance VAR Word
cmDistance2 VAR Word
DO

SERIN 7, 16468, [noparse][[/noparse]WAIT("!"),DEC3 cmDistance,DEC3 cmDistance2]
SEROUT 16,16468,[noparse][[/noparse]DEC3 cmDistance,DEC3 cmDistance2]
SEROUT 16,16468,[noparse][[/noparse]LF]

DEBUG HOME, DEC3 cmDistance, CR
DEBUG DEC3 cmDistance2

LOOP

Comments

  • dev/nulldev/null Posts: 381
    edited 2009-08-28 10:33
    This is because you use pin 16 in the SEROUT command. Pin16 is used by the DEBUG statement, and you get conflicts. If you want to use both DEBUG and send serial data to your PC in the same program, you should get a RS232-TTL level converter, and send data to your PC using Stamp pins between 0 and 15.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
  • niconico Posts: 28
    edited 2009-08-29 12:45
    hi dev/dull,

    you mean if i remove away the debug statement, the readings will be fine ?
  • dev/nulldev/null Posts: 381
    edited 2009-08-29 13:19
    Yes

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
  • niconico Posts: 28
    edited 2009-08-31 05:37
    hi, dev/dull

    thx for the help. i did try removing the debug previously but it still can't work because it's the pc that is having problem. now it's solved. thanks very much.
Sign In or Register to comment.