Smoked crystals (Oscillator)

Once upon a time, during a lecture about electronics, more specifically on crystal quartz oscillators, a professor said that you can break a crystal oscillator by dropping it, because the quartz inside can be broken due to the fall, even if it seems solid like a common 1/4W resistor. Let me start with a briefing on this crystal “rock piece”.

What is a crystal oscillator? You can see very well the (main) idea on Wiki. The quartz is piezoelectric material, meaning that if you apply a mechanical force on it, it will produce an electric potential. Based on its shape, the crystal is a resonator in a certain frequency (both mechanical and electrical, since it is a piezo), like a bell. But, differently from a bell, an applied voltage on that quartz, will generate a mechanical distorsion on it. On its turn, if the signal generated by the mechanical movement is amplified, sooner or later, the amplifier will detect the resonator frequency, because the mechanical distorsion will bring also a minimal vibration at that frequency: when you touch a bell, that bell will sound, even if it is a weak sound. This is transduced in voltage and only this signal is introduced in the feedback, bouding the system to oscillate at that frequency, sooner or later. The time to amplify this signal strongly enough, is the time of start-up of the crystal. In other words the crystal behaves like a series LC resonator:

220px-Series_LC_Circuit.svg.png

in which is almost a short circuit at its resonator frequency, allowing the signal to pass unattenuated, while rapidly reducing signals outside its resonant one.

If the amplifier is inverting one, with a very high gain and very low cost, an ugly, unaccurated digital NOT port can be used, since the accuracy is instrinsic to the quartz. And is the most adopted circuit for digital electronics (like microcontrollers):

xtalosc.jpg

When the system is powered, the inverting port may be in metastability thanks to Rf. But this is not a stable condition and the tiny amount of resonator frequency present in the feedback will lead the amplifier to start the oscillation bounded by the crystal frequency. Since the final signal is a square wave, Rs is used to dissipate the harmonics that would be instead dissipated inside the crystal, avoiding some stress on it.

Where were we?

All this brief introduction had the purpose to let the reader know what I’m talking about. But the fact about breaking up a crystal (these words sounds very close to Breaking Bad stuff) said in a lecture, is similar to what happened in reality and I never thought to say this. I write this to report also how electronics in domestic environment is designed in a “I don’t give a sh*t” way.

We bought recently a vacuum cleaner “centralized”, meaning that you have only one fixed aspiring motor placed outside the home, and inside only one long pipe used to clean every angle of the various rooms. This pipe is connected to the vacuum cleaner by a sort of outlet fixed in the wall: fixing the pipe on the wall, will close a circuit that will turn the motor on. This system can be controlled by a remote transmitter placed in one part of the pipe (the one that you hold), that upon user interaction will close a switch on the other side of the pipe attached to the wall, using a receiver which closes the morot circuit. Here the crap: handling a vacuum cleaner pipe, will result inevitably to banging it on the floor, at least a couple of times.

That being said, one day I heard something dancing around inside the handle of the pipe, I thought it was a piece of plastic that was broken… classic! And then no, opening the handle I found this:

DSCN4883.jpg

Everything normal? Something is missing here. We can see the exposed crystal of the microcontroller! We can spot the metallic square shaped armor placed on the crystal, almost transparent (it is quartz, probably):

exposedcryst.JPG
The crystal X1 opened (broken cover)

The armor trasfers the electric potential to the crystal, exploiting the piezoelectricity mentioned before. This was still working, so I searched the cover lost here around trying to fix it. And here the tiny bastard:

top.jpg
Top view of the crystal cover
bottom
Bottom view of the same cover

So, just to avoid that something else will damage the quartz, with some hot glue I covered up the crystal with its cover. A first step was searching few marks, trying to understand the original position:

match.JPG
Ready to put on top

 

Finally, the cover can be put on the top. And it still works. Perfect match, perfect glue!

cryst_endJob.JPG

Moral

Things are designed to cost very low, and this is the price often to pay at a second turn: you can repair it or pay to repair it, or you will change it.

NTC Measurements

When dealing with low-cost, home made termometers, the choice often fall on the NTCs. These sensors are resistors which are varying their resistance in function of the temperature, with a negative trend: Negative Temperature Coefficient is their name, also known as Thermistor. That means higher the temperature, lower the resistance:

Thermistor Response Curve1.gif
A typical NTC curve (www.arroyinstruments.com)

We observe that this cheap sensor have the price to be non-linear at all. There are various methods to derive a method to interpret the correct temperature. Here I will go through the ones that are used to achieve quite reasonable precision without having/paying a calibration laboratory.

