On Wed, Mar 17, 2004 at 05:51:17PM -0500, Spehro Pefhany wrote: > At 12:31 AM 3/18/2004 +0200, you wrote: > >Hi, > > > >Sorry to reply to my own mail, but I just had another thought. > > > >Won't using this algoritm change my 'duty cycle' from 1/4 to 1/32 since now > >I can only have one segment on at a time. That is correct . > >Will the 80ma I can now supply > >that single segment make up for the change in duty cycle? > > No, because the PIC can supply 25 * 8 = 200mA vs. 80mA. Thus your display > will be much dimmer. OK. Let's work through the numbers and see if there's a breakeven anywhere here. First off the 25ma is an absolute rating. Not a smart idea to actually try to draw 25ma of current through a pin (or the 200ma through a port) . Next with the 330 ohm resistors in the original circuit (and presuming a 1.7V LED drop) each segment is only getting 9.6 ma of current each. So in the original circuit (which may be fixable BTW) the average current through each segment is 9.6ma/4 -> 2.4 ma. Now with the single segment getting 80ma at a 1/32 cycle the average cycle is 80ma/32 -> 2.5 ma So Spehro is right, not a whole lot of advantage. > > >Also, could the algorithm be modified to the following: > > > >Segment Count, SC = 0 > > > >1) Turn off all displays > >2) Turn on SC segment with 7445 driver. > >2) For each display (1 to 4), see if this segment is on or off > >3) Turn on those displays that have that segment on > >4) Increment SC > >5) If (sc > 7), se SC = 0 > >6) Delay for fixed time > > > >That should change the duty cycle to 1/8, right? > > Yes you can do this, and it is better. You must move the resistors to > the anodes from the segments (so there are fewer of them). But the > total display current is still limited to 80mA, so the net result is > that you've added a part which draws 50mA all by itself, and have a > display that is about 1/3 as bright, but save 4 port pins and 4 resistors > (or 1/0.5 network). The display should be just about as bright as the original. But running the numbers indicates that you can drop the resistance significantly and still be in the PIC's current rating. This is a case where it's important to take the LED's forward voltage drop into account. Let me give the nickle explanation: The current limiting resistor in an LED circuit is designed to cap the total amount of current flowing through the circuit. Also each node of the circuit (LED and resistor in this case) have the same amount of current flowing them. Finally the LED will consume (called dropping) a portion of the voltage provided. This forward voltage is determined by LED type, temp, and current flowing through it. However at room temp it's pretty fixed for each type of LED. So the upshot of the explanation is that the current flowing through the circuit is determined by the resistance and the voltage drop. The current is computed using Ic = (V - Vled)/R where V is the supply voltage, Vled the LED voltage and R the resistance. Solving for R gives R = (V-Vled)/Ic. So let's plug in some numbers. 20 to 22 ma is pushing the PIC. I'll pick 22. Presume that the LED drops 1.7V (IIRC that's red LEDs typical drop). Assuming a Vdd of 5V. SO... R = (5-1.7)/0.022 -> 3.3/0.022 -> 150. Bingo! Put in 150 ohm resistors. The PIC I/O leads will sink 22ma and the average current will be 22/4 -> 5.5 ma which is more than twice the brightness of either the original, or my 7445 solution. Now the truth of the matter is that the really right way to do it is to wire in 8 NPN signal transistors (2N2222 or BC equivalent) along with 8 2.2K base resistors and tie them between the cathodes of the segments (collector), the current limiting resistor (after the cathode) to GND. Then you can drop the resistance down to the current limit of what the BC547 or the LED's can handle at 25% duty cycle. But I'd drop the resistors to 150 ohms first and see if it's bright enough. If so then call it a day. BAJ -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads