NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Basic Electronics » LCD backlight control via MCU

April 23, 2010
by mjswan
mjswan's Avatar

I'm trying to switch on and off the LCD backlight programmatically. I've tried to use a 2N7000 MOSFET but can't seem to get the functionality I'd like. The Gate is wired to MCU pin 28 (PC5) and I can set and reset PC5 via the MCU. The Drain is wired directly to the +5V rail. The Source is wired to pin 15 of the LCD, which requires +5V to enable the backlight.

The way I understand the MOSFET, if I apply a logic zero (turn off PC5) to the Gate, then no current flows from Drain to Source, so the backlight should be off. However, if I apply a logic one to the gate (turn on PC5), +5V should flow to the Source, so the backlight should be on. What I see instead is that the backlight is off regardless of the state of PC5.

I know the backlight functionality works because if I wire pin 15 of the LCD directly to +5V, the backlight is enabled.

I think perhaps I'm missing some basic understanding of the MOSFET although as a test I've used the MOSFET to successfully power an LED on and off via the same PC5 control of the Gate. What am I missing?

April 23, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi mjswan,

It looks like you are missing one key thing about mosfet. An n channel mosfet like the 2N7000 only acts like a switch in certain conditions. We talk a little bit about this in our servto squireter tutorial. If Vgs (the voltage from the gate to the source) is low enough, your mosfet will be in the cutoff region and no current will flow. When we hook up the mosfet with the source on the ground rail (0V), this works great as a switch, since we can then control the gate with the MCU and toggle the mosfet into and out of the cut off region.

In your circuit however, you have the the mosfet connected with the drain to +5 and the source to the anode of the LEDs. The source here is not necessarily going to be at 0V, in fact you are counting on the voltage at that node to rise to 4.2V so the LED backlight turs on. In that case having the gate at 5V is still not enough to turn the switch "on" since Vgs is not greater than the threshold voltage.

You could try putting the mosfet on the other side of the LED backlight (the cathode side). Put the source on the GND rail, and the drain to pin 16 of the LCD (with the current limiting resistor in series). The gate would still be wired to your mcu pin.

Hope that clears things up a little. Let us know if you don't understand something I said. I'll try to be more clear.

Humberto

April 23, 2010
by mjswan
mjswan's Avatar

Hi Humberto,

Your explanation makes sense. Thanks. Your suggested solution works fine.

Out of curiosity, when I reset PC5 (the Gate input), why does the LCD backlight slowly dim, rather than turning off immediately?

Michael

April 25, 2010
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hi mjswan,

Is it possible that you don't have PC5 set as an output pin?

DDRC |= (1<<PC5);

My best guess as to what might make you see the backlight "slowly dim" (over a period of many seconds?) would be that the pin PC5 is still an input, but that you're able to turn it on via the pull-up resistor.

Mike

April 27, 2010
by mjswan
mjswan's Avatar

Hi Mike,

Thanks for your reply. Yes, I did have PC5 set as an output pin. The problem seems to have cleared itself up with some other unidentified change I've made.

Michael

Post a Reply

Please log in to post a reply.

Did you know that using an alternating excitation voltage can reduce the noise in many sensor measurements? Learn more...