How to Connect Phototransistor to PIC

Discussion in 'Embedded Systems and Microcontrollers' started by JDR04, Mar 23, 2015.

  1. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    I'm hoping somebody would be able to help me out with this.

    I'm wanting to connect a phototransistor (which will be used to detect ambient light) to a microcontroller but I am not sure which method is the correct or best one.(See attached Schematic) If neither are advisable could you please show me the correct method.

    Thanks in advance.........JDR04
     
  2. DickCappels

    Moderator

    Aug 21, 2008
    2,651
    632
    I think method 2 is the better of the two approaches. What is your question?
     
  3. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Method 1 will not work at all...

    Method 2 is better, but is highly dependent on the resistance vs illumination curve of the specific photo-detector you select. If you connect it to a Digital input on the uP, to get a logical zero when the detector is not illuminated, the value of R3 will have to be adjustable over the range from ~2K to about ~100K, depending on where you place the photo-detector, and the specific detector you choose...
     
    Last edited: Mar 23, 2015
  4. Kermit2

    AAC Fanatic!

    Feb 5, 2010
    3,786
    945
    method 2 certainly.
    split the resistor value and add a pot. to the string to allow a sensitivity adjustment
     
  5. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    Thanks for that. Could I ask as to how one determines the resistor values?
     
  6. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,532
    2,369
    Also depends on if you are using an analogue or digital input, if digital, you may want to add a comparitor, LM311, between the sensor and the uP input to get a little snap action input.
    Max.
     
  7. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    I did not show it but I plan to have a 100k pot on another pin to set the threshold before triggering. Thanks for the suggestion.
     
  8. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    Thanks. I have hysterisis (I think its called) built into the programming.
     
  9. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Provide a link to the photo-detector data sheet.
     
  10. DickCappels

    Moderator

    Aug 21, 2008
    2,651
    632
    It sounds like you are looking at the light dependent resistor through the A-to-D converter; good choice because that gives you the flexibility to deal with the details in firmware.

    You will have to adjust the value of the resistor to suit your particular light dependent resistor and your application. The 100k pot is a good way to find the ideal resistance.
     
  11. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    A phototransistor isn't very good for detecting light level, because they typically don't match the response of the eye very well. You'll get a huge response from daylight or incandescent, for instance, and not much from fluorescent light. You'd do better with a cadmium-sulfide photoresistor. At least check the response curve of the part you plan to use, and compare with the type of light you expect to see.
     
  12. #12

    Expert

    Nov 30, 2010
    16,278
    6,791
    Reality testing. I went through all this with some CdS cells I had. None of them resembled each other. I learned that the full moon is about 1/2 of a foot candle and daylight is about 100,000 foot candles. Having no way to produce the in-between amounts and measure them, I just sat in the back yard and watched the ohm meter until I thought it was time to turn the lights on.

    One experimental result is worth a dozen theories.
     
  13. ScottWang

    Moderator

    Aug 23, 2012
    4,853
    767
    You didn't show what is the uC and what are you trying to detect the ambient light for?
    And what is the phototransistor or you want to change to using a CDS?
     
  14. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    Thanks to everyone, I'll work on all the suggestions and see what best suits my need. Thanks a lot.....JDR04
     
Loading...