Author Topic: Output <5V  (Read 8041 times)

germ

  • Jr. Member
  • **
  • Posts: 53
Output <5V
« on: July 08, 2013, 11:34:14 am »
Ok, so this will probably reveal how little I know about this kind of stuff, but hey, I have digispark to thank for even knowing anything about all this stuff.
So I was thinking of powering a few LEDs with the digispark. Now I'm not going to use the on-board LED, so I was thinking of just using other pins.
Now the LEDs are ofc not rated for 5v, and I know that "we" usually put resistor everywhere.
They will probably be rated for about 2v 20mA, and be one LED each on three outputs.
How do I go about to make this as easy, safe and cool as possible?

Can I just use PWM and bring the voltage down to 2v, or do I need a bunch of resistors anyway? Would I need anything else than resistors?

Thanks for your patience and for sharing your knowledge to us newbies ^^  ;D

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Output <5V
« Reply #1 on: July 08, 2013, 02:30:15 pm »
germ

The resistor is used to limit the current.
Think of a narrowing of a two lane road to one and how the flow of cars slows down, even on the other side.

Without the resistor the LED will draw as much current as it can until either the chip or the LED let the smoke out ...

PWM does 'effectively' give a lower Average voltage, but the initial ON period is at full voltage (and therefore current), and can cause issues.


Play it safe add a 220 or 330 ohm resistor in series with each LED. (5v-2v = 3v to drop at 10mA Led current, therefore R=E/I = 3/.01 = 300 ohms)
20mA is their maximum current that they can safely pass continuously, but you'll hardly notice any drop in brightness at 10mA.
 
Mark

germ

  • Jr. Member
  • **
  • Posts: 53
Re: Output <5V
« Reply #2 on: July 08, 2013, 03:12:32 pm »
Thanks for the reply!

Ran it through the LED-calculator and it said 150 ohm for 20mA and 330 for 10mA.
The data-sheet says:

Electrical characteristics 25ºC
Forward voltage typical 2v max 2.5v  (IF=20mA)

Maximum ratings 25ºC
DC Forward current 30mA
Peak forward current 175mA

So if i have anything between 180 and 330 ohm with every LED I should be good to go then I guess? It's not something that should be running for more than a few minutes at a time, tops.

Thanks again for the help! :)

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Output <5V
« Reply #3 on: July 08, 2013, 08:49:04 pm »
The 10mA limit is for the attached reasons.
http://digistump.com/board/index.php/topic,455.0.html

All these devices have limits, and some are a combined total limit.

Modern LED's are so bright you probably don't want them running at full brightness anyway, so 10mA is a good compromise.



Mark

germ

  • Jr. Member
  • **
  • Posts: 53
Re: Output <5V
« Reply #4 on: July 09, 2013, 07:48:06 am »
Thanks, but I thought we agreed on that it's not that critical after I powered 5 15-20mA relays at the same time with my sparky ^^
But I'll just buy a bunch of resistors and see what works. If the LEDs are too weak, I'll just put 2 of them with a 100ohm resistor instead.

I'm thinking of soldering 2mm SMD resistors and 2mm SMD LEDs on a 2.54mm hole matrix lab-card, see how that works. 2mm seems better than 3.2mm anyway.
 But will probably order both sizes because it's so cheap anyway. :)

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Output <5V
« Reply #5 on: July 09, 2013, 01:11:15 pm »
Okay

That kind of makes the chart not 100%. (but safe for 99% of use)

I've been caught before where someone has powered xyz which works, then added abc and wondered why the system is not stable.

Based on your relay experience you should be fine.
Good luck with the soldering, that's not a bad idea using it in that way.

Mark

semicolo

  • Full Member
  • ***
  • Posts: 137
Re: Output <5V
« Reply #6 on: July 10, 2013, 10:20:15 am »
The chart uses very conservative values, they are the recommended values from the datasheet. It looks like 20mA is still safe.
I'm still wondering if I should update the document to show 20mA instead of 10.
« Last Edit: July 10, 2013, 10:26:28 am by semicolo »

germ

  • Jr. Member
  • **
  • Posts: 53
Re: Output <5V
« Reply #7 on: July 10, 2013, 11:18:26 am »
I will probably keep it at 10-15mA anyway for this project.
Now my problem is the batteries instead. I saw the thread about running on different voltages, and powering the 5v pin with 4.5 ish (3x1.55V batteries) should be enough to run things pretty smoothly.
Now I want to batteries to survive for as long as possible ofc, and read about underclocking in the wiki.
Do I just select the digispark 1mhz from the board menu? What does the "NO USB" mean exactly?
And is it easy to deactivate the power LED? :)

Then the problem will just be to fit those batteries toghether...

