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

I think he was refering to this line in the example.pde:

const bool ShiftPWM_invertOutputs = 1; // if invertOutputs is 1, outputs will be active low. Usefull for common anode RGB led's.

I am sure this is just a binary switch. 1 is true, so it would invert(as he said active low). 0 is False, not inverted(active high). :slight_smile:

milamber:
I think he was refering to this line in the example.pde:

const bool ShiftPWM_invertOutputs = 1; // if invertOutputs is 1, outputs will be active low. Usefull for common anode RGB led's.

I am sure this is just a binary switch. 1 is true, so it would invert(as he said active low). 0 is False, not inverted(active high). :slight_smile:

Thank you, this worked a treat. Now I can continue my exploration into Arduinoness.
8)

I have a problem regarding the timeout duration for the example code. I'm currently using the ShiftPWM library in my first project with an Arduino to line the underside of my longboard with an array of 24 RGB LEDs passing through 9 shift registers. The electronics of the project are sound - I have 17 of the 24 LEDs wired up and working (the rest are being wired in tonight), and when plugged in via USB the examples run perfectly and for the full number of cycles. The problem comes when I disconnect the Arduino from the USB cord and attempt to power it via 9V. The board seems to reset itself quite frequently, interrupting itself less than 5 seconds after its initial execution and continually restarting in that fashion. At first I thought this had to do with the timeout comments in the ShiftPWM example code regarding the number of shift registers versus the interrupt duration. However, it's only 9 shift registers, meaning I should get close to the full 255 value for that duration. Does anyone have any ideas or comments on how to properly get this project functioning off a battery? Why is there this discrepancy between power sources?

Thanks in advance!

The problem comes when I disconnect the Arduino from the USB cord and attempt to power it via 9V.

If you are using those standard small 9vdc batteries then that is the reason for the failures, it just doesn't have the current capacity to handle your load. You need to use batteries that support the current requirements.

Lefty

retrolefty:

The problem comes when I disconnect the Arduino from the USB cord and attempt to power it via 9V.

If you are using those standard small 9vdc batteries then that is the reason for the failures, it just doesn't have the current capacity to handle your load. You need to use batteries that support the current requirements.

Lefty

Ah, thank you! What kind of battery/batteries should I use? Thanks so much.

What kind of battery/batteries should I use

A bigger one.

Voltage, anywhere from 8 to 12vdc
Current (MAH or AH) rating depends on how much current your project draws and for how long you want the battery to power the project. Rechargeable would save you lots of money in the long run. Learning about batteries and there specifications is part of learning of electronics. Do some research so you can answer your own questions in time, but ask questions when you get stuck or don't understand something.

First order of business is to know how much current your project draws, that takes a digital multimeter, which if you don't own one should get one as soon as possible. They can be very affordable and it's an important tool to have and learn to use if you want to be successful with electronic projects.

Lefty

retrolefty:

What kind of battery/batteries should I use

A bigger one.

This made me laugh way more than it should have :slight_smile:

How about this one? >> http://goo.gl/C82OT (58 Ah - hooah!)

Seriously though, LEDs are quite power hungry little beasts and will deplete small batteries in short order. Like Lefty says, you need to determine your device's current draw combined with the intended use for your device. If you want your design to run for several days off of a single battery/charge, your selection will be quite different than if you want to run it for a few minutes at a time. There is no shortage of information on the subject of power management available. It's an important aspect to learn and understand.

buzzdavidson:
This made me laugh way more than it should have :slight_smile:

How about this one? >> http://goo.gl/C82OT (58 Ah - hooah!)

Seriously though, LEDs are quite power hungry little beasts and will deplete small batteries in short order. Like Lefty says, you need to determine your device's current draw combined with the intended use for your device. If you want your design to run for several days off of a single battery/charge, your selection will be quite different than if you want to run it for a few minutes at a time. There is no shortage of information on the subject of power management available. It's an important aspect to learn and understand.

