Hi guys,
To try to solve the mystery with the too fast de-charging of the 1nF cap., I completely rebuild the circuit.
While de-soldering, there was nothing wrong, apart from some solder flux underneath the SMD components (R1, R2 and C1).
The values all measured correctly. I use the suggested 1N5711 as the Schottkey, it seems to be working fine.
My scope probe is a decent quality x10 one (TESTEC HF series), without a switch.
I replaced the COG 1nF SMD cap with a small radial high quality 1nF COG capacitor.
I made the measurements again with and without the 10Mohm resistor in the circuit. There is NO change on the waveform. This is plausible because the effect of the 10M and/or the 10x probe is dwarfed by whatever else is loading the circuit. Believe me, there is nothing else connected or otherwise attached to the circuit. It's no rocket science, and there really is no magic involved.
Below is the "probed" ISR :
ISR (TIMER1_CAPT_vect)
{
timer1CounterValue = ICR1; // read the captured timer1 200ns counter value
digitalWrite(probe, 1); // create a signal to probe the ISR with a scope
TIC_Value = analogRead(A0); // ns value
digitalWrite(probe, 0); // stop the probe
PPS_ReadFlag = true; // gives the decharge cycle some time as well
}
The bottom trace (yellow) on the attached picture shows the probes surrounding the ADC read cycle.
The top trace is the voltage across C1,
without the 10Mohm resistor present, but of course with my 10x scope probe. It also should have an impedance of 10M. (look it up if you doubt that)
As you can see, the de-charge of the capacitor has finished way before the end of the ADC cycle.
However, the circuit as is, with or without the 10M (resistor or probe) works!
So as a next step, I changed the code to show the raw ADC readings in the second column of the report. Below is one drift cycle.
2370 56 -39 33691 93.9 **** 49 560 500 1 23934 56.6 1120 0 0 0
2371 20 -70 33680 93.5 **** -32 200 500 1 23934 56.8 1121 0 0 0
2372 29 -63 33683 92.8 **** 8 290 500 1 23933 56.7 1122 0 0 0
2373 8 -81 33676 93.2 **** -18 80 500 1 23933 56.8 1123 0 0 0
2374 10 -79 33676 92.9 **** 2 100 500 1 23932 56.9 1124 0 0 0
2375 18 -72 33679 92.5 **** 7 180 500 1 23932 56.6 1125 0 0 0
2376 3 -85 33674 91.3 **** -13 30 500 1 23931 56.7 1126 0 0 0
2377 3 -85 33674 90.4 **** 0 30 500 1 23931 56.9 1127 0 0 0
2378 4 -84 33674 88.6 **** 1 40 500 1 23930 56.5 1128 0 0 0
2379 0 -88 33673 88.5 **** -3 0 500 1 23929 56.6 1129 0 0 0
(Note that I did not have the two LM35 connected properly - I use "****" instead op UnLocked))
The values, ranging here from 0 to 56 are relative to what I see on my scope, so the actual ADC reading of the value must be at the very beginning of the cycle. Luckily, just before the capacitor is completely discharged.
When I dis-connect my scope probe, and the circuit is still
without the 10Mohm resistor, the ADC values are almost exactly the same. As to be expected.
I would like to re-iterate that there is no strange connection anywhere on the circuit board that would explain the way too fast discharge.
By simple deduction, the only unexplained factor that remains is the loading or low impedance of the ADC input of the Arduino processor itself.
The specifications list 100M as the impedance, as you would expect from a CMOS device, but wait, there is a gotcha! I also found this:
During an actual sample, the input resistance is temporarily a lot lower as the sampling capacitor is charged up so it is recommended that whatever you connect to the A/D have an output impedance of 10k or less for best accuracy. This is to allow the A/D input capacitor on the sample and hold to charge up in the time allotted to it between switching the input multiplexer over and starting the conversion. As you may know the arduino analogRead() function is designed and assumes the source impedance of voltage to be read is 10K ohms of lower. The fact that the AVR adc has but a single sample and hold capacitor but multiple multiplexed analog input pins means that you have to deal with the problem that is trying to read a high impedance signal.Remember that the same ADC s/h circuit is also used for the two temperature inputs (A1 and A2)
I think the 10K output impedance clarifies what I'm measuring pretty well, unless there is something else and I have it wrong.
Is there one of you that can contribute or confirm this?
The big question however is: do we really care with all this if Lars's design works? (with or without the 10Meg)
Well, in my opinion only if you want to have a "real" 1:1 representation of the TIC value in relationship with the pulse width. (Yes I do care)
If so, the solution would be to add an op-amp as a non-inverting voltage follower between the C1 capacitor and the ADC input and also add my proposed circuit and code changes to dis-charge the capacitor under program control after an ADC measurement has finished.
Does this make sense?
Paul