rev counter with DAC

kpg:
There is no code for the bar graph driver.

Then we have been misunderstanding each other. In Reply #6 I asked if the bargraph is driven by the Arduino (meaning an Arduino program) and I understood your Reply #7 to mean that you did have a bargraph program on your Mega.

...R

The cct is attached.

The signal input pin is driven from the Arduino PWM output pin through the RC filter (2 k in series and 0.1uf to ground).

I will get a scope on it tonight to try and work out what voltage I am seeing and how smooth it is.

Hopefully I am using the right RC for the PWM frequency range.

Thanks

Hopefully I am using the right RC for the PWM frequency range.

Here is the link to the filter design tool

http://sim.okawa-denshi.jp/en/PWMtool.php

2K and .1uf is not good for the 500Hz pwm You will need a much higher frequency for those values, or else you will need larger values of r/c.

You will need to keep ripple down below the level which will illuminate higher and lower leds on the bar graph.

I managed to get a scope on it tonight.

Images attached.

First is the straight PWM image out of the Arduino.

2nd is after the filter. Filter is 2k in inline with 0.1uf to ground.

Peak volts of the RC output is about 1/2 the PWM signal.

I can see it working as PWM changes but it isn't really a clean voltage level (with small amount of ripple).

Wish I knew more about RC theory!!

Any guidance?

Thanks

Hi,
Try a 1.0uF cap instead of the 0.1uF.

Tom... :slight_smile:

As Tom says, increase the capacitance. However, at 500Hz you will still have significant ripple. I would recommend that you raise the pwm frequency on Timer 4 (controls pwm on pin 7) from the default value up to 31.4K by changing the prescaler to 1.

Add this line at the end of setup.

TCCR4B = TCCR4B & B11111000 | B00000001;    // set timer 4 prescaler to 1 for PWM frequency of 31372.5 Hz