Fast PWM output

I am working on a little synth that has a low pass filter and for controlling it I need a “controlled voltage” output and also I want to reflect the value on a led.

I stole from an example this line and adapted it for my use so I can send the CV output, also I added another one for the LED output.

(red_count++ >= r) ? PORTD &= ~(1 << 3) : PORTD |= (1 << 3);
(red_count++ >= cutoffLed) ? PORTD &= ~(1 << 5) : PORTD |= (1 << 5);

red_count is always zero, it’s there because the example I used. I really don’t know how this works and don’t understand any of the fast pwm tutorials.

Well, it works…the problem that I have is that if I only use one of the line each works perfectly. But using both you can see the led flashing and also you can feel it’s a very “stepy” output, I mean there should be intermediate points between two values when turning the pot but it jump from one to another, it’s like you have only 10 different output values both on LED and on CV output.

I think it’s because Arduino it’s being overused as it does a lot of calculations so it can keep up with both outputs.

I wanted to try getting an output from a different PORT PIN, for example PORTB, pin 8… but cannot manage to get the line that does it. How can I do that?

Thanks!

The trick would be to put the led on the same pin as the "controlled voltage" , than it's done. Use PWM (analogWrite()) to get your PWM and an RC filter to change thib to a voltage.

Mark

holmes4: The trick would be to put the led on the same pin as the "controlled voltage" , than it's done. Use PWM (analogWrite()) to get your PWM and an RC filter to change thib to a voltage.

Mark

I understand, the thing is that the CV output gets full range on the pwm values between 40-68. Then the led doesn't really shows too much difference on those values

CV output gets full range on the pwm values between 40-68

???

Mark

sorry, I meant that the "levels" of PWM output needed at the CV output are only between 40 and 68, if the CV output value goes higher (or lower) than that doesn't do anything