Shop OBEX P1 Docs P2 Docs Learn Events
Question about the use of RCTIME versus PULSIN — Parallax Forums

Question about the use of RCTIME versus PULSIN

denodeno Posts: 242
edited 2009-06-07 14:49 in BASIC Stamp
I find that I can quite successfully measure a pulse duration using RCTIME with no capacitor involved.· Is this the same as PULSIN?· Basiclly, I am measuring the time of a· pulse from transmission to return from an ultrasonic device (not a PING device) using RCTIME instead of PULSIN.· I really just discovered this when I was rewritting my code to accomodate the use of a BS2sx mentioned in a previous post and there it was stareing me in the face.·

Deno·

Comments

  • ZootZoot Posts: 2,227
    edited 2009-06-07 14:01
    The *biggest* difference is that RCTIME will not look for a starting edge -- the pin is presumed to already be in the state you are measuring. RCTIME then returns the time it takes for the pin to change states (fall to 0 or rise to 1).

    PULSIN on the other hand, measure the time that a pin is in a given state from START edge to END edge.

    Generally, if you have a real "pulse" PULSIN will return more accurate results, because RCTIME may or may not catch the beginning of the pulse. Of course, the logic of the program and the nature of the actual circuit being used may make it workable anyway (esp. if the pin is in known state prior to RCTIME). A good example is some of the IR Remote for the Boe-bot experiments where RCTIME is used in place of PULSIN because the Stamp will not be fast enough to "catch" the starting (falling) edge of the IR detector's pulses.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • denodeno Posts: 242
    edited 2009-06-07 14:49
    Thank you Zoot for the fast reply. This is what I figured, but you were able to put it into words for a better undertanding. The ultrasonic tranducer I am using is from Senscomp (the 120 inch range model). I have to external trigger the device with one pin on the stamp, with PULSOUT and the next instruction is the RCTIME instruction. Using the right integer math and the duration interval for the BS2, the devices are quite accurate. Down to the inch, anyways. I am running 3 of these devices which uses up 6 I/O's of the stamp.··The Senscomp device uses 2 pins, one for external trigger from the stamp, and the other pin outputs a PWM, length of which depends on how far away the target is.· So two I/O's are required for each device.
    Thanks again...
    Deno

    Post Edited (deno) : 6/7/2009 2:58:49 PM GMT
Sign In or Register to comment.