Shop OBEX P1 Docs P2 Docs Learn Events
Visual Basic, SERIN and SEROUT with RC-Time measurement — Parallax Forums

Visual Basic, SERIN and SEROUT with RC-Time measurement

GWebberGWebber Posts: 9
edited 2004-12-31 20:59 in BASIC Stamp
Hi All,

I really enjoyed playing with BOE SB2 with PBasic and Visual Basic for few days.· The Basic Stamp ran in debug mode with RC-Time measurement and Visual Basic was able to get the numbers from it but missed some of it.· I·tried with SEROUT in PBasic but did not have any luck with it.·Any suggestion?

' {$STAMP BS2}
' {$PBASIC 2.5}
time VAR Word
HIGH 15
PAUSE 10
RCTIME 15, 1, time
SEROUT 15, $4054, [noparse][[/noparse]time, DEC 3]

I also tried with·'Ready and Busy'·script

' {$STAMP BS2}
' {$PBASIC 2.5}
time VAR Word
datain VAR Byte· 'contains a 0 or a 1
PIN· CON· 16·· 'stamps dedicated serial input pin
baud· CON· $4054 '9600 baud
again:
SERIN PIN,baud, [noparse][[/noparse]datain]
IF datain = "1" THEN Ready
IF datain = "0" THEN Busy
GOTO again

Ready:
HIGH 15
RCTIME 15, 1, time
SEROUT 15, $4054, [noparse][[/noparse]time]
GOTO again

Busy:
LOW 15
RCTIME 15, 1, time
SEROUT 15, $4054, [noparse][[/noparse]time]
GOTO again

Comments

  • Martin HebelMartin Hebel Posts: 1,239
    edited 2004-12-31 20:03
    I suspect more of the problem may be on the VB side.

    As the data streams into the VB applications, when you read the buffer of the MSComm control, you may be getting reading several at once.· You can try putting about a 200mSec pause to give time for VB to respond and act.· What do you have receive buffer set to for triggering the OnComm event?

    It gets pretty tricky to capture fast data reliably.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel

    Electronic Systems Technologies
    Southern Illinois University Carbondale
    Personal Links - ·Lot of BASIC Stamp info
    and
    SelmaWare Solutions
    StampPlot Pro Version 3 Release 4
    Graphical Data Acquisition for your Micro and Imagination!
    Now allows additional controls to be added, or developed
    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-31 20:59
    Perhaps this article will help: http://www.parallax.com/dl/docs/cols/nv/vol3/col/nv89.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
Sign In or Register to comment.