1 Reply Latest reply on Nov 14, 2017 2:34 AM by user_49271930

    Timer problem for ultrasonic sensor (HY-SRF05)

    user_494419696

      Hi!
      I'm using psoc from september, I can't find a solution for read a module sensor. It is SRF05, ultrasonic distance sensor. It is said that it need to be triggered with a 10us minumum pulse, after that the send 8 pulse to search for objects, he recevice them back, he give to his echo pin an high signal time proportional to the distance (the duration in microseconds divided by 58 give us the distance in cm). With arduino library, no problem, so the module works. With psoc I tried several kind of configutation, normally with a pwm and a timer or counter in UDB implementation. I used PWM and timer with 50ms period, 1mega clock, pwm high for only 10-20 us, timer with trig pin and capture pin on the echo pin of the module. Interrupt is set on capture, i read the capture value in the interrupt and do stop star init for the timer every interrupt, and also isr clear pending.

      It gives me a value correct for the first cms, but if the object is more tahn 20 25 cm it gives crazy oscillation, with the low point of every oscillation at the correct value i think....
      I also tried to just set pin for trigger high and low with delays, it doesn't work...
      I hope to have some ideas from you. The best way to measure high period durations???

      I want to use two modules, so maybe also to trig them individually.
      Thanks