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.
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.
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.
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!
Or two of thesehttp://www.analog.com/en/digital-to-analog-converters/da-converters/ad5308/products/product.html$6 at digikeyLot easier to interface with.Can't do much about DIP - not much available these days outside of DUAL DACs.
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.
How about the idea with fixed 32 bit buffers and shift them out at a fixed frequency?
QuoteHow about the idea with fixed 32 bit buffers and shift them out at a fixed frequency?How does that solve your problem?
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.