Shop OBEX P1 Docs P2 Docs Learn Events
PULSIN and RCTIME — Parallax Forums

PULSIN and RCTIME

ArchiverArchiver Posts: 46,084
edited 2003-06-15 16:50 in General Discussion
Hello,

I'm TRYING to get a Polaroid sonar unit pulled fron a Polarois Sonar
OneStep camera (the one with the 45 degree connector)to work. I've
search the web and found the mod for the board and made them. My
problem is with the program.

'{$STAMP BS2}
'{$PBASIC 2.0}

'Polaroid SONAR programs for the Parallax Stamp II
'Copywrite Dennis Clark 9/2000, more or less.
DEBUG CLS
'SPKR con 1

'Polaroid SONAR one-step program
PWR con 13
XLOG con 14
MFLOG con 15

time var word
feet var word
inches var word

start:
'freqout SPKR,200,2000

pause 2000

onestep:
'Polaroid One-Step routine
input XLOG
input MFLOG
high PWR 'turn power off
DEBUG "power off", cr


srdng:
low PWR 'turn power on
DEBUG "power on ",cr

pulsin XLOG,0,time 'wait for XLOG (pulse started)
rctime MFLOG,1,time 'wait for MFLOG (ping returned)

'DEBUG "time is", time, cr


time = time*2 'actually 2us per count
inches = time/148 '1.78ms per foot transit time
inches=inches+2 'occasional hack needed.
high PWR 'turn power off

DEBUG "power off",cr

DEBUG dec time,"uS ",dec inches," in",cr, cr

pause 1000 'seems to take a while to recharge...
goto srdng

end



My problem is with these two commands/lines:

pulsin XLOG,0,time 'wait for XLOG (pulse started)
rctime MFLOG,1,time 'wait for MFLOG (ping returned)


I understand what they do and how they work, just NOT how you can use
them in the maner. Not with the same variable, 'time', in both.
Should the 'variable' be the same in both instructions?

Here is the link to the whole thing:
http://www.seattlerobotics.org/encoder/200010/dlcsonar.html

Thanks,
Duane

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-06-15 00:51
    Duane,

    The code looks correct to me, However I'm no expert.

    The time variable in the pulsin command is not used, it's just a way of
    detecting when the sonar unit has sent its pulse train. The pulsin requires
    a variable to store its data and so I guess to save valuable RAM the same
    one was re used.

    The useful one is the rctime command that also sets the time variable, but
    this time to something meaningfull.

    I hope I'm right and I hope this helps.

    Cheers

    Rohan

    Original Message
    From: mtn_biker37 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=_S9ILTs0RNxtg-UT68_FBHs9YFqTArhCu1u3NHf1ByZyX5QlFMoVcFIf2eAkGvm39h0YqS4njyuVcZUJZrc]mtn_biker37@y...[/url
    Sent: Sunday, 15 June 2003 9:20 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] PULSIN and RCTIME


    Hello,

    I'm TRYING to get a Polaroid sonar unit pulled fron a Polarois Sonar
    OneStep camera (the one with the 45 degree connector)to work. I've
    search the web and found the mod for the board and made them. My
    problem is with the program.

    '{$STAMP BS2}
    '{$PBASIC 2.0}

    'Polaroid SONAR programs for the Parallax Stamp II
    'Copywrite Dennis Clark 9/2000, more or less.
    DEBUG CLS
    'SPKR con 1

    'Polaroid SONAR one-step program
    PWR con 13
    XLOG con 14
    MFLOG con 15

    time var word
    feet var word
    inches var word

    start:
    'freqout SPKR,200,2000

    pause 2000

    onestep:
    'Polaroid One-Step routine
    input XLOG
    input MFLOG
    high PWR 'turn power off
    DEBUG "power off", cr


    srdng:
    low PWR 'turn power on
    DEBUG "power on ",cr

    pulsin XLOG,0,time 'wait for XLOG (pulse started)
    rctime MFLOG,1,time 'wait for MFLOG (ping returned)

    'DEBUG "time is", time, cr


    time = time*2 'actually 2us per count
    inches = time/148 '1.78ms per foot transit time
    inches=inches+2 'occasional hack needed.
    high PWR 'turn power off

    DEBUG "power off",cr

    DEBUG dec time,"uS ",dec inches," in",cr, cr

    pause 1000 'seems to take a while to recharge...
    goto srdng

    end



    My problem is with these two commands/lines:

    pulsin XLOG,0,time 'wait for XLOG (pulse started)
    rctime MFLOG,1,time 'wait for MFLOG (ping returned)


    I understand what they do and how they work, just NOT how you can use
    them in the maner. Not with the same variable, 'time', in both.
    Should the 'variable' be the same in both instructions?

    Here is the link to the whole thing:
    http://www.seattlerobotics.org/encoder/200010/dlcsonar.html

    Thanks,
    Duane



    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-15 01:09
    >
    >pulsin XLOG,0,time 'wait for XLOG (pulse started)
    >rctime MFLOG,1,time 'wait for MFLOG (ping returned)

    The program is really using "time" as a dummy variable in the first
    statement, then the real business is done by the rctime.

    When the power is turned on, there is a delay and then the ping is
    sent out. The pulsin command immediately detects the outgoing ping
    by going low and high. The actual time value (the duration of the
    ping) does not matter. It just gets things started. The ping is on
    its way. Now the rctime command gets started. When the echo ping
    finally returns, MFLOG goes low and that is the value of time of
    travel for the ping.

    -- Tracy
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-15 02:41
    Gotcha! Thanks guys! The program doesn't seem to be working. Must
    be on the hardware side.

    Duane
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-15 04:44
    >Gotcha! Thanks guys! The program doesn't seem to be working. Must
    >be on the hardware side.
    >
    >Duane


    An oscilloscope is indispensable for this kind of problem!
    Ultrasound can take some really weird bounces, and it is possible to
    see what is going on with the 'scope.
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-15 16:50
    I started doing that to 'see' what was going on. Still looks easier
    to just suck it up, spend the $35, and get one of the SR04 units.
    All is not lost, yet, though.

    D

    --- In basicstamps@yahoogroups.com, Tracy Allen <tracy@e...> wrote:
    > >Gotcha! Thanks guys! The program doesn't seem to be working.
    Must
    > >be on the hardware side.
    > >
    > >Duane
    >
    >
    > An oscilloscope is indispensable for this kind of problem!
    > Ultrasound can take some really weird bounces, and it is possible
    to
    > see what is going on with the 'scope.
Sign In or Register to comment.