Go Down

Topic: ShiftPWM support topic. Latest update: Schematics, high power LED's, LED strips (Read 83 times) previous topic - next topic

FireSlash

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. =(

elcojacobs

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.

FireSlash

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

nabbl

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:
Code: [Select]

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:

http://www.youtube.com/watch?v=n2icu88e8to

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

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

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

elcojacobs

Why did you change this line:
Code: [Select]
int numRGBleds = numRegisters*8/3;
into this?
Code: [Select]
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.

nabbl

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?


elcojacobs

Quote
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.

nabbl


Quote
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

http://www.youtube.com/watch?v=GUtdojLLIJs

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

elcojacobs

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

At which pin did you have that capacitor?

nabbl

I started with this:



http://arduino.cc/en/Tutorial/ShiftOut

Looks like I messed it up at that time :(

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...

elcojacobs

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.

cjdelphi

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 :)


thanks for your time :)

cjdelphi


vljubojevic

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)?

vljubojevic

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.

Go Up