Jump to content
  • 0

Ultrasonic module (HC-SR04) with Basys3


Mell

Question

Hello,

I'm building a project with the basys3 for reading an ultrasonic rangefinder (HC-SR04) signal in and convert with that signal the distance in meters.

But now i'm almost done writing my code and I search the connectors of the board and there are pmod connectors so i'm wondering can I use those connectors as a normally gpio input and output?

Already friendly greetings!

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

@Mell,

Waddaya know? I've been playing around with these same modules like you. In fact my set up is sitting next to me as I write this, I've been sojourning in Altera land or I'd have replied sooner.

No, you don't HAVE to use a level translator to use the HC-SR04. But you DO have to pay attention to signal compatibility. It turns out that you can power the module with 3.3V ( instead of 5V ) and they will work out just fine. Just make sure that your inputs are LVCMOS33 or LVTTL33. A 100 ms PRI ( pulse repetition interval ) is a pretty good choice.  These cheap modules are pretty accurate. I've been getting fairly reliable distance measurements in centimeters to 2 decimal places for short ( < 20" ) distances. I use a UART for control and acquiring echo pulse measurements.

The unfortunate thing about these modules, for my intended purpose at least, is that there is no echo if you don't supply the proper trigger pulse. I am interested in using an array of sensors for my application. Evidently, these modules use a micro and there is no schematic or access to the firmware.

I don't know what your intended use for these modules is but I encourage you to pursue an investigation of their usefulness. I will probably try to figure out if I can bypass whatever is controlling these to fit my needs... but they are nice as they are for general distance measurements.

best wishes

Link to comment
Share on other sites

@Mell,

Just remembered two things that I intended to say. One is that the modules are good to about 4 meters which would present an echo response of about 23.3 ms not counting the delay from the trigger to when the module energises the transmitter. I suspect ( I don't know this ) that past 1 meter the accuracy falls off considerably. This would depend on the target size, shape and material of course. Also.... the Project Vault is a place to post code and information for working projects. I mention this because there has been a lot of posts to this thread that make finding appropriate project vault posts difficult.

Link to comment
Share on other sites

@Mell,

Looks like a fun component to work with!

My initial thought was that you should just be able to wire the HC-SR04 pins to a Basys3 pmod port and control it with GPIO.  Just to be sure, though, I double checked the HC-SR04 data sheet.  What I read suggested that the HC-SR04 wanted a 5V power supply, and a 5V input and output.  To connect this to the Basys3 board, you'll also need a level shifter and a 5V source.  For the 5V source, you might be able to tap the power rail underneath the power selection jumper.  That'd get you access to the 5V USB power source.  Alternatively, you could provide that 5V from somewhere else.  (The Basys3 wasn't really designed to provide 5V power, but rather 3.3V power)

Dan

Link to comment
Share on other sites

@D@n

Thanks for the fast respond!

The sensor has 4 pins Vcc, Gnd, Echo, Trig. The Trig pin need a short pulse of 10µs for starting to send, I am going to send a pulse signal every 100ms. The Echo pin sends the pulse with to the board.

So I need the level shifter for the signal Trig? So that the sensor as an 5V input instead off 3,3v input?

Yeah it's fun to play with but more difficult with the fpga board (basys3) then an simple arduino board :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...