h2. Contents
* "Intro":#intro
* "Disclaimer":#legal
* "Pressure, what it is, and how to measure it":#pressure
* "A/D signal conversion intro":#adcintro
* "Overview on sensor design and construction":#sensor
** "All sensors pressure devices internal design":#ascd
** "All sensors Eval board review":#evalkit
** "Honeywell RSCDRRM020NDSE3 sensor design":#rscd
* "Test setup and methodology":#testrig
* "Interfacing pressure sensors to Raspberry Pi using Python":#pycode
* "Timing and output resolution tests":#timetest
* "Filtering and averaging tests":#avgtest
* "Temperature / power supply dependency test":#temptest
* "Calibration test":#presscal
* "Summary & Conclusion":#finals
h2. %(#intro)Intro%
Unlike digital electronics and Internet space real world is based on many complex analogue-type universe laws. Everything interacting, changing and constantly evolving, from microscopic atoms to galaxy-sized events in space. Today's advancement in science and technology brought us powerful computers, mighty measurement tools and many comprehensive methods to learn. This all to help us analyze different aspects of world around us, study and better understand underlying rules. And often vital interface, crucial link between abstract math and theory with the actual matter is some set of sensors. Engineers and scientists have sensors and tools to detect electric charge and flow, air or liquid parameters, temperature, light intensity, objects mass and time, and much more. Field of science, that ensures accuracy of all these measurement sensors is called metrology.
Regular readers may find number of articles and experiments around common electrical values, such as voltage or resistance presented in previous "xDevs.com publications":https://xdevs.com/article/. Many of them focus on quantities like voltage, current, temperature and time. However, world of metrology does not end here, so to expand a bit further, today will talk about pressure.
h2. %(#legal)Disclaimer%
Redistribution and use of this article or any images or files referenced in it, in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of article must retain the above copyright notice, this list of conditions, link to this page (https://xdevs.com/article/pressure/) and the following disclaimer.
* Redistributions of files in binary form must reproduce the above copyright notice, this list of conditions, link to this page (https://xdevs.com/article/pressure/), and the following disclaimer in the documentation and/or other materials provided with the distribution, for example Readme file.
All information posted here is hosted just for education purposes and provided AS IS. In no event shall the author, xDevs.com site, or any other 3rd party be liable for any special, direct, indirect, or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortuous action, arising out of or in connection with the use or performance of information published here.
If you willing to contribute or have interesting documentation to share regarding pressure measurements or metrology and electronics in general, you can do so by following "these simple instructions":https://doc.xdevs.com/contact/.
h2. %(#pressure)Pressure, what it is, and how to measure it%
Common definition for pressure is _force per unit area that a media volume exerts on its surroundings_. As result, pressure *P* is a function of force *F* and area *A*.
p=. *P = F/A*
The SI unit for pressure is the "Pascal":https://en.wikipedia.org/wiki/Pascal_(unit), but other common units of pressure also include pounds per square inch (*psi*), atmosphere (*atm*), *bar*, inches of water (*inH[^2^]O*), inches of mercury (*inHg*), and millimeters of mercury (*mmHg*) and few others. 1 Pascal is equal to pressure exerted by one newton of force, perpendicularly upon one square meter area.
p=. *1 Pa = 1 N/m[^2^]*
A pressure measurement can be static or dynamic. Static pressure measurement does not produce motion of the objects (e.g. still water in the bottle), while dynamic pressure measurement shows amount of force produced in moving systems (e.g. water flow in the pipe). Depends on type of pressure measurement methods and sensors can vary, to better fit specific task requirements.
Pressure is exactly the force that makes hot teapot whistle. When water boils into steam, internal teapot's volume pressure push harder on teapot walls. As there is only one tiny teapot connection with lower pressure space, nose exit, most of excessive steam pressure escapes this way creating the air flow and high-pitch sound we all can hear. When teapot cold, there is no excessive pressure, and no sound. For same reason if teapot left open, no whistle will be possible, as pressure cannot build without cap sealed.
Device to transform pressure level into electrical signal, such as voltage or current change is called pressure sensor, or pressure transducer. Modern pressure sensors have sensing element that changes its property with pressure change. This element can act as variable resistance or capacitance to produce electric current or field change with pressure application. Change of electric property can be then measured, and it will tell us what is the applied pressure to sensor. If main interest is dynamic pressure, such sensor output need to have fixed value offset removed, and provide only small change to detect small pressure changes.
Common and well-known method and circuit to measure these small resistance changes accurately is by using Wheatstone bridge. Invented in "Samuel Hunter Christie in 1833":https://nationalmaglab.org/education/magnet-academy/history-of-electricity-magnetism/museum/wheatstone-bridge-1843, the bridge circuit was later studied by another scientist, "Charles Wheatstone":https://en.wikipedia.org/wiki/Charles_Wheatstone. Wheatstone made circuit widely known and public, so this bridge arrangement was called after his name, as result.
p=. !https://xdevs.com/doc/Allsensors/img/wheatstone_bridge.png!
%(imgref)Image 1: Wheatstone resistor bridge circuit%
The principle of the circuit is that if three resistances R[~1~], R[~2~], R[~3~] are known, and the current in the cross branch *C-B* is nulled out to zero, and the fourth unknown resistance can be calculated. The measurement can be made very accurately since zero current detection can have very good accuracy. Let’s now look at the circuits used for measuring sensor resistance.
Bridge null voltage V[~Z~], measured between nodes *CB* can be calculated as:
p=. *V[~Z~]* = *V[~IN~]* * [ R[~X~] / (R[~3~] + R[~X~]) - R[~2~] / ( R[~1~] + R[~2~] ) ],
Where *V[~IN~]* is excitation voltage supplied at bridge nodes *A* and *D*, and R[~X~] is unknown resistance. Here is handy real-time calculator for *R[~X~]* from measured *V[~Z~]* to get better idea, working by this very same formula. Just enter your known resistance values, and browser will calculate unknown resistance.
==
VZ =
V, VZ =
V, R1 =
Ω, R2 =
Ω, R3 =
Ω
Resistance calculated: Ω
==
MEMS(Micro-Electro-Mechanical Systems) piezoelectric pressure sensor implements resistive elements that change resistance value from mechanical stress. Stress to sensor introduced from pressure differential on a thin silicon membrane. Cavity under membrane can be hermetically sealed (for absolute pressure measurement) or have other pressure as reference (atmosphere for gauge sensors, second pressure port for differential measurement). Most of pressure sensors use four or more piezo-resistive elements, fabricated on the same silicon die.
As result of input pressure difference from the internal cavity pressure, the very thin silicon die membrane will get slight deformation, resulting change the resistance of sensor elements. Larger pressure stress deform element more, also changing output in predictable way. Elements typically connected in a Wheatstone bridge configuration with resistors R[~1~] and R[~4~] showing increased resistance with input pressure increment and resistors R[~2~] and R[~3~] showing resistance decrement. This provide doubled sensitivity of the sensor die to the pressure change, making measurement easier. Differential pressure sensors work same way, but using second port to open cavity to measure pressure difference between the ports. Such sensors commonly used for flow measurement, be it airflow or liquid flow. Differential pressure sensor act as pressure comparator.
Desired pressure range of the sensor is realized by variation in membrane rigidity or physical thickness/area. Sensors for higher pressure would have less stress transferred to bridge resistors, resulting lower output signal sensitivity.
h2. %(#adcintro)A/D signal conversion intro%
All this sounds great and wonderful, but how to actually design a system that converts signal from sensor into digital data-stream, which can be further processed, stored or displayed in user application? Core component of this interface between analog physical world and digital information domain is *analog to digital convertor* or ADC.
ADC convert input analog signal, such as voltage into a digital code determined in relation to second known signal, which is usually called reference voltage. As result sole purpose of ADC is to work as a comparator of unknown signal to known reference, with result provided in digital code. Very same idea as operation of weighing balance.
Also due discrete nature of digital code, all ADCs have apply "quantization":https://en.wikipedia.org/wiki/Quantization_(signal_processing) to input signal. Because analog signal have infinite amount of steps, it would need infinite size digital code to represent 100% of the signal. But if we limit input scale to some predetermined levels, and split it to small enough steps, we can represent input signal with close approximation. Common definition for minimum digital code step size is *Resolution*, and measured in bits. Ideal 1-bit ADC will generate "1" when input analog signal larger than 50% of the range, and "0" if less. 8-bit ADC have 2[^8^] = 256 steps, thus able to determine 100% / 256 = 0.390625% range change. If we make our range limits between 0.0V and 10.0V, then such ADC resolve input analog signal with 39.0625 mVDC per 1bit of code output. Increase of resolution reduces this minimal step size. In same example of 10.0V range ADC, 16-bit solution will provide 10.0V / 2[^16^] = 10.0V / 65536 = 152.588 µV/bit.
Resolution of the ADC often confused and mistaken with accuracy, but actually these two parameters are almost unrelated. Higher resolution does not provide better accuracy, it only provides smaller digital step size. Together with input signal range resolution provide sensitivity of the ADC. There are many cases, when 24-bit ADC provide worse accuracy than 16-bit device. So resolution provides theoretical sensitivity level, in terms of smallest digital code difference, while accuracy is derived from mix of actual ADC design parameters, such as front end stability, temperature coefficients of amplifiers/voltage references, calibration and compensation correction and noise isolation from other components of the system.
To illustrate the example, using 0-10V range 8-bit and 16-bit theoretical ADCs, let's convert 5.000V analog signal into digital code, but this time with one extra variable. In case A voltage reference (known voltage against which ADC compare input signal) is precisely 10.0000 V, while in second case B there is 100mV error in voltage reference, so true reference voltage is 10.1000 V.
| |_. 8-bit "A" ADC|_. 8-bit "B" ADC|_. 16-bit "A" ADC|_. 16-bit "B" ADC|
|Input signal, *V[~IN~]* | 5.0000 V | 5.0000 V | 5.0000 V | 5.0000 V |
|1 bit step size| 0.0391 V | 0.0391 V | 0.0001525 V | 0.0001525 V |
|Reference signal, *V[~REF~]*| 10.0000 V | 10.0000 V | 10.0000 V | 10.0000 V |
|Reference error | 0 | 0.1000 V | 0 | 0.1000 V |
|Conversion result| 2[^8^] * (*V[~IN~]* / *V[~REF~]*) | 2[^8^] * (*V[~IN~]* / *V[~REF~]*) | 2[^16^] * (*V[~IN~]* / *V[~REF~]*) | 2[^16^] * (*V[~IN~]* / *V[~REF~]*) |
|Output digital code | 0x80 or 1000 0000'b | 0x7E or 0111 1110'b | 0x8000 | 0x7EBB |
|Output error | 0 | 2 bits or 0.1562 V | 0 | 650 bits or 0.09912 V |
As this example shows, error in reference signal cause output digital code error, unrelated how many bits of resolution is available have. There are multiple sources of errors, many of which reside in analog domain, and affected by input signal properties, operation temperature, proximity to other devices on the board, power delivery quality and even mechanical stress to the board.
This is well recognized by ADC manufacturers, such as Linear, Analog Devices, Texas Instruments, Maxim, and usually they spend lot of R&D resources to reduce impact of all these error contributors on overall output accuracy, trying to use better packaging, isolation, and better stability parts in the design. As result many of these improved performance parts may also have increased resolution, as it's relatively cheap to add, but it's important to understand that it's not the resolution that makes ADC with better accuracy.
Few other important keys, commonly used in A/D and D/A conversion applications.
*Bandwidth* - difference between the upper and lower signal or process frequency. It is essentially a whole set of frequencies, which carry valuable signal information. Bandwidth usually represented in Hertz (Hz). For example A/D system with bandwidth 0-10kHz able to measure any signals between DC and 10 kHz.
*Accuracy* - difference between the actual digital output and expected digital output for a known analog input signal. ADC accuracy shows how many bits from total resolution carry useful information about the input signal. Two ADCs with equal resolution can have very different accuracy.
*Calibration* - measurement of ADC/system error against known reference input signal. Calibration data can be used further to process ADC output data to compensate for measurement errors and improve total system accuracy.
*Compensation* - correction process of ADC errors, based on calibration results and design constrains knowledge. Compensation can be done in digital domain (math correction of raw converted samples) or analog domain (special circuit provide error signal to adjust front-end parameters).
*Linearity* - deviation of ideal to actual converter transfer function. Can have differential (DNL) type, which shows deviation between near code bits or integral (INL) which shows maximum overall deviation. This deviation is very difficult to remove, as it would need accurate measurement of input signal and related digital code on all possible ADC points. INL/DNL are often used as key merit of total ADC's accuracy.
There are different types of ADC designs depends on target application requirements and operation principle. Table below presents few most common types, their basic performance parameters and their strong/weak sides.
|_. ADC Type |_. Flash |_. Delta-Sigma ΔΣ |_. Integrating (slope) |_. Successive approximation (SAR) |
| Operation principle | Parallel comparator array | Oversampling with digital filtering | Integration vs known reference charges | Binary search comparison |
| Speed | Very fast | Slow | Slow or Very slow | Medium - Fast |
| Resolution | Low, <14bit | Medium to very high, 12-32 bit | Can be very high, 32 bits | 8 - 24 bit |
| Power | Very high | Low | Low-High | Low-Medium |
| Noise immunity | Low | Medium-High | High | Medium |
| Design complexity | High | Low | High | Low |
| Implementation cost | High | Low | Medium to very high for precision | Low |
Correct ADC type choice is key importance for specific applications. Common pressure sensor application operate with low bandwidth due to relatively large volumes of measured flow/mass, typical choice are ADC types like SAR, Delta-Sigma and less often Integrating type.
Different ADCs also may have very different packages, and different levels of integration. Larger packages often have integrated reference blocks, temperature sensors, input channel multiplexers, programmable current sources for sensor excitation. Often ADC block is also integrated part of bigger SOC(system-on-chip) system to further save space, however accuracy and resolution of such converters often inferior to discrete ADC designs.
p=. " !https://xdevs.com/doc/Allsensors/img/adc_types_1.jpg!":https://xdevs.com/doc/Allsensors/img/adc_types.jpg
%(imgref)Image 2. Different packages and types of ADC designs%
Easy to see from the photo, how complex is high-resolution discrete ADC can be. It using number of custom-made components in hermetic packages, expensive operational amplifiers, take lot of space and have number of control signals and power rails to operate. Today such precise integrating ADC in electronics limited to narrow niche applications, where cost and design footprint are less important that performance. One of such examples are 6½-digit+ multimeters, paired with discrete high-stability references or instrumentation applications. SAR and high-resolution ΣΔ ADC solutions got closer in performance to state of the art multi-slope integrating ADC, replacing them in many designs due to much smaller package options, ease of use and affordable cost.
Now we know how to convert voltage from sensor into digital code, and as result know how to convert analog pressure into digital code. Practical demonstration of using such design covered in next section using integrated sensor hybrid, which have both analog sensor and ADC components inside same compact package.
h2. %(#sensor)Overview on pressure sensor design and construction%
To demo pressure sensor and application in electronic device, I've got few modern sensors to perform some experiments and measurements. These sensors can be bought from usual retailers such as DigiKey or "Mouser":http://www.mouser.com/Sensors/Pressure-Sensors/Board-Mount-Pressure-Sensors/_/N-6g7qs/ in single quantities. Table below shows acquired sensors and their key specifications.
|_. Sensor |_. Typical accuracy |_. Product page|
|"All Sensors DLHR-L10D":https://www.digikey.com/product-detail/en/all-sensors-corporation/DLHR-L10D-E1BD-C-NAV8/442-1167-ND/6200358 | ±0.25% | "URL":https://www.allsensors.com/products/dlhr-l10d |
|"All Sensors DLHR-L02D":https://www.digikey.com/product-detail/en/all-sensors-corporation/DLHR-L02D-E1BD-C-NAV8/442-1165-ND/6200356 | ±0.25% | "URL":https://www.allsensors.com/products/dlhr-l10d |
|"All Sensors DLHR-L01D":https://www.digikey.com/product-detail/en/all-sensors-corporation/DLHR-L01D-E1BD-C-NAV8/442-1164-ND/6200355 | ±0.25% | "URL":https://www.allsensors.com/products/dlhr-l10d |
|"Honeywell RSCDRRM020NDSE3":http://www.digikey.com/product-detail/en/honeywell-sensing-and-productivity-solutions/RSCDRRM020NDSE3/480-6891-ND/6602130 | ±0.25% | "URL":https://sensing.honeywell.com/sensors/amplified-board-mount-pressure-sensors/trustability-rsc-series |
|"Honeywell RSCDRRI002NDSE3":http://www.mouser.com/ProductDetail/Honeywell/RSCDRRI002NDSE3/?qs=sGAEpiMZZMvhQj7WZhFIANo8tvaUK2t4do40Qu3tHHgYSxO2mxdWLA%3d%3d | ±0.5% | "URL":https://sensing.honeywell.com/sensors/amplified-board-mount-pressure-sensors/trustability-rsc-series |
%(tblref)Table 1. Pressure sensors with digital front-end selected for test%
Also worth to have a brief look on key specifications.
| |_. "(extlink)DLHR-L10D":https://www.allsensors.com/products/dlhr-l10d |_. "(extlink) DLHR-L02D":https://www.allsensors.com/products/dlhr-l10d |_. "(extlink) DLHR-L01D":https://www.allsensors.com/products/dlhr-l10d |_. "RSCDRRM020NDSE3":https://sensing.honeywell.com/sensors/amplified-board-mount-pressure-sensors/trustability-rsc-series |_. "RSCDRRI002NDSE3":https://sensing.honeywell.com/sensors/amplified-board-mount-pressure-sensors/trustability-rsc-series |
|Pressure range | Diff., ±10 inH[^2^]O | Diff., ±2 inH[^2^]O | Diff., ±1 inH[^2^]O | Diff., ±20 inH[^2^]O | Diff., ±2 inH[^2^]O |
|Sensor die configuration|\3. 5-resistor bridge, 2x2mm proprietary die |\2. 4-resistor bridge, 2.5x2.5mm proprietary die |
|ADC Type |\3. 16/17/18-bit Δ-Σ |\2. 24-bit Δ-Σ TI ADS1220 |
|Output rate |\3. 15 to 270 SPS |\2. 20 SPS to 2000 SPS |
|Typical ENOB min speed |\3. 14-16 SPS |\2. 18-20 bits |
|INL |\3. |\2. ±15 ppm of FSR (ADC) |
|PSRR,CMRR |\3. Unknown |\2. PSRR 80dB+, CMRR 90dB+, 95dB@50/60Hz (ADC) |
|Power requirements |\3. Single, 1.68 - 3.63 VDC |\2. Single, 2.3 - 5.5 VDC |
|Onboard temperature sensor|\3. Yes, 16 bits |\2. Yes, 14 bits |
|Temperature range |\3. -25°C to +85°C |\2. -40°C to +85°C |
|Digital interface |\3. I[^2^]C, SPI |\2. SPI |
|One off reference price (DigiKey/Mouser) |\3. $53.04 USD |\2. $57.61 USD |
%(tblref)Table 2: Specification comparison of used pressure sensors%
h3. %(#ascd)All sensors pressure devices internal design%
p=. " !https://xdevs.com/doc/Allsensors/img/testasct_1.jpg!":https://xdevs.com/doc/Allsensors/img/testasct.jpg
%(imgref)Image 2. All Sensors DLHR-type 18-bit pressure sensors%
All of these sensors are differential type, best suited for low pressure levels. This is one of most challenging applications, as low-pressure sensors usually affected more by common mode errors and offset. Especially interesting will be to evaluate if extra resolution available from digital domain translate to less noisy pressure reading. These calibrated and compensated sensors provide accurate, stable output over a wide temperature range. These sensors are designed for use with non-corrosive, non-ionic working fluids such as air, dry gases. All sensors also have protective parylene coating for moisture/harsh media as option.
p=. " !https://xdevs.com/doc/Allsensors/img/rsctop_1.jpg!":https://xdevs.com/doc/Allsensors/img/rsctop.jpg " !https://xdevs.com/doc/Allsensors/img/rscbot_1.jpg!":https://xdevs.com/doc/Allsensors/img/rscbot.jpg
%(imgref)Image 3-4. Honeywell RSC differential 24-bit pressure sensors%
These sensors are already equipped with internal mixed signal ASIC, containing ADC(Analog/Digital Converter), voltage reference, current bias circuitry to excite sensor bridge elements, digital interface logic and calibration memory. There is also temperature sensor, which is crucial to obtain accurate pressure readouts. Pressure measurement errors depend heavily also on sensor die temperature, so onboard temperature sensor used to correct errors from temperature variations.
p=. !/doc/Allsensors/img/dlhr_blk.png!
%(imgref)Image 5. ASC DLHR sensor internal block diagram%
Quite a lot going on in this sensor. From left to right, pressure bridge sensor signal is routed through multiplexer into amplifier and further converted by ADC into digital code. Digital code resolution is set by sensor SKU, and processed by on-board DSP ASIC. Additional channels of same multiplexer/ADC path are used to obtain temperature reading and zero reference for compensation and calibration purposes. Interface block and control is responsible of getting data in and out, as well as providing trigger and sync for the system.
All this functionality in a same package allow easy and quick integration of sensor into your specific design. However this comes at price, as sensors with digital readout are more expensive. For battery-powered systems, the sensor also has low power mode between readings to minimize load on the power supply.
p=. !/doc//Allsensors/img/rsc_sense.png!
%(imgref)Image 6. Honeywell RSC internal block diagram%
Honeywell's sensor is bit simpler, having only analog domain converter and EEPROM with manufacturer-written calibration data. So it needs host controller to perform calibration and correction math. Calibration constants are stored in sensor's EEPROM and readable by same SPI interface, just using separate chip select line. Both pressure readings must be compensated and corrected, depends on die temperature.
There are also simpler sensors available on the market, for smaller cost. However total solution implementation using analog sensor require higher engineering cost, increased complexity of design and more board space. Design and validation of accurate bridge analog front-end, ADC, current bias and compensation circuitry require significant effort, and in the end may be inferior to all-in-one digital pressure sensor. Such approach often viable only in large scale product manufacturing or with special specification requirements for particular application.
For educational purposes number of faulty analog sensors was taken apart to study their design and construction.
p=. " !https://xdevs.com/doc/Allsensors/img/sensorb_1.jpg!":https://xdevs.com/doc/Allsensors/img/sensorb.jpg
%(imgref)Image 7. Simpler All sensors analog sensor%
Transducer design on photo above does not have digital or interfacing logic. Other than sensor die, there are only trimming/linearization resistors embedded on bottom side of alumina substrate. Alumina ceramics material as module substrate for it's great humidity resistance and mechanical strength. Standard FR4 material usually greatly suspected to air humidity changes, and in application like pressure sensor humidity can easily cause a disaster. Pressure sensor die can detect even tiny stress changes, and FR4 flexibility may cause unwanted stress from baseboard PCBA into sensor. That would convert pressure sensor into assembly quality sensor, not what usual design engineer looking for.
Good eye can catch laser trim marks on dark resistor films. That meaning calibration and offsets correction to some extent for each manufactured sensor.
p=. " !https://xdevs.com/doc/Allsensors/img/sensord_1.jpg!":https://xdevs.com/doc/Allsensors/img/sensord.jpg " !https://xdevs.com/doc/Allsensors/img/sensoro_1.jpg!":https://xdevs.com/doc/Allsensors/img/sensoro.jpg
%(imgref)Image 8-9. Differential analog pressure sensor%
Differential pressure sensors usually have two cavity ports, available in multiple mechanical configurations and types. When you order specific sensor pay attention to type of ports, as order code and part number is different depends on design. Alumina substrate and sensor die itself are same across family.
p=. " !https://xdevs.com/doc/Allsensors/img/casea_1.jpg!":https://xdevs.com/doc/Allsensors/img/casea.jpg
%(imgref)Image 10. Rugged differential pressure sensor%
Some of the sensors come with rugged plastic or even metal chassis. This usually fits demanding applications, providing additional level of mechanical and electrical protection to fragile ceramic substrate and compensation circuitry. Also larger case allows integration of additional electronics, making possible custom-made pressure transducers for specific customer needs. Let's crack one open to see one inside?
p=. " !https://xdevs.com/doc/Allsensors/img/diffsensor_1.jpg!":https://xdevs.com/doc/Allsensors/img/diffsensor.jpg " !https://xdevs.com/doc/Allsensors/img/sensorp_1.jpg!":https://xdevs.com/doc/Allsensors/img/sensorp.jpg
%(imgref)Image 11-12. All Sensors differential sensor in CASE-A enclosure%
This is still analog sensor without analog/digital conversion or interface logic, but here are two pressure sensor die. Why two? It's not easy to compensate silicon die for good accuracy, linearity and stability. Instead of spending all the effort to make a perfect sensor on single die, All Sensors made alternative choice to use two of the same sensor dies, route pressure to them in opposite direction, and measure differential signal between the two.
Since silicon die from same batch have good correlation, errors such as non-linearity, temperature dependence and offsets can be nulled from the output signal. In simple words such arrangement is similar idea to making Wheatstone bridge from two on-die bridge sensors. This method is patented ("US6023978":https://www.google.com/patents/US6023978) by All Sensors as to provide "active dual-die compensation":https://www.allsensors.com/engineering-resources/white-papers/dual-die-compensation-for-mems-pressure-sensors for common mode pressure sensor errors.
Let's have a closer look on sensor die itself.
p=. " !https://xdevs.com/doc/Allsensors/img/ascdie_1.jpg!":https://xdevs.com/doc/Allsensors/img/ascdie.jpg
%(imgref)Image 13. ASC Pressure sensor die%
With bit of magnification actual die marking are visible, revealing *D04D01* and *All Sensors 2009* marking. Bit more magnification also reveals die signal pad names, such as *Vs+* (bridge supply input), *+Gnd*, *-Gnd*, *-Out* and *+Out*. Two grounds and separate resistor provided for compensation reasons.
Sensor is based around piezoresistive structure with special configuration silicon die. Square 2 x 2 mm die have cavity integrated on bottom side, right under the sensing element. Die structure used in All Sensors chip uses a proprietary Collinear Beam[^2^] Technology registered as COBEAM[^2^]™. This technology provide better performance, especially for low pressure measurements. COBEAM[^2^]™ Technology designed to provide better pressure sensitivity in small package, which previously required boss structures and larger die topologies. Smaller die design without boss structure significantly reduce both unwanted gravity and vibration sensitivity.
p=. !/doc/Allsensors/img/asc_cavi.jpg!
%(imgref)Image 14. Damaged membrane sensor with visible cavity area%
Laser trimmed film resistors on alumina substrate are adjusted to improve linearity and accuracy of the sensor output. Each sensor has unique trim to provide calibrated and specified output. Using one of dead sensors as test vehicle, measurement of temperature coefficient of such surface resistors was performed. Sensor die was disconnected by removing the bond wires, so purely passive resistance could be measured.
|_. Tested resistor |_. Nominal value at +24 °C|_. TCR(Temperature coefficient of resistance) |_. Graph |
| R[~5~] | 308.5885 KΩ | "-13.24 ppm/°C":https://xdevs.com/ascp_t1/ |/2. "!/doc/Allsensors/img/asc_tcr1.png!":/ascp_t1/ |
| R[~6~] | 274.3273 KΩ | "-12.37 ppm/°C":https://xdevs.com/ascp_t1/ |
| R[~7~] | 152.09743 Ω | "-52.12 ppm/°C":https://xdevs.com/ascp_t2/ |/2. "!/doc/Allsensors/img/asc_tcr2.png!":/ascp_t2/ |
| R[~8~] | 149.20517 Ω | "-55.13 ppm/°C":https://xdevs.com/ascp_t2/ |
%(tblref)Table 3. All Sensors embedded film resistors TCR matching test%
Temperature coefficient measured in range from +24 °C to +57 °C. Results show that compensation resistors are matched well <5 ppm/°C and overall resistance ratio maintained stable even with large temperature variation.
h3. %(#evalkit)All Sensors Eval board review%
"All Sensors evaluation kit":https://www.allsensors.com/engineering-resources/evaluation-kit targeted for testing pressure sensors, before the prototype design process. This evaluation kit is capable of providing data on digital, millivolt, and amplified pressure sensors and have following features:
* ZIF socket allows instant electrical connection, without need of soldering or pin forming.
* Display data from Digital sensors in one of 12 convenient units
* Capture data from Digital sensors to CSV text file, with sample index and timestamp on each readout
* Uses standard Windows USB HID drivers. Eval board using micro-USB connector for data/power.
* Standard 4mm "banana"-type terminals for lab test equipment and external power
p=. " !https://xdevs.com/doc/Allsensors/img/asc_evm_1.jpg!":https://xdevs.com/doc/Allsensors/img/asc_evm.jpg " !https://xdevs.com/doc/Allsensors/img/asc_evmb_1.jpg!":https://xdevs.com/doc/Allsensors/img/asc_evmb.jpg
%(imgref)Image 15-16. Evaluation board for All Sensors devices%
Evalkit based around "Texas Instruments TM4C1233D5PM":http://www.ti.com/product/TM4C1233D5PM Cortex-M4F ARM(R) microcontroller. It have native USB 2.0 interface, I[^2^]C and SPI interfaces to talk with sensors and specified to operate in industrial range.
p=. " !https://xdevs.com/doc/Allsensors/img/testascb_1.jpg!":https://xdevs.com/doc/Allsensors/img/testascb.jpg " !https://xdevs.com/doc/Allsensors/img/testsetup_1.jpg!":https://xdevs.com/doc/Allsensors/img/testsetup.jpg
%(imgref)Image 17-18. Sensor and connection to Evalboard socket%
Evaluation kit comes with simple to use software tool. It supports various sensors with both SPI and I[^2^]C interface connections, and can be used to set data timings, pressure units and average filtering power. Once sensor properly configured, software reads both pressure and temperature and display result on GUI. Storage into CSV file can be used for longer data captures and external data analysis.
p=. !/doc/Allsensors/img/evalsw.png!
%(imgref)Image 19. Demo kit software GUI%
h3. %(#rscd)Honeywell RSCDRRM020NDSE3 sensor design%
After sample data collection was complete, one of Honeywell RSC sensors was disassembled to find out what's hidden inside. Just like All Sensors design, circuit implemented on alumina carrier. After decapping three semiconductor components were found.
p=. "!/doc/Honeywell/RSC/rsc_rom_1.jpg!":/doc/Honeywell/RSC/rsc_rom.jpg "!/doc/Honeywell/RSC/rsc_adc_1.jpg!":/doc/Honeywell/RSC/rsc_adc.jpg
%(imgref)Image 20-21. RSC sensor ROM and ADC ICs%
Top side have just two ICs, which are "Texas Instruments ADS1220":/doc/Allsensors/pdf/ads1220.pdf 24-bit ΔΣ ADC, with speed up to 2KSPS and integrated PGA(Programmable Gain Amplifier), voltage reference and precision temperature sensor. ADC have 4 input channels, perfectly suitable for pressure sensor bridge measurements. Programmable 10 µA-1.5mA current source which is crucial for bridge operation is also present. TI's "1g Resolution over 15kg Range Front-End Reference Design":http://www.ti.com/tool/TIDA-00765 covering use of ADS1220 with bridge sensors very well. Tiny DFN16 package makes integration of this ADC on compact sensor carrier easy task, without need of additional wire bonding.
Also being able to identify ADC chip leaves us with full register information, so perhaps one can even play with different currents/filter modes to tune pressure sensor operation. Of course there would be no warranty or support from Honeywell, if you do so. :)
p=. "!/doc/Honeywell/RSC/rsc_mount_1.jpg!":/doc/Honeywell/RSC/rsc_mount.jpg
%(imgref)Image 22. DFN packages soldered to alumina substrate pads%
Smaller chip next to ADC is DFN8-packaged "CAT25040HU4I?GT3":/doc/Allsensors/pdf/CAT25010-D.PDF 4Kbit SPI EEPROM. Nothing very special about it. We can also see pressure port to sensor die cavity, it's a hole right between EEPROM and ADC. Time to look on the sensor itself.
p=. !/doc/Honeywell/RSC/rsc_die.jpg!
%(imgref)Image 23. Honeywell RSC pressure sensor die%
Sensor die marked as Honeywell 6030 and have design year 2011. Label next to 6030 state *X-17 Y-10*, probably meaning sensor element center position? Four piezoresistors located on the middle points of membrane edges. Membrane boundary can be easily seen by eight fiducial marks around. Die size is 2.5 x 2.5 mm.
p=. "!/doc/Honeywell/RSC/rsc_dieattach_1.jpg!":/doc/Honeywell/RSC/rsc_dieattach.jpg
%(imgref)Image 24. Die attach sealant%
Die bonded with semitransparent white adhesive, as it's important to maintain hermetic connection between alumina base and bottom of the sensor, where cavity port is located.
p=. "!/doc/Honeywell/RSC/rsc_diem_1.jpg!":/doc/Honeywell/RSC/rsc_diem.jpg "!/doc/Honeywell/RSC/rsc_diebond_1.jpg!":/doc/Honeywell/RSC/rsc_diebond.jpg
%(imgref)Image 25-26. Sensor structures and bridge piezoresistve assembly%
Purple-colored area is flexible section, with membrane visible in smaller box inside. Note two different resistor die configuration, used in the bridge. There is nothing else on the sensor, outside borders of the die just have some lot/batch cryptic code markings and etching test/alignment structures.
Based on "RSC product page site":https://sensing.honeywell.com/sensors/amplified-board-mount-pressure-sensors/trustability-rsc-series development kit based on Arduino Uno board. User Instructions how to connect everything, firmware for it and example source code available in Software Download sections.
h2. %(#testrig)Test setup and methodology%
To demo interfacing and operation of both DLHR-LxxD and RSC sensors popular single-board computer platform, such as "Raspberry Pi 3 Model B":https://www.raspberrypi.org/products/ chosen as development environment. This is well known Linux-based platform, with wide recognition in education, scientific labs and multitude of various application projects, including even industrial field. Raspberry Pi have set of different interfaces, including I[^2^]C and SPI, that can be used will to talk with sensors. Integrated networking functionality, ability to output image using standard HDMI port and rich Linux-based software toolkit allow quick and efficient prototyping and testing new ideas.
p=. "!/doc/RPi/rpi3/rpi3_top_1.jpg!":/doc/RPi/rpi3/rpi3_top.jpg
%(imgref)Image 27. Raspberry Pi 3 Model B used for test%
In our case Pi will interface pressure sensor interface (I[^2^]C in case of ASC DLHR-LxxD and SPI for Honeywell RSC), configure them and sample both temperature and pressure data into local SD-card filesystem. All data will be tagged with datestamp and stored in DSV-format for further math processing. Language of choice for the measurement experiments is Python 2.7.
p=. !/doc/Allsensors/img/raspberry_pinout.png!
%(imgref)Image 28. RPI3 Pinout. Courtesy of "www.raspberrypi-spy.co.uk":http://www.raspberrypi-spy.co.uk%
Since I had no means to generate different pressures for test, I've bought "Fluke 719 30G portable pressure calibrator":/review/f719-30g. It have integrated pressure pump, pressure sensor and 4-20mA current loop source/measure capability. This is commonly used tool for industrial applications, where pressure transducers required to be tested and calibrated. 719 30G model with electrical pump can source pressures in range from -850 mbar (-341 inH[^2^]O) to 2.4 bar (963 inH[^2^]O), with resolution of 0.1 mbar (0.0401 inH[^2^]O).
p=. "!/doc/Fluke/719/img/fluke_meas_2.jpg!":/doc/Fluke/719/img/fluke_meas.jpg
%(imgref)Image 29. Fluke 719 30G electric pressure calibrator%
Best accuracy over a year is 0.035%, sufficient for testing our sensors, which are specified around 0.25%. "Fluke 719 Manual":http://media.fluke.com/documents/719_____umeng0000.pdf covers operation and functions of calibrator. Detailed specifications also provided in the manual.
Now that we have pressure source and reference meter, time to get back figuring out how to connect sensor to the Raspberry Pi. Datasheets for both sensors have all the information required. DLHR sensors in ND package have following pinout:
|_. Pin number |_. Pin function |/5. Body|_. Pin function |_. Pin number |
| 1 | GND (Ground reference) | /SS (chip select) | 8 |
| 2 | V[~S~] Supply 1.65-3.6V| No connection | 7 |
| 3 | SDA/MOSI(Master Out Slave In) Data interface| MISO(Master In Slave Out) SPI Data | 6 |
| 4 | SCL/SCLK Clock | EOC(End of conversion) status | 5 |
%(tblref)Table 4. All Sensors DLHR pinout%
Honeywell RSC sensor also feature 8-pin package, with slightly smaller size.
|_. Pin number |_. Pin function |/5. Body|_. Pin function |_. Pin number |
| 1 | SCLK Clock input | MISO(Master In Slave Out) SPI Data | 8 |
| 2 | ~DRDY Data ready output | CS_ROM (Chip select for EEPROM) | 7 |
| 3 | DIN/MOSI(Master Out Slave In) | V[~S~] Supply 1.65-3.6V | 6 |
| 4 | CS_ADC (Chip select for ADC) | GND (Ground reference) | 5 |
%(tblref)Table 5. Honeywell RSC pinout%
Reference connections also presented in datasheet, to that's exactly what we do as well. Open-collector lines, such as SDA/SCL and chip-selects on RSC sensor need to be pulled up to power level for proper operation. This was done using 2.2 KΩ 1206-size SMT resistors connected to V[~S~] lines.
Both sensors are powered by low-noise LDO converter. It is based on "Linear LT3042EDD":http://www.linear.com/product/LT3042, very low noise adjustable linear regulator, capable of supplying enough current to run sensors. Great PSRR(Power-supply rejection rate) and RMS noise of this regulator help to reduce input noise coupling with our DUT.
p=. "!/doc/Allsensors/img/lt3042sch.png!":http://www.linear.com/product/LT3042
%(imgref)Image 30. Typical LT3042 regulator application. (Courtesy "Linear":http://www.linear.com/product/LT3042)%
As LT3042 have compact SMT package, to make it easier for prototyping I've developed and assembled few adapter boards with onboard ceramic capacitors and resistors per reference schematics. Output voltage range is from 0V to 15V. Capacitor from SET to GND improves noise, PSRR and transient response at the expense of increased start-up time. For best load regulation, Kelvin connect the ground side of the SET pin resistor directly to the load point.
p=. "!/doc/xDevs.com/KX/LMP/lmp1sch.png!":/doc/xDevs.com/KX/LMP/lmp1sch.pdf
%(imgref)Image 30. xDevs.com LMP1 Power supply regulator schematics (resistor R3 set for +15V output as example)%
Output voltage is set by resistor R3, connected at Pin 7 (SET). This pin is the inverting input of the error amplifier and the regulation set-point for the LT3042. Pin have fixed current source 100µA, so single resistor allow to set desired output voltage. Calculated output and resistance formulas presented as below.
p=. *V[~OUTPUT~]* = *100µA* * *R[~SET~]*, or *R[~SET~]* = *V[~OUTPUT~]* / *100µA*
Adapter board allow simple three terminal operation and assembly of regulator on typical 0.1" breadboard. Adapter module is designed for same size and pinout as TO-220 78xx-series LDOs, using 4-layer FR4 PCB for all connections and ground copper pour.
p=. "!/doc/xDevs.com/KX/LMP/lmp1aa_1.jpg!":/doc/xDevs.com/KX/LMP/lmp1aa.jpg "!/doc/xDevs.com/KX/LMP/lmp1ab_1.jpg!":/doc/xDevs.com/KX/LMP/lmp1ab.jpg
%(imgref)Image 31-32. xDevs.com LMP1 module comparison to 7805 TO-220 regulator%
Latest Raspberry Pi Linux distributive used as software platform with Python 2.7 development environment. Python is often a tool of choice for scientific and educational use, since it have easy syntax, have powerful functionality and comes with vast open-source library/API repository from developers community. Even people who never saw Raspberry Pi or Python can start and get first application running in matter of few evenings with tea and a laptop. All demo application code and test data presented in this article.
Connection map of sensors to Raspberry Pi I/O port is listed in table below.
|_. Pressure sensor pin |_. Signal type |_. Direction |_. Raspberry Pi pin |
| ASC DLHR pin 1 | GND (Ground reference) | Power | |
| ASC DLHR pin 2 | V[~S~] Supply 1.65-3.6V| Power | |
| ASC DLHR pin 3 | SDA/MOSI(Master Out Slave In) Data interface| Bidir | Pin 3 |
| ASC DLHR pin 4 | SCL/SCLK Clock | From Pi3 | Pin 5 |
| HW RSC pin 1 | SCLK Clock input | From Pi3 | Pin 23 |
| HW RSC pin 3 | DIN/MOSI(Master Out Slave In) | From Pi3 | Pin 19 |
| HW RSC pin 8 | MISO(Master In Slave Out) SPI Data | To Pi3 | Pin 21 |
| HW RSC pin 4 | CS_ADC (Chip select for ADC) | From Pi3 | Pin 24 |
| HW RSC pin 7 | CS_ROM (Chip select for EEPROM) | From Pi3 | Pin 26 |
| HW RSC pin 2 | ~DRDY Data ready output | To Pi3 | Pin 7 |
| HW RSC pin 6 | V[~S~] Supply 1.65-3.6V | Power | |
| HW RSC pin 5 |GND (Ground reference) | Power | |
%(tblref)Table 6. Sensors interfacing to Raspberry Pi 3%
h2. %(#pycode)Interfacing pressure sensors to Raspberry Pi using Python%
Example libraries and demo application was developed in Python for testing both sensors. This allows for easy and quick way to integrate All Sensors transducers for IoT field and applications. Source code and example test data can be cloned from "GitHub repository":https://github.com/tin-/ascp.
pre.. # git clone https://github.com/tin-/ascp
p. Also application have one additional sensor, Bosch BME280, used to log environment conditions, such as atmosphere pressure, relative humidity and temperature. Guide about using this sensor "was already covered on xDevs.com":https://xdevs.com/guide/thp_rpi/.
p. Directory structure have just few main files:
* *main.py* - Top level application code, contains menu, help prompts and module imports.
* *dlhr.py* - Have low-level and math for All Sensors DLHR type sensor.
* *rsc.py* - Have low-level and math for Honeywell RSC type sensor.
* *bme280.py* - Have low-level and math for Bosch BME280 environment sensor.
* *pressure.conf* - Configuration file for settings
This application depends on few external modules, which need to be installed in user's Python environment:
* "Adafruit_GPIO.I2C":https://github.com/adafruit/Adafruit_Python_GPIO - Provide binding to Pi I[^2^]C port to Python
* "spidev":https://pypi.python.org/pypi/spidev - Provide binding to SPI device in Python
* "RPi.GPIO":https://pypi.python.org/pypi/RPi.GPIO - Provide binding to Pi GPIO port to Python
* "ConfigParser":https://docs.python.org/2/library/configparser.html - Provide configuration file parsing
Take a brief look on used functions..
h3. dlhr.py - All Sensors DLHR sensor module.
This module have all necessary functions to interface I[^2^]C with DLHR sensor, read/write all necessary data and expose high-level functions for application's top level.
pre(Python).. class ASC_DLHR(object):
def __init__(self, mode=ASC_DLHR_I2CADDR, address=ASC_DLHR_I2CADDR, i2c=None,
**kwargs):
self._logger = logging.getLogger('Adafruit_BMP.BMP085')
# Check that mode is valid.
if mode != 0x41:
raise ValueError('Unexpected address'.format(mode))
self._mode = mode
# Create I2C device.
if cfg.get('main', 'if_debug', 1) == 'false':
if i2c is None:
import Adafruit_GPIO.I2C as I2C
i2c = I2C
self._device = i2c.get_i2c_device(address, **kwargs)
p. Class ASC_DLHR creates I[^2^]C device and checks correct address.
pre(Python).. def write_cmd(self, cmd):
if cfg.get('main', 'if_debug', 1) == 'false':
bus.write_i2c_block_data(ASC_DLHR_I2CADDR, cmd, [0x00, 0x00])
time.sleep(0.1)
if cfg.get('main', 'if_debug', 1) == 'true':
print "\033[31;1mDebug mode only, command = %X\033[0;39m" % cmd,
return 1
p. This function write command *cmd* into DLHR following protocol from datasheet on the sensor.
pre(Python).. def chk_busy(self):
if cfg.get('main', 'if_debug', 1) == 'false':
Status = bus.read_byte(ASC_DLHR_I2CADDR)
#Status = self._device.readRaw8() # Receive Status byte
if cfg.get('main', 'if_debug', 1) == 'true':
Status = 0x40
if (Status & ASC_DLHR_STS_BUSY):
print "\033[31;1m\r\nPower On status not set!\033[0;39m",
return 1 # sensor is busy
return 0 # sensor is ready
This function checks sensor flag if conversion already done and data is available to read.
p. Test code to read sensor data below:
pre(Python).. def read_sensor(self):
outb = [0,0,0,0,0,0,0,0]
time.sleep(0.04)
self.retry_num = 5
while self.retry_num > 0:
if self.chk_busy():
print "\033[31;1m\r\nSensor is busy!\033[0;39m",
time.sleep(0.01) # Sleep for 100ms
else:
self.retry_num = 0
self.retry_num = self.retry_num - 1
outb = bus.read_i2c_block_data(ASC_DLHR_I2CADDR, 0, 7)
StatusByte = outb[0]
# Check for correct status
if (StatusByte & ASC_DLHR_STS_PWRON) == 0:
print "\033[31;1m\r\nPower On status not set!\033[0;39m",
quit()
if (StatusByte & ASC_DLHR_STS_SNSCFG):
print "\033[31;1m\r\nIncorrect sensor CFG!\033[0;39m",
quit()
if (StatusByte & ASC_DLHR_STS_EEPROM_CHKERR):
print "\033[31;1m\r\nSensor EEPROM Checksum Failure!\033[0;39m",
quit()
# Ccnvert Temperature data to degrees C:
Tmp = outb[4] << 8
Tmp += outb[5]
fTemp = float(Tmp)
fTemp = (fTemp/65535.0) * 125.0 - 40.0
# Convert Pressure to %Full Scale Span ( +/- 100%)
Prs = (outb[1] <<16) + (outb[2]<<8) + (outb[3])
Prs -= 0x7FFFFF
fPress = (float(Prs))/(float(0x800000))
fPress *= 100.0
print "Status: 0x%X " % StatusByte,
print "\033[35;1mPressure: %4.5f %%FSS \033[33;1m Counts: %d " % (fPress, (outb[1] <<16) + (outb[2]<<8) + (outb[3]) ),
print "\033[36;1mTemperature: %3.3f 'C \033[39;0m" % fTemp
with open('asc_dlhr.dsv', 'ab') as o:
o.write (time.strftime("%d/%m/%Y-%H:%M:%S;")+('%4.5f;%3.3f;\r\n' % (fPress, fTemp)))
return 0
p. Now these low level functions can be used to get sensor data.
pre(Python).. print ("Reading AVG8 sensor Pressure/temp..\033[0;49m")
sensor.write_cmd(ASC_DLHR_AVG8_READ_CMD)
sensor.read_sensor()
h3. rsc.py - Honeywell RSC sensor module.
Same idea used for Honeywell RSC sensor.
pre(Python).. class HRSC(object):
def __init__(self, i2c=None, **kwargs):
self._logger = logging.getLogger('Adafruit_BMP.BMP085')
# Create device.
self.read_eeprom()
# Load calibration values.
p. Class HRSC used to create SPI device and initialize sensor port
pre(Python).. def read_eeprom(self):
print "Loading EEPROM data from sensor",
print ".",
# Assert EEPROM SS to L, Deassert ADC SS to H, Set mode 0 or mode 4
spi.open(0, 1)
spi.mode = 0b00
for i in range (0,255):
sensor_rom[i] = spi.xfer([HRSC_EAD_EEPROM_LSB, i, 0x00], 100000)[2] # Read low page
# print "%c" % (sensor_rom[i]),
for i in range (0,255):
sensor_rom[i+256] = spi.xfer([HRSC_EAD_EEPROM_MSB, i, 0x00], 100000)[2] # Read high page
# Clear EEPROM SS , set mode 1 for ADC
spi.close()
return 0
p. Function read_eeprom collects binary data from all 512 bits of sensor's internal EEPROM.
pre(Python).. def adc_configure(self):
# Clear EEPROM SS , assert ADC SS, set mode 1 for ADC
spi.open(0, 0)
spi.mode = 1
self.bytewr = 3
self.regaddr = 0
# Reset command
test = spi.xfer([HRSC_ADC_RESET], 10000)
time.sleep(1)
# Write configuration registers from ROM
print ("%02X" % sensor_rom[61]),
print ("%02X" % sensor_rom[63]),
print ("%02X" % sensor_rom[65]),
print ("%02X" % sensor_rom[67]),
test = spi.xfer2([HRSC_ADC_WREG|self.regaddr << 3|self.bytewr & 0x03, sensor_rom[61], sensor_rom[63], sensor_rom[65], sensor_rom[67] ], 10000)
spi.close()
return 1
p. Function *adc_configure* resets ADC and initialize it with correct configuration from ROM. Oscilloscope screenshot of this sequence and speed change shown below.
p=. !/doc/Allsensors/img/tek00003.png!
%(imgref)Image 33. Oscilloscope capture for ADC configuration. CH3 - CS_ADC.%
pre(Python).. def sensor_info(self):
# Check for correct status
print "\033[0;32mCatalog listing : %s" % str(bytearray(sensor_rom[0:16]))
print "Serial number : %s" % str(bytearray(sensor_rom[16:27]))
print "Pressure range :",
b = self.conv_to_float(sensor_rom[27], sensor_rom[28], sensor_rom[29], sensor_rom[30])
print b,sensor_rom[27:31]
print "Pressure min :",
b = self.conv_to_float(sensor_rom[31], sensor_rom[32], sensor_rom[33], sensor_rom[34])
print b,sensor_rom[31:35]
print "Pressure units : %s" % str(bytearray(sensor_rom[35:40]))
print "Pressure ref :",
if (sensor_rom[40] == 68):
print "Differential"
print "Checksum :",
b = self.conv_to_short(sensor_rom[450], sensor_rom[451])
print b,sensor_rom[450:452]
print "\033[0;39m"
return 1
p. *sensor_info* using EEPROM data to print sensor's partnumber, operation range, sensor type and it's serial number.
pre(Python).. def read_temp(self):
# Clear EEPROM SS , assert ADC SS, set mode 1 for ADC
spi.open(0, 0)
spi.mode = 1
self.bytewr = 0
self.regaddr = 1
spi.max_speed_hz = 10000
reg_dr = 0
reg_mode = 0 # 256kHz modulator
reg_sensor = 1 # temperature
self.reg_wr = (reg_dr << 5) | (reg_mode << 3) | (1 << 2) | (reg_sensor << 1) | 0b00
# Write configuration register
command = HRSC_ADC_WREG|(self.regaddr << 2)|(self.bytewr & 0x03)
print ("\033[0;36mADC config %02X : %02X\033[0;39m" % (command, self.reg_wr))
test = spi.xfer([command, self.reg_wr], 10000)
twait = 0.0591
while(1):
time.sleep(twait)
adc_data = spi.xfer([0,0,command, self.reg_wr], 10000)
#print "RDATA = ",
#print adc_data
temp_data = (adc_data[0]<<16|adc_data[1]<<8|adc_data[2])
self.convert_temp(temp_data)
spi.close()
return 1
p. Function *read_temp* issues command to obtain temperature reading and converts binary data from sensor into floating point temperature. Output resoluion of temperature is 0.03125 °C.
p=. !/doc/Allsensors/img/tek00004.png!
%(imgref)Image 34. Oscilloscope capture for temperature readout. MSB byte first.%
pre(Python).. def convert_temp(self, raw_temp):
raw = (raw_temp & 0xFFFF00) >> 10
if (raw & 0x2000):
#print "MSB is 1, negative temp"
raw = (0x3fff - (raw - 1))
temp = -(float(raw) * 0.03125)
else:
#print "MSB is 0, positive temp"
temp = (float(raw) * 0.03125)
print "RAW: %s %s , %f" % (hex(raw_temp), hex(raw), temp )
with open('rsc_temp.dsv', 'ab') as o:
o.write (time.strftime("%d/%m/%Y-%H:%M:%S;")+('%4.5f;%3.3f;\r\n' % (0.0, temp)))
return temp
p. Helper function *convert_temp* processes raw temperature binary value into floating point temperature, covering both negative and positive temperature ranges.
p=. !/doc/Allsensors/img/tek00000.png!
%(imgref)Image 35. Oscilloscope capture of timing between temperature readouts. CH5 - Data ready.%
pre(Python).. def conv_to_float(self, byte1, byte2, byte3, byte4):
import struct
temp = struct.pack("BBBB", byte1,byte2,byte3,byte4)
output = struct.unpack("