Shop OBEX P1 Docs P2 Docs Learn Events
Ultrasonic Sensor — Parallax Forums

Ultrasonic Sensor

CenlasoftCenlasoft Posts: 265
edited 2011-08-19 08:26 in Propeller 1
Hello,
With help from this forum, I am getting some good results with my ultrasonic sensor. I have attached a pcb design and I need some suggestions. I will send a PWM pulse (40khz, .5ms width, 20 ms interval) to the T/R Transducer. The circuit works, but I am trying to gate the PWM so that I can send a few cycles of PWM and then stop the output and wait for an echo. I am only using 9v to pulse the TX so I used a 3904 transistor. I get about 8.80v to the transducer. I get a 2 meters range. I can live with that. How do I gate the pulse and if there are any spin software tricks, please let me know.
Thank You,
Curtis
894 x 428 - 60K

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-19 08:04
    Curtis,

    Is there any reason that you're using PWM instead of just a 50% duty cycle clock? Also, you probably don't want to gate a free-running counter output, since you could -- and probably will -- get too-short pulses at the beginning and end of your pulse train. My recommendation would be to leave the pin set as an output and do your gating by enabling and disabling an NCO counter. Before enabling, be sure to reset the phsx register. After enabling, your program can either time the pulse string or count pulse edges to know when to shut the counter off.

    -Phil
  • CenlasoftCenlasoft Posts: 265
    edited 2011-08-19 08:20
    Thanks Phil,
    I thought you had to use PWM to get the correct pulse width and interval. How do you use 50% duty cycle clock? I'll do some reading on how to enable and disable the NCO and do the other things you suggested.Thanks, Curtis
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-19 08:26
    Curtis,

    See AN001 for a thorough introduction to the Propeller's counters.

    -Phil
Sign In or Register to comment.