So the first test I did when I got my PICAXE chip/project board is the LED test with the LED and 330 ohm resistor on output 4. I just wanted to know exactly why you connect the LED between the V+ and output pin? Just trying to figure this out so I understand it for hooking up 4 LEDs in parallel to output 4. If it were a simple circuit (battery, LEDs, and resistors), the current would flow from the battery, to the resistors, through the LEDs, and then to the 0V of the battery. But it seems that with the chip in the project board, it is the oposite. So do I just attach the LEDs to the V+ and then add a resistor to each of the LEDs, and then the other end of the resistors to the output 4?

Edited by - coastergeekrtc on 27/06/2006 07:55:36

Jeremy Leach

27-06-2006, 08:01

Hi coastergeekrtc

I hope this doesn't confuse you, but this may help:

An LED is a semiconductor device having Anode and Cathode connections. If the Anode is at a higher voltage than the Cathode then the LED will turn on. If the Anode is connected to the postive supply then the LED will light if it's cathode is below the positive supply voltage, and if the cathode is connected to a PICAXE output via a resistor, then if the PICAXE output is 'low' then the LED will light.

Be careful connecting LEDs in parallel from a single PICAXE output. I can't remember the figure, but a PICAXE output can drive something like 25mA maximum. Beyond this max figure you'll damamge the PICAXE. This means that there will be a limit to the number of LEDs you can drive in parallel.

andypro

27-06-2006, 08:09

Which project board do you have?

If it's the one with the driver chip (ULN2003 is it?) then this chip sinks current, it doesn't source it. This means that it has to be on the negative side fo the circuit, i.e. connecting the load (LED/Resistor) to ground.

The Picaxe itself can do this same thing. Each pin actually has 3 states. There is output high (sourcing current), output low (sinking current) and input (high impedance...essentially ignoring current, and going off of the voltage alone. Only a very small current flows).

Using the above, you can see that it's possible to connect the picaxe either between the V+ and the load, or the load and ground, depending on what the circuit calls for.

--Andy P

eclectic

27-06-2006, 08:20

Just continuing what Jeremy and Andy have said.

Have a look at the Interfacing manual.
That's part 3.
Page 8, then page 6.
e.

coastergeekrtc

27-06-2006, 08:54

So then if I run them in series, I will need a 9V battery connected to V2+ to run them.

premelec

27-06-2006, 17:17

You're getting into dangerous territory here as the PICAXE must not be exposed to more than 5.5volts on it's pins and so you should use a transistor switch between the PICAXE and the 9+V LED string...

Put a 1K ohm resistor from PICAXE pin to base of an NPN transistor with its emitter to
V- [same as PICAXE V-] and connect the string of LEDs in series with an appropriate current limiting resistor [ohms law excercise!]to the higher V+ on the + endand NPN copllector on the other end.

There are many ways to do this 'level shifting' this is only one.... just be sure to not get the PICAXE involved with over 5.5VDC directly!

coastergeekrtc

28-06-2006, 06:22

Ok, I think I get it, but just to make sure, is this it?
<A href='http://img.photobucket.com/albums/v55/coastergeekrtc/CoasterDynamix/Xcelerator/LED.jpg' Target=_Blank>External Web Link</a>
The LEDs are rated at 1.7V and 20mA. Volatge required for the LEDs is 6.8V + 2V for the resistor. So I need 8.8V to run the LEDs, or a 9V battery. And the value of the resitor is R = (V supply - V LEDs)/I. R = (9V - 6.8V)/0.02A giving a resistor value of 110 ohms, closest greater value is 150 ohms. I hope I did all this right.

BeanieBots

28-06-2006, 07:48

Looks spot on to me.

coastergeekrtc

28-06-2006, 08:31

Now I'm confussed. The datasheet for the 28-Pin Project Board says that the outputs are driven through the darlington driver, which will drive up to 800mA per output. So then why can't I just attach the LEDs in parallel...the current will never reach 800mA.

whizzer

28-06-2006, 08:53

LED’s are naughty little blighters –they don’t share the current evenly. Putting them in series <i>forces </i> them to have the same current and of course only a single resistor is required. However, you <i>can </i> run the LED’s in parallel from a single Darlington driver though, but you need to ensure that each LED has its own independent current-limiting resistor.

coastergeekrtc

28-06-2006, 08:58

