Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Biphonic Sound: Without a DAC?

Status
Not open for further replies.

DigiTan

New Member
I have a couple of sound-related questions...

I'm doing a short experiment with a Z80 processor to see if it is possible to create biphonic music directly from a TTL signal. The speaker would be attached directly to the I/O port, with no D->A conversion or filtering. Anotherwords the sound depth is 1-bit. Basically, I would have the music is stored as a string of note/volume/duration parameters within the program memory, and then play the tones in sequence or in pairs.

My conserns are volume and distortion. I want to be able to limit the volume using PWM. The idea seems to work for optics, but does it work for sound too? Also, since it can only produce rectangular waves, I am conserned that the two melodies will collide and annihilate each other most of the time rather than adding or subtracting from each other like in nature. If I use PWM, will this distortion be limited at all?
 
Hi DigiTan,
Maybe you want to do the same as class-D switching audio amplifiers. They have a special serial data input and the output is audio with many "melodies", which are all the musical instruments in an orchestra and all the harmonies they are playing. They use PWM for volume.

The switching is performed at a high frequency (150KHz to 500KHz) so you can't hear it but the inductance of a loudspeaker isn't enough to limit the switching current through it, resulting in wasted power. An LC filter is placed between the amplifier's output and the speaker to eliminate the wasted power.
Their distortion is about 0.1% to 0.5%, not bad but not yet as low as linear amplifiers (0.05%).
Their efficiency is about 90%, allowing a surface-mount IC to deliver 20W without a heatsink (but the power-pad base is soldered to the ground-plane).
 
Would it also be possible to achieve some PWM volume control using only an 8-ohm speaker with no preconditioning? What exactly is the relationship between pulse width and volume?
 
DigiTan said:
Would it also be possible to achieve some PWM volume control using only an 8-ohm speaker with no preconditioning? What exactly is the relationship between pulse width and volume?

Assuming you're talking about class D (PWM amplifiers) there is no relationship - the relation ship is between CHANGE of pulse width and volume. A constant pulse width only outputs a DC voltage.
 
So if I were to send a square wave with a 50% duty cycle to the speaker, would it have a greater volume than one with a 5% duty to the humar ear? (Without any amplification)
 
Hi Digitan,
Are you pulse-width modulating an ultrasonic carrier like in a class-D amplifier, or are you just making a variable frequency and variable volume buzzer?
If you change the pulse width of a buzzer it will sound different. A 50% square wave doesn't have any even harmonics, all harmonics are odd (3rd, 5th, 7th etc). An assymmetrical wave has even harmonics (2nd, 4th, 6th etc) and if square-topped also has odd. So just the tonal quality will change, not the volume. When the pulse becomes extremely narrow the speaker and your hearing won't respond as well so its volume will diminish.
 
audioguru said:
Hi Digitan,
...or are you just making a variable frequency and variable volume buzzer?

Ah, yes! I guess that's a perfect description of what I had in mind! :lol: The circuit is a TI graphing calculator connected to a set of stereo headphones. So basically, it's just a MCU pin driving a speaker. It's been done before, the loudness is defening unless your phones have a variable resistor built-in, so I was hoping to limit it somehow.

So I guess what you're saying is that any duty cycle besides 50% will generate side-tones. Does that mean if I did a 100Hz signal at a 25% duty cycle, I would begin to hear 50 and 200Hz as well?
 
Hi Digitan,
That's why the sound of a square wave or any other flat-topped wave (including electric guitar "fuzz") is descibed to sound like a buzzer.
The harmonics are never lower than the fundamental frequency.
Your 25% duty cycle 100Hz signal of course will contain a strong 100Hz fundamental frequency but also many harmonics whose amplitude drops off with their frequency. The harmonics will be 200Hz, 300Hz, 400Hz, 500Hz, 600Hz etc., at multiples of 100Hz all the way up.
With an exact 50% duty cycle the harmonics of a 100Hz square wave will be only 300Hz, 500Hz, 700Hz, 900Hz, 1100Hz etc., only at odd multiples of 100Hz.

