Guidance needed! I bought the wrong leds! Please help...

Hello. im new to this and decide to build a led cube according to this design Charliecube - Asher Glick
iv'e ordered al the parts i need but without realising ive ordered common annode rgb leds instead of common cathode rgbs!!!!!!
im sure theres a way i can alter the code to make it work but ive no idea how as im a complete noob..... :roll_eyes:

can someone please help as this is my first project and im panicking now...

this is the pin mappings

#ifndef _MAPPINGS_H_
#define _MAPPINGS_H_

/****************************** PIN PORT MAPPINGS *****************************\
|
\******************************************************************************/
#define P1B 0x00
#define P1C 0x00
#define P1D 0x04

#define P2B 0x00
#define P2C 0x00
#define P2D 0x08

#define P3B 0x00
#define P3C 0x00
#define P3D 0x10

#define P4B 0x00
#define P4C 0x00
#define P4D 0x20

#define P5B 0x00
#define P5C 0x00
#define P5D 0x40

#define P6B 0x00
#define P6C 0x00
#define P6D 0x80

#define P7B 0x01
#define P7C 0x00
#define P7D 0x00

#define P8B 0x02
#define P8C 0x00
#define P8D 0x00

#define P9B 0x04
#define P9C 0x00
#define P9D 0x00

#define P10B 0x08
#define P10C 0x00
#define P10D 0x00

#define P11B 0x10
#define P11C 0x00
#define P11D 0x00

#define P12B 0x20
#define P12C 0x00
#define P12D 0x00

#define P13B 0x00
#define P13C 0x01
#define P13D 0x00

#define P14B 0x00
#define P14C 0x02
#define P14D 0x00

#define P15B 0x00
#define P15C 0x04
#define P15D 0x00

#define P16B 0x00
#define P16C 0x08
#define P16D 0x00