I really appreciate the suggestion, however I feel I should note that this project is simply lining the underside of my longboard with the array of LEDs; a 20-pound battery would be a little much! Regardless, I appreciate all the advice you and Lefty have given me; I've been e-mailing back and forth with Elco about the best solution for this particular application, which is to say, only being powered a few minutes at a time (just while I'm riding around). I wasn't aware that LEDs were so power-hungry; on the contrary, I always had them in my mind as being more efficient light sources, although I guess by typical lighting standards they probably are. At any rate, I think I'm nearing a solution, so thanks again for all the help.

Well the fact that your project can run on USB power (did I understand that correctly?) then your total current consumption must be under 500ma otherwise the thermofuse on the board would open up and power down the board.

So rechargeable Nimh AA batteries are stated good for 2500+ mah or so, so six or seven AA cells wired in series could power the board via the external power connector, or four AA cells wired in series could power the board via the ground and +5vdc pins. This should give you at least four hours of run time and probably the most cost effective batteries avalible.

Lefty

retrolefty:
Well the fact that your project can run on USB power (did I understand that correctly?) then your total current consumption must be under 500ma otherwise the thermofuse on the board would open up and power down the board.

So rechargeable Nimh AA batteries are stated good for 2500+ mah or so, so six or seven AA cells wired in series could power the board via the external power connector, or four AA cells wired in series could power the board via the ground and +5vdc pins. This should give you at least four hours of run time and probably the most cost effective batteries avalible.

Lefty

Yes, you understood that correctly; the project runs just fine on USB power. I'll look into a battery pack; definitely seems more cost-efficient than a bunch of lithion batteries.

Thanks,

Sam

samling:
I really appreciate the suggestion, however I feel I should note that this project is simply lining the underside of my longboard with the array of LEDs; a 20-pound battery would be a little much!

Oops, I left off the [SARCASM] tag on that one. It wasn't a serious suggestion :P...

Is a long board a kind of skate board or surf board or maybe just a long 2" by 4" board? :wink:

buzzdavidson: Oh alright, so I'm justified in laughing at the suggestion then. :slight_smile: I wasn't sure if I'd forgotten to mention if the project was for a longboard or not.

retrolefty: A longboard is a long, flat skateboard that's meant more for pure locomotion than tricks and such. I just graduated from UC Santa Barbara and am still living right near it, and the school and surrounding area is flat and close-quarters, very conducive to getting around on a skateboard. Here's a picture of one to get an idea; mine's slightly different in shape without a raised tail, but the same idea: http://www.urbanbluelongboards.com/longboards/ub240-longboard-angle.jpg

retrolefty: A longboard is a long, flat skateboard that's meant more for pure locomotion than tricks and such. I just graduated from UC Santa Barbara and am still living right near it, and the school and surrounding area is flat and close-quarters, very conducive to getting around on a skateboard. Here's a picture of one to get an idea; mine's slightly different in shape without a raised tail, but the same idea:

Nice area, I worked on a company project at Golita about 50 miles north of SB, lived in Lompoc for 18 months. The area up near SLO and Morro Bay were very nice also.

Lefty

ShiftPWM helped me complete my "flight suit" project-- a black flight suit with bands of red lights bouncing to music. There are other modes too: "rolling," "all fade," "random" and "gravity" and while I have ideas for more, the main one is "audio 1". I posted a brief demo video to my blog if you're curious. Lots more to post after Burning Man-- I hope it survives :slight_smile:

Elco, thanks again-- great library!

Salsaman, you are the first to come back with results on video!
Looks great. That's what makes it worth making this publicly available and supporting it. All the projects together should make a great gallery.

Now for somethings else: Who wants to test a matrix version of ShiftPWM?
This version uses shift registers for the columns, driven by SPI, and shift registers to alternate rows, bit banged. Both invertible, so it will suit any matrix setup.
Performance is about the same as one long chain of shift registers, but the amount of registers you require is a lot less. Downside is of course that the maximum on time of each led i 1/rows. But you can use more current per led to get about the same brightness.

8x8 RGB matrix: 3 column registers, 1 row register. 64 brightness levels, total refresh rate 60Hz (so combined pwm frequency of 8*60Hz). Load = 0.54.

16x16 RGB matrix: 6 column registers, 2 row registers, 32 brightness levels, total refresh rate 60Hz (so combined pwm frequency of 8*60Hz). Load = 0.79.

I don't have a led matrix, so I cannot test this code myself. Would be cool if it just worked, wouldn't it?

Code is attached, unpack in the library directory like ShiftPWM.

ShiftMatrixPWM.rar (13.5 KB)

THANK YOU ELCO!

I will be playing with your code this weekend for sure. I will let you know how it goes. (reading through the example and code now.)

16x16 RGB matrix: 6 column registers, 2 row registers, 32 brightness levels, total refresh rate 60Hz (so combined pwm frequency of 8*60Hz). Load = 0.79.

Shouldn't that be "(so combined pwm frequency of 16*60Hz)"? It looks like that in the example.
edited
Reading through it, I just want to make sure I understand this right. There will be 2 chains of SR's coming from the Arduino. One chain to run the Columns (the R,G,B channels). And a seperate chain for driving the Row selection (the common LED lead).
With the above in mind I am assuming the Row selection SR's are being bit banged via normal port toggling and the Columns are being bit banged via the SPI.

This is a very flexible design. Thank you for putting the seperate inverting options in. I can't wait to build a proto setup and try this on a matrix.

milamber:
Shouldn't that be "(so combined pwm frequency of 16*60Hz)"? It looks like that in the example.

You are right, hasty copy paste job.
The refresh rate for each led of the 16x16 RGB matrix is 60 Hz, but it is 16 rows, so the PWM is as fast as 16x60=960 Hz, where each 60Hz is on a new row. Each brightness level is 1/(603216) seconds and maximum on time for a led is 1/(60*16).
Not the best explanation, but I have had a few beers.

milamber:
Reading through it, I just want to make sure I understand this right. There will be 2 chains of SR's coming from the Arduino. One chain to run the Columns (the R,G,B channels). And a seperate chain for driving the Row selection (the common LED lead).
With the above in mind I am assuming the Row selection SR's are being bit banged via normal port toggling and the Columns are being bit banged via the SPI.

This is a very flexible design. Thank you for putting the seperate inverting options in. I can't wait to build a proto setup and try this on a matrix.

Just to react to your latest edit: You are exactly right. The row selection has to happen only one in 1 in nr_brightness_levels interrupts, so it would be a shame to send it out via the SPI each interrupt. The columns are RGBRGBRGB.... and the rows are the common cathodes/anodes.
The row selection is done via fast sbi and cbi instructions. The alternative pins_arduino include i wrote makes sure the ports/masks are known at compile time to compile to fast code.

Ok I put a breadboard prototype together and quickly ran through some things. Just to let you know I am not using 595's I have some constant current SR's (MBI5026). Everything compiled and uploaded fine. I had some weird display issues to start with but I worked out it was that I didn't have the setting right. Fixed those up and it behaved very well. The set all function worked well in the all fade in and then fade out code. After that I had issues. I don't know why but the two led chasing code was commented out. The next function was the rainbow which didn't run. The micro just seemed to hang and needed to be reset. If I comment out the rainbow lines then it runs the main loop over and over fine, which now only has the fade in and fade out. I uncommented the two led chase code and recompiled and uploaded.

That ran fine as well. So setall was working and set one was working.

One of the weird things I came across was flickering. I played with the frequency and found that if the divided frequency was not a whole number it got the occasional odd flicker. Not sure how to explain that further. but I was able to play with it and find a frequency that was solid. After that the functions that were working ran well.
Due to time restraints (and family commitments) I am not sure I will be able to test further for a few days. I was unable to do any debugging on why the group by 3 rainbow didn't work.

Thanks again Elco. For my purpose even this does great!