Announcement

Collapse
No announcement yet.

Auto brightness with PIC (PWM) and LDR for Lilliput 701 LED Backlit

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Auto brightness with PIC (PWM) and LDR for Lilliput 701 LED Backlit

    Has anyone tried using a microcontroller to control the brightness of the LED backlight in a Lilliput? To my understanding, the monitor isn't actually controlling the brightness of the backlight, it's just simply controlling the contrast and so on. I'm measuring the voltage to the LED backlights and it's pretty much staying a constant 9.4V while adjusting contrast and brightness through the menu function.

    Just curious to see if anyone else has done this before I try it. I know I can do it but if someone else has already experimented with it would be nice
    Love

  • #2
    Geez, I don't know whether I should even comment....
    LOL!

    Yes, it has been done. By others.
    But I lost track - I was dealing with a self professed expert with 20 years experience that couldn't apply Ohms Law and reckoned a PWM would need a capacitor to filter out the PWM!

    You should be able to search on here...
    Or if curiosity doesn't kill the cat, I could suggest a name or nine.

    Comment


    • #3
      I searched but nothing I got really applied. I feel like the search function got worse with the new upgrade.

      ---------- Post added at 11:41 AM ---------- Previous post was at 11:34 AM ----------

      Just did a search using different keywords and found some stuff so nevermind! Thanks
      Love

      Comment


      • #4
        Originally posted by rEegLer View Post
        Has anyone tried using a microcontroller to control the brightness of the LED backlight in a Lilliput? To my understanding, the monitor isn't actually controlling the brightness of the backlight, it's just simply controlling the contrast and so on. I'm measuring the voltage to the LED backlights and it's pretty much staying a constant 9.4V while adjusting contrast and brightness through the menu function.

        Just curious to see if anyone else has done this before I try it. I know I can do it but if someone else has already experimented with it would be nice
        I'd be interested in this. I bought a Lilliput with "5 way adjustable LED backlight" as an advertised feature. Well, big surprise, there's no backlight adjustment (it just alters the brightness/contrast of the displayed image).

        Comment


        • #5
          I got it to work with a PICAXE mcu and Darlington Transistor array. Works really well actually. Now I just need to perfect the code and adjust some hardware. I'm powering the backlight off a 12v linear regulator but need an LDO regulator as it needs Vin to be above 14V which isn't always the case for my car. I'll post of some pictures when I finish everything.
          Love

          Comment


          • #6
            Finished everything and it works pretty well. My only issue is where to put the LDR. Below is my code and some pictures of the circuit. I'm a novice at programming (and with PICAXE basic) so if you see a more efficient way to do it please comment! And this is for instantaneous fading whereas delayed fading might be more appropriate.

            Code:
            ;LED Backlight PWM program V3 with instantaneous fading
            ;Written for Mazda3 CarPC by Tim Stocker
            ;
            ;Output 2 - LED Backlight
            ;Input 4 - LDR with 10kOhm Resistor
            ;Input 0 - Power-on V+ from monitor (9.45V = 65 w/100kOhm & 33.3kOhm voltage divider)
            
            
            symbol LED = 2
            symbol LDR = 4
            symbol PWR = 0
            
            setfreq m8								;overclock to 8MHz
            
            Startup:					
            	readadc PWR,b3		
            	if b3<50 then Standby				
            	readadc LDR,b1						
            	if b1>=160 then Sunny					
            	if b1>80 and b1<160 then Dusk
            	if b1<=80 then Night
            	goto startup
            
            Sunny:
            
            	readadc PWR,b3
            	if b3<50 then Standby
            	pwmout LED, 86, 275
            	readadc LDR,b1
            	if b1<=160 then DES_Sunny_to_Dusk
            	goto Sunny
            
            
            DES_Sunny_to_Dusk:
            
            	readadc PWR,b3
            	if b3<50 then Standby
            	b2=254
            	for b2 = 254 to 100 step -1
            	   pwmout LED, 88, b2
            	   pause 5	   			
            	next b2
            	goto Dusk
            	
            
            ASC_Dusk_to_Sunny:
            
            	readadc PWR,b3
            	if b3<50 then Standby
            	b2=100
            	for b2 = 100 to 254
            	   pwmout LED, 88, b2
            	   pause 5	   			
            	next b2
            	goto Sunny
            
            Dusk:
            
            	readadc PWR,b3
            	if b3<50 then Standby
            	pwmout LED, 90, 100
            	readadc LDR,b1
            	if b1>=180 then ASC_Dusk_to_Sunny
            	if b1<=80 then DES_Dusk_to_Night
            	goto Dusk
            		
            ASC_Night_to_Dusk: 
            
            	readadc PWR,b3
            	if b3<50 then Standby
            	b2=20
            	for b2 = 20 to 100
            	   pwmout LED, 92, b2
            	   pause 5	   			
            	next b2
            	goto Dusk
            
            DES_Dusk_to_Night:
            
            	readadc PWR,b3
            	if b3<50 then Standby
            	b2=100
            	for b2 = 100 to 20 step -1
            	   pwmout LED, 92, b2
            	   pause 5	   			
            	next b2
            	goto Night
            	
            Night:
            
            	readadc PWR,b3
            	if b3<50 then Standby
            	pwmout LED, 94, 20
            	readadc LDR,b1
            	if b1>=100 then ASC_Night_to_Dusk
            	goto Night
            	
            Standby:
            
            	pwmout LED, off
            	readadc PWR,b3
            	if b3<50 then Standby
            	goto Startup




            Pretty simple program and circuit. The circuit is just the PICAXE controller, Darlington transistor array, a 12V regulator (soon to be a LDO 10V regulator since 12V is not necessary as the max voltage to the LED is 9.5V), and a 5V regulator for the PIC and LDR.
            Last edited by rEegLer; 03-22-2011, 08:32 AM.
            Love

            Comment


            • #7
              That's cool!
              I've been mulling over how to do this on my setup.
              What are you reading to determine when it's sunny, night or dusk?

              I've never worked with PIC's but the rest of the electronics look doable. Any chance you could post or pm the schematic? Even better would be if I could buy a programed PIC from you with the schematic?

              Great job!
              Thanks
              davidk

              Comment


              • #8
                Originally posted by davekra View Post
                What are you reading to determine when it's sunny, night or dusk?
                Looking at the code
                ;Input 4 - LDR with 10kOhm Resistor
                .....
                .....
                readadc LDR,b1
                if b1>=160 then Sunny
                if b1>80 and b1<160 then Dusk
                if b1<=80 then Night
                Corolla WorkLog

                Comment


                • #9
                  Originally posted by davekra View Post
                  That's cool!
                  I've been mulling over how to do this on my setup.
                  What are you reading to determine when it's sunny, night or dusk?

                  I've never worked with PIC's but the rest of the electronics look doable. Any chance you could post or pm the schematic? Even better would be if I could buy a programed PIC from you with the schematic?

                  Great job!
                  Thanks
                  davidk
                  PICAXE controllers are really easy to program so I would just recommend buying a couple and playing around with them. Their website has a lot of information on them. Each chip varies from $3 to 10 depending on the number of I/O's. I buy mine from SparkFun.com. I bought the PICAXE -14 project board to get started.

                  I'm using an LDR (light dependent resistor) along with a 10kOhm resistor (to act as a voltage divider) to get an analog readout for the brightness. My circuit is a bit overkill because the Darlington transistor array has 8 channels but I'm only using 1 pulling only ~400mA. A smaller PICAXE controller might be able to be used (like the 08M) as I'm using the 14 pin one and only using 3 I/O's.

                  ---------- Post added at 11:12 AM ---------- Previous post was at 11:05 AM ----------

                  Originally posted by davekra View Post
                  Any chance you could post or pm the schematic?
                  Yea I'll post the schematic at somepoint. It's not that complicated.
                  Love

                  Comment


                  • #10
                    Cool, thanks.
                    davidk

                    Comment


                    • #11
                      Fixed the code, added fading when going into standby mode and corrected some errors:

                      Code:
                      ;LED Backlight PWM program V3 with instantaneous fading
                      ;Written for Mazda3 CarPC by Tim Stocker
                      ;
                      ;Output 2 - LED Backlight
                      ;Input 4 - LDR with 10Kohm Resistor
                      ;Input 0 - Power-on V+ from monitor (9.45V = 65 w/100kOhm & 33.3kOhm voltage divider)
                      
                      
                      symbol LED = 2
                      symbol LDR = 4
                      symbol PWR = 0
                      
                      setfreq m8								;overclocking to 8MHz
                      
                      Startup:	
                      				
                      	readadc PWR,b3		
                      	if b3<50 then Standby				
                      	readadc LDR,b1						
                      	if b1>=160 then Sunny					
                      	if b1>80 and b1<160 then Dusk
                      	if b1<=80 then Night
                      	goto startup
                      
                      Sunny:
                      
                      	readadc PWR,b3
                      	if b3<50 then subsunny
                      	pwmout LED, 86, 275
                      	readadc LDR,b1
                      	if b1<=160 then DES_Sunny_to_Dusk
                      	goto Sunny
                      	
                      subsunny:
                      	b4=255
                      	goto Standby
                      
                      
                      DES_Sunny_to_Dusk:
                      
                      	readadc PWR,b3
                      	if b3<50 then subsunny
                      	b2=255
                      	for b2 = 255 to 100 step -1
                      	   pwmout LED, 88, b2
                      	   pause 15	   			
                      	next b2
                      	goto Dusk
                      	
                      
                      ASC_Dusk_to_Sunny:
                      
                      	readadc PWR,b3
                      	if b3<50 then subdusk
                      	b2=100
                      	for b2 = 100 to 254
                      	   pwmout LED, 88, b2
                      	   pause 15	   			
                      	next b2
                      	goto Sunny
                      
                      Dusk:
                      
                      	readadc PWR,b3
                      	if b3<50 then subdusk
                      	pwmout LED, 90, 100
                      	readadc LDR,b1
                      	if b1>=180 then ASC_Dusk_to_Sunny
                      	if b1<=80 then DES_Dusk_to_Night
                      	goto Dusk
                      	
                      subdusk:
                      	b4=100
                      	goto Standby
                      		
                      ASC_Night_to_Dusk: 
                      
                      	readadc PWR,b3
                      	if b3<50 then subnight
                      	b2=20
                      	for b2 = 20 to 100
                      	   pwmout LED, 92, b2
                      	   pause 20	   			
                      	next b2
                      	goto Dusk
                      
                      DES_Dusk_to_Night:
                      
                      	readadc PWR,b3
                      	if b3<50 then subdusk
                      	b2=100
                      	for b2 = 100 to 20 step -1
                      	   pwmout LED, 92, b2
                      	   pause 20	   			
                      	next b2
                      	goto Night
                      	
                      Night:
                      
                      	readadc PWR,b3
                      	if b3<50 then subnight
                      	pwmout LED, 94, 20
                      	readadc LDR,b1
                      	if b1>=100 then ASC_Night_to_Dusk
                      	goto Night
                      
                      subnight:
                      	b4=20
                      	goto Standby
                      	
                      Standby:
                      
                      	b2=b4
                      	for b2 = b4 to 0 step -1
                      	   pwmout LED, 86, b2
                      	   pause 5	   			
                      	next b2
                      	do
                      	 pwmout LED, off
                      	 readadc PWR,b3
                      	loop until b3>50
                      	goto Startup
                      Love

                      Comment


                      • #12
                        I just read the datasheet on the PICAXE and it looks easier to use than I thought.
                        I believe I can read your code and figure out how it's working. This is going to be a fun project.
                        I'm off to place an order for some of these things.
                        Thanks again,
                        davidk

                        Comment


                        • #13
                          It's extremely easy to use. I will probably add more notes to my code so it's easier to understand.
                          Love

                          Comment


                          • #14
                            Good stuff Reegler!

                            Though its a big jump from circuitry etc, it is the simplest way to do this stuff. Gone are the days when non-PWM techniques could be used. (Though I'd use PWM for efficiency on incandescents.... and necessity for flouros.)


                            So many want a vehicle's lighting to be soft start (brighten), then on, then dim after a delay; controlled by door or unlock or remote start but overridden by headlights or....
                            The logic alone is almost easiest with a PIC, but add the up/down dimming....
                            Try that with circuitry!


                            Now, will you add a capacitor to smooth out the PWM voltage?
                            (That's a joke. I'm just crapping on an old experienced dude that though that; and that one LED string can rob current from another etc...)

                            Comment


                            • #15
                              Damn these little things have a lot of commands to learn!
                              I was going over your code and I think I've got it sorted. It is pretty simple I guess.

                              One question I have is how you measured the voltage for the LED's at ~9 volts? Just put a meter on them while still hooked up to the display?
                              Then just feed them that voltage using PWMOUT? Are you using a current limiting resistor? Again, measure the draw while still hooked up to the display?
                              If the display is feeding them PWM power, do you get somewhat accurate readings?

                              Thanks
                              davidk

                              Comment

                              Working...
                              X