/*
// LED PIN MAPPINGS
#define b111 4,8
#define b112 16,4
#define b113 12,16
#define b114 8,12
#define b121 4,7
#define b122 13,4
#define b123 11,13
#define b124 7,11
#define b131 4,6
#define b132 15,4
#define b133 10,15
#define b134 6,10
#define b141 4,5
#define b142 14,4
#define b143 9,14
#define b144 5,9
#define b211 3,8
#define b212 15,3
#define b213 11,15
#define b214 8,11
#define b221 3,7
#define b222 14,3
#define b223 12,14
#define b224 7,12
#define b231 3,6
#define b232 16,3
#define b233 9,16
#define b234 6,9
#define b241 3,5
#define b242 13,3
#define b243 10,13
#define b244 5,10
#define b311 2,8
#define b312 14,2
#define b313 10,14
#define b314 8,10
#define b321 2,7
#define b322 15,2
#define b323 9,15
#define b324 7,9
#define b331 2,6
#define b332 13,2
#define b333 12,13
#define b334 6,12
#define b341 2,5
#define b342 16,2
#define b343 11,16
#define b344 5,11
#define b411 1,8
#define b412 13,1
#define b413 9,13
#define b414 8,9
#define b421 1,7
#define b422 16,1
#define b423 10,16
#define b424 7,10
#define b431 1,6
#define b432 14,1
#define b433 11,14
#define b434 6,11
#define b441 1,5
#define b442 15,1
#define b443 12,15
#define b444 5,12
#define g111 16,8
#define g112 12,4
#define g113 8,16
#define g114 4,12
#define g121 13,7
#define g122 11,4
#define g123 7,13
#define g124 4,11
#define g131 15,6
#define g132 10,4
#define g133 6,15
#define g134 4,10
#define g141 14,5
#define g142 9,4
#define g143 5,14
#define g144 4,9
#define g211 15,8
#define g212 11,3
#define g213 8,15
#define g214 3,11
#define g221 14,7
#define g222 12,3
#define g223 7,14
#define g224 3,12
#define g231 16,6
#define g232 9,3
#define g233 6,16
#define g234 3,9
#define g241 13,5
#define g242 10,3
#define g243 5,13
#define g244 3,10
#define g311 14,8
#define g312 10,2
#define g313 8,14
#define g314 2,10
#define g321 15,7
#define g322 9,2
#define g323 7,15
#define g324 2,9
#define g331 13,6
#define g332 12,2
#define g333 6,13
#define g334 2,12
#define g341 16,5
#define g342 11,2
#define g343 5,16
#define g344 2,11
#define g411 13,8
#define g412 9,1
#define g413 8,13
#define g414 1,9
#define g421 16,7
#define g422 10,1
#define g423 7,16
#define g424 1,10
#define g431 14,6
#define g432 11,1
#define g433 6,14
#define g434 1,11
#define g441 15,5
#define g442 12,1
#define g443 5,15
#define g444 1,12
#define r111 12,8
#define r112 8,4
#define r113 4,16
#define r114 16,12
#define r121 11,7
#define r122 7,4
#define r123 4,13
#define r124 13,11
#define r131 10,6
#define r132 6,4
#define r133 4,15
#define r134 15,10
#define r141 9,5
#define r142 5,4
#define r143 4,14
#define r144 14,9
#define r211 11,8
#define r212 8,3
#define r213 3,15
#define r214 15,11
#define r221 12,7
#define r222 7,3
#define r223 3,14
#define r224 14,12
#define r231 9,6
#define r232 6,3
#define r233 3,16
#define r234 16,9
#define r241 10,5
#define r242 5,3
#define r243 3,13
#define r244 13,10
#define r311 10,8
#define r312 8,2
#define r313 2,14
#define r314 14,10
#define r321 9,7
#define r322 7,2
#define r323 2,15
#define r324 15,9
#define r331 12,6
#define r332 6,2
#define r333 2,13
#define r334 13,12
#define r341 11,5
#define r342 5,2
#define r343 2,16
#define r344 16,11
#define r411 9,8
#define r412 8,1
#define r413 1,13
#define r414 13,9
#define r421 10,7
#define r422 7,1
#define r423 1,16
#define r424 16,10
#define r431 11,6
#define r432 6,1
#define r433 1,14
#define r434 14,11
#define r441 12,5
#define r442 5,1
#define r443 1,15
#define r444 15,12

// LED PIN Positions
#define b111 4,8
#define b112 16,4
#define b113 12,16
#define b114 8,12
#define b121 4,7
#define b122 13,4
#define b123 11,13
#define b124 7,11
#define b131 4,6
#define b132 15,4
#define b133 10,15
#define b134 6,10
#define b141 4,5
#define b142 14,4
#define b143 9,14
#define b144 5,9
#define b211 3,8
#define b212 15,3
#define b213 11,15
#define b214 8,11
#define b221 3,7
#define b222 14,3
#define b223 12,14
#define b224 7,12
#define b231 3,6
#define b232 16,3
#define b233 9,16
#define b234 6,9
#define b241 3,5
#define b242 13,3
#define b243 10,13
#define b244 5,10
#define b311 2,8
#define b312 14,2
#define b313 10,14
#define b314 8,10
#define b321 2,7
#define b322 15,2
#define b323 9,15
#define b324 7,9
#define b331 2,6
#define b332 13,2
#define b333 12,13
#define b334 6,12
#define b341 2,5
#define b342 16,2
#define b343 11,16
#define b344 5,11
#define b411 1,8
#define b412 13,1
#define b413 9,13
#define b414 8,9
#define b421 1,7
#define b422 16,1
#define b423 10,16
#define b424 7,10
#define b431 1,6
#define b432 14,1
#define b433 11,14
#define b434 6,11
#define b441 1,5
#define b442 15,1
#define b443 12,15
#define b444 5,12
#define g111 16,8
#define g112 12,4
#define g113 8,16
#define g114 4,12
#define g121 13,7
#define g122 11,4
#define g123 7,13
#define g124 4,11
#define g131 15,6
#define g132 10,4
#define g133 6,15
#define g134 4,10
#define g141 14,5
#define g142 9,4
#define g143 5,14
#define g144 4,9
#define g211 15,8
#define g212 11,3
#define g213 8,15
#define g214 3,11
#define g221 14,7
#define g222 12,3
#define g223 7,14
#define g224 3,12
#define g231 16,6
#define g232 9,3
#define g233 6,16
#define g234 3,9
#define g241 13,5
#define g242 10,3
#define g243 5,13
#define g244 3,10
#define g311 14,8
#define g312 10,2
#define g313 8,14
#define g314 2,10
#define g321 15,7
#define g322 9,2
#define g323 7,15
#define g324 2,9
#define g331 13,6
#define g332 12,2
#define g333 6,13
#define g334 2,12
#define g341 16,5
#define g342 11,2
#define g343 5,16
#define g344 2,11
#define g411 13,8
#define g412 9,1
#define g413 8,13
#define g414 1,9
#define g421 16,7
#define g422 10,1
#define g423 7,16
#define g424 1,10
#define g431 14,6
#define g432 11,1
#define g433 6,14
#define g434 1,11
#define g441 15,5
#define g442 12,1
#define g443 5,15
#define g444 1,12
#define r111 12,8
#define r112 8,4
#define r113 4,16
#define r114 16,12
#define r121 11,7
#define r122 7,4
#define r123 4,13
#define r124 13,11
#define r131 10,6
#define r132 6,4
#define r133 4,15
#define r134 15,10
#define r141 9,5
#define r142 5,4
#define r143 4,14
#define r144 14,9
#define r211 11,8
#define r212 8,3
#define r213 3,15
#define r214 15,11
#define r221 12,7
#define r222 7,3
#define r223 3,14
#define r224 14,12
#define r231 9,6
#define r232 6,3
#define r233 3,16
#define r234 16,9
#define r241 10,5
#define r242 5,3
#define r243 3,13
#define r244 13,10
#define r311 10,8
#define r312 8,2
#define r313 2,14
#define r314 14,10
#define r321 9,7
#define r322 7,2
#define r323 2,15
#define r324 15,9
#define r331 12,6
#define r332 6,2
#define r333 2,13
#define r334 13,12
#define r341 11,5
#define r342 5,2
#define r343 2,16
#define r344 16,11
#define r411 9,8
#define r412 8,1
#define r413 1,13
#define r414 13,9
#define r421 10,7
#define r422 7,1
#define r423 1,16
#define r424 16,10
#define r431 11,6
#define r432 6,1
#define r433 1,14
#define r434 14,11
#define r441 12,5
#define r442 5,1
#define r443 1,15
#define r444 15,12
*/

