Sudden Photon Death

That will work, assuming your sensor can drive some current! The resistors can be much higher in resistance, particularly if you're using a unity gain op-amp buffer.
And my bad for not thinking ahead quite far enough. I understand the concern about loss of resolution; you probably could get away with a series resistor and a switching diode (i.e. 1N914--or pretty much anything!) to the 3.3v rail. (And one to the ground rail, just to be safe!) Basically, you're trying to ensure that a spike of any sort either won't reach the Photon, and/or ensure that there won't be enough current to do any damage.

Sorry if it doesn't make too much sense, but I've generally found it difficult to get truly quiet ADC readings.
As a quick overview, microcontroller ADC units generally use a "sample-and-hold" system as follows:

  • ADC CONVERSION REQUEST
  • Internally "switch" the sample-and-hold capacitor (generally a few hundred pF) to the specified ADC input
  • Wait "tAD" (also known as the acquisition time), to allow the capacitor to charge. This time determines the input impedance, and is the source of the challenge!
  • Internally "disconnect" the capacitor from the ADC input
  • Start ADC conversion
  • Wait for conversion to complete (and I won't be technical about this!)
  • ADC result to code.

Basically, when the input signal has a high-impedance (read: low current, not very strong, weak signal), if the acquisition time is too short, it won't allow the capacitor to fully charge, resulting in unpredictable ADC results. A longer acquisition time will help, as will reducing the impedance (read: op-amp at unity gain, smaller bridge resistors, etc.)

I had a pretty in-depth discussion on this issue some time back (unfortunately without any outcome that I'm aware of) regarding how the ADCs are handled in at least the Core's firmware. (I'm not sure about the Photon yet; I'll have to delve into the source code sometime.) Basically, the firmware does a "pipelined ADC read" to read the ADC value 10 times, and then averages the result. In theory, that would provide a more stable ADC result. The only problem is that now you have 10 little "drains" on your input signal in very quick succession (dozens of microseconds apart), which will capitalize on capacitance ANYWHERE (wires, etc.), and result in unstable readings.

As mentioned in the linked (very technical) discussion:

(SAR = successive approximation register, referring to the methodology used to implement the ADC unit in the Core.)

You can also easily use that op-amp to amplify the signal for more range--and the op-amp won't care if you put a 100K resistor in series with your signal line. (I don't recommend it, though--10K should be more than adequate for safety :wink:.) To do that, simply replace the wire between the output and inverting (-) inputs with a resistor. The bigger the resistor, the higher the amplification. I'm really not much of an analog guy, so I'm not too much more help on that...

1 Like