Go Down

### Topic: best solution for 12 analog outputs (5 bits) (Read 7421 times)previous topic - next topic

#### Oldchatterman

##### Oct 18, 2012, 01:53 pm
My project involves setting 12 voltage levels at 12 analog inputs of a controller.
The required levels are:
0V < L0 < 0.425V < L1 < 1.266V < L2 < 1.961V < L3 < 2.514V < L4 < 3.205V < L5 < 4.027V < L6 < 5V

The analog inputs of the controller use voltage dividers with 15 kOhm to 5V and 15 kOhm to GND.

My requirements:
-   Low cost
-   Small area
-   Pin through
-   Voltage levels are fixed (used for initialization of the controller)
-   Steady state < 1 s

I investigated a solution with 3x TLV5620 DAC to have 12x 8 bits DAC channels, test results:
-   I chose the wrong DAC, this DAC is not able to sink current, so it was not able to reach the levels below L3.
-   I can look for a DAC that can sink more current
-   I can look for a DAC that can source more current and lower the base level by an additional resistor to GND

The DAC's I can find are:
-   Expensive
-   SMD

So I decided to investigate a different solution:
-   PWM (frequency=490Hz)+ RC filter (eg R=1 kOhm, C=47 uF)

This seems feasible for me. Only the capacitor is a bit big.

I can user a smaller capacitor when using a higher PWM frequency. Therefore I was thinking: what would be the best solution when I want to have 12 PWM outputs with fixed duty cycle at high frequency (e.g. 20 kHz). I only need 32 steps resolution.

Is it possible to pre-program a fixed buffer of 32 bits for each voltage level (L0 to L6) and send the bits, bit by bit to a digital output, by using an interrupt routine?
Is it possible to work with 1 interrupt and write 12 digital outputs each cycle? Is it possible to reach 20 kHz? This is the only task the microcontroller has to do.

#### dhenry

#1
##### Oct 18, 2012, 02:59 pm
You can use a mcu digital-out pin to power a divider. And pick your divider to get the desired output levels.

If you need precision output levels, use the digital-out pins to power a voltage reference and then use the reference to power a divider. This approach requires multiple voltage references.

An alternative is to use 1 voltage reference and then pull a divider to ground with the digital-out pin.

Each approach can be made to work.

#### Grumpy_Mike

#2
##### Oct 18, 2012, 03:06 pm
Quote
So I decided to investigate a different solution:
-   PWM (frequency=490Hz)+ RC filter (eg R=1 kOhm, C=47 uF)

This seems feasible for me. Only the capacitor is a bit big.

I can user a smaller capacitor when using a higher PWM frequency.

All you need is the same time constant so  R=1 kOhm, C=47 uF is the same as  R=10 kOhm, C=4.7 uF or  R=100 kOhm, C=0.47 uF.
What will change is the output impedance of the filter, but if you are using a buffer then that will be no problem.

However the TLV5620 have a voltage output so it is a simple matter to arrange some sort of buffer if the output impedance is too high for your application.

#### KeithRB

#3
##### Oct 18, 2012, 06:17 pm
Also, it will take some time for the PWM to charge the filter and get the value to settle. How quickly do you need it to respond?  Any time you talk about Kohm resistors and uF, you can expect to wait a while!

#4
##### Oct 18, 2012, 07:07 pm
How about a couple of these? \$1.89 each
http://www.microchipdirect.com/ProductSearch.aspx?Keywords=MCP4728

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#5
##### Oct 18, 2012, 07:18 pm
Or two of these
\$6 at digikey
Lot easier to interface with.

Can't do  much about DIP - not much available these days outside of DUAL DACs.

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### Oldchatterman

#6
##### Oct 18, 2012, 07:59 pm

You can use a mcu digital-out pin to power a divider. And pick your divider to get the desired output levels.

If you need precision output levels, use the digital-out pins to power a voltage reference and then use the reference to power a divider. This approach requires multiple voltage references.

An alternative is to use 1 voltage reference and then pull a divider to ground with the digital-out pin.

Each approach can be made to work.

These approaches require a lot of resistors on my pcb.

#### Oldchatterman

#7
##### Oct 18, 2012, 08:07 pm

All you need is the same time constant so  R=1 kOhm, C=47 uF is the same as  R=10 kOhm, C=4.7 uF or  R=100 kOhm, C=0.47 uF.
What will change is the output impedance of the filter, but if you are using a buffer then that will be no problem.

However the TLV5620 have a voltage output so it is a simple matter to arrange some sort of buffer if the output impedance is too high for your application.

A small R requires a big C. A big R requires a impedance buffer.

The buffer requires additional components (R or Opamp) and in my hunt for less components I decided to look for a RC filter without buffer (impedance of the RC filter has to be << 15 kOhm). C can be smaller with high PWM frequency.

#### Oldchatterman

#8
##### Oct 18, 2012, 08:52 pm

Also, it will take some time for the PWM to charge the filter and get the value to settle. How quickly do you need it to respond?  Any time you talk about Kohm resistors and uF, you can expect to wait a while!

A RC filter with R=1kOhm and C=47uF has a risetime of 0.1 s and a ripple of 0.05 V. This fits within my specifications (I can wait for 1 s for stable voltage level)

#### Oldchatterman

#9
##### Oct 18, 2012, 09:03 pm

Or two of these
\$6 at digikey
Lot easier to interface with.

Can't do  much about DIP - not much available these days outside of DUAL DACs.

The MCP4728 is a good solution: low cost, straight forward

The only think that annoys me is that these DAC solutions can perform much better than required (8 and 12 bits instead of the required 5 bits, risetime within us -> I need 1 s ...), therefore still thinking on simpler solutions with less or low cost components.

How about the idea with fixed 32 bit buffers and shift them out at a fixed frequency?

#### borref

#10
##### Oct 18, 2012, 09:03 pm

Is it possible to pre-program a fixed buffer of 32 bits for each voltage level (L0 to L6) and send the bits, bit by bit to a digital output, by using an interrupt routine?
Is it possible to work with 1 interrupt and write 12 digital outputs each cycle? Is it possible to reach 20 kHz? This is the only task the microcontroller has to do.

Using a 16MHz mcu and bit-bang PWM at 20kHz, you would have 400 instructions available for each interrupt cycle (16e6 / 40e3). This may be achievable (not using the Arduino core), but it doesn't leave you with much for anything else. Direct port IO is 8 bit wide and requires two instructions only. Interrupt overhead is about 50 instructions.

#### dhenry

#11
##### Oct 18, 2012, 09:07 pm
Quote
How about the idea with fixed 32 bit buffers and shift them out at a fixed frequency?

How does that solve your problem?

#### Oldchatterman

#12
##### Oct 18, 2012, 09:15 pm

Quote
How about the idea with fixed 32 bit buffers and shift them out at a fixed frequency?

How does that solve your problem?

I meant shift the 32 bits stream to a RC filter. I didn't investigate it, but I think the Atmega has a hard job with 12 outputs at PWM with a reasonable frequency. Therefore I was thinking to preprogram the levels (to decrease the processing load) and decrease the counts to 32 to be able to raise the frequency on 12 outputs to > 500 Hz (preferable in the kHz range).

#### Oldchatterman

#13
##### Oct 18, 2012, 09:26 pm

Using a 16MHz mcu and bit-bang PWM at 20kHz, you would have 400 instructions available for each interrupt cycle (16e6 / 40e3). This may be achievable (not using the Arduino core), but it doesn't leave you with much for anything else. Direct port IO is 8 bit wide and requires two instructions only. Interrupt overhead is about 50 instructions.

You must help me with this calculation: 16e6/40e3 -> where is the 40e3 coming from.

The only thing the mcu has to do is supply the voltage levels and keep them stable, nothing else.

#### dc42

#14
##### Oct 18, 2012, 09:27 pm
I agree with Crossroads, if the components you need to use are only available in SMD packages, then use SMD adapters so you can use them on a breadboard, stripboard or perfboard. There are lots of tutorials on SMD soldering on the web. I use a hotplate, a flux pen, solder paste and solder wick.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Go Up