I am new to arduinos. I am trying to generate a square wave with negative and positive amplitude using PWM pins. I am having troubles creating the negative voltage component. I read on line to create a virtual ground and when the PWM output is 0% the output will be the negative output. Please elaborate.
Thanks
You're not going to get negative voltage with a DC device, I'm afraid.
if you were up for having fun with an op amp you could get one
Are you sure you need a negative voltage?
The best way to get a negative voltage would be to use a bipolar supply to get the negative power supply voltage. Then run that +/- power supply into some more electronics (maybe an op-amp) to amplify/shift the the 0 to +5 Volt output from the Arduino.
I'm working on a project now that will run off a car battery but it needs positive & negative voltage. I'll be using a DC-DC converter to get -12V.
I read on line to create a virtual ground and when the PWM output is 0% the output will be the negative output. Please elaborate.
Let's talk about DC, rather than getting confused with PWM...
A virtual ground can work if you don't connect to anything with a "real" ground to your virtual ground circuit.
It's pretty simple. Ground is just a reference point (usually connected to earth ground somewhere back at the AC power supply). If you connect a pair of equal-value resistors in series between 5V and ground, you will get 2.5V (referenced to true ground) where the two resistors connect together. If we call that "virtual ground", we can connect the common/ground lead of our voltmeter to that virtual ground. If you now connect the + lead of the meter to +5V, the meter will read +2.5V. If we connect the + lead of the meter to true-ground, the meter will read **-**2.5V.
Resistors usually don't work too well, because as soon as we connect something that draws current* (say an LED) you muck-up the voltage divider, and your virtual ground no-longer has 2.5V relative to true ground. The solution is to use an active circuit (transistors, or an amplifier, etc.) to hold the virtual ground at 2.5V.
A multimeter draws a little current, but we'll assume it has much higher resistance than the voltage-divider resistors, so the current is insignificant.
P.S.
In some applications, a series capacitor on the output might work with PWM. A capacitor will block the DC component, letting the AC part of the signal through. This is how most battery operated audio amplifiers work. The DC gets blocked and the AC going to the speaker swings between positive and negative.
Your PWM pulses will go truly negative, mostly between +2.5V and -2.5V, with possible larger voltage spikes when you start/stop the PWM.
With a MAX232 and a few capacitors, you could get that bipolar output (+10/-10V) without an extra split supply.
[A MAX233 doesn't need the capacitors, but costs a couple $ more.]
If you just need to reverse the current flow through a component, rather than actually generate a negative voltage then look at using an H-bridge. There are normally used for reversing the direction of motors.
with the PWM function and two supply sources (5V and -5v) I created two individual sq wave forms.. a 0V to 5V pulse and a -5V to 0V pulse. Now I want to combine the two pulses into single +-5V sq wave...no idea how to do that. Please help
Show the schematic of what you have done. This is vital if anyone is going to help.
I created two individual sq wave forms.. a 0V to 5V pulse and a -5V to 0V pulse. Now I want to combine the two pulses into single +-5V sq wave.
This cannot be done without additional components, and it's a LOT easier if you have a -5V power supply.
Two or more 5V outputs from the same device and/or the same ground reference DOES NOT HELP to get more voltage or negative voltage.
In THEORY, you can get more CURRENT by connecting two or more outputs together, but not more voltage. And in the real world, it's a VERY BAD IDEA idea to connect outputs together, because you can fry the chip.
Here what I will do.
-
Digital to analog. Use a chip or make one. Use dual supply. and op-amps. Th signal is a stair case ( going up and down ) and filter the signal.
-
Genarated a square wave - 50 % duty, Use dual supply. And op-amps. The circuit is a filter ( more than 1 filter circuit ) to remove the higher harmonics of the square wave. You only got the frequency of the square wave.
But both ideas are design for a fix frequency. If you want variable frequency, I choose the DAC way.
you can also fake it with a 555 timer, a decent sized cap and a couple diodes, though dont expect it to do anything serious
Hi,
I SUGGEST TO USE MAX232 FOR THIS PURPOSE ...
THE OUTPUT OF MAX232 CAN BE AMPLIFIED
AS REQUIRED...
Ravi
cluelessarduino:
I am new to arduinos. I am trying to generate a square wave with negative and positive amplitude using PWM pins. I am having troubles creating the negative voltage component. I read on line to create a virtual ground and when the PWM output is 0% the output will be the negative output. Please elaborate.
Thanks
But first... probably need to explain what parameter of a square wave you want to control with pwm. Frequency of square wave that depends on pwm duty cycle? Got to provide adequate details.
If you mention pwm pins..... then should explain what you plan to do with those pins to generate your square wave. It might also reveal what you're actually attempting to do.
cluelessarduino:
I am new to arduinos. I am trying to generate a square wave with negative and positive amplitude using PWM pins. I am having troubles creating the negative voltage component. I read on line to create a virtual ground and when the PWM output is 0% the output will be the negative output. Please elaborate.
Thanks
Ground is a reference point that the circuit it uses to compair all other voltages in that circuit to.
If you create another circuit and do not connect the earths, voltages on circuit 1 will appear to be floating on circuit 2.
Please explain what you are trying to do?
Why do you need an AC voltage and how high does it need to be?
It is possable to create an AC voltage from PWM but it will be around 2.5 volts without any amplification.
Depending on what you are driving you may need more or less.
Others may have another, even better way to do what you want so dont limit it by saying you need an AC voltage.
Daz
Have you three noticed that this thread is 6 years old?
Pete
Still think its unfair that clueless does not reply. (SILLY GRIN ON FACE)
Missed the start of thread date.
Daz