views:

631

answers:

3

Hi guys,

Ive just bought a Rainbowduino to control a load of individual LEDs (NOT an RGB matrix). All the documentation so far is aimed towards controlling RGB arrays which is not what I'm after.

If youre unfamiliar with the Rainbowduino its an Arduino clone with 24 constant current channels of 120mA, 8 super source driver channel of 500mA each and a wide output voltage adaption from 5V-12VDC. Perfect for driving LEDs. The product webpage is here: http://www.seeedstudio.com/blog/?page_id=187

Ive connected up 16 LEDs and want to be able to turn each one on and off individually with digitalWrite(). Ive uploaded some demo code to the board which isnt really working. Ive worked out that the 8 driver source channels are easily controllable with digitalWrite() on pins 3-11. However controlling the other 24 sink channels is more difficult. Apparently they are controlled by 3 shift registers (one each) which I can only access with shiftOut. Ive got no idea how this works. Can somebody help point me in the right direction?

Half the LEDs are wired into Blue 1-8 and the other half are wired into Green 1-8. The positive legs are wired into VCC1-2 which have been set to HIGH. Im confident the circuit is wired up correctly, its the programming im having issues with.

Ive looked over the sample code which is shipped with the Rainbowduino but I cant make make sense of it. Can anybody help?

+3  A: 

The use of a shift register to multiplex (or de-multiplex, depending on your point of view) inputs/outputs is very common in digital electronics.

Basically, you trade saving pins on your controller for having to include another chip (the shift register) in the design.

In this case, the register works as a serial-to-parallel converter; it has a serial input line, which is fed with bits from your CPU. It also has 8 parallel outputs, connected to an 8-bit memory that is loaded serially from the CPU. Using this, you can "shift out" 8 bits of data on a single pin (plus one pin for clocking, typically), which are then stored in the shift register and can drive 8 LEDs in parallel.

In this particular case, you need to figure out which AVR port pins the shift registers (the MBI5168 constant-current sink drivers contain the shift registers, here) are connected to. They ought to be chained to a pair of outputs, one for data and one for clock. Once you know those pins, you should be able to drive them yourself using the ShiftOut command.

Digging a bit further, this sample "sketch" contains the following definitions, in the file called "Rainbow.h":

//MBI5168
#define SH_DIR_OE    DDRC
#define SH_DIR_SDI   DDRC
#define SH_DIR_CLK   DDRC
#define SH_DIR_LE    DDRC

#define SH_BIT_OE    0x08
#define SH_BIT_SDI   0x01
#define SH_BIT_CLK   0x02
#define SH_BIT_LE    0x04

#define SH_PORT_OE   PORTC
#define SH_PORT_SDI  PORTC
#define SH_PORT_CLK  PORTC
#define SH_PORT_LE   PORTC

This is of course total digital "hearsay" (I don't own the device, I've never programmed on any kind of *duino), but I'd say this is the particle-spewing bullet delivery system you're looking for.

I interpret this like so:

  • PORTC is the one connected to the shift registers, all control pins are in PORTC.
  • Four pins are dedicated (rather than the optimistic two I mentioned above).
  • The clock is pin PORTC:2 and the data is PORTC:1.
unwind
Thanks unwind, im familiar with the basics of shift registers but I just dont know which 2 ports (data pin and clock pin) I need to use for each channel.
James
Many thanks again unwind. I used your answer along with the sample code the Rainbowduino posted yesterday (here: http://www.seeedstudio.com/blog/?p=512) and now its working perfectly. Video here: http://www.youtube.com/watch?v=t9m28RFg14E
James
A: 

Hi, great job man! I would like to do the same thing: control single leds using the RGB pins. But really can't understand how to guess the pinout of the 24RGB pins and write the code to address the single pins. I would be really grateful if you could point me in the right direction, can suggest some datasheet or else that can help. My email: [email protected] Thanks a lot, bless kk

+2  A: 

controlling each single led is quite time expensive, it's better to think in rows, whereas each led color is presented as on bit, so it's 8bits x 3 colors (red, green, blue). I wrote a small Rainbowduino Library which allows you to set each row or frame easily. :

Read my blog post on that

Cheers!

RngTng
ah, an and see my Rainbowduino Editor: mtXcontrol as well:http://www.rngtng.com/mtXcontrol
RngTng