Using an ADC with a PIC to build PWM wave - diyAudio
Go Back   Home > Forums > Amplifiers > Class D

Class D Switching Power Amplifiers and Power D/A conversion

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 18th November 2008, 09:05 AM   #1
jocthbr is offline jocthbr  Brazil
diyAudio Member
 
Join Date: Nov 2008
Lightbulb Using an ADC with a PIC to build PWM wave

Hi people...

First of all, excuse my english. I'm brazilian, and I don't know english very well...

But, I asked my self a thing about Class D amplifiers: Would a PIC microcontroller and an ADC converter make the work of generating the PWM wave for the mosfets?

I just imagined this, and searched it on the internet, but didn't find anything about...

The only thing I found was the price of an ADC for 16bit and high sample rate... VERY EXPANSIVE!

Do you know any low cost ADC with 16bit and good sample rate?


I hope you help me!

=)

thanks!
  Reply With Quote
Old 18th November 2008, 12:26 PM   #2
Eva is offline Eva  Spain
diyAudio Member
 
Eva's Avatar
 
Join Date: Oct 2003
Location: Near the sea
Send a message via MSN to Eva
Have you considered an analog modulator?

The PIC won't be up to the job anyway, data volume is too high.
__________________
I use to feel like the small child in The Emperor's New Clothes tale
  Reply With Quote
Old 18th November 2008, 02:50 PM   #3
diyAudio Member
 
Join Date: Aug 2005
Send a message via Yahoo to trilobugz
Yes, a PIC microcontroller and an ADC would work in creating PWM for Class D amplifiers but, designing it to work properly would be very hard to achieve. Considering the complexity of Class D amplifiers, it would take you months or maybe years to finished it with that kind of approach.

If you are concerned of the price, try obtaining free samples from semiconductor companies like Texas Instruments. They have chips that are designed for Class D amplifications for audio.
  Reply With Quote
Old 18th November 2008, 03:57 PM   #4
Gyula is offline Gyula  Hungary
diyAudio Member
 
Gyula's Avatar
 
Join Date: Feb 2004
Location: Kunszentmárton, Hungary
Send a message via Yahoo to Gyula
Hi jocthbr!

PIC is c r a p for this purpose. It can multiply very slowly and the clock frequency is also low-end. You can't make a good resolution PWM. And You will get to nowhere in quality with UPWM.
Try using FPGA. You don't have to learn any instruction set or something like that. You should only know digital logic and digital signal processing, so you should only know what you want to do. For example Xilinx enabled to download free evaluation version of Xilinx System Generator for DSP, what is a MATLAB Simulink-based tool for FPGA signal processing. You can make your hardware from blocks down to logic elements. You can do anything with that. Then you can simulate your design bitwise with Simulink. Simulate your filters and control loops exatly, make any nonlinear model of the analog environment, make FFT or whatever you want. Then the whole design is compilable to your FPGA board and uploadable through JTAG. For example a Xilinx XC3S400 contains 16 pieces of 18x18 bit ~5ns cycle time multipliers, ~7168 registered configurable logic, 36 kbytes of zero-latency SRAM, four high-frequency PLLs, huge number of I/O ports. For example signal processing with this basic one is possible up to ~100 MHz clock assuming <= 64 bit word-length adders between two register-fields. For audio frequency range you can make 2048-tap 18-bit coefficient FIR filter with only one multiplier unit, or 16 pieces of 128-tap or etc. I think even 10000 PIC couldn't do what this can if all units would be utilized. And it's only a single basic FPGA IC for a few $s.

Regards,
Gyula
  Reply With Quote
Old 18th November 2008, 06:09 PM   #5
jocthbr is offline jocthbr  Brazil
diyAudio Member
 
Join Date: Nov 2008
yeah...

it makes the question go harder..

I could use a FPGA, but I don't have any knowledge about them...
I'm not looking for a high-end Class D amplifier...

For me, it's enough a low-frequency (like 10 to 2000hz) class d amplifier...

Do you know any other efficient way to make a simple class d amplifier?
  Reply With Quote
Old 18th November 2008, 06:41 PM   #6
Gyula is offline Gyula  Hungary
diyAudio Member
 
Gyula's Avatar
 
Join Date: Feb 2004
Location: Kunszentmárton, Hungary
Send a message via Yahoo to Gyula
Maybe other diyer's have more experience about analog Class-D than me. I have already done only analog switching-mode PSUs but not switching-mode amps. Eva and Fredos are very skilled on that field. Maybe they are the brightest on this forum. They have much more experience about analog switching-mode instruments than me.

Gyula
  Reply With Quote
Old 18th November 2008, 08:15 PM   #7
diyAudio Member
 
darkfenriz's Avatar
 
Join Date: Jun 2004
Location: Warsaw
Quote:
Originally posted by Gyula
Hi jocthbr!

PIC is c r a p for this purpose. It can multiply very slowly and the clock frequency is also low-end. You can't make a good resolution PWM. And You will get to nowhere in quality with UPWM.
Try using FPGA. You don't have to learn any instruction set or something like that. You should only know digital logic and digital signal processing, so you should only know what you want to do. For example Xilinx enabled to download free evaluation version of Xilinx System Generator for DSP, what is a MATLAB Simulink-based tool for FPGA signal processing. You can make your hardware from blocks down to logic elements. You can do anything with that. Then you can simulate your design bitwise with Simulink. Simulate your filters and control loops exatly, make any nonlinear model of the analog environment, make FFT or whatever you want. Then the whole design is compilable to your FPGA board and uploadable through JTAG. For example a Xilinx XC3S400 contains 16 pieces of 18x18 bit ~5ns cycle time multipliers, ~7168 registered configurable logic, 36 kbytes of zero-latency SRAM, four high-frequency PLLs, huge number of I/O ports. For example signal processing with this basic one is possible up to ~100 MHz clock assuming <= 64 bit word-length adders between two register-fields. For audio frequency range you can make 2048-tap 18-bit coefficient FIR filter with only one multiplier unit, or 16 pieces of 128-tap or etc. I think even 10000 PIC couldn't do what this can if all units would be utilized. And it's only a single basic FPGA IC for a few $s.

