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

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:

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

...

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

Hi,
I'm not very good in coding Arduinos, but I wonder if you could include the ShiftPWM library into the "master" library?

Just sayin'.

Hi,

let me share an application of ShiftPWM with Souliss to make it controlled over Android and driven by the music played by the smartphone :slight_smile:

Regards,
Dario.

Hi!

I'm running into some troubles using your library together with other devices running off of interrupts and sharing the SPI bus. In our case it's a radio frequency module transceiver, it's for sending data around. Upon receiving a valid preamble it sends an interrupt which triggers the ISR for reading the message from the radios registers, all fine and well, but it stops doing this when used in cominbation with ShiftPWM. I suspect because of interrupts being disabled at some points and atomic operations that need to be protected from other interrupts?

Is there anyone who has experience with this kind of situation?

Another thing, there is a start function, but is there a stop? Any way to disable interrupts for this library (without doing it so globally)?

PS the radio library we are using is this excellent piece of software written by mikem RF22: RF22 library for Arduino

I've tried to configure the ShiftPMW with the Arduino Micro using the Leonardo defaults (MOSI and SCK) but I'm getting the following compiling error:

arduino-1.0.5-r2\libraries\ShiftPWM\CShiftPWM.cpp: In member function 'void CShiftPWM::InitTimer2()':
error: 'TCCR2B' was not declared in this scope
error: 'WGM22' was not declared in this scope
error: 'TCCR2A' was not declared in this scope
error: 'WGM21' was not declared in this scope
error: 'WGM20' was not declared in this scope
error: 'CS22' was not declared in this scope
error: 'CS21' was not declared in this scope
error: 'CS20' was not declared in this scope
error: 'CS22' was not declared in this scope
error: 'CS21' was not declared in this scope
error: 'CS20' was not declared in this scope
error: 'CS22' was not declared in this scope
error: 'CS21' was not declared in this scope
error: 'CS20' was not declared in this scope
error: 'CS22' was not declared in this scope
error: 'CS21' was not declared in this scope
error: 'CS20' was not declared in this scope
error: 'CS22' was not declared in this scope
error: 'CS21' was not declared in this scope
error: 'CS20' was not declared in this scope
error: 'CS22' was not declared in this scope
error: 'CS21' was not declared in this scope
error: 'CS20' was not declared in this scope
error: 'OCR2A' was not declared in this scope

I cannot find any suggestions on the support boards so I'm hoping you can offer some guidance.
Thanks

Hello, I'm having some trouble with the library, or the examples, not sure which.

I've wired everything according to the schematic, and it all works fine when I connect it to the SPI pins., but when I change to no SPI (I'll need it for a digipot later), they all start twitching and blinking mostly fully on or just something that I can only describe as random behavior. I've tried clearing the code and only setting the values one by one but still, unexpected behavior occurs. Anyone else had this problem and solved it perhaps?

I have not seen any releases of ShiftMatrixPWM since Elco's comment of Aug 9, 2012. Does anyone have a working library (plus any improvements) they would like to share?

I have tried working with an pre-release library posted here a while back, but my C++ is not good enough to update the library. With the release of cheap faster boards like the Teensy 3.1 ($19.80) I'd like to try this library on larger LED arrays if the pinouts could be mapped. (I get PORTB, C, and D errors on compile). Adding setPinGrouping(8) to use with 8x8 LED boards from ShiftPWM would also be helpful. I for one would be willing to test the code on a number of LED configurations.

Hi all,

I have problems with using the shiftpwm library with the EthernetUdp or the ArdOSC libraries.

Here is my code:

#include <SPI.h> 
#include <Ethernet.h>
#include <ArdOSC.h>

byte myMac[] = {0x90, 0xA2, 0xDA, 0x0F, 0x37, 0xEF  };
byte myIp[]  = { 2, 0, 0, 50 };
int  serverPort  = 12334;

int pin=100;
int value=100;
int t=100;

OSCServer server;

