ShiftPWM support topic. Latest update: Schematics, high power LED's, LED strips

Looking for some advice here...how well does this library work when you start trying to multiplex the LED's? Is there any built in support for that? I'm looking to drive 100RGB led's multiplexed 10 times for a 10x10x10 RGB LED cube, would this be the fastest possible solution? What kind of processing power would I need to achieve persistence of vision across all 10 layers?

@mnpumar: There is a separate library that Elco wrote that does handle 2D led matrix. I believe this could be easily modified to run as a 3D cube. (ShiftPWM support topic. Latest update: Schematics, high power LED's, LED strips - #88 by system - LEDs and Multiplexing - Arduino Forum)

There are limits on how many LED's you can address and if you are using a standard Arduino (328) the limitation is the array size (memory limitation). But if you were to use a MEGA with more memory I believe you could go beyond that. Currently with a 328 Arduino the limit is 1024 Leds. I currently have this many Leds running in a 16x64 single colour matrix. There are a number of other variables that influence how many LED's you can address (Frequency and Brightness levels) vs the speed of the arduino.

I am not sure if 10x10x10 RGB would be feasible....that would be 300 LED's per plane of the cube, with 10 planes that would be 3000 LED's that would need to be addressed total. I just don't know if you could do this at a fast enough frequency to not have flicker......

But that is not to say don't try. Would be very awesome to see!!!

@milamber Thank you for the link! Is shiftMatrixPWM being actively developed alongside ShiftPWM? If so, where can I get the latest version?

I think it may be possible to do this using the ardunio uno. Has anybody tried using the uno to control shift registers running at 5V using something like this: http://rocky.digikey.com/WebLib/Texas%20Instruments/Web%20data/SN74LVC4245A.pdf ? Would this work?

I'm nearing wits end on this one, perhaps someone else can point out my mistake.

I'm trying to use shiftmatrixpwm to drive a fairly simple LED matrix, which is wired like this:

so I have my schematic:

And all is well. Sort of. If I clear all and set 0,0 on, I get 8 LEDs on instead. This persists through functions like OneByOneFast/Slow, etc.

Scope output for data, clock, and latch respectively on the high and low side respectively.

I'm out of ideas. I've triple checked the pins, I'm using the simple example sketch, this should really work. =(

Did you build the LED matrix yourself or did you use a premade one?
Do you have resistors in series with your LED's somewhere?

@mnpumar: I am not actively developing the matrix version. I have not updated it for a year, because I have been busy with BrewPi.
I still intend to get it up to par with the normal version and upload it to GitHub, but I don't have time soon.

This is pre-built. It's actually the lamp matrix on a Williams pinball machine. The lamps have been replaced with compatible LEDs which have their own local resistors.

The matrix itself has been tested and worked fine with an older board design I had using a TLC5940, and it was a working pull from an existing game, so I have no reason to doubt the matrix at this point.

Further inspection shows that the high side was inverted, so I corrected this but now I get nothing at all. The high side cycles as one would (I assume) expect, simply going down each rail and giving it a pulse. Conversely, the low side seems to be exhibiting a similar "correct" behavior of sinking current per rail at specific times. However it's like the timings never line up. If I tie a LED from +5 to the tpic's drains, it pulses around once every 1.5 seconds with onebyonefast(), and the scope confirms the high side is pulsing every rail. So I have no idea why I'm not getting anything back. I went back and did a sanity check on the matrix and it's not plugged in backwards.

I'm sure i'm doing something obviously wrong somewhere, but I can't find it.

Edit 2: Ok, yeah, that seems to be the case.

Notice that ch2 is sinking just before power is applied, during an idle trough when power was already bleeding out of the matrix. So what it sink's during this cycle is nowhere near enough to light the LEDs

Edit 3: Ok, so individual outputs one at a time don't work, but fading in/out ALL at once works as you'd expect.

Edit 4: So ShiftMatrixPWM.OneByOneFast(); is the culprit. Manually controlling LEDs seems to work fine. PROBLEM SOLVED WOO

Hi there!
I'm just trying around with my first Arduino Project, but I have some flickering with the ShiftPWM-Lib.
I use 4 74HC595B1 Shift Registers to control about 10RGB-LED-Stripes. The 10th Stripe has about 1m distance to the breadboard/arduino.
I don't use mosfets, but some ULN2001A to power the Stripes.

Here is my code so far:

const int ShiftPWM_latchPin=8;
const bool ShiftPWM_invertOutputs = false; 
const bool ShiftPWM_balanceLoad = false;

#include <ShiftPWM.h>   // include ShiftPWM.h after setting the pins!
unsigned char maxBrightness = 255;
unsigned char pwmFrequency = 100;
int numRegisters = 4;
int numRGBleds = int(numRegisters*8/3)-1;
int iDelay = 5;

void setup(){
  Serial.begin(9600);
  Serial.println("---------------");
  Serial.println("Reset / Start");
  Serial.println("---------------");

  // Sets the number of 8-bit registers that are used.
  ShiftPWM.SetAmountOfRegisters(numRegisters);

  // SetPinGrouping allows flexibility in LED setup. 
  // If your LED's are connected like this: RRRRGGGGBBBBRRRRGGGGBBBB, use SetPinGrouping(4).
  ShiftPWM.SetPinGrouping(1); //This is the default, but I added here to demonstrate how to use the funtion

  ShiftPWM.Start(pwmFrequency,maxBrightness);

  // Print information about the interrupt frequency, duration and load on your program
  ShiftPWM.PrintInterruptLoad();
  ShiftPWM.SetAll(0);
  Serial.print("Maximum Brightness: ");
  Serial.println(maxBrightness);
  Serial.print("Delay is set to: ");
  Serial.print(iDelay);
  Serial.println("ms.");
  Serial.print("Calculated RGB-LEDs: ");
  Serial.println(numRGBleds);
  Serial.println("---------------");
}


void loop()
{ 
  ShiftPWM.OneByOneFast();
}

I also made a Video some weeks ago:

There you can see that the last Stripes are flickering / react too early. In natura it's even worse :frowning:

I hope you can reproduce my problem and maybe could help me :slight_smile:

Sorry for my (very) bad english and greetings from Germany,
Horst

Why did you change this line:

int numRGBleds = numRegisters*8/3;

into this?

int numRGBleds = int(numRegisters*8/3)-1;

Adding the line driver circuit on my website might help with flickering, start with adding it to your clock line.
The arduino has some difficulty driving long signal lines at 4 MHz.
Do you have decoupling capacitors on your shift registers?

Edit: Could you try setting the number of shift registers to 5 and report what happens? This should tell you whether it is a software or hardware problem.

Hi Elco,
I changed this line some time ago, seemed legit when I did that. I've changed it back.
I edited the code so the number of Shift Registers is now 5. What happens? Nothing :). It's now testing every color at it works. Only the 11th "imaginary"-Stripe is tested so all the lights are off.
Currently I'm just using one capacitors with the first register.