Look-Up Table approach

Usually the datasheet provides a set of values which are sampled from a sensor and correspond to our being inside their stated tolerance:

ntctab.jpg

In this picture you can see the stated resistance at a certain temperature, and its tolerance. An immediate drawback, if no other tables are available, is that this table can bring a precision of up to 5°C only. The parameter “B” is called normally \beta.

Moreover, a sensor with a tolerance of 5%, refers to 25°C only. This error of the resistance must be added with the “\frac{\Delta R}{R} due to β toll.” factor in the table above, from now on called Δβ/β. Associated with it, there is the temperature coefficient, TCR (also known as \alpha), which describes how steep  is the curve. You may understand that with a very steep curve, so an high TCR, there is a little deviation of the temperature in the X axis, associated with a high variation of resistance on the Y axis therefore we have an high sensitivity. The situation is the opposite when reading high temperatures with a low TCR, the sensitivity drops rapidly.

The thermistor error of a punctual read is then devised as follow:

\frac{\Delta R_{therm}}{R_{therm}} = (((1 + \frac{\Delta R_{25^{\circ}C}}{R_{25^{\circ}C}}) \cdot (1 + \frac{\Delta \beta}{\beta})) - 1) \cdot 100               (eq. 1)

where R_{25^{\circ}C} is the resistance tolerance at the reference temperature (specified in the datasheet, here is 25°C), and  \beta  is a coefficient which characterize the NTC material, devised by measuring two different temperature (and is specified in the datasheet). If we need to keep the right tolerance after changing the sensor with another of the same model without calibration, we need to observe these tolerances. Combineing them with the TCR, we obtain the temperature’s punctual error:

\Delta T = \frac{\Delta R_{therm}}{R_{therm}} / TCR            (eq. 2)

Equation approach

There are a lot of methods which are used to linearize the behaviour , by linearizing the model. The most famous is the Steinhart-Hart equation, which uses a set of coefficients which are provided in two ways: from manufacturer, or can be devised by measuring 3 different temperatures and solving 3 equations for 3 unknowns. If these coeffients are not provided from manufacturer, one can use a more precise termometer, measure 3 temperatures and its resistance temperature, solving this equation for the S-H of 3rd order:

coeff.JPG

The sensor’s manufacturer adopted to experiment provides the coefficients up to 4th order, both for reversed anddirect measurement:

sh.JPG

With a sensor stated to have 5% of tolerance, one can actually use the coefficient without the full decimal precision instead used (ideally) from the manufacturer, because the error provided by such formula is in the order of mK, while the final reading, due to various errors, is higher than 1.5K. I neglect this S-H error.

Error estimation

Assuming a negligible error from the S-H calculus that uses the parameters given by manufacturer, usually we use a microcontroller with an ADC and a voltage divider. The error from a common ADC is half LSB, so that

\frac{\Delta ADC}{ADC} \% = \frac{1}{2^{(N+1)}} = 0.5 LSB      (eq. 3)

The error of the voltage divider tends to be double of the two resistors used if are too much different, otherwise tends to be the mean of the two relative errors of the two resistors, like \frac{\Delta R1 + \Delta R2}{2}. See the graph, where 100% is the mean value between errors of the 2 resistors, and 200% represent the sum of the 2 errors:

facd_IRC_fig3_oct2009.gif
(electronicproducts.com)

These two resistors are used in this way, in which one is the Thermistor:

 wmpzaqgd7647148542451899915.jpg

where at the reference temperature (provided by manufacturer and usually 25°C) the Rref and Rtherm have the same value (so we bought a matched thermistor with a certain resistance to reduce errors). Depending on your temperature range, you can se how varies the the ratio and see how greater can be considered the total error.

How greater is the error in my temperature range? The previous value of \frac{\Delta R_{therm}}{R_{therm}} and its TCR will lead to a temperature error like this:

dtt.JPG

in which the ADC and condition circuitry errors are NOT considered. But an idea of performance can be made if no calibration is performed (see later). If the resistance at the extremes of my range is not so different from the reference resistor (a normal fixed resistor in the schematic above), then it is not a mandatory to sum it up both errors of the two resistors, but can be a little less.