const int ShiftPWM_latchPin=8;
// #define SHIFTPWM_NOSPI
// const int ShiftPWM_dataPin = 11;
// const int ShiftPWM_clockPin = 13;

const bool ShiftPWM_invertOutputs = false; 
const bool ShiftPWM_balanceLoad = false;

#include <ShiftPWM.h>  

unsigned char maxBrightness = 255;
unsigned char pwmFrequency = 75;
int numRegisters = 8;

int r = 0;

void setup()   {     
  Ethernet.begin(myMac ,myIp); 
 server.begin(serverPort);
 
  //set callback function
 server.addCallback("/wall/1",&func1);

  ShiftPWM.SetAmountOfRegisters(numRegisters);
  ShiftPWM.Start(pwmFrequency,maxBrightness);  
  ShiftPWM.SetAll(r);
}

void loop() {
  if(server.aviableCheck()>0){    
    ShiftPWM.SetOne(pin, value);
  }  
}

void func1(OSCMessage *_mes){
  pin = _mes->getArgInt32(0);
  value = _mes->getArgInt32(1);
}

If I comment this line in the void setup: ShiftPWM.Start(pwmFrequency,maxBrightness);
then everything if fine. But of course I need it to use shiftPWM. Uncommenting the lines for the noSPI option didn't do the trick either.

Any help is greatly appreciated!

p

Does anyone know how to combine ShiftPWM with DMXSerial? Or know of any similar solutions? Working on the code but gets errors. I can share what I have.

So I am jumping on the RGB matrix bandwagon.

I've desgined a PCB which seems similar to what elco posted, except that instead of the FET/Diode/595 arrangement for the row drivers, I just have a MIC2981. Would this work, or do I need to do add something else?

I am using the ShiftPWM library to drive 171 white LEDs on 22 TLC5916 shift registers (serial daisy-chained). I am running into a strange anomaly, though. The last (read OUT7) LED attached to some of the later registers in the chain are turning on when earlier LEDs are turned on.

I am running a test where each LED is faded on and off, in sequence. This sequence seems to run fine, however LED 127, 143, 151, 159 and 167 seem to flicker dimly throughout the sequence. These LEDs are OUT7 of registers 16, 18, 19, 20, and 21.

Strangely, when the sequence reaches each of these LEDs, the flickering stops for a couple of seconds (on that LED only). All 5 of these LEDs seem to be flickering in time at the same brightness.

I have adjusted PWM frequency, brightness levels, forcing these LEDs to 0 brightness on each pass, and the only effect I've seen is that when setting the maximum brightness of the intended LED very low, the flickering brightness decreases significantly as well.

Has anyone else experienced anything like this? Thanks for your help.

Hi !

I'm pretty amazed by the work done on ShiftPWM...
The functions, code and tests are really very pleasant to use, and helped me understand how constant current shift registers (in my case) work

I'm trying to use three daisy-chained STP16CPS05. I've seen there's a board with four STP04CM05XTTR, so it should be possible to use ShiftPWM in my case too.
As suggested on the web and datasheet, I've wired them like this :

  • 1k resistor between the R-Ext pin and ground
  • ~OE pin to ground
  • 100nF capacitor between Vdd and GND pins
  • 200uF tank capacitor for the whole power supply
  • SDO of each component to SDI of the next one

There are two differences between my component and the STP04 :

  • it is 16-bit capable
  • it has 16 outputs

Here is what I did :

  • As I'm using an Arduino Uno, I've uncommented the line to use Timer2
#define SHIFTPWM_USE_TIMER2
  • As it is 16 bits, i've adapted the value of maxBrightness
unsigned char maxBrightness = 65535;
  • I think I'm supposed to change numRegisters and numOutputs too
unsigned int numRegisters = 3;
unsigned int numOutputs = numRegisters*16;
  • And I've tried to add a new function to the library, in order to specify the number of channels per component :
void CShiftPWM::SetAmountOfRegistersAndOuts(unsigned char newAmount, int newNumChans){
 cli(); // Disable interrupt
 unsigned char oldAmount = m_amountOfRegisters;
 m_amountOfRegisters = newAmount;
 m_amountOfOutputs = m_amountOfRegisters * newNumChans;

 if(LoadNotTooHigh() ){ //Check if new amount will not result in deadlock
 m_PWMValues = (unsigned char *) realloc(m_PWMValues, newAmount * newNumChans); //resize array for PWMValues

 for(int k=oldAmount; k < (newAmount * newNumChans);k++){
 m_PWMValues[k] = 0; //set new values to zero
 }
 sei(); //Re-enable interrupt
 }
 else{
 // New value would result in deadlock, keep old values and print an error message
 m_amountOfRegisters = oldAmount;
 m_amountOfOutputs = m_amountOfRegisters * newNumChans;
 Serial.println(F("Amount of registers is not increased, because load would become too high"));
 sei();
 }
}

But I have problems with the addresses of the LEDs of the 2nd and 3rd component (16-to-31 and 32-to-47). I've also tested with just of the two modifications (either maxBrightness or numRegisters-and-numOutputs) and addresses for the 2nd and 3rd components seem to be messed up too...

Here's my test code :

  for (int i = 0 ; i < numOutputs ; i++) {
    if (i > 0) {ShiftPWM.SetOne(i-1 , 0);}
    else {ShiftPWM.SetOne(numOutputs-1 , 0);}
    ShiftPWM.SetOne(i , maxBrightness);
      Serial.println(i);
      delay(500);
  }

I'm quite sure I should do modifications in the library, but I don't know exactly where
Could my problems be related to bitshifting in the lib ? Or MSB / LSB ? Or SPI specific commands ?

Some help will be more than appreciated :slight_smile:
Thanks in advance !

Mil

Hi everyone, elco,

I've been experimenting with ShiftPWM and ShiftMatrixPWM for a while now, as I am working on a project revolving around it, and doing so I encountered an odd behavior of the library... or circuitry, I'm not entirely sure, but seems more like it's software bug.

What I am trying to build here, is a matrix made out of RGB led strip segments. The idea is, to interface a big numer of 12 LED's that are connected as matrix. So I've build a following circuit:


Apologies for such an awful image.

Top register is regular 74HC595, bottom one is TPIC6B595 PFET is now IRF9310, it's an overkill, but it's what I had laying around, in final design I intend to use FDC638P instead. FET's gate is driven by eqvivalent of BC847.

Since now I'm only testing high voltage switching part, I only connected one LED to see how it works.

So it does perform as expected, BUT, and here goes the whole reason why I'm writing here,
whilst using SetAll method, LED current is going up to it's 20mA, and led is shining bright.
But when method SetOne is used, led is glowing at a half of brightness, and current is 2.5mA respectively.

So it seems to me, that PWM is generate d somehow differently in those two methodes. As soon as I will get my hands on osciloscope, I'm gonna examine difference in those signals.

My other concern is, that since now I'm testing it with only one LED, the whole thing might behave differently with full 8x8 matrix, but for now, I had only one FET to test it on breadboard.

That would be all for now. If anyone has experience building something similar, any advice would be appreciated.

P.S.
Since I have to get this project done by the end of the month, I'm looking for alternative strategies as well. Maybe I should:

  • Switch to 5V LEDs instead of 12V strip segments, and just get more powerful leds to achieve necessary brightness
  • Use series connection instead of matrix
  • Use FET for driving LEDs cathode as well as anode (instead of TPIC6B595)

Although.. ideal case would be to understand the mechanics of SetAll/SetOne function, and perhaps find out is something can be done in software..

Thank you, and have a nice day you all :slight_smile:

UPD:

So here are differences in SetOne and SetAll PWM signals.

I wonder why is it done so, and is there a way of getting the same duty cycle in SetOne as in SetAll.
Or am I talking gibberish? Because I don't entirely understand how PWM signals are formed in this library.