DAC R-2R voltage follower and low pass filter

Thread Starter

rfpd

Joined Jul 6, 2016
101
Hey there, I'm using an arduino to take as an input a square wave, calculate the frequency and reproduce a sine wave with half the frequency. I didn't get it to work, I even put it through 3 RC low pass filters (after the voltage follower), and the signal was still a litlte fuzzy, like I was doing it to a square wave. Why isn't the sound clear?

About the voltage follower, I understand that it's made to limit the current, since the R-2R (in some scenarios?) would have low impedence, I just don't get how it affects the signal. Is it just a current limitator, or does it have any influence in the signal?

I'm using 4.8k and 10k resistors.
And this is my sine lookup table.
 

Thread Starter

rfpd

Joined Jul 6, 2016
101
No attachment(s)?
I put a spoiler, guess it didn't show.

Here it is:

unsigned int sinw[85] = { 128,137,146,156,165,174,182,191,199,207,214,220,227,232,238,242,246,249,252,254,255,255,255,254,253,251,248,244,240,235,230,224,217,210,203,195,187,178,169,160,151,142,132,123,113,104,95,86,77,68,60,52,45,38,31,25,20,15,11,7,4,2,1,0,0,0,1,3,6,9,13,17,23,28,35,41,48,56,64,73,81,90,99,109,118};

I tried using various samples, I guess I couldn't use a lot of them, or it would come out a triangle wave.
 

Thread Starter

rfpd

Joined Jul 6, 2016
101
Why not use a flip flop to divide frequency........then filter to sine.
Tried that, using a 3 stage RC filter, the signal would get muddy and not well filtered, the best I could do was using an integrator and then a 2 stage RC filter, it wasn't clear aswell.

Btw, from my research the low pass filter used is an inductor and a capacitor, perhaps that's my problem, I just read 'low pass filter'.
 

crutschow

Joined Mar 14, 2008
23,378
What does the signal look like at the input to the filter?
Are you using a lookup table to generate the sinewave with the DAC?
 

Thread Starter

rfpd

Joined Jul 6, 2016
101
What does the signal look like at the input to the filter?
Are you using a lookup table to generate the sinewave with the DAC?
I'm using this 8 bit lookup table, I just measure the time of the wave and divide it by 85 so that I can delay that between each sample. It's tracking well, but it's fuzzy.

unsigned int sinw[85] = { 128,137,146,156,165,174,182,191,199,207,214,220,227,232,238,242,246,249,252,254,255,255,255,254,253,251,248,244,240,235,230,224,217,210,203,195,187,178,169,160,151,142,132,123,113,104,95,86,77,68,60,52,45,38,31,25,20,15,11,7,4,2,1,0,0,0,1,3,6,9,13,17,23,28,35,41,48,56,64,73,81,90,99,109,118};

EDIT: I don't know how it looks, I don't have any osciloscope
 
Last edited:

crutschow

Joined Mar 14, 2008
23,378
So when you say the signal is "fuzzy" that's the sound of the signal through a speaker?

Without an oscilloscope it's difficult to determine the problem.
 

Thread Starter

rfpd

Joined Jul 6, 2016
101
Tried with 256 samples and 512, signal fuzzy aswell, using this java function to produce the samples:


int i = 0;
while(i<512){
int a = (int) ((int) 128*Math.sin((2*Math.PI / 512) * i) + 128);
System.out.print(a);
System.out.print(',');
i++;
}


Perhaps I should have mentioned it's a signal in the order of 40-200 Hz.

The signal sounds fine, and it's tracking well, but it sounds fuzzy like the top of it was cut off.
 

MrAl

Joined Jun 17, 2014
6,513
Hi,

It is hard to tell what is wrong without a scope. You can get a low cost ARM based scope these days for less than 30 dollars USD if you dont have to look at signals above about 200kHz.

If the signal is a constant frequency then a bandpass filter works better.
 

Thread Starter

rfpd

Joined Jul 6, 2016
101
Hi,

It is hard to tell what is wrong without a scope. You can get a low cost ARM based scope these days for less than 30 dollars USD if you dont have to look at signals above about 200kHz.

If the signal is a constant frequency then a bandpass filter works better.
Yeah, I work with low frequencies, so I might just buy one. Thanks for the answer.
 

Thread Starter

rfpd

Joined Jul 6, 2016
101
If, as I understand, the DAC is an R/2R ladder then please show how this is connected to the processor.
To the right I have a pre-amplifier and a Schmit-Trigger. Then into PIN 10 of Arduino, the lowest significant bit is on the left, and msb is on the right. I pass it through a voltage follower and then to a high pass filter (big blue cable in the mid), followed by a low pass filter.


This arduino was given to me after a contest, it works just like a normal one.
 

Attachments

MrAl

Joined Jun 17, 2014
6,513
Or for 0USD, 20kHz, https://www.zeitnitz.eu/scope_en

This also includes a spectrum analyser which might be useful for your problem.
Hi,

That's not a bad idea for people who dont want to buy anything and just have to do some low frequency stuff.
I might have to suggest this to other people too, but did you actually try it yet yourself? Wonder what the pros and cons are other than the obvious like limited bandwidth and no isolation between the circuit and computer hardware.

I got one of the smaller ARM based scopes because i needed extreme portability which included battery operation.
 

Thread Starter

rfpd

Joined Jul 6, 2016
101
If, as I understand, the DAC is an R/2R ladder then please show how this is connected to the processor.
Update:

The pins are well conected and the signal is being well produced after the DAC, the problem seems to be the voltage follower. The wave that comes from the DAC oscilates from 0 to 5V, the voltage follower is powered by 5V. Therefore it's clipping the values above 4.48V or so, I mean it makes sense, since it's not linear. The next thing I tried was powering the op amp with a 9 V battery, but as it seems, voltages between a certain threshold (near 0) are being considered as a high voltage on the output. So I tried again with arduino's 5 V, and it happened again, values near 0 get an output of 4.5 V. Anyone knows why? I connected the DAC's output to PIN 3 of the op amp, PIN 2 to 6, and 6 to the rest of the circuit, also 4 to ground and 7 to VCC (TL071).
 
Top