PIN and Charlieplex issue

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am trying to debug some Charlieplex code and I am not sure what is going on. Let me see if I understand this:

So this is how I intrepret these lines:

DDRB = ( 1<<0 | 1<<5 );
PORTB = ( 1<<0 );

DDRB will be set up with PINB0 and PINB5 as output the rest will be input and PIN0 will be high (5v) and PIN5 will be ground?

 

The problem I have is that I am using CharliePlex to control 50 LEDs. There is only one to 6 lights that will be "on at one time" (I am cycleing through the lights so that they appear that way) But sometimes I am getting more than one light on at a time. I started looking at the wiring and it all seemed correct then I started looking at the pin voltages and  PINB3 was outputting a little over 3v. I removed all connections from this pin (except for the programmer) and it was still showing over 3V. I don't think the MOSI line is actually outputting anything when it is not programming, is it? I had to go to work so I will look at it some more when I get home. Any ideas or comments?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Disconnect the wire from PB3.  What voltage do you read at the pin then?  What voltage do you read on the wire that was connected to PB3?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After I left for work, I thought about doing that.... I will when I get home. I thought someone would know off the top of thier head...

I will let you know what I find out...

 

Also, was I correct on the values in DDRB and PORTB?

Last Edited: Wed. Feb 25, 2015 - 09:57 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Starting out with all eight pins, eh?

 

required. That is, L LEDs can be driven by  \frac{1 + \sqrt {1+4\cdot L}}{2} pins.

PinsLEDs

1 0

2 2

3 6

4 12

5 20

6 30

7 42

8 56

9 72

10 90

20 380

40 1560

n n2 − n

What AVR model are you using?  Do you have ISP connected?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I actually did a  similiar project with 12 LEDs....then stepped up to this one....It was a simple transition once you figured out the concept. Yes the ISP is connected, I was using it for the power source for testing (this is probably my problem...I will know in a little over an hour when I get home) I am using an ATMega168A

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes the ISP is connected, ...

Have you told us which AVR model?  What port pins are connected with the ISP header on that model?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did mention the model. It is an Atmega168A. Well in looking at things I think I must have been tired and might have touched the lead to a wire nearby when I was testing....so I took all the wires off and the signals seemed to be what they should be on the pins. So then I looked at the wiring diagram and I think I see the problem. I thought I had it figured out but when I expanded to 50 lights it didn't quite work. I looked for other wiring diagrams and mine was similar to others I found  and theirs seemed to have the same flaw. In the diagram below you want to light LED3 so Pin 1 and 6 are output with Pin1 high. I traced the electrical route. Then the next diagram shows how 2 additional lights will light up with the same outputs. I have run across several diagrams and they all seen to have the same flaw...What am I missing?

LED route

LED2

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dusteater wrote:

What am I missing?

 

In your first diagram, with just one LED lit, there will be a one LED voltage drop across the wires. You are right that this same voltage will also appear across 2 LEDs in series. HOWEVER, and this is the whole point of charlieplexing, that voltage will not be enough to light up the two LEDs. They don't start to conduct at that voltage.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I didn't catch that in reading about Charlieplexing.  I was actually concerned that I had too much resistance because I am using red LEDs and I am running at 5V and with the LEDs forward voltage of 2.1V, so if I am correct, the required resistor for 1 led would be 150 ohm. I actually used 100 ohm on each pin for a total of 200 ohms. So is there a way to calculate the resistor you will need?

After thinking about it, I think I might have used 2 different red LEDs and therefore the forward voltage could be different and then one of the circuits with 2 LEDs might actually have the ability to pass current through it... I will check them all when I get home after work....

Last Edited: Thu. Feb 26, 2015 - 03:54 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wouldn't worry too much about using different red LEDs. The voltage drop = threshold voltage = diffusion voltage only really depends on the material used to make the LED. A red LED will sit in the 1.6 - 2.0v range so one LED is guaranteed not to drop enough volts to light two in series.

 

Pick resistors to drive enough current through the LED to give sufficient brightness without overloading either individual pins or the total allowed for a chip (see datasheet for numbers). As an example, I've got a unit using charlieplexed LEDs and I use 82 ohm resistors on a 5v supply.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, works great now!