Show Posts
Pages: [1]
1  Using Arduino / LEDs and Multiplexing / Re: ShiftPWM support topic. Latest update: Schematics, high power LED's, LED strips on: May 10, 2013, 09:25:51 pm
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'.
2  Using Arduino / Project Guidance / Re: mega 2560 PWM frequency on: April 28, 2013, 08:30:13 am
@valerio_sperati
Wow! Thanks!
http://playground.arduino.cc/Main/TimerPWMCheatsheet
is very similar buy that articles seems to be only for ATmega328p or so. Definitely not for Arduino Mega. Mega's timer selections are different to the UNO.
3  Development / Other Software Development / Nice font from Adobe made for coders and programmer. on: February 16, 2013, 07:52:05 am
Hey,
There's a font from Adobe called Source Code Pro.
Very suitable for programming and coding.
Even the zeros have a dot in the middle so a capital "O" definitely looks like an "O".
More info:
http://blogs.adobe.com/typblography/2012/09/source-code-pro.html

In the preview, font size is set to 20.


Download:
http://store1.adobe.com/cfusion/store/html/index.cfm?store=OLS-US&event=displayFontPackage&code=1960

It's so good, you might want to include it in the Arduino ERW as the default font type.

You're welcome smiley-razz
4  Using Arduino / LEDs and Multiplexing / Re: ShiftPWM support topic. Latest update: Schematics, high power LED's, LED strips on: September 01, 2012, 10:52:08 am
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-grin
5  Using Arduino / Project Guidance / Re: How to sequence individual LEDs, Dream-color LED strip, DMX, MAX485 chip on: August 09, 2012, 07:49:34 pm
The strips you linked to don't let you control down to each LED but only the whole strip. The controller is included with the package, it's a ready-to-use package, more or less.

What you like have is something like these http://shop.boxtec.ch/pixel-strip-ws2801-p-40601.html. There every LED has it's own controller chip. The chips gets their commands by some sort of SPI and they are chained (easily extensible). You then need only a strong power supply and two digital pins of your Arduino. Lots of example code is available.

I use the kind of strip that pylon is talking about and it ROCKS!!!!

Here's Sparkfun's WS2801 strip:

https://www.sparkfun.com/products/10312

Here's the sample code for the Sparkfun strip:

http://www.sparkfun.com/datasheets/Components/LED/LED_Strip_Example.pde

Thanks a lot smiley

Wow... The price is too high for my budget.
I plan to buy many many of them...
Are you sure the Dream-color cannot be controlled individually?
(like this one? )
But instead of using the packaged controller, I use Arduino and set my own custom sequence.

6  Using Arduino / Project Guidance / How to sequence individual LEDs, Dream-color LED strip, DMX, MAX485 chip on: August 09, 2012, 08:16:04 am
Hi,

I'm trying to work on a project to control every individual RGB LEDs on a 12V LED strip.
And sequence each of the LEDs using a software (Vixen? http://www.vixenlights.com ; Freestyler? http://users.telenet.be/freestylerdmx/)


I'm still quite a beginner in the circuitry (hardware, connections) but I can work around with the code (have been modifying other's Javascript code for my website)


I've done some research and I'm still quite confused.

