[PD] Re: [PD-announce] PWM in Pd

Martin Peach martinrp at alcor.concordia.ca
Fri May 26 17:25:09 CEST 2006


Hans-Christoph Steiner wrote:
> 
> On May 25, 2006, at 7:24 PM, Martin Peach wrote:
> 
>> Hans-Christoph Steiner wrote:
>>
>>> I should say, I forgot that PWM was used in synthesis some, so I  
>>> was  thinking about electronics and control when I was talking  about 
>>> PWM.   That's why my PWM objects are tailored towards, but  should 
>>> work fine  in the audio context too, unless you need the  wandering 
>>> DC offset.
>>
>>
>> For controlling things with PWM I think you'll need to modify your  
>> sound card if you want DC output. AFAIK they all have capacitors on  
>> the ouput to block DC. I find it easier to program a PIC to do the  
>> PWM and talk to it from PD using MIDI continuous controller  messages 
>> for 14-bit resolution, or noteon with velocity meaning  pulsewidth for 
>> 7-bits.
> 
> 
> No, you don't need DC at all with PWM, unless you call the HIGH  section 
> of the pulse DC.  But since that section lasts in the range  of 
> milliseconds to microseconds, I think its safe to call it AC. ;)

Actually for digital electronics you need to have signal levels that are 
very close to zero and the positive supply, anything in between causes 
undefined behaviour and can destroy the device. If a motor driver is 
switched on halfway it's output transistors will probably burn out. 
(power = current squared times resistance; when the transistor is fully 
on, its resistance is near zero, when it is off the resistance is near 
infinite, ideally no power is dissipated in the device. In-between 
states dissipate too much heat)

> Actually the audio range of 20-20,000 is a good working range for  cheap 
> PWM.  High-quality PWM is much higher frequency.  The Atmel  ATMEGA8 in 
> the Arduino, for example, has three hardware PWMs which  operate at 
> ~30kHz.  That means in order to ensure its a real square  wave, it has 
> to have a frequency response that covers much higher  that 30kHz.

As a digital chip the atmel has a frequency response in the hundreds of 
MHz. The hardware PWM is just a digital counter and a digital 
comparator. It clocks at some subharmonic of the system clock frequency. 
If it's a 10-bit pwm it needs to clock at around 30MHz to have full 
resolution.
(30kHz*1024)

> 
> The question I wonder about when using a sound card to output a PWM  
> control signal is whether you can reliably get a positive-only  voltage 
> range, and not the usual -1 to 1 of audio.

The voltage range is determined by your output amplitude, and always 
tends to be symmetric about zero because of the output capacitors.
If you can hack your soundcard, take the output right at the dac and 
buffer it with an op-amp. Then you can use DC levels.

Martin

> 
> .hc
> 
> ________________________________________________________________________ 
> ____
> 
>                   ¡El pueblo unido jamás será vencido!
> 
> 
> 





More information about the Pd-list mailing list