Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems controlling a Rainbowduino

Tags:

I've 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 you're unfamiliar with the Rainbowduino it's an Arduino clone with 24 constant current channels of 120 mA, 8 super source driver channel of 500 mA each and a wide output voltage adaption from 5 V - 12 V DC. Perfect for driving LEDs. The product webpage is here: http://www.seeedstudio.com/blog/?page_id=187

I've connected up 16 LEDs and want to be able to turn each one on and off individually with digitalWrite(). I've uploaded some demo code to the board which isn't really working. I've 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. I've 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. I'm confident the circuit is wired up correctly, it's the programming I'm having issues with.

I've looked over the sample code which is shipped with the Rainbowduino, but I can't make sense of it. How can I fix this problem?

like image 893
James Avatar asked Jul 15 '09 11:07

James


1 Answers

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.
like image 132
unwind Avatar answered Nov 15 '22 04:11

unwind