germ

  • Jr. Member
  • **
  • Posts: 53
Re: Output <5V
« Reply #8 on: July 10, 2013, 11:23:26 am »
Also, removing the boot time would probably be preferred too, as I want to keep the sparky off for power savings with the button, instead of just starting the program with a button.
I really don't have much experience, but learning a lot thanks to you guys <3!

semicolo

  • Full Member
  • ***
  • Posts: 137
Re: Output <5V
« Reply #9 on: July 10, 2013, 01:04:04 pm »
To disable the power led you need to desolder something, the led or the resistor.

No USB means you intend to run the digispark not connected to USB, when it detects USB it uses it to calibrate its clock.
So yes digispark 1MHz should allow running down to 1.8V, but the outputs drop with the supply, your circuit may stop working before that.

germ

  • Jr. Member
  • **
  • Posts: 53
Re: Output <5V
« Reply #10 on: July 10, 2013, 01:51:46 pm »
Thanks semicolo!
So then running the sparky with 3 1.55v batteries should be fine, and just put my resistors parallel to compensate for the voltage drop.
(4.5v -> 2x2A LED (series) + 2x100ohm resistors (parallel) = LEDs at 10mA)
Yeah, didn't order any smaller resistors, didn't think I'd need it.

Not powering with the USB is obviously not an issue.
That onboard LED is pretty damn small tho, not sure if I'm going to attempt to desolder that. It should be fine anyway I guess...

semicolo

  • Full Member
  • ***
  • Posts: 137
Re: Output <5V
« Reply #11 on: July 10, 2013, 05:38:15 pm »
If you don't care about putting it back, just use small cutter pliers and cut it in half, possibly ripping the pcb pads (but as I said only if you don't intend to ever put it back).

The thing is, the current in your leds will drop with the supply, for example when the supply will be down to 4.1V, the current will be 2mA and below 4V the LEDS won't light at all.

If you have a free pin you could monitor the supply and apply a pwm on the LEDS depending on the current supply value.

germ

  • Jr. Member
  • **
  • Posts: 53
Re: Output <5V
« Reply #12 on: July 10, 2013, 11:29:20 pm »
Well I guess I don't really need the power LED on it, so maybe I could try killing it.

I'm going to have free pins, I'm doing like a miniature traffic light keyring thing. So 3 outputs to R,Y,G LEDs.
I was thinking of possibly using one for a Potentiometer to control the speed, but I'm not so sure about that one yet.

How would applying PWM work (and how do I do it?)
I could put the LEDs in series, to get the minimum voltage down to 2v, if that would help in any way.

Thanks!

semicolo

  • Full Member
  • ***
  • Posts: 137
Re: Output <5V
« Reply #13 on: July 11, 2013, 06:14:33 am »
The digispark is supposed to have hardware PWM on P0, P1, P3 and P4
you just use analogWrite(pin, value)  instead of digitalWrite
For example analogWrite(0, 128) will toggle pin 0 50% of the time off and 50% of the time on.
Value is between 0 (completely off) and 255 (always on).
If you use 10, the pin will be on for 10 cycles and off for the remaining 245
by changing the value depending on the supply voltage you can maintain the same LED intensity throughout all the battery discharge.

Say you want your LED to remain on until the supply drops to 2.5V
You need a 50ohms resistor for a 2V LED drop and 10mA of current.
So at 2.5V you set the pin always on and you get 10mA in your LED.
But at 4.5V, you need to use the PWM to drop the voltage to 2.5V: you have to use a value of 255*2.5/4.5 or 142

Beware to always start by setting the pins to low in the setup() to prevent burning the LED if the supply is high (like when connected to USB)
Then start monitoring the supply using analogRead() on a pin, you'll need to use a voltage divider and an internal voltage reference since the supply will change.
I'd use analogReference(INTERNAL1V1) and a 1/5 ratio divider.
Then estimate the supply voltage (using analogRead(0) for pin 5 for example), calculate the PWM value needed and set the corresponding pin with it.
Make sure your supply/pwm part works before connecting a led or use larger resistors when debugging.

The last problem could be that you may need to add a capacitor to filter the pwm output, we'll talk about that if you notice the led intensity is changing when the supply voltage drops.

germ

  • Jr. Member
  • **
  • Posts: 53
Re: Output <5V
« Reply #14 on: July 11, 2013, 07:50:04 am »
That's a lot to understand... let's see...
Yeah OK I get what you are saying.

I'm with you all the way to the monitoring part, not exactly sure how write that. But I'll research it a bit and see if I get stuck.
I'd rather not add more hardware if it can be avoided, but being able to keep going down to 2v is pretty nice.
Thanks!