PIC comparator input impedance (solar panel)

Discussion in 'Electronics & Electrics' started by dufflover, Apr 1, 2018.

  1. dufflover

    dufflover Member

    Joined:
    Dec 27, 2005
    Messages:
    1,660
    Location:
    Melb
    I'm trying to use a small leftover 5V solar panel as a darkness sensor, as in input into a PIC12F675 inbuilt comparator.

    But the difference in reading between the multimeter and when hooked up the PIC is extreme to the point it's not really usable. Like say 1.5V on the meter, but then only 10mV if that hooked up to the PIC.

    I know the virtual open circuit voltage is different from a solar panel vs loaded, but the difference is far more than I thought.

    As a test I also charged up a cap to 5V, then let it drain purely on that comparator input pin, and it drops quite quickly.

    I thought it was meant to be relatively high impedance input?
    Any workarounds or ideas?
     
  2. mtma

    mtma Member

    Joined:
    Aug 12, 2009
    Messages:
    4,578
    Does that pin have a pulldown set or installed?
     
  3. OP
    OP
    dufflover

    dufflover Member

    Joined:
    Dec 27, 2005
    Messages:
    1,660
    Location:
    Melb
    It has a weak pull up option which I've disabled. The data sheet says it's disabled anyway when a pin is set to analog mode. I've tried adding a resistor to ground anyway but no difference.
     
  4. mtma

    mtma Member

    Joined:
    Aug 12, 2009
    Messages:
    4,578
    The PIC still seems a little suspicious as we are talking only microamp scale typical leakage, however since you are only measuring a fraction of the voltage from the panel with a multimeter it would seem to suggest that you solar panel is only providing microamps of current. Which is a little weird as photovoltaic optocouplers do better than that and the photocell in those is truly tiny. What model multimeter are you using to measure the panel with?

    To estimate the current output from the panel you can charge up a large-ish cap (like 1000 or 100 uF) for a preset time and check the voltage of the cap with the multimeter.
     
  5. OP
    OP
    dufflover

    dufflover Member

    Joined:
    Dec 27, 2005
    Messages:
    1,660
    Location:
    Melb
    Yesterday I came across in the datasheet that the "Unit Resistor Value" (no idea what that is) of the Comparator module was 2k ohm with a nice asterisk to say characterised but not tested. So far it's the best clue at the moment to what resistance value is in it which explains what is going on. I know these solar panels can provide enough current to light an LED from some previous mucking around, so at least a few milliamp.

    But I've figured out a work-around that does the job, finally. After a lot of mucking around I remembered I had a spare BJT around and have wired it up now to a Schmitt-buffered input PIN with weak pull-up enabled, and when the panel gets enough light to turn on the BJT the PIN is brought low. A cap to give some "buffer" time combined with inbuilt Schmitt levels seems to be prototyping well enough anyway!

    A real guru probably would've had this idea instantly :upset: lol. I was just really fixated on thinking surely the PIC could do it without any external circuitry. This is the closest/best working I've gotten.
     
  6. OP
    OP
    dufflover

    dufflover Member

    Joined:
    Dec 27, 2005
    Messages:
    1,660
    Location:
    Melb
    *Update*

    I've put together my circuit on a stripboard but now having an issue with the way the SR501 PIRs are wired up. PIRs on 12V, PIC on 3.3V via regulator.

    The issue is I use a FET to switch on/off the ground connection of the PIRs as a way to save power during the day. But I've encountered an issue where when the PIR ground is disconnected, a high voltage still presents on the signal pin. And when on 12V (I prototyped on USB 5V), the voltage is around 7~9V which is outside the PICs specs so I'm guessing why it's constantly resetting out - this is after going around adding bypass caps, reducing the voltage to the regulator, etc.

    I did think of using a P MOSFET to switch the positive side instead, but 3.3V logic wouldn't switch 12V Vgs anyway without extra parts so N switching was easier at the time.

    With the circuit all on the board now, any ideas? I have room for maybe one small filler part. The other idea is to just logically always have the FET/PIR properly on so the signal pin is always correctly 3.3V/0V levels.
     

Share This Page