Regards,
Gyula

Hi

What kind of class D amplier using FPGA do you have in mind?
Open loop?
Clocked with feedback from ADC?
What is the use of FIR filter in a class D design?

Regards,
Adam
  Reply With Quote
Old 18th November 2008, 10:36 PM   #8
Eva is offline Eva  Spain
diyAudio Member
 
Eva's Avatar
 
Join Date: Oct 2003
Location: Near the sea
Send a message via MSN to Eva
To Jonathan:

It seems that you got the concept all wrong. You don't need any ADC or digital processing to produce a class D amplifier. Operational amplifiers and comparators are enough.
__________________
I use to feel like the small child in The Emperor's New Clothes tale
  Reply With Quote
Old 18th November 2008, 11:05 PM   #9
Gyula is offline Gyula  Hungary
diyAudio Member
 
Gyula's Avatar
 
Join Date: Feb 2004
Location: Kunszentmárton, Hungary
Send a message via Yahoo to Gyula
Hi darkfenriz!

I made my thesis about a fed-back Class-D amplifier. It utilized a 2-DOF controller embedded in Smith-Predictor structure. The control loop also contained feedforward Power Supply voltage compensation and drove a linerized and noise-shaped PWM modulator. The main innovation was in the feedback which cancelled the transposed carrier sidebands in the audible range.
The input ADC was a PCM4202. The output and PSV ADCs were two ADS8422s driven with OPA1632s. It had lower distrortion with feedback than open-loop.
There were 2 pieces of 2x FIR interpolators from the 99MHz/1024 input sample rate to the 99MHz/256 PWM carrier. There was also a 256x CIC interpolator for the PWM linearization. Later I wondered about phase-linearization of the fed-back system with the interpolator filters but I haven't do that because lack of time.

A short P.S. to jocthbr:
I made an analog-input based digital Class-D amp like you are planning to do few years ago, not with PIC but with Flash-converter and counters. The main problem for these low word-length PWMs comes from the quantization. Which happens at the input ADC and the output PWM as well. For low-frequency or low-amplitude audio signals the signal will remain in the same quantization step for two or more samples. Let's make a simple modelling of the quantization with adding an error signal to the unquantized audio. Then the error signal is the difference between the exact input and the derived quantization level. Consider this you can see the error signal is wrapped to the quantization step range, and when the audio signal reaches the next quantization level it falls to zero. If the audio signal remains in the same quantization step range for more than one samples the randomization effect between the sample values caused by the wrapping will not happen and the samples will be deterministic (correlated), will depend on the input signal. This causes the noise spectra become lined and means there are high energy frequencies what relates to periodic components in the time-domain. Periodic noise is very well audible and can be annoying as well. This means that you will always hear hissing with low-frequency or low-amplitude input. In order to cancel this effect after the input ADC you should do dithering what I don't want to describe now, but I will if you want me to do. At the PWM modulator for the cancellation you should apply noise-shaping which means feed back of the difference of unquantized and quantized audio signal to the PWM input through a simple filter. Assuming good linearity for the PWM the quantized audio signal is simple to make with trucation to the PWM word length. And the difference of original and the truncated signal will represent the added error signal multiplied by -1 in the former linear model of additive noise. Expand this model with a few taps of delayed error values and you will get the noise-shaper filter with the first tap fixed to -1 value. Now the model with the filter not only adds an error signal to the audio but adds a filtered error signal to that. You can set the noise spectra with the taps' coefficient set amplitude characteristic of this noise-shaper filter. For real zeros on the unit circle of z-domain the tap coefficients have to be integer values what makes the multiplications reduceable to a few bit-shift and add operation even if those are not integer power of 2. The zeros should be set to the audible range what is around z=1 and maybe few of them are practical to be set to Fs/2 in order to reduce the noise power of high-order noise-shaper filters. The price of the fixed first coefficient is the largest deal with the noise shaping and it comes from the impulse energy of the filter is always greater than 1 because of the integer coefficients greater than or equal to 1 in absolute value. This means the filter always enlarges the noise power apart from the good attenuation around z=1 what is a benefit in at about the f<=Fs/20 range. This causes Fs/20 should be higher than the audible frequency range and you can only hope your speakers are linear enough not to transpose the higher frequency noise components to the audible range. Or you have to use steep, high-order demodulation filter after the PWM in order to attenuate the noise power in the audible range, and this filter will also have large phase-shift. You have to consider if a PIC can do it or not. I think it's on the edge of it's capability because of the possible high Fs and word length larger than 8-bit. And it does almost nothing with this task. There's no feedback with regulator, no linearizer for the PWM, no volume control. It can do almost nothing. Only a litter of somehow PWMed something.
So I think a simple analog Class-D can perform much more better.
  Reply With Quote
Old 19th November 2008, 09:54 AM   #10
Pafi is offline Pafi  Hungary
diyAudio Member
 
Join Date: May 2004
Location: Budapest
Gyula!

From where did you fed it back?
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Full wave or half wave rectification help! HaLo6 Digital Line Level 1 26th March 2009 01:14 AM
Sine wave - Square & Triangle wave generator using Transistors / OP-Amps lineup Solid State 20 9th October 2006 12:15 AM
Microphone turns triangle wave into square wave? Circlotron Analogue Source 18 25th January 2003 06:44 AM


New To Site? Need Help?

All times are GMT. The time now is 03:49 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright ©1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2