I'm new to the world of Digital Systems :D I want to know whether the output of the Ultrasonic range finder sensor is analog or digital, so I can connect it to Altera DE2 GPIO directly or I need an ADC? Thanks in advance :)
-
\$\begingroup\$ Have you read the documentation? It pretty clearly describes how the device communicates. It even has an example program in BASIC. \$\endgroup\$– skrrgwasmeNov 17, 2014 at 21:25
-
\$\begingroup\$ I've read it definitely, but really I can't understand that, I'm a Computer scientist and I'm not involved in that staff, Thanks for your comment :) \$\endgroup\$– MCubbedNov 17, 2014 at 21:28
-
\$\begingroup\$ In that case, you should clearly describe what you've read and what you don't understand about it in your question. Your current question is likely to attract downvotes and/or RTFM responses. \$\endgroup\$– skrrgwasmeNov 17, 2014 at 21:30
1 Answer
The PING Ultrasonic Range sensor will emit a pulse on the 5V signal line that corresponds to the amount of time between emitting a 40kHz ultrasonic pulse and receiving the echo of that pulse. When the sensor emits the pulse, its 5V SIG line will be set to a logic high (5V), and when the echo is received, the line will go low again. Your goal is to measure how long the SIG line is high and perform a calculation to convert that time to distance.
You can connect it to your GPIO. There is no need for an ADC, because the sensor output is a digital signal. It will either be high or low. My HDL programming is a bit rusty so I won't try to give you a code sample, but essentially you need to create some logic that monitors the GPIO your sensor is connected to and measure the time between the signal going high and when it goes low again. Then, use the test data from the manual here to make the proper conversion from time to distance.
As was pointed out in the comments, you probably don't want to connect it directly to the GPIO. You may need to put some resistors in between the sensor and the GPIO, but the datasheet for your board or chip should tell you that.
-
\$\begingroup\$ almost directly - the FPGA probably can't tolerate direct connection to 5v, but the data sheet will show how to do it with a series (and possibly shunt) resistor. \$\endgroup\$ Nov 18, 2014 at 4:57