Shop OBEX P1 Docs P2 Docs Learn Events
Having a little problem with PULSIN...any thought on this Mike Green — Parallax Forums

Having a little problem with PULSIN...any thought on this Mike Green

denodeno Posts: 242
edited 2008-05-29 11:50 in BASIC Stamp
Here is what I am doing...I am triggering with PULSOUT (BS2) to a ultrasonic transducer (for range measurements...similar to the PING))) but not a PING))) device.· The PULSOUT is on a different I/O pin then the PULSIN command that I am using to try and measure the TOF (time of flight).· The PULSIN command is the next line of code after the PULSOUT trigger.· I know for a fact that the PULSOUT trigger is working, because I can hear the click of the transducer, and the onboard LED's of the transducer are working.· However, I cannot get the stamp to see the incomming pulse and measure the pulse width.· I can see the pulse clearly on the scope, but the stamp does not.

The incomming pulse according to the documentation starts low AT the trigger, then goes high until the echo is received then goes low.· I have tried every combiniation of "states" for the PULSIN command, and always get a 0 returned for the variable.

Now, I know using the PING))) device, the PULSOUT and PULSIN command uses the same I/O pin, where I am using one I/O for the PULSOUT trigger, and another different I/O for the PULSIN command.

Has anyone had the same problem?· Any work arounds, as I really would like to be able to measure the length of the incomming pulse to determine the range.· BTW, according to the scope, the amplitude of the incomming pulse is a full 5 volts.· Easy to see on the scope.

I would appreciate any thoughts on this.· And, the transducer I am using is from Senscomp...Mini-SE.

Deno

Post Edited (deno) : 5/28/2008 10:19:01 PM GMT

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-05-28 22:22
    Can we see the code? And a schematic of your circuit and while you are at it the part number of the transducer you are using. I used a SRF05 (I think that's the part number) with seperate in and out and the only difference I remember was the pulsin/pulsout had different pin numbers. The rest of the code was right from "Roaming with the Ping)))"

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-05-28 22:54
    What pulse widths are you seeing on the scope?· Are you checking that with this device connected to the Stamp?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-05-29 00:21
    PULSIN has to see both edges of a pulse to measure it. If the pulse has already started when PULSIN is invoked (which your description seems to indicate), the pulse will be ignored.

    -Phil
  • denodeno Posts: 242
    edited 2008-05-29 00:32
    Here is the sub routine that I call when I want a range reading:

    center_trigger···· PIN······ 2

    senter_sensor·····PIN······ 3

    Trigger······· CON······ 10

    islow·········· CON········ 0

    isHIGH········ CON·········1

    target········· VAR········ Word



    check_center_sensor:
    ···PULSOUT center_trigger, Trigger······················ '* activate sensor by pulsing HIGH
    · ·PULSIN· center_sensor, islow, target················ ·'* measure echo pulse
    ·RETURN



    Trigger works, I can hear the tranducer "click".

    Scope pulse width is about 20 mSec., varies with TOF (time of flight) connected to stamp at P3 with transducer also connected to P3.

    Any "trick" way for PULSIN to see both edges of pulse?

    Deno





    Post Edited (deno) : 5/29/2008 12:37:29 AM GMT
  • FranklinFranklin Posts: 4,747
    edited 2008-05-29 01:07
    This is what I use. It works for me.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-29 01:11
    You'd need some external logic to delay the trigger pulse and use it to open a "gate" for the echo pulse. A 555 timer could be triggered (TR input) by the falling edge of the sensor trigger pulse. The timer output (Q) could be inverted and used with an AND gate (3 parts of a 74HC00 as two inverters and a NAND gate) to inhibit the echo signal until the 555 times out. You'd have to add a fixed adjustment to the sensor pulse width.

    You could also invert the sensor trigger pulse and use that to trigger the timer if you wanted to use the leading edge of the sensor trigger pulse as your time reference point.
  • LarryLarry Posts: 212
    edited 2008-05-29 02:24
    I'm with PhiPi on this one. I suspect that the stamp is too slow to catch the rising edge of the pulse. That's precisely why the Ping))) sensor has the delay in firing.

    There is a workaround. The Mini S has a self triggering mode. use the Trigger Enable pin ( pin 4 on the sensecomp) instead of the trigger. It will fire continuously when you hold the enable pin high and stop when you pull it low. That gives you more than one shot to see a rising and falling edge for PULSIN.


    It would look something like this in your program.
    enable   CON   10
    
    
    enable ihigh                                                       ' activate self triggering
       PULSIN  center_sensor, islow, target                  '* measure echo pulse
    enable islow                                                        ' disable self triggering
    
    



    Here's the datasheet. The datasheet is unclear as to whether the enable pin has an internal pullup. I'd try just making the Stamp pin an input instead of pulling the enable pin high .

    www.senscomp.com/specs/Mini-S%20PB%20spec.pdf
    whoops, I got the high/low backwards first time.
    

    Post Edited (Larry) : 5/29/2008 3:18:56 AM GMT
  • denodeno Posts: 242
    edited 2008-05-29 02:24
    Franklin, is that a standard PING))) device from Parallax?· I am a little confused, because the PING))) device from Parallax only has one (1) data port.· The same port is used for the trigger in and the data or PWM out.

    Do you have PIN 5 and PIN 6 tied together?

    Thank you Mike for your input, but I was hoping not to have to build alot more circuits to make it work.· I will be using 3 of these devices.· That would be alot of extra components.

    Larry, thank you aswell, and I will try your software advice and let you know.

    deno


    Post Edited (deno) : 5/29/2008 2:38:14 AM GMT
  • Tracy AllenTracy Allen Posts: 6,667
    edited 2008-05-29 03:06
    Try this:
    check_center_sensor:
    PULSOUT center_trigger, Trigger '* activate sensor by pulsing HIGH
    RCTIME center_sensor,1, target '* measure echo pulse
    RETURN

    If it misses the rising edge of the pulse, the RCTIME will measure the time until the pin goes back low. On the other hand, if center_sensor is low when it comes to RCTIME, then it will return target=1. The results from RCTIME might be nearly as good as the PULSIN would have been.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • denodeno Posts: 242
    edited 2008-05-29 11:50
    Tracy...that's it.· RCTIME works very well.· Between the time that PULSOUT excutes and the RCTIME starts to measure is only about 2 inches of range.· Easily compinsated for.· Thanks for the knowledge.

    When it is finished, I will post a movie on U TUBE of the follow me golf·caddy that I am building.· A pull cart with brains. Getting tired of carrying my golf clubs.

    Deno
Sign In or Register to comment.