| ??? 02/05/03 01:12 Read: times |
#38289 - RE: Sound sampling for PWM? Responding to: ???'s previous message |
Hi Andy,
I apologize for my bad English. In my previous mail I tried to say using a PWM is very straightforward. Exactly like an ordinary DAC. I shell answer to every sentence. >A "conventional" parallel-output ADC gives you instantaneous samples of the analogue input waveform's amplitude, but for PWM you need to know what pulse width will give the required analogue amplitude at the filter output. No, you don’t! You do nothing. It’s automatically. Take a look to one PWM implementation in an 8051/2 derivative. You will store an word, representing the output tension, in an SFR and this word will be converted in an train pulses with the width proportional with that number. After the low pass filter you will obtain the integral witch is proportional with the number in the SFR. >So, what I was wondering is how do you convert the analogue amplitude samples to pulse widths for the PWM output? The idea is very straightforward. A PWM converter is made of a free counter, a storage register in SFR area( the DAC input) and a digital comparator. For ex. an 8 bit counter, an 8 bit register and an ( 8+8) bit comparator. The overload period of the counter gives the output period of the PWM converter. The comparator compares the counter with the storage register. While (counter<=register) then PWM out is TRUE else PWM out is FALSE. For different register values you will have different width pulses. This schema is almost a standard. I even used to implement it with external discrete components in the past. >I presume there must be a technique to do this directly? (ie, straight to pulse widths, rather than via amplitude samples) You can implement it in an analog way using an sowtooth generator and an analog comparator. One imput of the comparator is put at the signal source and the other to the sowtooth generator. The output of the comparator is exactly the PWM wave. >For the kind of thing I was thinking of - and, I think, for Waqar's Big Ben project - the generation of the PWM data could be done "off-line" (eg, on a PC); it wouldn't need to be done by an 8501. No ! You store the sampled chime of the clock (according to the Nyguist criteria) in the memory and move them right to the PWM DAC’s register (in SFR area) You have to calculate nothing in a PC or elsewhere. You can use the PWM like an ordinary parallel DAC. You can use this technique for music as for voice playing. For voice only I advice you to use another technique called ADPCM for a 1:4 compression af the signal. This ADPCM is also relatively easy to be implemented in an 8051/2 . If you have any question please ask me. Best regards, Cristian |



