PING Sonar Sensor with PIC18F452
Joseph123
Posts: 1
Folks,
I am trying to interface the PING Sonar Sensor with the PIC18F452. I have been able to program the PIC to produce a trigger pulse of 5us ( verified that on the scope) and also been able to capture the waveforms and compute the ON pulse width (supplying a 20ms pulse using the function generator). I am using the in-built Capture/Compare module (CCP1) which allows for effective timing control.
Here's the problem: The PIC configures CCP1 pin as output and produces a 5us trigger pulse. I can see the LED on the PING to blink. I then configure the CCP1 module to change the pin to an input and wait for the return waveform. Well, the moment I change the pin to an input, the sensor shuts off. My subroutine is waiting for the return pulse to capture, it never comes. I have tried using a pullup resistor to 5V to keep it ON, connected to another pin that supplies 5V, etc but nothing seems to work. The moment the pin is changed from output to input, the module shuts down. The only way to restart the module is to power down the circuit and power it up.
Any ideas on what's happening?
-Joe
I am trying to interface the PING Sonar Sensor with the PIC18F452. I have been able to program the PIC to produce a trigger pulse of 5us ( verified that on the scope) and also been able to capture the waveforms and compute the ON pulse width (supplying a 20ms pulse using the function generator). I am using the in-built Capture/Compare module (CCP1) which allows for effective timing control.
Here's the problem: The PIC configures CCP1 pin as output and produces a 5us trigger pulse. I can see the LED on the PING to blink. I then configure the CCP1 module to change the pin to an input and wait for the return waveform. Well, the moment I change the pin to an input, the sensor shuts off. My subroutine is waiting for the return pulse to capture, it never comes. I have tried using a pullup resistor to 5V to keep it ON, connected to another pin that supplies 5V, etc but nothing seems to work. The moment the pin is changed from output to input, the module shuts down. The only way to restart the module is to power down the circuit and power it up.
Any ideas on what's happening?
-Joe
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
The coding for the Propeller is much more like that for the PIC
This does much the same thing as you're trying and it does work. You might try checking your pulse width, maybe just make it a little bit wider. This sets up the control pin as a low output, maybe 2us later sets it to high for a little more than 5us, sets it to low for about 2us, then changes it to input and waits for the leading edge of the echo timing pulse.