#endif

thank you in advance....

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

What do you have for hardware?
With common anode, you'll need a PNP transistor to connect to the layers and individual current sinks for the columns.

Vs individual current sources for the columns and a NPN transistor or ULN2803 kind of part as a layer sink.

in the design: Charliecube - Asher Glick there are no resistors and the hardware is arduino nano 3.0.

ive been thinking about it and according to the way the spires are made it should still work but it will display backwards???? i think this is right but im not sure if i need to alter the pin settings so that it just works in reverse....

(note) i do not have any of the parts yet, not even an arduino. im using curcuit simulators and emulare until it comes but im trying to just get all the bits right... (ive built this damn thing about 100times in my head!!!...) im just doing the thinky bit now so ive got a head start... and im slightly obssesive... :astonished:

about the resitors, i was thinking about adding some just in case... just not sure where now...

i am very very green.... im looking to do a electronics course soon.... this is a step on hte ladder. i know a bit... but not much so go easy on me....

Hmm, that is clever. Would have to draw it out as a schematic to understand why no resistors are needed.

CrossRoads:
Hmm, that is clever. Would have to draw it out as a schematic to understand why no resistors are needed.

thank you for looking. will the cube still work as i believe it will? the way the current flows through the wires means it should still make the connections required to light them up right?

im more concerned with what i need to modify to make this work with the common annode leds....

mmmm. i can see a lot of reding in my future... :astonished:

Got the schematic sussed out for common cathode.
If common anode, I don't know of just flipping the LEDs over will work, or if that will try & turn on too many LEDs at one time.
Need to work out the signal flows to understand turning on the LEDs still.

Hi! I made the Charliecube. Do not fear your LEDs will work just fine! If you want to change the LEDs from common cathode to common anode you just reverse the pins. The way charlieplexing works is that in order to turn one of the LEDs on you pick two pins. Set one to HIGH (5v) and one to LOW (Ground/0v) all of the other pins are set to high impedance, which we assume is 'off' or 'disconnected'. If you look at the function flush buffer you will see 192 lines of

