|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
PWM Input?
We need to be able to read a PWM input from a Radio Shack ultrasonic range finder. The PWM class only works for output, and we can't seem to get the counter class working either. Is there any way to read PWM from a digital input?
|
|
#2
|
||||
|
||||
|
Re: PWM Input?
Not through digital since it is on/off and the range finder would output multiple values other than 0 and 1, but you can through the analog breakout on the cRIO
|
|
#3
|
|||
|
|||
|
Re: PWM Input?
This is the one we have http://blog.radioshack.com/2013/07/f...-range-sensor/
We're pretty sure it's PWM not analog. |
|
#4
|
||||||
|
||||||
|
Re: PWM Input?
You are correct that it is a digital PWM input. However, it is also requires a digital output on the same pin to trigger a distance measurement. The cRIO FPGA wasn't designed to handle this use case. There are many other ultrasonic sensors that would be easier to use, including digital ones where the request and the response are on different pins. Alternately, you could build a circuit to separate the two signals.
|
|
#5
|
||||
|
||||
|
Re: PWM Input?
I wonder if you could read the pulse width by treating it like a counter.
Oops... Maybe not with that part number. Last edited by Ether : 08-02-2014 at 18:01. |
|
#6
|
|||
|
|||
|
Re: PWM Input?
Tried that. It never returned anything but 0, and infinity. We even tested the counter with slower inputs and it worked that time. I think the sensor is too fast for the counter class.
|
|
#7
|
||||
|
||||
|
Re: PWM Input?
The bottom of Page3 of the User's Guide for 2760342 implies that the SIG pin is a "Serial Monitor (9600)". Sounds like RS-232 to me, not PWM. Am I misinterpreting this? |
|
#8
|
||||||
|
||||||
|
Re: PWM Input?
Quote:
Here's the relevant portion of the arduino code for reading the sensor. Code:
/*Begin the detection and get the pulse back signal*/
void Ultrasonic::DistanceMeasure(void)
{
pinMode(_pin, OUTPUT);
digitalWrite(_pin, LOW);
delayMicroseconds(2);
digitalWrite(_pin, HIGH);
delayMicroseconds(5);
digitalWrite(_pin,LOW);
pinMode(_pin,INPUT);
duration = pulseIn(_pin,HIGH);
}
|
|
#9
|
||||
|
||||
|
Re: PWM Input?
Thanks Joe. I searched for a datasheet that documents the protocol of the SIG pin for this device but was not successful. What I was looking for was this: Is the protocol strictly command/response, or can it be set up to continuously broadcast its distance measurements? And if so, is the pulse width user configurable into a range that the FPGA sampling rate could handle? Last edited by Ether : 08-02-2014 at 18:57. |
|
#10
|
||||
|
||||
|
Re: PWM Input?
Would not a counter count pulses rather than pulse width? It seems unless something is programed in the FPGA it is not doable.
|
|
#11
|
||||
|
||||
|
Re: PWM Input?
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|