Ultrasonic Sensor PMOD

Hello, I’m trying to connect ultrasonic sensors to my PYNQ-Z2 board and I’m wondering if I need and ADC to do so? If not is there anywhere I could get a .tcl, .hwh and .bit file from so that I can test the sensor?

Hi @Eoin, can you provide more information? the sensor model and the interface for instance.

Mario

The ultrasonic sensor model is HC-SR04. I currently have nothing to interface the sensor to the board and I’m trying to find out what I need. Do you know what can be used?

@Eoin the sensor is digital and provides the information encoded in a pwm signal. You can connect the sensor directly to the arduino pins in the board. You can also use the arduino IOP to use the sensor.

https://pynq.readthedocs.io/en/v2.6.1/pynq_libraries/arduino.html

However, you will need to write your own driver to do so.

You can find more information about the sensor here (Documents tab), datasheet and example tutorial

Mario

1 Like

Hi @marioruiz ,

I have to use this sensor as well. Moreover i would like to use the arduino IOP as you mentionned above.

The pins on the arduino are exactly the same than on the PYNQ Z2 ?

Can you give me more detail about the driver ?

My first idea was to use the Rasperrry PI GPIO. So i will use the pynq.gpio library. However I don’t know which pins i have to call because there are arduino IOP as well and I don’t know the name of their pins.

Regards,

Hi @symbole,

You can find the I/O information on the user guide, they are also labelled on the board. Someone has also made a handy representation

Can you give me more detail about the driver ?

All the information about the driver(s) is in ReadTheDocs

https://pynq.readthedocs.io/en/latest/pynq_libraries/arduino.html

Mario

Hi @marioruiz ,

Thanks for your reply.

As mentionned above I would like to use few pins of the raspberry pi on the PYNQ Z2 board. Could you give me an example ?

I already read the link below this is why i asked to you some help.

Regards,
Symbole

Hi @symbole,

There’s a section on RPi RPi — Python productivity for Zynq (Pynq) and you should be able find examples on the SD Card image.

Mario

Hi @marioruiz,

I already read this article. It describes the architecture but don’t describe how to use them.
On the SD card there is 1 example but it doesnt describe how to use rpi pin.
The MicroBlaze is not so clear for me.

We just want to plug in our HC SR04 and recover values to calculate a distance.

Regards,
Symbole

Hey @symbole,

I was wondering if you were able to figure this out. I would love to know how you did this if you were able to complete this.
If anyone else has some tips, that would be appreciated as well

Thanks!

Hi mate,

I used arduino library to communicate with the sensor. Works Well !

~WRD0000.jpg

hi,

Thank you very much for getting back. I really appreciate it! How did you copy over the arduino library? and did you use c or python?

If you could share your code, a simple process of what you did, or any kind of information I would greatly appreciate it. Thanks!!!

I used Python. You should find easily the Arduino library in the PINQ library and use it. I’m sorry, I no longer have the code…

~WRD0000.jpg

when you say Arduino library in the PINQ library do you mean microblaze? Also did you have to create your own driver? if so how?

I used : https://pynq.readthedocs.io/en/latest/pynq_package/pynq.lib/pynq.lib.arduino.html#module-pynq.lib.arduino.arduino_io

Thanks to base.iop_arduino.mb_info I configured the pins trigger and echo and after send an alternative signal thanks to write(0) and write(1).

Good night

~WRD0000.jpg

1 Like