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

Starmonkey:
After 3 days of trying to get an Arduino Uno with a TLC5916IN with shiftPWM I still cannot get it to function properly. I am unsure as to where the problem even stems from, Although the code says to put ShiftPWM_invertOutputs = true for the tlc5916 when i do so my LED lights up when ShiftPWM.SetAll(0); when set at 255 my led is still dimly lighting and blinks on and off at a steady rate. Any intermediate value leads to the led blinking on and off in a non random pattern. I have constructed the circuit as per the instructions on the website including decoupling capacitors. Does the problem lie with the fact that I am using a single LED for testing rather than a common anode RGB led? After writing the above i think it makes sense that the LED is blinking the way it does as the load would normally be split by 3 and so the visible blinking from one would correspond to a dimming effect on an RGB LED. However I still do not understand why it the LED is on when it should be off (granted my understanding of how a common anode led functions is extremely limited) If its simply a matter of plugging in a RGB LED case I'm going to feel very dumb about wasting so much time trying to find a problem in my circuitry.

ShiftPWM_invertOutputs should be set to false for the TLC5916. That was an error on my website, which has been corrected now. How many 5916's do you have connected and how long are your wires? It sounds like your clock signal is missed sometimes. You can try using the push-pull line driver to improve the clock signal.

Hippynerd:
I cant seem to get this to install or work.
I am using ubuntu, I tried to follow the very simple directions, but had to vary a bit.

"
Go to the GitHub repository the download the latest version of ShiftPWM.
Extract ShiftPWM directory from the archive to your Arduino libraries directory (for example: ???\arduino-1.0\libraries).
Extract it with the ShiftPWM directory intact, so the result will be ???\arduino-1.0\libraries\ShiftPWM).
Restart Arduino
Open one of the examples from the Arduino menu (File –> Examples –> ShiftPWM –> pick one) "

I cant extract to the /usr/share/arduino directory as the user, that has to be done as root. I extracted the files as user, then su'd to root, and copied the files to /usr/source/arduino/libraries, then chown -R, chgrp -R, and chmod -R to have all the files ownership, and everything set like the other files.
When I try to load up an example, they are not listed, but I can load the libarary by clicking sketch/import library (ShiftPWM shows up in that list).
I copied the examples directory over to the examples directory under /usr/share/arduino, but no shiftPWM examples show up in the program.

I tried downloading the zip file, and then su ing, and unzipped the file in the /usr/share/arduino/libraries as root. It still doesnt show up any examples.

I opened the ShiftPWM_RGB_Example.ino in a text editor, copied it to a blank sketch, and tried to upload it to my uno, but it failed, stating:

/usr/share/arduino/libraries/ShiftPWM/CShiftPWM.cpp: In member function ‘bool CShiftPWM::IsValidPin(int)’:

/usr/share/arduino/libraries/ShiftPWM/CShiftPWM.cpp:51:61: error: ‘F’ was not declared in this scope
/usr/share/arduino/libraries/ShiftPWM/CShiftPWM.cpp: In member function ‘void CShiftPWM::SetAmountOfRegisters(unsigned char)’:
/usr/share/arduino/libraries/ShiftPWM/CShiftPWM.cpp:229:94: error: ‘F’ was not declared in this scope
/usr/share/arduino/libraries/ShiftPWM/CShiftPWM.cpp: In member function ‘bool CShiftPWM::LoadNotTooHigh()’:
/usr/share/arduino/libraries/ShiftPWM/CShiftPWM.cpp:253:44: error: ‘F’ was not declared in this scope
/usr/share/arduino/libraries/ShiftPWM/CShiftPWM.cpp: In member function ‘void CShiftPWM::Start(int, unsigned char)’:
/usr/share/arduino/libraries/ShiftPWM/CShiftPWM.cpp:297:11: error: ‘SS’ was not declared in this scope
/usr/share/arduino/libraries/ShiftPWM/CShiftPWM.cpp:316:71: error: ‘F’ was not declared in this scope
/usr/share/arduino/libraries/ShiftPWM/CShiftPWM.cpp: In member function ‘void CShiftPWM::PrintInterruptLoad()’:
/usr/share/arduino/libraries/ShiftPWM/CShiftPWM.cpp:416:45: error: ‘F’ was not declared in this scope
/usr/share/arduino/libraries/ShiftPWM/CShiftPWM.cpp:426:45: error: ‘F’ was not declared in this scope
/usr/share/arduino/libraries/ShiftPWM/CShiftPWM.cpp:467:38: error: ‘F’ was not declared in this scope