Do you like listening to "square waves"? I didn't think the output of an MCU could provide enough current to drive headphones very loud. You could limit the volume by simply connecting a resistor or pot in series with the headphones or as a voltage divider. Headphones don't require the damping of a direct amplifier connection like speakers do.
 
I guess that would explain why I could still hear so many harmonics when I was still using a 50% duty cycle. Anyway, the port drives the earphone pretty well -- using a bipolar transistor to pull the signals away from the TTL noise margins. The hardware guides says it uses SMT resistors as artificial fuses, but what the exact current limit is, I'm not certain.
 
Alright, I took audioguru's advice on making the pulses extremely narrow and so far it works. Instead of using square waves that are up to 61 milliseconds long, I play back every wave as a group of micro-pulses that are only 2.167 microseconds long. Those pulses are well out of the human hearing range, so your ears hear the groups of pulses and not individual ones. Widening the pulses also increases the volume significantly.

If my guess is correct, the program can create 27 levels of volume this way, without introducing additional components. The 2.5mm headphones plug directly into the data link port.

Here are some simulations that came from a TI-82 emulator. Note: the second recording was noise-reduced but is still loud...

* Original Audio :Sonic the Hedgehog 3 (1994)
* TI-82 Output (squarewave method) [LOUD!]
* TI-82 Output (pulsed method) [Very quiet]
 
thats pretty cool.. does your TI 82 eat batteries like mine does.. it gets so bad that i have to take them out if i dont want them to get depleated..
 
Hi Digitan,
Ouch! I was right. You do like to listen to square waves and are trying to re-invent the class-D amplifier.
Go to www.ti.com and check their class-D audio amplifiers. They are so good now that most people can't tell that they are digital.
TI has combinations of a few ICs that are digital all the way from the disc to the speaker and screen.
 
Last edited by a moderator:
Your 25% duty cycle 100Hz signal of course will contain a strong 100Hz fundamental frequency but also many harmonics whose amplitude drops off with their frequency. The harmonics will be 200Hz, 300Hz, 400Hz, 500Hz, 600Hz etc., at multiples of 100Hz all the way up.
The harmonics divisible by 4 will be missing
 
Thanks, Fried.
I forgot Nyquist and FFT theory. Like the 10-stepped sine-wave generator I built. It has no harmonics up to its 9th. The 9th and 11th are pretty strong but the 10th is missing. It was easy to filter the steps and get very low distortion.
 
I'll be sure to check out those Class-D amps and maybe apply them to the sound project somehow. I might begin searching for some hardware to get rid of those upper harmonics, or at least smooth out the waveforms a little bit.

williB said:
thats pretty cool.. does your TI 82 eat batteries like mine does.. it gets so bad that i have to take them out if i dont want them to get depleated..

Mine's, not too bad with the batteries, but that might be because it's one of the older models on that series. Someone approached me about the battery situation a while ago so I made a little power augmentor circuit to allow for larger AA batteries to be used. Now, I can get about 22-24 hours battery life out of it, and it even graphs a little faster than before.
 
Say, I'm having some trouble figuring out where this background noise keeps coming from. I tried sending a constant stream of 1's to the program to see if I could hear anything if I played it at the normal 8000 samples/sec on my TI emulator. I found the greatest noise occoured in the 3,200Hz part of the spectrum and not 8,000Hz or ultrasonic region like I was expecting. If the audio pulses are only 2.167us wide, shouldn't most of the noise occour at 8,000 or 461,467Hz? Or could my emulator producing this low noise becaue maybe it can't emulate 461KHz?
 
Hi DigiTan,
You shouldn't have any noise without modulation. Your emulator is probably randomly varying the width of the pulses. Then the 8KHz carrier will be randomly modulated, creating noise.
 
D'oh! I guess it's out of the frying pan; into the fire. :lol:
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top