If I need to measure between 0°C and 100°C, the datasheet provides the additional error of the resistance due to the tolerance of β parameter, called Δβ/β. We will find that at 100°C there is low TCR and high relative error. ONLY NOW we can apply the worst case total error \Delta T = \frac{\Delta R}{R} / TCR with \frac{\Delta R}{R} = \frac{\Delta R_{therm 100^{\circ}C}}{R_{therm 100^{\circ}C}} + \frac{\Delta R_{ref}}{R_{ref}} , where R_{therm 100^{\circ}C} is the (eq. 1) at temperature of 100°C using the table from manufacturer, while Rref is the the fixed resistor in the schematic above and \frac{\Delta R_{ref}}{R_{ref}} its relative error.

TCR will be chosen to achieve the higher relative error, so will be the TCR at 100°C (as said before, the higher temperature of the range), along with the estimated resistance value at that temperature (of course..). You may see how the error can be greatly reduced if reading values with higher TCR at lower temperatures, and how small is it at 25°C. But the boundaries must contains the greater error tolerance, allowing the user to change the sensor in the field without recalibration.

With the calibration using the set of 3 equations above, all these errors are compensated, voltage divider included. The remaining one will be truncation error of the S-H coefficients due to the finite machine precision (whether is a PC or an MCU used to make the calibration),  the errors of the reference termometer and the intrinsic errors of the S-H model, the quantization error of the ADC (half LSB) and for sure others that I have missed. It is not trivial to quantify everything. And quantification, when talking about measures, is almost everything.

Where is the ADC?

We have found how greater is the error of the analog quantities. Now where is the least sensible part of the NTC curve? The one at the higher temperature, as said before (lower TCR). Until now I have estimated a certain error of the total voltage divider’s resistance.

Now is needed to find how an ADC error can mismatch the resistance. Let’s go at 100°C, using an S-H estimation or the Look-Up table, then calculate a sort of manual derivative, let’s say the value R_{therm} = R_{100^{\circ}C} + \Delta R, where ΔR is the immediate available step to achieve a temperature lower of a step equal to the required precision (if I want a precision of 1°C, then is the resistance at 99°C if I have the S-H equation, or it is the resistance at 95°C if I have a rough Look-Up table like the one in this article).

From the circuit of the voltage divider, we have V_{adc1} = V_{refADC} \cdot \frac {R_{100^{\circ}C}}{R_{100^{\circ}C}+R_{REF}} and V_{adc2} = V_{ref ADC} \cdot \frac {R_{100^{\circ}C} + \Delta R}{R_{100^{\circ}C} + \Delta R +R_{REF}}. The \frac{V_{adc1} - V_{adc2}}{V_{LSB}} is how many discrete steps can be sampled inside a ΔR variation. E.g., if 1LSB = 3mV (ADC provides 3mV/bit) and from 100°C to 99°C the variation read from ADC is 6mV, I can’t have an accuracy higher than 2LSB, meaning 0.5°C (2LSB to represent 1°C). If I am lower than 1LSB, I can’t discern my prefixed step lower than 1°C.

Saying the same more mathematically: consider the reference voltage applied to voltage divider to be 3V. And the datasheet provides a certain TCR at 100°C. Then the resistance at 99°C will be:

\Delta R_{1^{\circ}C} = R_{100^{\circ}C} - R_{100^{\circ}C} \cdot \frac{TCR_{100^{\circ}C}}{100}\cdot 1^{\circ}C

so that:

1.5mV \leq 3V \cdot \frac{R_{100^{\circ}C}}{R_{100^{\circ}C} + R_{REF}} - 3V \cdot \frac{R_{100^{\circ}C} - \Delta R_{1^{\circ}C}}{R_{100^{\circ}C} - \Delta R_{1^{\circ}C} + R_{REF}} = \Delta V_{1^{\circ}C}

Finally, the additional temperature error from the ADC is, in the worst case:

\Delta T_{ADC} = \frac {1^{\circ}C}{\frac{\Delta V_{1^{\circ}C}}{0.5LSB[V]}}          (eq. 4)

Conclusions

The final precision, from (eq.2) and (eq. 4), is:

\Delta T = \frac{\frac{\Delta{R}}{R}}{TCR_{100^{\circ}C}} + \Delta T_{ADC}

One can try and find out that with an ADC of N = 10 bit, and components at 5%, included the NTC, in range between 0°C-100°C, hardly can be achieved a precision lower than 3°C/4°C, despite the accuracy can be around 0.5°C/1°C, without calibration. But note that this low precision is due to the consideration of the range up to its most imprecise extreme: reducing the range to, let’s say, 60°C the precision can be improved a lot. Just keep that in mind when you read 25°C, or 150°C using an NTC.

2381 640 63103.jpg
The beauty and the beast