View previous topic :: View next topic |
Author |
Message |
arrow
Joined: 17 May 2005 Posts: 213
|
A Real Newbie Q: LED Duty cycle? |
Posted: Thu Jul 07, 2005 8:53 am |
|
|
Hi
I have a real newbie question:
I would like to have an LED that shows that the circuit is on.
However, I would like to use as little current (power) as possible to do this e.g. by having a duty cycle (?). Can someone please suggest how an LED can show that the PIC is "on", while consuming as little current as possible?
If possible I would like to use the PIC itself to do this with no extra components. At the moment the PIC is executing a continous loop with INT_RB enabled.
Thank you in advance
arrow |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Thu Jul 07, 2005 9:12 am |
|
|
Use one of your timer interrupts to blink the LED. The blink rate needs to be high enough to seem constant on (persitance of vision). You can also fool around with the duty cycle to adjust the apparent brightness of the LED.
Or instead of setting up the period so the LED seems constant ON, you might consider blinking it. Think of it like a heartbeat. You can even alter the speed to indicate normal or error states. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Thu Jul 07, 2005 10:00 am |
|
|
Just to expand on what was already said, if you blink the LED at a rate higher than about 100 Hz, it will look like it is continuously on. Just play with the duty cycle, starting at maybe 50%, and work down to about 1% or less. Stop where you feel comfortable with the brightness. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Thu Jul 07, 2005 10:23 am |
|
|
Use one of the newish high efficiency LEDs - these require less current for the same effective light output.
Varying the duty cycle will not produce you a better result (lower average current) than limiting the current through the LED by increasing the value of the series resistor. The resistor is simple to implement - no code required :-)
You play with duty cycle when you want to be able to dim a led under program control. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Jul 07, 2005 11:56 am |
|
|
Another way is doing a short blink every 2 sec (aprox) using interrupts, it will be enough
to show that the circuit is running and is alive.
Humberto |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Thu Jul 07, 2005 5:32 pm |
|
|
What's the power supply voltage? If it's low, close to the LED's forward drop, then you're about as efficient as you can be already. If it's a 5V system, then you're losing power in the series resistor.
If that's the case and you really must minimize current flow, then you need a circuit involving an inductor--basically you'd be creating a switching voltage regulator; more like a current regulator. The idea would be output on, current builds up through inductor and LED. Output off, inductor keeps current flowing via a diode, Schottky type for best efficiency. You can improve on that if you replace the diode with a transistor controlled synchronously, but it ends up more complicated and needs an extra pin. Actually you might be able to do it with a transistor drive off a single pin, with the LED acting as the diode in the inductive circuit. No promises, but it would be fun to try. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Thu Jul 07, 2005 7:08 pm |
|
|
John P wrote: | What's the power supply voltage? If it's low, close to the LED's forward drop, then you're about as efficient as you can be already. If it's a 5V system, then you're losing power in the series resistor.
If that's the case and you really must minimize current flow, then you need a circuit involving an inductor--basically you'd be creating a switching voltage regulator; more like a current regulator. The idea would be output on, current builds up through inductor and LED. Output off, inductor keeps current flowing via a diode, Schottky type for best efficiency. You can improve on that if you replace the diode with a transistor controlled synchronously, but it ends up more complicated and needs an extra pin. Actually you might be able to do it with a transistor drive off a single pin, with the LED acting as the diode in the inductive circuit. No promises, but it would be fun to try. |
If you wanted to try this approch you should use a FET instead of a traditional transitor otherwise you waste current driving the BE junction. Using a LED instead of the schottky diode is not likley to be very efficient and could lead to the failure of the transistor / FET as the LED response time will likely be to slow to protect these devices.
LEDs are a current driven device, not a voltage driven device. Attempting to operate a LED without a series resistor can (and likely will) lead to problems (note John P was not proposing to remove the resistor I just added this in case others made that assumption). The LED has a typical diode transfer function but the knee happens around 1.5volt as opposed to 0.7 volts. Also the knee is very much dependant on the characterists of the specific implementation just as the knee for a schottky diode is significantly different to that of a typical IN4148 silicon diode. If you apply to high a voltage then you will start conducting large current through the diode. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
arrow
Joined: 17 May 2005 Posts: 213
|
|
Posted: Fri Jul 08, 2005 4:25 am |
|
|
Hi
Thank you all for your posts.
I like the flashing of the LED every 2 seconds idea.
However, I have a problem with interrupts.
I already have interrupts INT_RB- my sensors are on that interrupt, and I would not like to disturb things with another interrupt (unless it has no effect on the performance).
Can someone please tell me how I would implement a short flash with very little consequences?
In general will a delay_ms(100) effect my INT_RB?
Thank you and
Regards
arrow |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Jul 08, 2005 6:46 am |
|
|
It should have little impact. But there is nothing stopping you from polling the interrupt flag bits in the main loop. Since you are only concerned with 2 seconds, the accuracy doesn't have to be that great so just poll the flag bit and if set, then execute some function. |
|
|
arrow
Joined: 17 May 2005 Posts: 213
|
|
Posted: Fri Jul 08, 2005 7:01 am |
|
|
Hi Mark
Thank you for your post.
Which has a higher priority: INT_RB or INT_Timer2.
I would like INT_RB to have a higher priority- is there any way of setting this?
I am assuming that INT_RB will interrupt a "delay_ms(100)" command- is this right?
Also, if an INT_RB occurs while I am in INT_TIMER2 subroutine, will the INT_RB start after INT_TIMER2 is complete? (or will the INT_RB not execute at all in this case?)
Thank you
arrow |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Jul 08, 2005 11:40 am |
|
|
I am assuming that INT_RB will interrupt a "delay_ms(100)" command- is this right?
Yes so long as you don't use a delay routine in an interrupt or a function called by an interrupt. The compiler will disable ints if you do.
Which has a higher priority: INT_RB or INT_Timer2.
They have the same on a PIC. You can use the priority statement to set the order for which the interrupt flags are checked.
Also, if an INT_RB occurs while I am in INT_TIMER2 subroutine, will the INT_RB start after INT_TIMER2 is complete?
Yes |
|
|
prajeesh Guest
|
controlling GSM modem |
Posted: Mon Apr 17, 2006 4:44 am |
|
|
hi,
am trying to communicate with a GSM modem using rs232. am facing some problem while reading the response from the modem. i used #int_rda for triggering the read operation. am not able to read the response from the modem
can anyone help me in this
thanks
prajeesh |
|
|
|