How to vary 0 to 5 V and then reverse the polarity of DC Voltage?

I know, it is possible to vary the output DC voltage through coding and then changing the polarity. This means, say starting from 1.00 V, DC voltage output is increased gradually say 0.1 per second and when it reaches to say 4.9 V then the polarity (+ and -ve terminals) should be changed.

Thank you.

You appear to be describing a bipolar digital to analog converter (DAC), which must be purchased as a separate module.

Very few Arduinos have a genuine DAC (the Uno does not), and those few are unipolar (positive output voltages only).

If the DAC was knocking out voltages along a sine curve that could be ac/transformer coupled.
Depends on what you're trying to accomplish.

Sorry, no kits.
A fundamental experiment, involving an old IC, DAC0808.
https://www.ti.com/lit/ds/symlink/dac0808.pdf
It's a simple thing to work with.
What ac frequency do you require?

There is a difference between change a voltage and changing polarity.
It's pretty easy to come up with a variable voltage.
That could be done with PWM and a low-pass filter.

image

That's not a panacaea though.
How many milliamps do you need?

This +/-10V DAC might be OK: https://www.ebay.com/itm/153655629968

I am sure you can use the Arduino's PWM and a single op-amp. With biasing the output negative.

Some nice person has even done this before (the correction is towards the end of the page). You will have to alter scaling for your output. Witht the Arduno PWM based DAC you are using the power supply as your reference, if you need precision then a better voltage reference and precision resistors will be needed (part of your error budget calculation).

Good luck :slight_smile:

Let me be blatantly commercial for a minute.

I have a product (complete circuit board in a DIN rail enclosure) that's based on an Arduino Nano that will provide you with a 12-bit resolution +/-12V output biased around ground.

It's overkill for what you need and the pricing isn't exactly hobbyist-friendly but if you get stuck and want to consider it, send me a PM.

Dear cedarlakeinstruments
Please provide more details.
Since I am focussing on such tailor-made proto, I am not a buff of either Arduino or integrated circuits. And this project is purely for electrochemical sensing and we are planning to automate the variation of DCV as well as recording.

Dear jremington
Thank you ...can we integrate for reversing the polarity after an upper limit of DCV.

Do you actually want to apply a negative voltage with respect to ground or do you want the electrodes to be swapped over. All replies have assumed the former.
If it is the latter then use a circuit called a h-bridge. Its main use is for controlling the direction of motors but it does this by swapping the wires over. This is a good one
https://www.pololu.com/product/2130

Avoid the L298 chip as it is crap.

If you combine either of the suggested circuits for 0-5V with the H-bridge Mike suggested in Reply#17, you wind up with a circuit that steps from 0-5V and when you reverse the direction
of the H-bridge the polarity will be reversed. If the sequence needs to always start at zero then
you need to change the 5V to 0V before you reverse polarity.

or PWM output with a 4.7k resistor on the output connected to a 4.7uF cap with one end connected to GND. (it's called and RC LPF (resistor capacitor low pass filter). It will convert
the PWM output to a steady state dc voltage. The DAC is a much better solution though.

If you're having trouble visualizing this, just imaging that the 'motor' is not a motor but is
in fact the output of your circuit to which you connect your widget you want to power.
The h-bridge power terminals are the GND and 5V, which unlike normal power supplies,
it not fixed, but rather the stepping voltage. How does this work (well in fact it may not
if the H-bridge doesn't cooperate, but if you read the page Mike linked its says:

This tiny breakout board for TI’s DRV8833 dual motor driver can deliver 1.2 A per channel continuously (2 A peak) to a pair of DC motors. With an operating voltage range from 2.7 V to 10.8 V and built-in protection against reverse-voltage, under-voltage, over-current, and over-temperature, this driver is a great solution for powering small, low-voltage motors.

So the bold numbers are the 'catch' . It should work if the voltage output by the DAC or PWM/RCLPF circuit remains within the allowable voltage stated in the H-BRIDGE SPECS.
When you get below the 2.7V, more than likely the H-bridge will NOT work.

If you need it do what you stated exactly, that could get complicated.
(not saying it isn't doable, but it may NOT be doable by YOU)
Why ? (analog switches, op amps, where does it end ?)

I have a design for a project that sweeps the output voltage from 0 - 5V under program control.
It also measures the current in the circuit to graph device characteristics.

It would be a simple matter to change the polarity across your sample using a eg changeover relay.
However if you REALLY NEED the output to go 0 ...4.9V | - 4.9V ...0 you would need a source of -5V.

Is your project the same as this one?
https://forum.arduino.cc/t/dna-electrowetter-device/956082

It certainly sounds like it.

Thanks Grumpy_Mike
But the key part is to vary the voltage or step up and step down the DCV.
Thank you for your suggestion and it can be useful for polarity reversal.

Thanks raschemmel

Dear johnerrington
Can I get proto kit? Because I am not an Arduino buff. Help me to sort out. Thanks

Dear raschemmel
Thank you for your solution.
But we wish to procure the integrated kit as I am not an expert in Arduino or the related integrated Arduino.

Just applying -ive voltage. We are searching for proto kits rather than our own circuits. We look into the site and we will look into this. Thank you

You MUST CLEARLY DEFINE what you require.
What we dont know:
1: Whether you need a voltage output that goes negative, or you just need to reverse the connections to the test system.
2: What current the voltage will supply
3: How fast it needs to change
4: The size of the steps.
5: how your system will respond to the changing voltage.
6 ..97 as yet undefined.