Go Down

Topic: Charlieplexing issue (Read 2043 times) previous topic - next topic

jopiek

May 13, 2012, 11:22 pm Last Edit: May 13, 2012, 11:39 pm by jopiek Reason: 1
I am trying to control two traffic lights using 4 pins and charlieplexing...

All modes work save both red (and that should be the initial state so...
It gives me two lights with both red and green on.



Code: [Select]


|----->4---------+
|                    |
|-<5-+-<2-+-<1-+
|      |     |     |
|->6-|->3-|     |
|      |     |     |
A     B      C    D

Note: > and < are LED's
+ is just a node
A, B, C and D are digital pins on an Arduino 2009




1 and 4 are green
2 and 5 are yellow
3 and 6 are red

I use this code:
Code: [Select]

pinMode(ledpinA, OUTPUT);
 digitalWrite(ledpinA, HIGH);
 pinMode(ledpinB, INPUT);
 digitalWrite(ledpinB, HIGH);
 pinMode(ledpinC, OUTPUT);
 digitalWrite(ledpinC, LOW);  
 pinMode(ledpinD, INPUT);
 digitalWrite(ledpinD, HIGH);


A should be +, B input with pull-up activated, C - and D also input with pull-up
That way only red should be activated since D is not giving any output, but it is :s

Any help appreciated.

Below the circuit in Fritzing:



Left signal is straight, right in an L-shape (just the circuit design of course, not the real light...)

johnwasser

The pins that are not driving LED's should be INPUT with the pull-up OFF, not ON (LOW not HIGH).
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

jopiek

Code: [Select]
  pinMode(ledpinA, OUTPUT);
  digitalWrite(ledpinA, HIGH);
  pinMode(ledpinB, INPUT);
  digitalWrite(ledpinB, LOW);
  pinMode(ledpinC, OUTPUT);
  digitalWrite(ledpinC, LOW); 
  pinMode(ledpinD, INPUT);
  digitalWrite(ledpinD, LOW);



That didn't do the trick unfortunately. Even not with pull down resistors (I understand why my first option didn't work since of course it drew the B and D high instead of low).

I could use an XOR port but that makes the circuit more complicated of course...

jopiek

As one can also see in this tutorial:

http://uzimonkey.blogspot.com/2009/01/charlieplexing-on-arduino.html

The problem is that I didn't use any resistors. A resistor value of about 120? should be sufficient in my case (I tested that).

So... it seems when using charlieplexing, one needs to include resistors.

Grumpy_Mike

When ever you drive an LED you need to use resistors.

jopiek

Of course, one should. But one doesn't NEED to if the output doesn't output more than 40mA or so...

Grumpy_Mike

No the output will deliver more than 40mA, I have got 250mA in one experiment.
Damage starts at 40mA that is why it is called the current limit. However the current IS NOT limited to 40mA.

jopiek

That is interesting, I was not aware of that, should also make sure I take that into account. But it isn't wise of course to connect too much to a pin without driving it using a transistor.

johnwasser

The point of Charlieplexing is that only the one LED that is forward-biased when you turn one pin HIGH and one pin LOW was supposed to light up.  Having two LEDs in series was supposed to double the voltage drop and thus cut the current enough to not light both lights.  Your problem is that voltage/current enough to light both Red LEDs is also enough to light both Green LEDs.  Adding the resistors should help.

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

jopiek

#9
May 14, 2012, 11:47 pm Last Edit: May 15, 2012, 12:04 am by jopiek Reason: 1
It seems to be quite hard to compute suitable values for the resistors in the system though. I didn't succeed until now.

When I use 470? for A and C and 220 for B and D, one almost can't see the green.

JohnSan


I'm no expert on this, but Charlieplexing is a dynamic function.

It is intended to control leds INDIVIDUALLY by pulsing them ON when required.
For two (or more) leds to be ON 'at the same time' - eg. for traffic lights - they are actually being switched ON then OFF individually rapidly. So they 'look' as if they are on at the same time due to persistance of vision.

It looks as if what you are trying to do isn't strictly Charlieplexing....

For software and examples, refer to the library :-

http://arduino.cc/playground/Code/Charlieplex

For 6 leds, you only require 3 outputs.
Your green leds should be connected between 'ledpinA' and ledpinC

For your hardware, make these basic tests on the leds.

Assumiming a 5V supply and limited Arduino output current to 20mA.

Nominal forward voltages.
Red led Vf = 1.8V
Green/yellow led Vf = 2.2V

This equates to 160R and 140R resistors.
So for a test, use a standard value 150R resistor to supply one colour led individually from a 5V supply.
Note the brightness.


Test conclusion.
Are the colours similar (acceptable) in intensity?


No.  -> You're stuffed until you find some that are.

Yes. -> Continue.


Because each output pin is used as a source and sink (5V supply and 0V) during Charliplexing, each output pin needs a resistor in series with it.
Using a 75R resistor in each output gives a 150R (for a nominal 20mA) total resistance.

because at any one time:-
One output will be ON (+5V).
One output will be OFF (0V).
All the others will be in input mode. (High resistance).

Hope this helps.




I'll be glad when I've had enough!

johnwasser


I'm no expert on this, but Charlieplexing is a dynamic function.

It is intended to control leds INDIVIDUALLY by pulsing them ON when required.
For two (or more) leds to be ON 'at the same time' - eg. for traffic lights - they are actually being switched ON then OFF individually rapidly. So they 'look' as if they are on at the same time due to persistance of vision.


The Wikipedia article on Charlieplexing says that you CAN turn on more than one LED at a time if they have a Common Anode.  Set the common anode pin HIGH and set the two cathode pins LOW.  I think the Common Cathode configuration would also work.  Set the common cathode pins LOW and set the two anode pins HIGH.  Unfortunately the original poster does not have the LEDs wired with common anodes or common cathodes.  He would have to reverse one of the Reds, one of the Yellows and one of the Greens.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

JohnSan

#12
May 16, 2012, 04:58 pm Last Edit: May 16, 2012, 05:17 pm by JohnSan Reason: 1
Ok on the multiple leds.
But I was thinking of Charlieplexing more in Arduino terms... as in that library.

But yes. You can turn on more than one led at a time.

But, that makes it difficult to calculate a resistor value for current limiting.
For any fixed resistor value, the led brightness will vary, depending on how many leds are on at a given time (in a common group).

It's probably better (at least would be more consistent/easier)  to stick to 'one at a time'.

Or maybe PWM would help solve the multiple leds on current/brightness issue?  XD

I'll be glad when I've had enough!

jopiek

I could of course do multiplexing using the common kathode / common anode method. There is however an extra connection needed to both signals. That way one is able to control all colors more exactly of course. In one signal pole for the Dutch train signal system only one LED needs to be lit.

MarkT

In general you can't charlieplex a mix of different coloured LEDs unless all the colours are close in voltage (red/orange for instance, or green/blue/white)

2 red LEDs in series just start to glow around 3.2V, one green/blue/white fully can be about 3.3 to 3.5V.  A charlieplexed array relies on the forward voltage of every LED being more than the double the threshold voltage of any of the others.  Having said that forward voltages do vary with precise colour and manufacturer, there may be some combinations that do work.

If you really need it to work I suppose adding an ordinary diode in series with each red/orange LED would up the forward voltage enough to overcome the issue.

Incidentally its no accident that the energy of a photon of red light is about 1.7eV and for blue light 3.1eV - LEDs require a forward voltage equal/exceeding the photon energy in electron volts.  White LEDs are actually violet LEDs with a fluorescent material in front of them.
[ I won't respond to messages, use the forum please ]

Go Up