Go Down

Topic: New Library for BiColor LEDs (Read 5 times) previous topic - next topic

wolfgang42


Quote
To turn the LED red, pin1 is set HIGH and pin2 is set low, so the power goes one way. To turn it green, the polarity of the two pins is swapped, so the power goes the other way. Yellow is produced by rapidly switching between red and green, producing AC

You are not producing AC. AC is alternating current, where the voltage changes from positive to negative 50 or 60 times per second. All you are doing is switching which way the current, at +5V, is flowing.

I refer you to Merriam-Webster's definition of Alternating Current: http://www.merriam-webster.com/dictionary/alternating+current.
Quote
an electric current that reverses its direction at regularly recurring intervals


  • An electric current: This is electricity we're working with, even at 5V.

  • that reverses its direction: in other words, which way the current is flowing

  • at regularly recurring intervals: If you call drive() at regularly recurring intervals (which you should, to make the yellow look right), then the current reverses at regularly recurring intervals.



If there's any part of this you don't understand, have a look at my explanation above, or hook the output of my library up to an oscilloscope and see for yourself.

Docedison

#6
Aug 30, 2012, 10:31 pm Last Edit: Aug 30, 2012, 11:59 pm by Docedison Reason: 1
Pulsating dc and ac are the same, a variable flow of electrons. The primary difference is the "Reference"... If "AC" is "Referenced" from the most negative level them you could say "It''s Just pulsating DC.
Whether it is sinusoidal, square rectangular (duty cycle not 50%) triangular.
Come to think about the definition a little and you will see that the prime requirement for AC... The one Difference that sets AC apart from noise is just Periodicity.
It is the periodicity that sets it apart and allows it to do useful and predictable work is it's periodicity.
If you put in place a device that passes AC only, a capacitor or a transformer will pass your "DC" very well.
As to the library it does produce a signal that makes the LED light up Yellow... So the difference is?.. The LED works the same as if it had AC on it
Just the point of reference... Put it in the right place and your "DC" signal becomes "AC".
Place a diode in series and you remove 1/2 of the DC signal... Just as a diode would with AC... and you have DC again... pulsating but of one polarity... The signal cannot pull down when the input goes to it's lowest point because the diode will not conduct in the reverse direction.

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

wolfgang42


Pulsating dc and ac are the same, a variable flow of electrons. The primary difference is the "Reference"... If "AC" is "Referenced" from the most negative level them you could say "It''s Just pulsating DC.
Whether it is sinusoidal, square rectangular (duty cycle not 50%) triangular.
Come to think about the definition a little and you will see that the prime requirement for AC... The one Difference that sets AC apart from noise is just Periodicity.
It is the periodicity that sets it apart and allows it to do useful and predictable work is it's periodicity.
Noise can be called AC... Pink noise (audio) and White noise (Full Spectrum) and random impulse noise are AC but because of the lack of predictability, little real work can be done with them.
If you put in place a device that passes AC only, a capacitor or a transformer will pass your "DC" very well. it will also filter the signal due to its reactance or response to an "AC" signal... again the Periodicity.
As to the library it does produce a signal that makes the LED light up Yellow... So the difference is?
Just the point of reference... Put it in the right place and your "DC" signal becomes "AC".
Place a diode in series and you remove 1/2 of the DC signal... Just as a diode would with AC... and you have DC again... pulsating but of one polarity... The signal cannot pull down when the input goes to it's lowest point because the diode will not conduct in the reverse direction.

OK, that mostly lost me. I just know the library works by reversing the direction of the power at regular intervals...

Docedison

#8
Aug 30, 2012, 11:52 pm Last Edit: Aug 31, 2012, 12:04 am by Docedison Reason: 1
I apologize for "loosing" you but my "Rant" was about users that ASSUME that they KNOW everything.
If for example, you consider a 60Hz 10V PP signal... AC Right?, NO WRONG, a repetitive signal of 10 Volts amplitude only... repeating @ a 16.67 Ms interval.
The AC signal requires a reference of +5V. to recover the "Negative" part. It is still a 10V PP signal.
The basic concept of AC is a negative going signal... A Voltage that alternates polarity.
However polarity is a thing related to a "reference" point, usually 0 volts.
The point is that this signal Will pass through devices made for AC only.
Your alternating dc voltage will pass through a transformer... DC won't. Even a single pin from an Arduino coupled through a capacitor
with a repeating pulse present will pass both the transformer and the capacitor and be present at the other transformer winding... DC won't.
The capacitor isn't required but I included it to drive home the point about AC vs DC.
So it clearly isn't DC any more. To prove it is simple. It requires an external "reference" a pair of equal value resistors from Vcc to ground.
Measure from the center point of the resistors to the pin outputting the "Pulse" you will measure an AC 5 V PP signal.... at least on an Oscilloscope.
A DVM  will "average" or really mangle the signal But it is AC.

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

PaulDriver

in BiColorLED.h please change

Code: [Select]
#include "WProgram.h"

to

Code: [Select]
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif


For Arduino 1.x support

And to help PaulS and anyone else Doc lost, you must look at the current from the viewpoint of the Bi-Polar LED pair, not the Arduino.  To the the Arduino, it's just DC, BUT to the pair of diodes being driven by the Arduino, it's A/C.

Go Up