Some stuffs that I've found out:
- I'm going to use Arduino Nano (I have a Mega)
- DMX method (not quite sure what it is, it's like giving every RGB LED an address)
- Dream-color RGB LED strip (receives the DMX signal? http://goo.gl/lKdRN)
- MAX485 chip to output DMX signals to the dream-color LED strip (use a module? http://goo.gl/h0Zqx)

How do I get started?

Thanks for all the info smiley
7  Using Arduino / Installation & Troubleshooting / Question: Upload to Multiple Arduinos at Once? on: July 23, 2012, 07:27:50 am
Hello smiley

Just asking, is it possible to upload multiple Arduinos at once?
I think it's pretty possible though.

Not really important...
Well I have four Adruino Nano clones and when I try to upload the same code I wondered how to upload the code to all of them at once.

Thanks for solving my curiosity! smiley-grin
8  Using Arduino / LEDs and Multiplexing / Re: ShiftPWM support topic. Latest update: Support not using the SPI on: May 30, 2012, 01:01:54 am
Thanks for the reply smiley-grin

I bought some ULN2803 transistor that was intended for me to make RainBoard... but now still waiting for my shipment of RGB LED strips :/

The UL2803 transistor looks like a complicated transistor to me.
They do work well for me to switch the LED strip, right?

Thanks again smiley
9  Using Arduino / LEDs and Multiplexing / Re: ShiftPWM support topic. Latest update: Support not using the SPI on: May 28, 2012, 05:07:03 am
Hi,

I need to shrink my project...
I'm using an Arduino Mega 2560 and it's size is too big for what I need.

I heard about the ATtiny :/

which ATtiny can I use for ShiftPWM?
What are the requirements for ShiftPWM to run

Or which other method do you recommend?

Can you also give me some tips on how to power many LEDs?
I know that you are selling powerful LED drivers but if it's in my budget and if it would be worth it to buy and works just fine for me, I would buy yours! smiley

More details:
My team will be performing something and we will be using LEDs.
Some effects to fade in and fade out, perhaps in some props we will need RGB leds.

I've bought  4 single coloured led strips, (600 leds in each strip - red, green, blue and white)
I've also bought 1 RGB led strip, 300 leds in that strip
I bought few EL wires of different colours (they need AC current)


The idea is to use the blue led strip one of the props, (just switch on)
one guy to use the red led strip and EL wire(use one ATtiny to run ShiftPWM? with shift registers?)
the other guy to use the green led strip or RGB led strip and EL wire (use one more ATtiny to run ShiftPWM? with shift registers again?)
one more prop will use about 5 leds, just fade in and fade out selected ones in a certain time (use one more ATtiny to run ShiftPWM? with shift registers again?)

So I need some recommendations how to power the LEDs...

I'm still a newbie specifically in this (circuitry) but not very newbie in stuffs like this (creating stuff).


Really grateful of any help that you can provide, I just need some tips to kick start what to do next...
10  Using Arduino / LEDs and Multiplexing / Re: ShiftPWM support topic. Latest update: Support not using the SPI on: May 28, 2012, 03:53:51 am
Thanks a lot!
I think it's done.
I hope this code of mine will also be useful to others.
Or maybe someone would modify it to make it better.

Code:

fIn(1, 1000, 2000); //led1, trigger the fade in at 1st second (1000ms), for 2secs (2000ms)

fOut(1, 3000, 500); //led1, trigger the fade out at 3rd second (3000ms), for .5secs (500ms)

//it takes led1 2secs to get to maximum brightness, so the fade out trigger will start at the 3rd second.


void fIn(int ledN, int tStart, int period){
  //ledN - which LED?
  //tStart - start from when
  //period - for how long
  unsigned long elapsed=millis(); //timer
  int tEnd = tStart+period; //the end of the fading is after the period.
  int tEndX = tEnd+100; // give extra time to complete fading
  if(elapsed > tStart && elapsed <= tEndX){ //fade in for 'period'sec from tStart to tEndX.
    unsigned long h = tStart; // total time before trigger
    unsigned long p = tEnd-tStart; //fading period
    //or "unsigned long p = period;" will do.
    unsigned long eh = elapsed-h; //total time passed since triggered
    unsigned long j = maxBrightness*eh/p; //"eh/p" = time passed over fading period (percentage) then multiply by maxBrightness
    if (elapsed >= tEnd){
      j = maxBrightness;
    } //when ending, bring j to maximum brightness (to complete the fading) because millis(); is not perfect.
    ShiftPWM.SetOne(ledN ,j);
  }
}

void fOut(int ledN, int tStart, int period){
  unsigned long elapsed=millis();
  int tEnd = tStart+period;
  int tEndX = tEnd+100;
  if(elapsed > tStart && elapsed <= tEndX){
    unsigned long h = tStart;
    unsigned long p = tEnd-tStart;
    unsigned long eh = elapsed-h;
    unsigned long j = maxBrightness*eh/p;
    if (elapsed >= tEnd){
      j = maxBrightness;
    }
    unsigned long k = maxBrightness-j; // invert value of fade in to become fade out
    ShiftPWM.SetOne(ledN ,k);
  }
}



But this code will be quite different when it comes to RGB leds, right?
Is there a colour cross-fading (or morphing) effect in ShiftPWM for RGB leds?
-to change from blue to green smoothly.

Will my code work for RGB leds to simply set it's brightness without affecting it's current colour?
for example that led1 is set to keep on changing from green to blue then back to green, then with my code i just make its brightness dimmer without affecting the colour changing?
Or is there a function in SHiftPWM to do this?

 haven't any RGB led yet...
So, sorry if I might be asking this question for granted :/

Thank you very much smiley
11  Using Arduino / LEDs and Multiplexing / Re: ShiftPWM support topic. Latest update: Support not using the SPI on: May 27, 2012, 09:50:10 am
Thanks a lot! That gave me a big boost! smiley-grin

That code doesn't really work smoothly, the LED blinks a few times and then fades in.

Done some changes (I don't really understand bit shifting also, so I used simple math)
Code:
unsigned long elapsed=millis();

if(elapsed > 1000 && elapsed < 11000){ //fade in for 10secs at 1-st sec
   unsigned long h = 1000; // total time before trigger (from "elapsed > 1000")
   unsigned long p = 10000; //fading period (11000 minus 1000)
   unsigned long eh = elapsed-h; //timer-head (time passed)
   unsigned long j = maxBrightness*eh/p; //time passed over fading period multiply maxBrightness
   ShiftPWM.SetOne(0 ,j);
}

if(elapsed > 1500 && elapsed < 2500){ //fade in for 1sec at 1.5-th sec
   unsigned long h = 1500; // total time before trigger (from "elapsed > 1500")
   unsigned long p = 1000; //fading period (2500 minus 1500)
   unsigned long eh = elapsed-h; //timer-head (time passed)
   unsigned long j = maxBrightness*eh/p; //time passed over fading period multiply maxBrightness
   ShiftPWM.SetOne(2 ,j);
}

That's a big help! smiley-grin

Perhaps an easier way that I could set values of 'h' and 'p' using calculations?
That way I would need a function, right?

For this one:
Code:
if(elapsed > 1500 && elapsed < 2500){ //fade in for 1sec at 1.5-th sec
   unsigned long h = 1500; // total time before trigger (from "elapsed > 1500")
   unsigned long p = 1000; //fading period (2500 minus 1500)
   unsigned long eh = elapsed-h; //timer-head (time passed)
   unsigned long j = maxBrightness*eh/p; //time passed over fading period multiply maxBrightness
   ShiftPWM.SetOne(2 ,j);

I want to make it to just need me to manually set two values (which is 1500 and 2500) then value of 'h' and 'p' will be automatically set.
Perhaps also need a way to set if I want to fade in or fade out (invert the value 'j'? - 0 to represent 255 and 255 to represent 0?)

I'm trying to set the functions now, any tip will surely be useful too! smiley-grin

Thanks!!!!
12  Using Arduino / LEDs and Multiplexing / Re: ShiftPWM support topic. Latest update: Support not using the SPI on: May 26, 2012, 11:00:58 am
Hi,

It took me some time to understand millis()
And I found out it's just basically a timer.

For now what works best by far for me is:
Code:

 unsigned long elapsed=millis();

if(elapsed > 1000){
    int j =255*0/100; //at 1-st second, brightness is 0%
    ShiftPWM.SetOne(0 ,j);
  }
  if(elapsed > 1100){
    int j =255*10/100; //at 1.1-st second, brightness is 10%
    ShiftPWM.SetOne(0 ,j);
  }
  if(elapsed > 1200){
    int j =255*20/100; //at 1.2-nd second, brightness is 20%
    ShiftPWM.SetOne(0 ,j);
  }
  if(elapsed > 1300){
    int j =255*30/100;
    ShiftPWM.SetOne(0 ,j);
  }
  if(elapsed > 1400){
    int j =255*40/100;
    ShiftPWM.SetOne(0 ,j);
  }
  if(elapsed > 1500){
    int j =255*50/100;
    ShiftPWM.SetOne(0 ,j);
  }
  if(elapsed > 1600){
    int j =255*60/100;
    ShiftPWM.SetOne(0 ,j);
  }
  if(elapsed > 1700){
    int j =255*70/100; //at 1.7-th second, brightness is 70%
    ShiftPWM.SetOne(0 ,j);
  }
  if(elapsed > 1800){
    int j =255*80/100;
    ShiftPWM.SetOne(0 ,j);
  }
  if(elapsed > 1900){
    int j =255*90/100;
    ShiftPWM.SetOne(0 ,j);
  }
  if(elapsed > 2000){
    int j =255*100/100; //at 2-nd second, brightness is 100%
    ShiftPWM.SetOne(0 ,j);
  }
(fading period=1000, increases brightness by 10% after every 100ms)

I need to find a better way to set brightness after every 1ms.

I cannot use:
Code:
for(int j=0;j<maxBrightness;j++){
   ShiftPWM.SetOne(0, j); 
   delay(20);
   }
Because delay() will also stop the next task to proceed.

How do I set a function to have any fading period, and increases brightness after every 1ms?

Thanks! smiley
13  Using Arduino / LEDs and Multiplexing / SoftPWM + ShiftPWM on: May 01, 2012, 11:41:43 am
Hi,

I'm quite new to this, but I've done websites and modifying other people's Javascripts to suit for my websites.

I'm trying to fade in and out LEDs simultaneously (non-RGB LED, just one colour).

I'm using Arduino Mega 2560...

Meaning:
I'm trying to fade in LED Two and halfway, LED Three fades in and out before LED Two even completes fading out.


I can't figure how to do this using ShiftPWM.
SoftPWM can fade LEDs without delay, but not through shift registers.
(http://code.google.com/p/rogue-code/wiki/SoftPWMLibraryDocumentation)

My attempt in ShiftPWM:
Code:
#include <SPI.h>
#include "hsv2rgb.h"
const int ShiftPWM_latchPin=8;
const bool ShiftPWM_invertOutputs = 0;
#include <ShiftPWM.h>
unsigned char maxBrightness = 255;
unsigned char pwmFrequency = 75;
int numRegisters = 3;

void setup()   {                
  pinMode(ShiftPWM_latchPin, OUTPUT);  
  SPI.setBitOrder(LSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV4);
  SPI.begin();
  Serial.begin(9600);
  ShiftPWM.SetAmountOfRegisters(numRegisters);
  ShiftPWM.Start(pwmFrequency,maxBrightness);  
}

void loop()
{  

  int fxDuration=1000; //standardises effect duration
  int d=fxDuration/255; //the delays are for each change in brightness, so I devide them for each brightness change

  ShiftPWM.SetAll(0);
  ShiftPWM.PrintInterruptLoad();


  // "int j=0;j<maxBrightness;j++" kinda means fade in

  //fades in LED 0
  for(int j=0;j<maxBrightness;j++){
    ShiftPWM.SetOne(0 ,j);
    delay(d);
  }

  //fades out LED 0
  for(int f=maxBrightness;f>=0;f--){
    ShiftPWM.SetOne(0 ,f);
    delay(d);
  }

  //attept to fade in LED 2 while LED 1 still fading in
  for(int j=0;j<maxBrightness;j++){
    int fxDuration=5000;
    int d=fxDuration/255;
    ShiftPWM.SetOne(1 ,j);
    delay(d);
    ShiftPWM.SetOne(2 ,j);

  }

  //fades out LED 2
  for(int f=maxBrightness;f>=0;f--){
    ShiftPWM.SetOne(2 ,f);
    delay(d);
  }
}


SoftPWM code which works will for now but not using shift registers and not for RGB LEDs (might need RBG LEDs in the future)
Code:
#include <SoftPWM.h>

void setup(void)
{
  int ledPin1 = 12;
  int ledPin2 = 11;
  int ledPin3 = 9;
  SoftPWMBegin();
  
  // Create on pins 9, 11, 12.
  SoftPWMSetPercent(ledPin1, 0);
  SoftPWMSetPercent(ledPin2, 0);
  SoftPWMSetPercent(ledPin3, 0);

  // Set full scale fade time of pin 9 (fade in duration 1000 ms, fade out duration 1000 ms)
  SoftPWMSetFadeTime(ledPin1, 1000, 1000);
  // Set full scale fade time of pin 9 (fade in duration 4000 ms, fade out duration 4000 ms)
  SoftPWMSetFadeTime(ledPin2, 4000, 4000);
  SoftPWMSetFadeTime(ledPin3, 2000, 2000);
}

void loop(void)
{
  int ledPin1 = 12;
  int ledPin2 = 11;
  int ledPin3 = 9;


 //fades led 1 brightness to 100%
  SoftPWMSetPercent(ledPin1, 100);
  delay(1000); //to allow led 1 to fade completely not allowing the next one to come in
  //fades led 1 brightness to 0%
  SoftPWMSetPercent(ledPin1, 0);
  delay(1000);
  //fades led 2 brightness to 100%
  SoftPWMSetPercent(ledPin2, 100);
  delay(2000);//to allow led 2 to fade halfway (50%) allowing led 3 to come in
  //fades led 3 brightness to 100%
  SoftPWMSetPercent(ledPin3, 100);
  delay(2000);//led 2 completes fading in to 100%
  //fades led 2 brightness to 0%
  SoftPWMSetPercent(ledPin3, 0);
  delay(2000);
  SoftPWMSetPercent(ledPin2, 0);
  delay(4000);//just to delay the time before next loop

}

Please help me...

Thanks a lot  smiley
Pages: [1]