if (_cube_buffer[  #] != 0)flushElement(copy_frame, ##,##,_cube_buffer[  #]);

a short cut of code is

if (_cube_buffer[  0] != 0)flushElement(copy_frame, 4, 8,_cube_buffer[  0]);
  if (_cube_buffer[  1] != 0)flushElement(copy_frame,16, 4,_cube_buffer[  1]);
  if (_cube_buffer[  2] != 0)flushElement(copy_frame,12,16,_cube_buffer[  2]);
  if (_cube_buffer[  3] != 0)flushElement(copy_frame, 8,12,_cube_buffer[  3]);
  if (_cube_buffer[  4] != 0)flushElement(copy_frame, 4, 7,_cube_buffer[  4]);
  if (_cube_buffer[  5] != 0)flushElement(copy_frame,13, 4,_cube_buffer[  5]);

in order to fix the code you will need to switch the two numbers next to each other, so you would now have

if (_cube_buffer[  0] != 0)flushElement(copy_frame, 8, 4,_cube_buffer[  0]);
  if (_cube_buffer[  1] != 0)flushElement(copy_frame, 4,16,_cube_buffer[  1]);
  if (_cube_buffer[  2] != 0)flushElement(copy_frame,16,12,_cube_buffer[  2]);
  if (_cube_buffer[  3] != 0)flushElement(copy_frame,12, 8,_cube_buffer[  3]);
  if (_cube_buffer[  4] != 0)flushElement(copy_frame, 7, 4,_cube_buffer[  4]);
  if (_cube_buffer[  5] != 0)flushElement(copy_frame, 4, 13,_cube_buffer[  5]);

I also must say that this is a very poorly written function and I am currently trying to make it better for the 2.0 release of the code. Along this line of 'I need to make it better' the entire file of #defines do nothing, they used to and they will again but they don't right now.

I hope that answers your questions (even if it is kinda tedious)

On the note of resistors, some people feel worried about blowing out their LEDs if you are as well put a resistor on each of the IO pins connected to the LEDs (16 in total).

  • Asher

:slight_smile: :slight_smile: Aww dude. Thank you!! Like I said this is my first build and this is a learning aid more than anything. Once Ive got this built I'm gonna use it to learn about coding, so I'm quite excited about having to do a bit of work to make it operate properly. 8)

I kinda already thought what you suggested about Charlieplexing. I can think how it works and came to the same conclusion. I just wasn't sure.

I was "this" close to ordering some different leds...
Thank-you again. And thanks to bob too for the wicked schematic!! That's really useful...

I have a question, is "Charlieplexing" (a guy from Maxim invented it) the same as "Crossplexing" (I saw it in a LED chip driver datasheet, Austria Microsystems)??

I could figure out myself maybe if I wanted to, but you have the answer available much faster.

ok ive changed the code. im gonna build a simulation in emulare to see what happens... just cuz im bored.

also, what strength ressistors do you think i will need? will 250ohms be enough?

250 will do fine, that will keep the current to <20mA if you are only driving 1 LED at a time.

CrossRoads:
250 will do fine, that will keep the current to <20mA if you are only driving 1 LED at a time.

its not gonna cause the spire to be dim though right?

also do you know if it possible to simulate an arduino or equivilent in yenka?

No, not dim.

You could make the design with 2 16-pin wirewrap socket and put 8 resistors in each, will give you the chance to change values, example below.

RGB's usually have a different voltage drop across each color = ~1.7V for Red, Green, ~2.5 for Blue

So with just 1 resistor value for all outputs, worst case current of 20mA yields (5V - 1.7V)/20mA = 165 ohm, next standard value is 180.
Current draw with Blue is then (5V-2.5V)/180ohm = 13.8mA

Stick in values for your actual LEDs.

Also, I know nothing of yenka.

ok so after waiting for nearly 2months i finnally got a ll the peices together to build the cube... and i have. but now i cant seem to get the code to upload to the arduino? does anyone have any ideas. iv been writing a bit of code but i have no idea how to fix this... :confused: it says there's loads of errors in it when i try to upload or verify it!?
any help would again be greatly aprieciated... thanks

Got some code to review? Can't help with errors without seeing what you have.

ahh of course... https://github.com/AsherGlick/Charliecube/zipball/master this is the link to download the source code.. im not sure if he has used a different program to write/upload it, or some way of loading with the errors in hte code stil? im well confused.. i have re-written the code to work with my leds so if u could figure this out i can just fix what i need to in my vesion... thanks agin dude. :smiley: