November 22, 2024, 01:15:25 AM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


I don't have full LED brightness with PWM command

Started by GOT, August 21, 2008, 10:58:12 AM

Previous topic - Next topic

GOT

I have 5 white LEDs wired in parrallel (3.2V forward voltage, each with its own 100 OMH resistor) hooked up to PIN 0.  If I say:

Led             PIN      0
HIGH Led

I get full brightness from my 5 LEDs.  If I say:

level           VAR     Byte
Main:
  FOR level = 0 TO 255
    PWM Led, level, 1
  NEXT
  FOR level = 255 TO 0
    PWM Led, level, 1
  NEXT
  GOTO Main

My LEDs reach only about one third of the brightness of the HIGH state.  If their an amp restriction with the PWM command?  Should I use the OUTx rather than the PINs?

JonnyMac

The problem is that you're only sitting on full brightness for one millisecond -- if you do a test that runs PWM at full output for an extended period you'll see that 255 gives you very close to full brightness.

I would suggest running those LEDs from an OUTx terminal.  The spec says that you should only run 20 mA per I/O pin, with a total of 50 ma for the entire group of eight.  By my calculation your LEDs are drawing about 25 when on.  This isn't hurting the pin because it's being modulated but if you turned it on full blast and other things were going on you could exceed the processors (PIC chip) limit and create a problem.
Jon McPhalen
EFX-TEK Hollywood Office

GOT

Ok, I think I understand the PWM and "must be in a loop" thing.  I had a pause in my loop that averaged out some of the ON time of the LEDs.

JonnyMac

Yep, the LED is only being modulated while the PWM instruction is running; as soon as PWM is done the output goes low (which is why we add a HIGH command at the end when we're fading up).
Jon McPhalen
EFX-TEK Hollywood Office

GOT

My problem is that I want a very slow fade (over a period of about 20 seconds).  Looks like the Prop1/2 can't do that.  Fortunately, I fell upon a motorized 20K pot from Electronics Goldmine for just a few bucks.  It will take three pins rather than one, but it will do what I need.

JonnyMac

You can do a fade that slow (we do it in our "mood skull") -- but not while other things are going on.  The Prop-1 and Prop-2 are really easy to program (well, most of the time) but being single-threaded we sometimes limited with what we can do with them.
Jon McPhalen
EFX-TEK Hollywood Office

GOT

How do you do a slow fade?  The LED turned off during my PAUSE command.

JonnyMac

What I was saying is that you can do a slow fade, you just can't do anything else in the middle of it.  You could do a 20 second fade up like this:

Fade_Up:
  FOR level = 0 TO 255
    PWM Led, level, 78
  NEXT


256 levels x 78ms per level = 19,968 milliseconds.

We use code like this (though not quite as long) in the mood skull prop to create slow, subtle fades of LEDs (we have R, G, and B) into the bottom of a crystal skull.  Of course we tag a HIGH command on the end of the fade up before switching to another LED.
Jon McPhalen
EFX-TEK Hollywood Office

GOT

Cool.  I didn't know what that last number was for.  Just freed up a few pins.