[sdiy] simple octave divider questions/in ARDUINO w CODE

Gordon JC Pearce gordonjcp at gjcp.net
Sat Feb 5 19:43:35 CET 2011


On Sat, 2011-02-05 at 13:27 -0500, dan snazelle wrote:

> I set up the code to label the input and output
> and then I tried dividing the input by 4
> 
> this did not work (on the PWM pin) it seemed to simply decrease the volume

What you're actually doing there is reading in a voltage, and then
setting the output width of the PWM depending on what you read.

Now, the analogue inputs on the AVR go from 0-1023, and the PWM outputs
(typically) go from 0-255.  You'd need to divide by four for the full
scale to fit into the PWM output scale.

You're not actually dividing the frequency though.  You're just dividing
down the amplitude.

To divide the frequency you'd need to detect the incoming frequency and
generate an output at half that frequency.  One way to do that would be
to use the comparator input to detect zero-crossings and use a zero
crossing to trigger a counter.  Every two zero-crossings (or, every
positive-going zero-crossing) you toggle the output pin.

Gordon MM0YEQ




More information about the Synth-diy mailing list