Is 1 meter already a "huge" distance for the Arduino?

It's now testing every color at it works.

I cannot make sense of this sentence. Did the problem going away by setting the number of registers to 5? In that case it is a bug in the library that I have to fix.

You should have a decoupling capacitor on each shift register of about 100nF or bigger.

1m is not huge, but it depends on your wire and how much is on the wire.

elcojacobs:

It's now testing every color at it works.

I cannot make sense of this sentence.

Hm. I meant "It's now testing every color and it works." What I wanted to say is: It doesn't seem to be an error of the library or the code by itself. It runs as expected: Every Stripe changes from Red To Green To Blue. The Flickering is not has intense as in the video before but still there. I just uploaded a new one where you can see what I mean:
Have a look at the last Stripes at 0:04

€dit: Strange! I accidentally removed the one-and-only capacitor and now there is no more flickering?

Strange! I accidentally removed the one-and-only capacitor and now there is no more flickering?

At which pin did you have that capacitor?

I started with this:

Looks like I messed it up at that time :frowning:

Edit: Now I see what I f****d up -.-" First Read, then wire... Now it's connected between Pin 8 and 16...

Sorry for stealing your time and thank you for your patience...

I really do not understand why they still have that 1uF capacitor on the latch line in that tutorial.
It just shouldn't be there.

it would be great if you could get these libraries to support shiftpwm using an attiny45/85

i attached my cut down version which supports the 85 over arduino as isp / select the attiny85 1/8mhz internal osc

extract inside arduino...\hardware

restart... now then you can compile and test it without needing an attiny chip ill glady test your code :slight_smile:

thanks for your time :slight_smile:

http://hlt.media.mit.edu/?p=1695

i have pin compatibility errors with the pwmlibrary

Hello,

I am working on my first Arduino project, a 16 x 16 monochrome led matrix controlled with ShiftMatrixPWM. All is going fine, but I am afraid I will run out of memory since 32k memory on my Uno is too small to store all the patterns to be displayed on the led matrix. MicroSD cards also use spi and are conflicting with ShiftMatrixPWM.

While waiting for a non-spi ShiftMatrixPWM, I am asking if there is any way to use a sd card reader, even if it means that the led matrix periodically gets disconnected for a moment while sd card is accessed (reading only)?

Replying go myself, just for a record here.

I found that sdFat library can be configured to use software SPI on any digital pins.
So now both ShiftMatrixPWM and sdFat are running on the same arduino.
No problems so far contolling just a couple of leds in the prototype.

Hi,

I hope someone has done this before and that there is a simple fix for it.

I have a relatively complex system of about 30 or so library files that I am using for a project. One of those files is a 'master' class, allowing me to keep my actual sketch I load onto my arduino super short, like this:

// sketch
#include "Master.h"

Master myObject;

void setup(){
myObject.begin();
}
void loop(){
myObject.update();
}

I would like to include the ShiftPWM library within this system of files. So, I created my own 'Registers.h' file, which would deal with interacting between my own LED objects in my code and the shiftPWM implementation. The top of my 'Registers.h' file looks like this (similar to how my working sketches look):

// Registers.h
#define SHIFTPWM_NOSPI
const int ShiftPWM_latchPin = 2;
const int ShiftPWM_dataPin  = 4;
const int ShiftPWM_clockPin = 3;
const bool ShiftPWM_invertOutputs = true;
const bool ShiftPWM_balanceLoad = false;
#include "../ShiftPWM/ShiftPWM.h" // this syntax is required to include this library from within a separate folder

When I go to compile the code, I get the following errors:

multiple definitions of '__vector_11'
.../ShiftPWM/ShiftPWM.h:175 first defined here
multiple definitions of 'ShiftPWM'
.../ShiftPWM/ShiftPWM.h:175 first defined here

The line the errors are referring to is:

ISR(TIMER1_COMPA_vect) {
	ShiftPWM_handleInterrupt();

It seems, from my research, that people get these sorts of errors when two libraries are trying to use the same timer to handle interrupts. A lot of people experience issues when they try to use the Servo and Tone libraries, for instance. But, I don't think that I am defining ShiftPWM twice, and don't understand why my compiler is suggesting that 'ShiftPWM' and '__vector_11' are first defined in the ISR() macro.

I don't get this error when I run the example sketch Elco Jacobs provides with the libraries. I even crafted my own example sketch only using the ShiftPWM library and all works well.

Is there something particular I need to do to be able to #include this library into one of my own? I feel like there has to be a stupid easy fix that I am just not seeing.

Thanks in advance!

Hi,

I get errors while using this with the DUE, so I guess its not ready yet. Any date when its done? Or are there any simple steps to make it work?
My Goal is to have Duo LEDs Shiftpwmed on the DUE :slight_smile: