LED "capacitance" won't get lower


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938

    Unhappy LED "capacitance" won't get lower

    Hello,

    I've been reading some threads about the LED's capacity feature and that they can be used as "sensors".

    Now, I made a short program where I involve 3 LEDs to be discharged and measured in time like this:
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1583&stc=1&d=117804885 4">

    The shema is simple: one port connected to all Anodes (through a 330 ohms resistor) and three ports connected each to one Kathode. I use a 16F88 @ 20MHz.

    I reduced the code as much as I could and here it is:
    Code:
    LOOP:
        for Counter = 1 to 3                                                 
            PORTB.0 = 0 : PORTB.0(counter) = 1 'reverse power to the LED to "charge" it
            TRISB.0(counter) = 1               'make the last HIGH port an Input and...
            while PORTB.0(counter) = 1         '...read it. As long as port is 1, increment "Discharge"
                discharge = discharge + 1
            wend
            discharge(counter) = discharge     'store Discharge's value for later comparision
            discharge = 0
        next
        gosub display
        TRISB = 0
        goto loop
    end
    I know I can reduce the overall process time by modifying the program but this is currently not the problem since I want to reduce the discharge time of each LED.

    I thought I would be able to lower the LED's capacitance by reducing the voltage applied to it. So I put a 10K instead of the 330ohms one.

    I even added a 10Mohms resistor in parallel with the LED to make a kind of load.

    Result: no change(!?). The time values never change.

    What am I doing wrong here? Should I use a 40MHz PIC instead?
    Attached Images Attached Images  
    Roger

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post
    Hello,
    I've been reading some threads about the LED's capacity feature and that they can be used as "sensors".
    Now, I made a short program where I involve 3 LEDs to be discharged and measured in time like this:
    The shema is simple: one port connected to all Anodes (through a 330 ohms resistor) and three ports connected each to one Kathode. I use a 16F88 @ 20MHz.....etc....etc....etc....
    Check my webpage, www.srt.com/~jdgrotte, click on LED touch sensor.
    I did basically the same thing awhile back, used 8 LEDs, NO resistors, standard parallel LCD, and an 18F4620 @ 40Mhz.
    Most of the code is posted on the page itself. Should work with a 16F88 at 20Mhz, not sure, never tried.
    Check the video to see it in action (it's a crappy video, I've been meaning to update, never got around to it).
    This is actually my 18F4620 code:
    Code:
    looper var byte
    anode var porta.1              'common anode of all IR LEDs
    
    t1 var portc.5 : t2 var portc.4 : t3 var portc.1 : t4 var portc.0 : t5 var porte.2 : t6 var porte.1 : t7 var porta.4 'all IR LEDs cathodes pins
    
    touchval var word[7] : touchmin var word[7] : touchmax var word[7] : touchrange var word[7] : touchpos var word[7] : touchaverage var word[7]
    touchmidpoint var word[7] : maxval var byte : maxtemp var word
    
    skipsubs: 'generic setup I use for all my programs, YMMV
    flags=0 : pause 1000 : intcon=0 : intcon.7=1 : intcon.6=1 : intcon.5=1 : intcon2=0 : intcon2.2=1 : intco3=0 : pir1=0 : pir2=0 : pie1=0 : pie1.5=1 : pie1.4=1
    pie2=0 : t0con=0 : t0con.7=1 : t0con.6=1 : t0con=t0con+2 : t1con=0 : t2con=0 : t3con=0 : ccp1con=0 : ccp2con=0 : pwm1con=0 : eccp1as=0 : sspstat=0
    sspcon1=0 : sspcon2=0 : txsta=0 : txsta.6=0 : txsta.5=1 : txsta.4=0 : txsta.2=1 : rcsta=0 : rcsta.7=1 : rcsta.6=0 : rcsta.4=1 : baudcon=0 : baudcon.3=1
    spbrgh=4 : spbrg=16 : adcon0=0 : adcon1=$f : adcon2=$ff : cmcon=7 : cvrcon=0 : hlvdcon=0 : trisa=0 : porta=0 : trisb=0 : portb=0 : trisc=0 : portc=0 : trisd=0
    portd=0 : trise=0 : porte=0 : input switch1 : input switch2 : output led1 : led1=1 : led1=0 : pause 200 : led1=1 : pause 200 : led1=0 : pause 200 : led1=1
    pause 200 : led1=0 : pause 200 : led1=1 : pause 200 : led1=0 : pause 200 : led1=1 : pause 200 : led1=0 : pause 200 : lcdout $fe,1 : switchignorecount=0
    menu=1 : switchdelay=1000 : output serialdataoutputpin : input serialdatainputpin : touchmin = 65000 : touchmax = 100
    
    loop2:
    led1 = counter.0
    for looper = 1 to 7 'light an LED, even though you can't see it
        output anode : anode=1 : input t1 : t1=0 : input t2 : t2=0 : input t3 : t3=0 : input t4 : t4=0 : input t5 : t5=0 : input t6 : t6=0 : input t7 : t7=0
        select case looper
            case 1
                output t1 : t1 = 0
            case 2
                output t2 : t2 = 0
            case 3
                output t3 : t3 = 0
            case 4
                output t4 : t4 = 0
            case 5
                output t5 : t5 = 0
            case 6
                output t6 : t6 = 0
            case 7
                output t7 : t7 = 0
        end select
        pause 1 : anode = 0
        select case looper 'reverse bias that same LED
            case 1
                output t1 : t1 = 1
            case 2
                output t2 : t2 = 1
            case 3
                output t3 : t3 = 1
            case 4
                output t4 : t4 = 1
            case 5
                output t5 : t5 = 1
            case 6
                output t6 : t6 = 1
            case 7
                output t7 : t7 = 1
        end select
        pause 1
        select case looper 'switch that LED to an input to read it
            case 1
                input t1
            case 2
                input t2
            case 3
                input t3
            case 4
                input t4
            case 5
                input t5
            case 6
                input t6
            case 7
                input t7
        end select
    loop3a:
        'run a counter in a tight loop (loop3a) and keep checking and waiting for the particular LED input to drop from
        'a logic 1 to a logic 0 because the voltage sitting on the LED due to the internal capacitance drops 'slowly'
        touchval[ looper ] = touchval[ looper ] + 1 : if touchval[ looper ] > 65000 then goto kickoutloop3a
        'if we wait too long or the pin is stuck, we'll never get out of the loop
        select case looper
            case 1
                if t1 = 1 then goto loop3a
            case 2
                if t2 = 1 then goto loop3a
            case 3
                if t3 = 1 then goto loop3a
            case 4
                if t4 = 1 then goto loop3a
            case 5
                if t5 = 1 then goto loop3a
            case 6
                if t6 = 1 then goto loop3a
            case 7
                if t7 = 1 then goto loop3a
        end select
    kickoutloop3a:
        counter = counter + 1 'just a counter to show a 'heartbeat'
    next looper
    
    maxval = 0 : maxtemp = 0 'maxval keeps track of which led had the lowest value, maxtemp keeps track of the lowest value
    
    for looper = 1 to 7 'check al 7 LEDs to find the lowest one
        if touchval[ looper ] > maxtemp then
            maxtemp = touchval[ looper ] : maxval = looper
        endif
    next looper
    
    'clear out the line, then display the number of the darkest LED
    lcdout $fe , $80 , " " : lcdout $fe , $80 + ( 7 - maxval ) , DEC1 ( 7 - maxval ) : lcdout $fe , $c0 , " " : lcdout $fe , $c0 + ( 7 - maxval ) , $ff
    for looper = 1 to 7 : touchval[ looper ] = 0 : next looper
    goto loop2
    END
    Last edited by skimask; - 1st May 2007 at 21:25.

  3. #3
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Wink already done

    Hi skimask,

    I've read lots of threads and went already on your site (btw: thank you) and many others about this topic.

    The problem is not to make it work - it does.

    I want to understand how to modulate the LED's capacitance.

    It's maybe more an electronics issue, not a PIC one at this time.

    Any idea?
    Roger

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post
    Hi skimask,
    I've read lots of threads and went already on your site (btw: thank you) and many others about this topic.
    The problem is not to make it work - it does.
    I want to understand how to modulate the LED's capacitance.
    It's maybe more an electronics issue, not a PIC one at this time.
    Any idea?
    I tried a few different things, added resistors, added small cap's in parallel with the LED, couldn't really get the results to change to get a larger 'range'. The results would 'shift' up and down, but never really stretch out the way I wanted them to.
    Are you trying to 'widen' the range of the number you get back from the function? In other words, instead of, say 0-10, you'd get 0-1000?
    The key might be finding the right LED vs. adding components to the circuit, or just plain counting it all really fast.
    As you can see from my page, basically, as soon as I got that to work, I called it good...something in the hobby toolbox for the future...

  5. #5
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    I've been doing some reading on this subject and had it in the back of my mind for sometime now, using an led as a switch instead of a mechanical switch. A few things that I've read that may influence the range your after are the color of the lens... I think a clear lens works better, and the amount of ambient light in the room. It would be an easy experiment to see how it reacts in total darkness compared to whatever your normal lighting conditions are. Here's a couple links for info.
    http://www.edn.com/article/CA6387024.html
    Check out some of the references at the bottom of the page. I especially like the reference to the Mitsubishi Electric Research lab paper.
    THIS is originally where I saw a demonstration. And ofcourse Skimask has video proof that it works, not to mention nice enough to post some code. Nice video!
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rhino View Post
    A few things that I've read that may influence the range your after are the color of the lens... I think a clear lens works better
    I tried a couple of type of red lensed LEDs, barely got any results at all. Tried a clear-greenish lensed, got some results, but nothing useful. The LEDs I ended up using were IR LEDs. You can barely see them in that 'video' I made. They show up on the camera, but you can't really see them.

    and the amount of ambient light in the room. It would be an easy experiment to see how it reacts in total darkness compared to whatever your normal lighting conditions are
    I sorta wrote the code to compensate for ambient lighting. I'd keep track of the high and low values and the one that was the darkest was the one with my finger over it. And the code on the site isn't exactly the finished product. The 'real' code (before I shelved the project) had a couple of extra lines in it to 'reset' the high and low values over time so they wouldn't get 'stuck'.

    That same video is where I got the original idea from.

    And of course Skimask has video proof that it works, not to mention nice enough to post some code. Nice video!
    (Code posting) - First time for everything I guess

    Someday, when I get my basement/LAB rework finished (major water damage, repainting walls in the works), I'll put it back together with a few more LEDs and redo the video. Bought the wife a new camera for Xmas last year (or was it me? I forget )...has a really decent movie mode on it.

Similar Threads

  1. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  2. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 20:19
  3. For next loop using: Led var Byte
    By quester in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th March 2008, 10:16
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. can't even flash an LED
    By bruno333 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th April 2005, 13:27

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts