Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > General Electronics Chat


General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion?

Reply
 
LinkBack Thread Tools Display Modes
Old 4th November 2006, 06:22 AM   (permalink)
Default Microcontroller Music - Harmonic Distortion.

I was recently trying to get an AVR play music. I successfully managed to get the AVR playing 3 octaves from about 130Hz to about 2KHz. However, the output from the AVR is a square wave, which results in a vary harsh sound from the speaker.

I was using the LM380 Power amplifier.

There was a strange thing that I noticed. The power amplifier gave sound output when the input voltage was below 20mV p-p. However, there was no sound output when the input voltage was increased. Then Again there was some sound heard when the input was directly fed from the AVR (0-5v) to the LM380.

How do I get a lower distortion sound from the AVR?

Please Help... :-(
__________________
Bharath Bhushan Lohray.
M.Sc. Electronics.
lord loh. is offline  
Old 4th November 2006, 09:44 AM   (permalink)
Default

Quote:
Originally Posted by lord loh.

How do I get a lower distortion sound from the AVR?
You don't, you add a lowpass filter between it's output and your power amplifier, this helps to reduce the harmonics - even better if you have one that can be adjusted for the particular note you're playing in real time.

You might consider using a digital to analogue converter?, and outputing sinewaves instead of square, but you still need a low pass filter anyway.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 4th November 2006, 11:16 AM   (permalink)
Default

If you're just using squarewaves then you don't need an audio amplifier, a simple complementary pair of MOSFETs acting as a push pull buffer will be far more efficient, add a simple low-pass filter and you have a little class-D amplifier.
__________________
I also post at the following sites:
http://www.stop-microsoft.org http://www.heated-debates.com
Screen name: Aloone_Jonez
And http://www.silicontronics.com, same screen name as here.
Hero999 is offline  
Old 4th November 2006, 11:26 PM   (permalink)
Default

If you don't like distortion then don't play square-waves.
A square-wave with the same p-p amplitude as a sine-wave has twice the power of the sine-wave. So the harmonics of a square-wave have the same amount of power as the fundamental sine-wave of the square-wave.
__________________
Uncle $crooge
audioguru is offline  
Old 5th November 2006, 04:48 AM   (permalink)
Default

Use hardware PWM for audio on an AVR. The higher the PWM frequency the better. Using a tiny15 you can use it's high speed PWM to generate a 100khz square wave at 8 bits resolution for the duty cycle, passing the output through a lowpass filter with a cutoff frequency of about 20khz will give you moderatly acceptable output. Using a scheme like this you'll likley be able to get a 'clean' signal at 1/8 to 1/16th of the driving frequency (100khz) So for a 100khz PWM signal you're not going to get a clean output much above about 5khz.. That's at the upper limits of what an AVR can do.
Sceadwian is offline  
Old 5th November 2006, 06:14 AM   (permalink)
Default

The LM380 seems to have a fixed voltage gain of 50. Chances are that when you drive the chip directly it's going into some weird nonlinear/saturation. If you were to scope out the waveforms, they probably wouldn't make too much sense.

A small D-A converter is probably the best bet. That with DDS (google it) will probably give you some reasonable results.
hjames is offline  
Old 5th November 2006, 03:28 PM   (permalink)
Default

Years ago I heard 8-bit long distance telephone calls. The quality with voice was horrible. I don't want to think about music like that.
__________________
Uncle $crooge
audioguru is offline  
Old 5th November 2006, 07:11 PM   (permalink)
Default

Quote:
Originally Posted by audioguru
Years ago I heard 8-bit long distance telephone calls. The quality with voice was horrible. I don't want to think about music like that.
8 bit audio is fine, if the 8 bit phone was poor it's the system used, and NOT the number of bits. The Commodore Amiga used 8 bit sampled sound, and the audio quality was fine, even through a HiFi system - certainly compared with PC's of the day which didn't have sound at all!.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 5th November 2006, 07:26 PM   (permalink)
Default

8 bits isn't good enough for really hi fidelity music, but only because the dynamic range isn't very good. It's fine for simple waveforms. ulaw encoding can increase the dynamic range but it's not as good as increasing the number of bits. The music you're going to get out of an AVR is never going to be much better than clicks and beeps. It's possible to do simple polyphonic music but the quality will never really be very good.
Sceadwian is offline  
Old 5th November 2006, 11:35 PM   (permalink)
Default

It's easy to hear what 8-bit is like just by convering an audio file on your PC to 8bit 44.1khz stereo wav. I expect with a lot of modern, extremely compressed music, it wouldn't even be that evident!
__________________
Angry!? I'm absolutely electrolytic!

Will have to make do with myspace now I guess...
Dr.EM is offline  
Old 6th November 2006, 09:42 AM   (permalink)
Default

Quote:
Originally Posted by Dr.EM
It's easy to hear what 8-bit is like just by convering an audio file on your PC to 8bit 44.1khz stereo wav. I expect with a lot of modern, extremely compressed music, it wouldn't even be that evident!
No it wouldn't, the Amiga's 8 bit audio was quite satisfactory, and probably better than most car stereos?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Old Distortion Analyzer and Audio Analzyer walters General Electronics Chat 50 28th January 2006 02:17 AM
Connection of Siemens c167 microcontroller to peripherals. Roslan Electronic Projects Design/Ideas/Reviews 3 23rd March 2004 07:52 PM
The ultimate distortion measurements Vladimir_K Electronic Projects Design/Ideas/Reviews 0 29th February 2004 05:03 PM



All times are GMT. The time now is 12:42 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

eXTReMe Tracker