DAC as digital attenuator

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

DAC as digital attenuator

Post by Jan Lichtenbelt »

DAC will mostly be used to convert a byte or integer into an analogue signal. The analogue signal can mostly be any value between the power supply voltages 0 and 5 Volt. However, instead of the 5V also an external Vref can be chosen. So far it sounds familiar.

But you know, Vref can be a signal between 0-5Volt, not only dc but any signal. Most DACs are just a number of resistances in series, see scheme. By changing the byte of the DAC Vref will be connected to one (or more) of the resistances with result that the Vref will just be attenuated at the output.
P1070090_tt.jpg
P1070090_tt.jpg (34.88 KiB) Viewed 5197 times
I started with a sinus signal top-top between 0-5 Volt. In the two scope pictures you see both input (larger sinus) and output of the DAC (smaller sinus). Youtube movie shows the output as with variating of the byte value of the DAC (5 bits for 16F1847).
https://www.youtube.com/watch?v=1XD8VF9WPvQ
P1070085_t.jpg
P1070085_t.jpg (43.84 KiB) Viewed 5197 times

P1070092_t.jpg
P1070092_t.jpg (42.81 KiB) Viewed 5197 times
Jan Lichtenbelt

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

DAC as digital attenuator II

Post by Jan Lichtenbelt »

Please find the flowcode 7 attached.
DAC_as_Digital_attenuator_V1.fcfx
(8.19 KiB) Downloaded 346 times
Jan Lichtenbelt

User avatar
petesmart
Valued Contributor
Valued Contributor
Posts: 395
Joined: Thu May 06, 2010 11:42 am
Location: Sydney, Australia
Has thanked: 187 times
Been thanked: 140 times
Contact:

Re: DAC as digital attenuator

Post by petesmart »

Very clever Jan.... Thanks for sharing

Best

Pete
sorry about that Chief!

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: DAC as digital attenuator

Post by Benj »

I hadn't thought about using a varying signal into VRef+, great idea. :D

I guess you could use a similar approach for something like volume control. The DAC outputs the signal and you can use a pot to control the voltage to VRef which scales the output.

Very cool, thanks for sharing.

Post Reply