Thats good...I really didn't want to deal with a second voltage supply and transistors...what a relief.

BeanieBots

28-06-2006, 11:56

You will still need a transistor to cope with the current of more than one LED if you connect them in parallel.

Hi coastergeekrtc
Just to clarify… If you are planning on driving four LED’s directly from a Picaxe pin, then what has been stated in the last two posts would apply. (And a 5V supply could be used with appropriate resistors).

However, if you are going to use the ULN2803A Darlington driver on the 28-Pin Project Board, then a single output pin of that device will comfortably drive the four LED’s (with the separate current-limiting resistors as previously noted).

Edited by - whizzer on 28/06/2006 16:59:47

coastergeekrtc

28-06-2006, 22:18

Ok, just to make sure I have this right, the LEDs run at 1.7V and 20mA. Using the equation Resitor Value = (V supply - V LED)/Current I get R = (4.5V - 1.7V)/0.02A = 140 ohms...closest value is 150 ohms. So I should have 4 resistors, one for each LED, and it all should look like this if I have it attached to the Project Board.
<A href='http://img.photobucket.com/albums/v55/coastergeekrtc/CoasterDynamix/Xcelerator/ParallelLEDs.jpg' Target=_Blank>External Web Link</a>

whizzer

29-06-2006, 05:05

Your diagram looks good and your calculations are OK also.

However there are a few fine details that you may like to consider though. You haven’t mentioned the spec sheet for the LED’s you intend to use, however it’s possible that the current rating of 20mA may be something close to a maximum recommended value. And with the efficiency of modern LED’s, quite often using a lower current of say 10mA can provide good brightness &amp; will have the advantage of reduced battery drain also. And some people who are aiming for absolute minimum overall current drain would choose very high efficiency LED’s, and then operate them at currents significantly less than 10 mA. –But let’s just assume 10mA for this example though.

Another factor that you may care to be aware of is the small voltage drop across the Darlington driver when it is conducting which is referred to as Vce(sat). The spec sheet states that this is 0.9V when the device is passing 100mA, and doing a bit of interpolating suggests that the figure is likely to be approx 0.75 to 0.8V for currents of around 40mA. This small voltage drop slightly affects the calculation for the resistor values.

So with these factors in consideration, the calculation for the resistor values might be something like this for a 4.5 volt supply:
R = (4.5V - 1.7V – 0.75) / 0.01A = 205 ohms, with 220 being the nearest preferred value.

However, you may even find that 330 ohms or even higher is suitable for you -it all very much depends on your requirements &amp; the efficiency of the LED’s that you are using.

coastergeekrtc

29-06-2006, 06:44

Well I will be using a power adapter to run the Project Board/28X Chip. You want that to be 5V and 500mA, right? So I also have to take in consideration that the supply voltage will be higher. And the LEDs (Orange) have a voltage range of 1.7-2.6V @ 20mA. This confuses me...in the Max ratings, the Orange-UE has a max current of 50mA and the Orange-HE has a max current of 30mA. What does UE and HE mean? Here is the datasheet.
<A href='http://www.jameco.com/wcsstore/Jameco/Products/ProdDS/333340.pdf' Target=_Blank>External Web Link</a>

Edited by - coastergeekrtc on 29/06/2006 06:58:00

whizzer

29-06-2006, 08:20

It’s a fact that different colour LED’s operate with different voltages dropped across them, and different models can have varying current requirements &amp; limitations also. (And in the spec you referred to, I think that the ‘UE’ and ‘HE’ are just letters that follow the letter ‘L’ for the various part numbers of that particular brand of LED).

So if you are using different colours, or different models, you do need to calculate the required resistor value for each type. The formula is still as per the previous post -with different LED voltages &amp; currents substituted if required, and you can substitute 5V instead of 4.5V in the formula also. It will just come up with slightly different resistor values in each case.

Just bear in mind that the currents specified are absolute maximums which should never be exceeded. The actual current you allow to pass through the devices should be less, and can even be considerably less if you so desire.

I can say a little more on the subject of power adapters, but as I need to attend to something else at the moment, I will have to do this a little later.

Cheers

flyingnunrt

29-06-2006, 08:41

Here is a link to a neat led calculator, but you still need to know the details of the particular led that you are using.
http://www.luxeonstar.com/resistor-calculator.php