Pages: [1] 2 3   Go Down
Author Topic: best solution for 12 analog outputs (5 bits)  (Read 3036 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34532
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Edison Member
*
Karma: 33
Posts: 1468
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27353
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How about a couple of these? $1.89 each
http://www.microchipdirect.com/ProductSearch.aspx?Keywords=MCP4728

Put them on a SMD adapter for breadboarding.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27353
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Or two of these
http://www.analog.com/en/digital-to-analog-converters/da-converters/ad5308/products/product.html
$6 at digikey
Lot easier to interface with.

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

Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Or two of these
http://www.analog.com/en/digital-to-analog-converters/da-converters/ad5308/products/product.html
$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 AD5308 is too expensive

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?
Logged

Offline Offline
Edison Member
*
Karma: 3
Posts: 1001
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

How does that solve your problem?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Pages: [1] 2 3   Go Up
Jump to: