fake lm35dz temperature sensors

Anything not related to STM32
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: fake lm35dz temperature sensors

Post by ag123 »

And one more round of checks on the 'scope' graphs. LMT86 patched directly on the breadboard - no long wires / no cords / no op amps etc.

500k samples per sec LMT86 to STM32F401 ADC PA0
Image

There are still some visible artefacts, but that the amplitudes are much smaller.

This basically confirms the 'radio waves' interference hypothesis
Last edited by ag123 on Thu Sep 23, 2021 8:12 pm, edited 1 time in total.
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: fake lm35dz temperature sensors

Post by dannyf »

The trick here is to do the smoothing in Var' x N, where N is power of 2 (alpha = 1 / N).

So rounding errors don't accumulate.
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: fake lm35dz temperature sensors

Post by dannyf »

21 / 0.16 = 20+ or 4 to 5 effective digits.

I tend to there is something seriously wrong here. What do you get if you add a fixed vitale?
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: fake lm35dz temperature sensors

Post by ag123 »

@dannyf
Thanks for the suggestion of using factor of 2 as N values, I'd try some values to test the averages.
Oops, I do not understand the statement
21 / 0.16 = 20+ or 4 to 5 effective digits.
But I still think my analysis is somewhat flawed. It seemed, what I really measured is really the variance caused by radio wave interference i.e. EMI.
Thoughts are that in an ideal, no EMI environment, this measurement errors may literally be much smaller down to the LSB on the 12 bit ADC.
The fit isn't a normal distribution in a general case, but that if values outside +/- 0.5 deg C from median is rejected, the resulting samples have a good fit on the normal distribution. Which gives an apparent standard deviation of 0.16 deg C.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: fake lm35dz temperature sensors

Post by ag123 »

Another thing I'd likely try is to place an RC low pass filter before the ADC input or before an Op-Amp as a buffer.

I managed to make a bode plot for an RC filter
bode plot
bode plot
rc1.png (11.02 KiB) Viewed 22426 times
This is for
R = 500 ohms
C = 1.0uF
It gives me a -3 dB cut-off frequency of 318.3 Hz.

The data sheet for LMT86, stated that for 1 uF, the minimum R value needs to be 1 K ohm.
I'm not sure if that is a strict limit or that it is merely a suggestion. The trouble is, if 1 K ohm is used, the cut-off frequency falls to 159.15 Hz.
While a low cut-off value is good, the phase lag can be quite extreme. During rapid heating, say when I replace it with a thermistor eventually, actual hot end temperatures may exceed the filtered value and may be quite a bit higher than the value at the ADC. This may cause some troubles for PID controls, I'd guess.

I took a look at the impulse step response using R = 1K and C = 1 uF
rcstep1.png
rcstep1.png (6.83 KiB) Viewed 22424 times
It seemed this is still feasible as the RC step response is about 10 milliseconds, i.e. if the capacitor is initially discharged it charges to the original Vin voltages in 10 ms. But in this calc, I may have neglected the temperature sensor limits, which is 50 uA max. So the response may be significantly longer.

If I work the internal resistance of LMT86, this way R = 2.2v / 50 uA ~ 44k ohms
putting R = 44k, C = 1.0 uF
rcstep1a.png
rcstep1a.png (9.76 KiB) Viewed 22420 times
^ the step response looks like this. This is significantly worse than if it is just R 1K and C 1uF
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: fake lm35dz temperature sensors

Post by ag123 »

I tried patching a 1 nF cap at the ADC input as an RC filter.
bode plot looks like this C = 1nF, R = 44 k ohms (LMT86)
1nf bode plot
1nf bode plot
rc1nf.png (10.76 KiB) Viewed 22365 times
-3dB cutoff at 3.6 kHz

step response looks like this
1nf rc step response
1nf rc step response
rcstep1nf.png (7.9 KiB) Viewed 22365 times
looks good.
Last edited by ag123 on Fri Sep 24, 2021 1:33 pm, edited 2 times in total.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: fake lm35dz temperature sensors

Post by ag123 »

Tests with the 1nF in place at the op amp input to GND, this is with the LMV358 op amp, long antenna style wires for the probe, the probe LMT86, an extra 220 uF from 3.3v to GND (bypass capacitor, to bypass all that radio waves on the power supply lines)
Image

result looks like this
2000 samples LMT86 - LMV358 op amp - stm32f401 ADC pa0
LMT86 - LMV358 op amp - stm32f401 ADC pa0 1nF filter
LMT86 - LMV358 op amp - stm32f401 ADC pa0 1nF filter
hist1nf.png (10.88 KiB) Viewed 22355 times
count 2000.000000
mean 31.280675
std 0.384260
min 27.760000
25% 31.180000
median 31.260000
75% 31.400000
max 34.790000

Looks decent, but the outliers are pretty much still there. And it isn't a normal distribution, literally.
It is radio waves, after all, not thermal noise.

I'd guess to get any better precision, I'd need to use shielded cables to the probe to eliminate the RF EMI

I've been wondering for a while why low cost 3d printers which have thermistors with long antenna style wires don't seem affected.
Then i took a look at RAMPS
https://reprap.org/mediawiki/images/f/f ... ematic.png

And so it turns out, RAMPS & all the similar 3d printer circuits place a 10 uF ! capacitor at the thermistors. Now we know why all the 3d printers seemed to be printing away just fine. The implications are quite pronounced, PID control probably need to account for the delay and avoid heating up the hot end and heated bed too quickly.

The outliers are hazards literally for things like PID control etc. 'normal distribution' thermal noise is not an issue unlike straight out RF EMI, the voltages for RF received measures volts, not millivolts.
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: fake lm35dz temperature sensors

Post by mrburnette »

ag123 wrote: Fri Sep 24, 2021 1:21 pm ...
It is radio waves, after all, not thermal noise.

I'd guess to get any better precision, I'd need to use shielded cables to the probe to eliminate the RF EMI
...
'been involved with uC stuff since my retirement 12 years ago; and preaching to the flock about the noise in our modern world. Until someone like you take the time to really validate the issue, it is a hard-to-believe story. :shock:

Ray

Everyone needs a Faraday Cage:

Image
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: fake lm35dz temperature sensors

Post by ag123 »

I tried this.
heating 30-100 deg C
heating 30-100 deg C
heating.png (23.68 KiB) Viewed 22314 times
this is a bit brutal but that, fortunately, this is a temperature sensor. So I blow off the candle flame once it touches 100 deg C. :lol:
30-100 deg C in 8 secs ! Sample rate, 10 samples / s.
The surface temperature at the LMT86 is possibly much higher, because normally there is a temperature gradient, and at this extreme heating up, the surface temperature is probably double that. I thought I saw some blue smoke, but it is OK it is still working fine :lol:

So it looks like the heating up process is a little difficult to model. But the cooling process seems to follow Newton's law of cooling and is apparently an exponential curve. This probably means It is possible to fit a curve on it and reject values that are 'radio wave noises'.

But otherwise, this curve looks decent, this is done with the 1 nF RC filter in place, long antenna wires to the probe etc.

Edit,
Difficult, can't get a good fit
fitting newton's cooling
fitting newton's cooling
heatfit.png (18.7 KiB) Viewed 22294 times
Real data do not fall entirely on an exponential curve. Nature is full of surprises.

It seemed quite possible that at higher temperatures, heat transfers could be driven by other processes as well, e.g. thermal radiation
https://en.wikipedia.org/wiki/Stefan%E2 ... tzmann_law
newton's model seem to consider mainly conductive, convective heat transfers.
It is a complicated world really :lol:
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: fake lm35dz temperature sensors

Post by dannyf »

mean 31.280675
std 0.384260
looked quite decent.

in real world application some type of filtering would needed. for example ignoring the extremes, a hardware or software lpf...

looks like the chip is actually not fake?
Post Reply

Return to “Off topic”