Photodiode Measurement with PIC, Help

Discussion in 'General Electronics Chat' started by atakan1907, Mar 27, 2011.

  1. atakan1907

    Thread Starter New Member

    Jan 23, 2011
    9
    0
    Hi,
    Im trying to measure light using a standard LED, an OPAMP a feedback resistor and PIC16F690. When i connedted the led to opamp, it shows good values. Then i connected its output to pic, and measure, it fails. Altought i read the actual value as 5mv aproximately, the pic measurements are 0, 0, 130, 0, 150, ----- (of 1024). I'm working for two days but nothing changed. The circuit i built like below. (the led reversed in mine) The feedback resistor is 20MΩ. Maybe i can extend the hold capacitor charging time in pic. Please tell me the problem.
     
    • led.GIF
      led.GIF
      File size:
      2.8 KB
      Views:
      36
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    We really need to see a complete schematic, with components identified, and all values indicated.
     
    atakan1907 likes this.
  3. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,769
    969
    You have a 10bit ADC in your PIC micro.. You should be getting values from 0 to 1023.. You need to write code in the pic for converting that back to a voltage. Sounds to me like its working as it should.
     
    atakan1907 likes this.
  4. atakan1907

    Thread Starter New Member

    Jan 23, 2011
    9
    0
    I attached the required part of the circuit. There is a LCD also. Where this noise come from? How can i supress it. I used a software filter also but it failed too. I collected 8 samples and sorted lower to higher, ignored first and last two values and take the average of other 4 samples. But still absurd values came frequently.
    Then added the dashed components, the rc filter help some but not exactly.
     
    • ddd.JPG
      ddd.JPG
      File size:
      83.9 KB
      Views:
      60
  5. atakan1907

    Thread Starter New Member

    Jan 23, 2011
    9
    0
    No, i know that :)
     
  6. atakan1907

    Thread Starter New Member

    Jan 23, 2011
    9
    0
    Ok, i got stable results by connecting 100uF and u1F to ±9v supply and one 3n3F across 10MΩ feedback. I used to connect 100pF before. As i told, im using a software filter;
    1)sample 8times,
    2)sort samples in ascending order,
    3)average the middle 4 numbers
    Now everything looks okay =)
     
  7. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Do you have bypass caps across your PIC Vdd/GND terminals?
    Is the ground connection between the ground side of D1, and the analog ground or ground of the PIC, a very good connection?

    Do you have bypass capacitors from the +V and -V opamp supply to analog ground?

    Do you have a 10nF capacitor from the PIC adc input to the analog ground or ground of the PIC to keep the voltage stable?

    Do you put the PIC in sleep mode when starting the ADC sample?

    Are you certain that you are reading the correct I/O pin with the ADC? Can you give the I/O pin a fixed voltage and read it?

    Is your wiring long? Noise picked up on long wires will cause strange ADC readings.
     
    atakan1907 likes this.
  8. atakan1907

    Thread Starter New Member

    Jan 23, 2011
    9
    0
    Yes i put the pic in sleep mode at the start of the convestion.
    No cap on analog input.
    And its better to make a strong connection of diode and pic grounds.
    Thank You ;)
     
Loading...