myRIO Student Projects

Showing results for 
Search instead for 
Did you mean: 

myUltraHarp : Ultrasonic Proximity + Musical Instrument

For best viewing, watch this video in 720p






myUltraHarp is an ultrasonic musical instrument that uses the myRIO to interface with multiple ultrasound proximity sensors. A code running on the FPGA of the myRIO measures distance from all four sensors using pulse width measurements. the distance is then converted into a sine wave frequency, with a dfferent offset for each sensor so that they behave like different "strings". This frequency is used to generate an output on the myRIO's audioout, which can be outputted to a speaker or headphones.


The idea was inspired originally by the concept of laser harps, though scaled down to meet the time constraints of a one week project, and a smaller budget.



Ultrasound module operation:





The Ultrasound module is very straightforward to interface and operates in three main steps.



Step 1 : With the module appropriately powered and grounded, send a 10uS TTL pulse on the TRIG line to start a measurement. Note that at the moment the module is triggered, the ECHO line will be set to high, and remain this way until the final step.


Step 2: The module will emit 8 40khz sound pulses that will interact with the environment, before returning to be received.



Step 3: When a response is received, the ECHO line will be set low again. This means you will have a digital pulse with pulse width equal to the time of flight of the sound wave. Using pulse width measurement you can find this time, and using the speed of sound you can use it to find the distance.





Instructions on how to use Code:


The current iteration of this projects code runs entirely on the FPGA, and is straightforward to deploy and use:


Open the project





Note: all pins used in this project are on the connector C side of the myRIO



The pins used in the project and their purpose are as follows:


Pin 11 - DIO0 - Echo line for sensor 1

Pin 12 - DIO1 - Echo line for sensor 2

Pin 13 - DIO2 - Echo line for sensor 3

Pin 14 - DIO3 - Echo line for sensor 4 

Pin 18 - DIO7 - Trigger line for all sensors

Pin 19 - DGND - Digitial ground for all sensors

Pin 20 - 5V - Vcc line for all sensors

Audio out - Speaker output




Required Hardware:



4 x HC-SR04 Ultrasound Sensors

Plastic pipe or similar to make arc

Velcro to attach sensors

Speaker for sound output (3.5mm Jack for myRIO audioout)

Wire to connect modules to myRIO

Stripboard - putting the modules on stripboard makes it easier to wire the lines through multiple modules.



Code snippet:



To learn more about myRIO, visit the National Instruments website, where you can find information about the device, addons, courses and more.

Matt H
Applications Engineer
National Instruments UK
Member TG2

Hi, This project is really cool!

I have a HC-SR04 too, but I do not have a MYRIO. I have an NI USB-6211.

How can I reach a similar results? Is it possible with 6211?

Thanks Your reply!

NI Employee

Hi TG2,

My example uses the onboard FPGA for manual PWM, and therefore is rather

specialised to the myRIO. I believe this example uses a multifunction DAQ

card, but you will need two onboard counters to acheive this.

Kind regards,

Matthew Hutchinson

Applications Engineer

National Instruments UK & Ireland

Matt H
Applications Engineer
National Instruments UK
Member TG2

Hi, Thanks Your help, it is working well!

Member salimnitk


is this code working?

Member salimnitk


please give me front panel view and provide some information how to initialize input and output in this project.

Member zulfad88


Thank for this tutorial.. i had done this project on myclass and it work very well..