Shop OBEX P1 Docs P2 Docs Learn Events
Serin — Parallax Forums

Serin

dakota77dakota77 Posts: 23
edited 2009-04-24 19:20 in BASIC Stamp
Hello,

I'm using a Bstamp B2P to control a relay and a mini SSCII to control a servo.
The 2 devices are connected to the same com port of a Pocket Pc (Ipaq HX4700).
The data sent to the Mini SSCII are in the range : 1 to 255.
So to prevent any interference between the 2 devices, I·can not use·values from 1 to 255 to control the relay.
Actually my problem is that when I send a sequence to control the Mini SSCII (for example chr(255) chr(1) chr(140) )·the relay is actuated.
So I have to find a sequence to send with the Pocket pc that will only actuate the relay.
Example :· I send "ABC" with the Pocket pc and the relais1 routine is run.

(I'm new to Bstamp and I think I don't master the SERIN command [noparse]:)[/noparse] )

Do you have an idea to solve this ?
Thanks for your time.

This is the code I use :

·x VAR Byte

loop:
·· SERIN 7,16468,[noparse][[/noparse]x]
·· DEBUG "--",x,"--"
·· IF x·="ABC" THEN relais1
GOTO loop

relais1:
· HIGH 0
· PAUSE 600
· LOW 0
··GOTO loop

·

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-04-24 13:20
    Hi , something like this might work

    x VAR Byte(3)

    SERIN 16,16468,100,timeout,[noparse][[/noparse]STR x\3]

    IF x(0)="A" AND x(1)="B" AND x(2)="C" THEN
    GOSUB relais1
    ENDIF
    timeout:

    look at the Pbasic help files under SERIN / SEROUT for explanation of the STR formatter

    Jeff T.
  • dandreaedandreae Posts: 1,375
    edited 2009-04-24 14:23
    You'll need to change the baud rate to 16624 for the BS2p.

    Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Parallax Tech Support·
  • dakota77dakota77 Posts: 23
    edited 2009-04-24 19:20
    Hello,

    It works fine within a few minutes [noparse]:)[/noparse] !

    Thanks a lot for your help.

    Mario

    x VAR Byte

    loop:
    ·· SERIN 7,16624,[noparse][[/noparse]STR x\3]
    ·· IF x(0)="A" AND x(1)="B" AND x(2)="C" THEN relais1
    GOTO loop

    '****** Relais 1 photo
    relais1:
    · HIGH 0
    · HIGH 1
    · PAUSE 600
    · LOW 0
    · PAUSE 200
    · LOW 1
    · GOTO loop
Sign In or Register to comment.