This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Driving LED from MSP430 ports

Other Parts Discussed in Thread: MSP430F2013

I tried to drive an IR LED from MSP430 - anode connected to a port and cathode grounded. It worked, but the brightness wasn't enough. So I connected the cathode of the LED to another port. So, when the port driving the anode was high, the port connected to the cathode was low. I got significantly higher brightness with this circuit. 

What I am not sure is - when one port is high and other port is low, is the current 2x compared to the first method?

  • You would have to measure the current to answer your question.  The current demanded by the LED is not linear with the voltage driving it.  And the voltage held by the MSP430 is dependent on the current being drawn (see data sheet for your specific MSP430 model).

    However, I think it is fair to say that two MSP430 pins can provide twice the power (P=IV) of a single pin, up to a limit.  Eventually, though, adding more pins gives diminishing returns as the total current through the MSP430 power distribution approaches limits.

    Your configuration using two MCU pins makes twice the power available to the LED, but we still cannot say the LED is using twice the power because it may have reached a flatter part of its power curve.

    Jeff

  • The OP had one pin sourcing and one pin sinking.

  • eltury said:
    The OP had one pin sourcing and one pin sinking.

    Oh.  That makes his observation of higher LED output pretty strange.

    Hithesh, can you measure the anode and cathode voltages for both configurations?  Can't help but be curious.

    Does your MCU offer "full" drive strength and "reduced" drive strength?  By chance to did you tweak these settings (in the PxDS registers)?

    Jeff

  • Hithesh said:

    I tried to drive an IR LED from MSP430 - anode connected to a port and cathode grounded. It worked, but the brightness wasn't enough. So I connected the cathode of the LED to another port. So, when the port driving the anode was high, the port connected to the cathode was low. I got significantly higher brightness with this circuit. 

    What I am not sure is - when one port is high and other port is low, is the current 2x compared to the first method?

    What is the forward voltage for the rated current associated with the desired brightnes for the LED you are using?  If the MSP430 voltage is high enough you may be able to souce the current.  If the MSP430 voltage was not high enough, you would have to sink the current.

    Some insight into LEDs might help.

    LED brightness can vary between batches of LEDs in the manufacturing process.  To account for this, they are binned.  The brightness of the LED should be either be specified in the part number, or by the manufacturer's binning.  If you're using cheaper LEDs, they may have skipped the binning process to save cost in which case you can expect some variation between LEDs even when they each use the same power.

    For any one particular LED, its brightness is roughly proportional to its current.  In approximate terms, doubling the current will double the brightness.  The best way to regulate an LED's brightness is to regulate the current through it.  The cheaper option is to set the current once and pulse width modulate the output above 100 Hz to vary the brightness.

    For each current, the LED has an associated forward voltage.  Since forward voltage is not proportional to brightness using the voltage to regulate the brightness is not recommended.  However if you limit the voltage to set the current at just one point, you can get away with this inexpensive solution if you also pulse width modulate.  The tradeoff for this cheap approach is the voltage for the same brightness might change from one LED to another (due to poor binning, or different LED colours).  To compensate the current limitng resistor from your voltage souce might need to be deterimned on a LED by LED basis, or you could just live with the variation and set one resistor for all. 

    You will also need to consider how much the MSP430 you are using can source and sink on each pin.  Find, "Typical Characteristics, Outputs," in the data sheet and the graphs should have the data you're looking for.  Consider the forward voltage of the LED's compared to the MSP430 Vcc when looking at the design.  Referring to the MSP430-LED8x8-BOOSTERPACK may also be helpful.

  • Hithesh said:
    . So, when the port driving the anode was high, the port connected to the cathode was low. I got significantly higher brightness with this circuit. 

    This is really strange. The current should be less because the current causes twice the voltage drop, once on the sourcing pin and once on the sinking pin.
    The current is definitely not twice of that of a single pin with fixed ground. But it exposes the MSP to twice the power loss.

    What might have happened is that you were over-driving the LED. Depending on diode material, this may lead to a shift in the color and also a reduced brightness. And increased temperature :). So more current is less good above a certain threshold.

    The method of two complementary pins is only useful for two applications: first, if multiplexing segments. For a dual multiplex, you can mount the diodes of batch 1 with anode to the common pin and for batch two with the cathode. So when setting the common pin to low, the separate pins control batch one, else batch two. (can be expanded to 3 or four batches, but then each batch with its own common pin).
    The other one is to enlarge the voltage swing. If you mount a speaker between two port pins, you can source it with +-VCC instead of just GND/VCC. Especially on piezo speakers this gives a significantly louder output.

  • Jens-Michael Gross said:
    The other one is to enlarge the voltage hub.

    can't say I've ever heard "hub" used in that context before?

    I think the more conventional term is, "voltage swing"?

     

  • Andy Neil said:
    I think the more conventional term is, "voltage swing"

    Right. A false friend. 'Hub' is the proper German word. (derived from 'heben' which means 'lifting')

    I changed it in my original post.

  • You should not drive a LED directly with a msp430 pin, they are only rated 4mA

    I do drive a IR_Led with a 1k resistor directly
    and I use the pin to sink it to turn it on as N-channel normally are more efficient.
    To turn it off I simple turn it back to input.

    bic.b   #1<<3,&P2OUT           ; P2.3 Ir-LED   if set as output = sink
    bic.b   #1<<3,&P2DIR            ; P2.3 Ir-LED input = off  
    bis.b   #1<<3,&P2DIR            ; P2.3 Ir-LED output = on

    For high brightness LED application, use a small signal mosfet to turn it on.

     

     

     

  • Tony Philipsson said:
    You should not drive a LED directly with a msp430 pin, they are only rated 4mA

    Depends on the MSP and the allowed voltage drop.

    MSP pins are CMOS drivers. The higher the current, the higher the voltage drop. The rated current is for a specified voltage drop. If driving an LED, the voltage drop may be significantly higher. Effectively an equilibrium of diode forwared voltage and port pin voltage drop at a certain current. The resulting current is where diode forward voltage + port pin voltage drop == VCC.

    For a diode with 1.7V forward voltage and VCC=3V, this may be at a current as high as 30mA. (well at some point the maximum power dissipation of the MSP needs to be checked too)

  • Update: I took a 13 ohm resistor, connected between port 1.2 and port 1.5 (MSP430F2013)

    P1.2 was driven high, P1.5 was low.

    The current was around 45mA. When I connected the resistor between port1.2 and ground, the current was around 60mA

    I guess connecting an LED between 2 ports wouldn't increase the current compared to connecting to port and ground.

    Can anyone care to double check this?

  • Hithesh said:
    I guess connecting an LED between 2 ports wouldn't increase the current compared to connecting to port and ground.

    As I already said, using two port pins only increases the voltage drop by the drop on the second port pin. More voltage drop on the pins means less voltage on the resistor, which means less current through the resistor, which means less voltage drop on the port pins which means more voltage on the resistor which means more current on the resistor...
    The equilibrium seems to be at 45mA through the resistor = 0.585V voltage for two port pins and 60mA = 0.78 for only one.

    Assuming VCC=3V, it means that you have 2.22V drop on one port pin for 60mA. Producing 133mW heat on the port pin. Two pins produce a voltage drop of 2.42V for 45mA which means only 1.21V drop per pin but also 54mW heat per pin (=108mW total). Both far above the specs and risking a burnout.

  • If you want to achieve high currents, the best way is to put the microcontroller out of the loop. Drive a bipolar or FET transistor with the MSP, and achieve whatever current you need on the LED (of course within the limits needed to, for example, saturate the bipolar transistor driver. If more current is needed, you can cascade transistors).

  • I always suggest the ULN2003. It contains 7 transistors wich can be directly driven by MSP output. THe transistors sink anly source to a common GND and contain free-running diodes. Maximum current per Transistor is IIRC ~500mA, with a total limit for all 7 together. The chip is cheap and small (SOIC16) and reliable. I use it to drive relay, LED, whatever.

**Attention** This is a public forum