Category Archives: Electronics

Controlling Ultrasonic Piezo Transducer Output with PWM Duty Cycle

For my capstone project at university I am working with a bunch of ultrasonic piezo transducers that require a variable sound pressure level (SPL) output. One way of achieving this is by driving the transducer with a pulse width modulated (PWM) signal and varying the duty cycle. My application actually requires a way of changing the output SPL in a linear manner, so I decided to conduct an experiment to see what the SPL output is with different duty cycles of the piezo transducer I have on hand, the Murata MA40S4S.

The Experiment

To do this, I taped together two Murata MA40S4S transducers together directly. As both of these transducers are specified as transmitting transducers, this was not ideal, but for the purpose of this experiment it will do the job for both transmitting the pulses with varying duty cycle, and measuring the resulting output.

The two MA40S4S piezo transducers taped together.

I connected a Picoscope 2204A’s arbitrary wave generator (AWG) directly to one of the transducers, and the channel A input of the Picoscope 2204A to the remaining transducer. This formed the transmitter/receiver setup.

The transmitter/receiver setup

From there, I found the resonant frequency that resulted in the greatest voltage output from the receiving piezo transducer. To do this, I setup a 2Vpp square wave with a duty cycle of 50% with picoscope’s software, and then slowly sweeped different frequencies around 40kHz. I found that the highest receiver voltage peaked with a driving frequency of 43.9kHz.

The picoscope software setup for creating square waves with different duty cycles and measuring the response

Then everything was simple. I just changed the duty cycle of the square wave and recorded the peak to peak voltage of the receiving transducer.

The Results

The following charts show the measured receiver output when the transmitting transducer was driven with a 43.9kHz square wave signal with differing duty cycles.

Output measured from receiving transducer at different transmitting duty cycles

From these measurements we can see that the greatest output occurs with a duty cycle of 50%. We can also see that as duty cycle is decreased, the voltage output does not decrease in a linear manner. In order to get an idea of how non-linear the transducer is at different driving duty cycles, I made the following chart which displays the ideal and measured response in decibels relative to a duty cycle of 50%.

Transducer response relative a 50% duty cycle

We can see from this chart that the error is significant. If linearity is required in the reduction of SPL output from these transducers when using PWM with a varying duty cycle, some kind of calibration would have to take place. This is especially the case as piezo transducers of this kind often have large tolerances.

The Conclusion

Driving piezo transducers with PWM signals that vary in duty cycle is a great way to reduce SPL output in an easy manner. However changes in duty cycle do not result in a proportional change in SPL output. If linearity is required in this sense, some form of calibration should be performed.

It should be noted that the poor linearity of the results could be influenced by the receiving transducers own non-linearities. Frustratingly this kind of thing is not defined in the Murata MA40S4S or MA40S4R datasheet, but I have no way to know for sure other than by purchasing a decent ultrasonic microphone and performing the same measurements.


How Cold Can a Raspberry Pi Get?

The other day I was discussing with a colleague how cold the CPU of a Raspberry Pi would get if it were left out in the harsh Sarajevian winter. With Sarajevo being the capital of Bosnia and Herzegovina, and my current whereabouts.

He assured me the thing would not get very cold and me being my stubborn self I had to test this out. “If only we had a temperature chamber”, I mused. “A temperature chamber? We are in Bosnia! Our temperature chamber is our kitchen freezer and oven! Let’s just put the damn thing in the freezer”, he retorted. So that is what we did.

The Experiment

This Raspberry Pi had a Tiny Core distribution installed, which is a very cool minimalist distribution particularly well suited for embedded applications that I would recommend to anyone who has the time to learn its quirks. Being only a Raspberry Pi version 2, we had to add WiFi connectivity via a USB dongle, and we powered the Pi with a mobile charger battery. In the end this shenanigan looked a bit like this:

Setup of the great Raspberry Pi in freezer experiment.

After setting up the WiFi dongle driver and getting the Pi to automatically connect to the offices WiFi network at boot up (no easy feat using Tiny Core as a beginner), I SSH’d in to the Pi and used the following very simple Bash command to print out the temperature in Terminal every 3 seconds, and also save it to a CSV file.

while true
    echo "$(date),$(cat/sys/class/thermal/thermal_zone0/temp)"
    echo "$(date),$(cat/sys/class/thermal/thermal_zone0/temp)" >>temp_freezer.csv
    sleep 3



The Results

Keeping in mind that there is not much that is scientific about this test, The Raspberry Pi was kept at around 22 degrees before the test started (measured by a DHT22 sensor from a different project and the room air conditioner read out. After putting the Pi in the freezer, we got the following results.

Results from the experiment.

The Conclusion

After getting these results, we used a mercury thermometer to measure the temperature inside the freezer, which returned around -14 degrees. So, what can we gather from this experiment? A Raspberry Pi will cool in a linear fashion when placed in the cold. The Raspberry Pi CPU resting temperature is not linear when it comes to different ambient temperatures (42c-22c = 20c, 14c-(-14c) = 28c. The Raspberry Pi CPU thermometer has a pretty low resolution, which can be seen by the quantising like spikes in the results.

I am hoping that one day I can repeat this experiment in a controlled environment with a temperature chamber, as well as with the inclusion of other variables such as CPU load. But in the near future I will try and do similar experiments with Raspberry Pi CPU temperature vs CPU frequency. Hope this helps someone who needs to put their Pi in the freezer!