[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 580: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 636: sizeof(): Parameter must be an array or an object that implements Countable
Brads Electronic Projects Forum • Controlling an LCD backlight - example using a mosfet
Page 1 of 1

Controlling an LCD backlight - example using a mosfet

Posted: Mon Aug 25, 2014 12:32 am
by bitfogav
A recent project as required me to use an LCD (cheap 16x2) but I needed a way of controlling the LCD backlight, mostly to save power when the PIC is in sleep mode.. The LCD backlight only needed to either be fully on or completely off so a good transistor could have been used, but I decided to make the LCD backlight more controllable by using a mosfet (2N7000) and a PWM channel from a PIC, this would allow me to completely control a good range of brightness and to turn the backlight on/off.. :)

Below Fig1 shows a common way of connecting up a LCD backlight and Fig2 shows how to connect up a mosfet to the LCD backlight.
fig1and2.png
fig1and2.png (14.55 KiB) Viewed 36620 times
Example Swordfish code:

Code: Select all

Device = 18F2553
Clock = 20

#option LCD_DATA = PORTB.4 
#option LCD_EN = PORTA.4 
#option LCD_RS = PORTA.5 

Include "LCD.bas"                
Include "PWM2.bas"          

Dim LcdBrightness as byte                                                         

TRISB  = %00000111
ADCON1 = %00001111       
CMCON  = %00000111 

LcdBrightness = 0
lcd.writeat(1,2,"LCD Backlight") 
lcd.writeat(2,1,"PWM Controlled!")                                                      
PWM.SetFreq(5000)
PWM.Start1
PWM.SetDuty1Percent(LcdBrightness)

While True                               
   repeat 
      pwm.setduty1percent(LcdBrightness)
      inc(LcdBrightness)
      delayms(50)                 
   until LcdBrightness = 100 
   repeat
      pwm.setduty1percent(LcdBrightness)
      dec(LcdBrightness)
      delayms(50)       
   until LcdBrightness = 0     
Wend
Example Video:

Re: Controlling an LCD backlight - example using a mosfet

Posted: Tue Aug 26, 2014 6:26 pm
by brad
Nice simple design there bitfogav. Will, you have brightness control buttons or a potentiometer perhaps?

Re: Controlling an LCD backlight - example using a mosfet

Posted: Wed Aug 27, 2014 4:38 am
by bitfogav
Indeed a simple design :) The project as a few buttons so I was thinking of having a user "lcd settings" menu to which the brightness of the LCD could be controlled..

The thing I like is that the pic as it's own on board PWM module, you just set it up and it runs in the back ground :)

Re: Controlling an LCD backlight - example using a mosfet

Posted: Thu Aug 28, 2014 9:05 pm
by brad
I just re-read my comment about the nice simple design. I didn't mean it at all to sound like you were dumb and that the only kind of circuit that you could design is a simple one!

Sorry if that's how it sounded...

What I really meant to say was - Nice design there bitfogav, I really like how you have managed to come up with a solution to your brightness dilemma with the most efficient circuit possible!

Does that sound better?

Anyway, I too like the PWM feature of the PIC micro controllers. in fact, the USB Meter that I made has a pic18f26k22 micro controller which has two PWM pins. These pins control the voltage that go to the USB port of your mobile phone / tablet.

PWM is great!

Re: Controlling an LCD backlight - example using a mosfet

Posted: Fri Aug 29, 2014 8:59 am
by bitfogav
brad wrote:I didn't mean it at all to sound like you were dumb and that the only kind of circuit that you could design is a simple one!
Sorry if that's how it sounded...
I didn't take your comment in that way anyway bud :) so no worries :)

I see the USB Meter is doing well on kickstarter. :)

Re: Controlling an LCD backlight - example using a mosfet

Posted: Fri Aug 29, 2014 9:02 pm
by brad
It has been doing alright(ish) Unfortunately it has had some bad feedback because of the legion meter that appeared on Kickstarter in May this year. They actually emailed me and threatened me with legal action because I had stolen their idea. However I was able to show them proof (via this link) viewtopic.php?f=17&t=948 that I had been working on my design months before they had even made theirs public.

It would have been very interesting to see just how well mine would have done if I had have started my campaign before theirs, since mine does the same thing as theirs (they just have a much nicer screen).

Re: Controlling an LCD backlight - example using a mosfet

Posted: Sun Aug 31, 2014 10:50 pm
by bitfogav
Oh no that's not good :cry: I see loads of usb doctors around the internet so why would they think you copied them? but glad you got it sorted in the end..
I actually like the retro look of your display, I think the layout of the leds are actually neat. And I'm glad to be on board of the kickstarter campaign :)
Would there be some different colour led versions in the future?

Re: Controlling an LCD backlight - example using a mosfet

Posted: Mon Sep 01, 2014 7:22 am
by brad
Great to have you on board with the campaign bitfogav!

Since I very much like working with LEDs, It's no real surprise that I went for a simple LED matrix with the display for this project. Now that I think about it, an OLED would have been much better, but I thought others may have also liked the retro feel of my device.

I was thinking of different LED colours, the only problem with that is it becomes a little bit more expensive for manufacturing and makes shipping a little harder because you have to make sure you match up the correct colour with each address. It may not sound like a big deal - but it caused quite a bit of a headache for the different PCB colours of the picnduino!