Shop OBEX P1 Docs P2 Docs Learn Events
Using the P2 as a 5V DAC — Parallax Forums

Using the P2 as a 5V DAC

I need several 5V DACs for a project I'm working on. In the past I've used MCP492x chips.
Can I take advantage of the P2's DACs in such a way as to use it a better 5V DAC?
My initial plan is just to use an op amp with a small gain in order to boost the voltage to the appropriate level. Are there better options than this?

The output is close to DC. At most the level changes will occur a few times a second.

Comments

  • jmgjmg Posts: 15,173
    That would work fine, you would use rail-rail opamps, and might want to check how close to 0V and 5V those allow you to get, given your expected loads.
    You could also include some RC filtering, to allow use of the dithered dac options in P2, (if the load does not already average).
    The accuracy of that will depend on the precision & noise of your 3v3 regulators, and the gain resistors.
  • jmg wrote: »
    check how close to 0V and 5V those allow you to get

    We actually use 5.1V rather than 5V just to make sure we can reach full scale on a DAC output. We'll likely do the same thing with the op amp.

    Thank you for verifying the op amp is a good option and thanks for your other suggestions.



  • Hi Duane Degn

    Since you seems to be concerned that the selected op amp will be able to achieve full rail-to-rail 5V output-swing at 5.1V supply levels, then consider using Analog Devices ADA4500-2 duals, or similar devices.

    You'll also need to verify the selected op amps will be able to sink/source the expected output current drive levels, without disturbing (causing imbalances at) their input bias resistor networks, or the "small gain' you'd mentioned at the first post will not be stable enough to achieve design goals.

    Also, the "several" you'd mentioned is a bit "vague" quantity. If the numbers could reach the "outrageous" level, and design contraints does permit (timing), perhaps you could even consider using 74HC/HCT4067D analog muxes with small sample-and-hold capacitors at their outputs, in order to be able to transfer the intended analog voltage levels to each output gain stage, and scan them, sparing some (many) of P2 pins for further creative uses. :lol:

    Hope it helps

    Henrique
  • RaymanRayman Posts: 14,646
    edited 2020-07-01 00:12
    If the source is low impedance seems u could just use voltage divider with resistors.

    If high impedance u need some kind of amp anyway..
  • Yanomani wrote: »
    Also, the "several" you'd mentioned is a bit "vague" quantity.

    These DACs are used in a flow meter for variety of purposes.
    Here's a list of some of these uses.
    0V to 5V output for legacy control devices which like an analog interface.
    0V to 5V output for a valve control which uses an analog interface.
    A DAC may also be used in conjuction with platnium resistors and other circuity as one sensor option.

    The meter includes conventional digital interfaces such as Bluetooth, USB and Modbus over RS485 but some customers like the oldschool analog outputs.

    We also have a 4mA to 20mA current driver output but this is electically isolated so I don't see a way around using an external DAC with optoisolators on the digital interface.

    We still have lots of unused I/O pins so far. I make a habbit of always bringing these pins out to at least some sort of pad so they can be accessed in the future if needed. This habit is kind of selfish since I end up with all sorts of prototype boards which I like to repurpose into robots and other fun personal projects.

    Thanks for all the great suggestions.



  • Rayman wrote: »
    If the source is low impedance seems u could just use voltage divider with resistors.

    Did you read "DAC" as "ADC"?
  • RaymanRayman Posts: 14,646
    edited 2020-07-01 00:13
    Oops, sorry, got that wrong... must be dyslexic...
  • RaymanRayman Posts: 14,646
    Anyway, opamp is good idea. Maybe an RC filter to smooth out the 16-bit modes...
  • If you don't need more than 30 outputs and not more than 1kHz bandwidth I'd use a P1. You need one OPAMP per DAC anyway so you could also do low-pass filtering of the output of a counter in DUTY mode. However, the P2 would give you much more pins, more bandwidth and more memory.

    The attached schematic is a 3rd order sallen-key low-pass filter I use for converting a 5V PWM signal to +/-10V analogue voltage. You can change the R and C values to adjust gain, offset and corner frequency.
    1280 x 1024 - 28K
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-07-02 12:05
    BTW, Tachyon for the P1 has a 32 channel 8-bit 4.76kHz PWM built-in. In fact everything is built-in anyway. It's very easy to use too.
    Correction, it's been so long that I had forgotten but I just checked and it is 7.6kHz 8-bit PWM at the standard 80MHz P1 clock.
Sign In or Register to comment.