I have another computer I could try it on, but I will have to free up some space on that computer to install it.

I have not tried ShiftPWM on Linux, but I can tell you that in your library directory, you should have a directory called ShiftPWM. In this directory you will have the file CShiftPWM.h and his friends.

I don't know if that is the cause of the compiler not recognizing the F() function. That is an Arduino version of PSTR(). Is your Arduino install up to date?

elcojacobs:
ShiftPWM_invertOutputs should be set to false for the TLC5916. That was an error on my website, which has been corrected now. How many 5916's do you have connected and how long are your wires? It sounds like your clock signal is missed sometimes. You can try using the push-pull line driver to improve the clock signal.

I have only a single 5916 wired in at the moment, everything is just bread boarded right now and so the wires from the arduino to the 5916 are only about 4 cm. I'll try to add in the push-pull line driver and see what happens.

I have tried many things, none of which have worked. I think I first tried to unzip as user, and it wouldnt let me unzip it to /user/source/arduinio/libraries, so I unzipped it to a folder on my desktop. Then I logged in as root, and copied that folder (ShiftPWM) to /usr/source/arduino/libraries, changed ownership to root recursively, changed group to root recursivly, and changed the file permissions to reflect what other file permissions were in the same directories. When that didnt work, I looked around and found an examples directory, and put the 2 directories that were in the examples folder, into the /user/share/arduino/examples directory

/usr/share/arduino/examples$ ls
1.Basics 4.Communication 7.Display ShiftPWM_Non_Blocking
2.Digital 5.Control 8.Strings ShiftPWM_RGB_Example
3.Analog 6.Sensors ArduinoISP

It still didnt work.

/usr/share/arduino$ ls
Arduino.mk examples hardware lib libraries reference tools

/usr/share/arduino/libraries$ ls
ArduinoTestSuite examples Matrix ShiftPWM Sprite
EEPROM Firmata SD SoftwareSerial Stepper
Ethernet LiquidCrystal Servo SPI Wire
/usr/share/arduino/libraries$ cd ShiftPWM/
/usr/share/arduino/libraries/ShiftPWM$ ls
CShiftPWM.cpp examples pins_arduino_compile_time.h
CShiftPWM.h keywords.txt ShiftPWM.h

I just tried copying the ShiftPWM directory to the examples directory and no luck there too.

So, I have a copy of the ShiftPWM directory in /usr/share/arduino/libraries, and a copy in /user/share/arduino/examples, and I have a copy of the exampes directorys also in there.

I have an old mac that I was able to install it on, and i was able to get it working on a couple test fixtures I setup, but I still wont work on my main computer.

This version of arduino software is 0022ubuntu0.1 It says alpha. Its THE version available for ubuntu.

If I click sketch/import library, it shows the ShiftPWM library, so the program does see stuff I added, but fails when I try it, and doesnt show up in my examples menu.


Using that old mac, I was able to get shiftpwm running on my uno. I have 2 test setups both use 8 RGB LEDs an 3 Shift registers. Each setup has different pin grouping that I havnt figured out yet. One setup uses 1 chip for each color (red, green, blue), the other one is setup with the LEDs interlacd RBGRGB....
The one that is RGBRGB seems to work as expected, but the other one seems work wrong, even if i set its pingrouping to 8.

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: