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

I already did this here

You can't use pwm on relays btw. I will post my code this afternoon

elcojacobs said before that ShiftPWM could be used for relays just set to maxbrightness for on and zero for off.
Looking forward to seeing your code.

ematson, I too would love to see your code and how you setup vixen to use it. I have a similar "Christmas" project in mind.

I have read threw quite a bit of the forum posts, and still had a few questions. I am trying to make tail lights for my car that are a set of 5x10 rgb LEDs. I was wondering if it would be better to use ShiftMatrixPWM or ShiftPWM? I would essentially be controlling 600 LEDs so it is within the scope of ShiftPWM but I am concerned about the brightness. I'm very new to programming and Arduino. So if there are some easy examples that would help me out it would be greatly appreciated, maybe something that will help me build a power supply for the ShiftMatrixPWM? I have already made a mock up of an led matrix. Thanks for any help.

Skinner

I have made a schematic of the circuit I would like to make. Any help wiring it to the arduino would be greatly appreciated. Also i'm not sure about my power circuit and if I need anything else like capacitors in it.

Hey here's the vixen code for you all. Tell me if it works as it isn't my original code. It got erased. Here it is

#include <SPI.h>


//Data pin is MOSI (atmega168/328: pin 11. Mega: 51) 
//Clock pin is SCK (atmega168/328: pin 13. Mega: 52)
const int ShiftPWM_latchPin=8;
bool ShiftPWM_invertOutputs = 1; // if invertOutputs is 1, outputs will be active low. Usefull for common anode RGB led's.

#include <ShiftPWM.h>   // include ShiftPWM.h after setting the pins!


unsigned char maxBrightness = 255;
unsigned char pwmFrequency = 75;
const int numRegisters = 6;
const int CHANNELS = numRegisters*8;



const long baud = 19200; // USB Serial is actually always 12 Mbit/sec
HardwareSerial Uart = HardwareSerial();

static unsigned char currByte;
static unsigned char prevByte;


unsigned char aChannelValues[CHANNELS];
unsigned char ChannelIndex = 0;


// the setup() method runs once, when the sketch starts

void setup() {
    pinMode(ShiftPWM_latchPin, OUTPUT);  
  SPI.setBitOrder(LSBFIRST);
  // SPI_CLOCK_DIV2 is only a tiny bit faster in sending out the last byte. 
  // SPI transfer and calculations overlap for the other bytes.
  SPI.setClockDivider(SPI_CLOCK_DIV4); 
  SPI.begin(); 
  
  Serial.begin(baud);
ShiftPWM.SetAmountOfRegisters(numRegisters);
  ShiftPWM.Start(pwmFrequency,maxBrightness);  
}


// the loop() methor runs over and over again,
// as long as the board has power
boolean bInDataBlock = false;
boolean bSerial = false;


void loop() {
  if (Serial.available())
  {
    if (Serial.available())
    {
      currByte = Serial.read();
      //Uart.write(currByte); return;
      bSerial = true;

    }
    

    
    if (bInDataBlock)
    {
      if (currByte == 0x7F) // Escape Sequence
      {
        if (bSerial) currByte = Serial.read();
        currByte += 0x4E; 
      }
      aChannelValues[ChannelIndex++] = currByte;
      if (ChannelIndex >= CHANNELS)
      {
        bInDataBlock = false;
        Transfer_To_Ports();
      }        
    } 
    
    if ( prevByte == 0x7e && currByte == 0x80 )
    {
      bInDataBlock = true;
      ChannelIndex = 0;
    }
    prevByte = currByte;
  }
}



void Transfer_To_Ports()
{
  for (int i; i < CHANNELS ; i++ )
  {  
    ShiftPWM.SetOne(i,aChannelValues[i]);
  }
}

What are these for.
HardwareSerial Uart = HardwareSerial();
Transfer_To_Ports();

This error when compiling
VixenShift.cpp: In function 'void loop()':
VixenShift:72: error: 'Transfer_To_Ports' was not declared in this scope

Could you give some basic info on how this code works. I am a newbie but want to understand

Thanks Again for your code and hard work put into it! I will be sure to give you credit in any code i create as well as my Light Displays!

Hi!

I put everything together and (first) thought it worked.

I got 4 Shift registered wired Serial with 16 DUO Leds. I uploadet the and it looked like as if it worked. But then it comes to the "Fade in all outputs" part. My Arduino crashes and it starts from the beginning.

How could that happen? Is it a wiring problem? I used the USB Port or a 10W power supply, the problem is the same.

I made a movie of my Problem attached to this post.

-tsaG

EDIT: I already uploaded the Blink.sketch to verify if the Arduino is working correctly, and it is.
I already changed the pwmFrequency or setClockDivider . but the problem persists.

IMG_0223.MOV (2.07 MB)

Sorry ron, I completely forgot to reply. Those are from the code that I modified. It is designed for teensy, a board with more functionality than a standard arduino. It should work if you delete the serial and uart line. As for the other error, its clearly defined in the function, so I don't know.

tsaG, sorry I can't help you, I currently don't have a way to open .mov on my tablet. I'll try to find an app, if I can, I'll post back

It seems as if you aren't using decoupling capacitors. Put a .1 uf capacitor between the 5v and gnd of each chip, because your chips signals probably look like this Do You Know WHY You’re Supposed To Use Decoupling Capacitors? | Hackaday

Ill give it a try. I tried getting the signal onto my osci. Its hard to trigger the signal when the arduino resets half every second :smiley:

It looks quite good, I think (?)

  1. Latch Pin
  2. Clock Pin

EDIT: I didnt check the Serial Input pin. Ill check it later!

Foto 1.JPG

Foto 2.JPG

Those seem fine. If the capacitors don't solve the problem then try making a sketch that uses the shiftout command that sets all outputs to high to rule out a bad power supply

The decoupling capacitor solved the problem. Thanks!

No problem. Decoupling caps are a frequently forgotten necessity

And elco, can I use other SPI devices while using shift(matrix)Pwm? Like ethernet shield and sd card etc.

Hi guys,

Sorry I have not been responding too much in this topic lately. I have been a bit busy.

I completely rewrote the ShiftPWM documentation. Now there is a function reference, a load estimator and schematics for regular LED's, high power LED's and LED strips. Please let me know if you are missing something or if I made any errors.

I also added a schematic for a push-pull line driver for when you have issues driving long signal wires.

I also update the ShiftPWM code base:

  • Moved some initialization into the library: cleaner sketches, easier to switch between SPI and no SPI.
  • Added optional load balancing: shift the PWM phase by 8 PWM bits for every register. This will distribute the current peeks more evenly.
  • Added Leonardo compatibility

And finally I opened a web shop where you can buy boards to drive 350mA high power LED's and LED strips.

Now that I got this done, I finally have time to work on the matrix version to get it up to par with the normal version, so I can officially release it. To answer ematson's question: I will rewrite the matrix version to inlcude a no-spi option as well.

So check it out at www.elcojacobs.com/shiftpwm

I am attempting to port this to Energia (Arduino IDE for the TI launchpad) I will post updates as I go

Hi,
Are there any software that you know which can provide a graphical user interface for us to easily change the sequence of the lights?
Something like Vixen Lights? (http://www.vixenlights.com/downloads.html, there's a plug-in called "Simple 595 with pulse width")
How do I get started?

Thanks a lot! :smiley:

This has been discussed previously. Go back a page or so

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.

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.