Eloi Benabarre Còrcoles Design and characterization of a...
Transcript of Eloi Benabarre Còrcoles Design and characterization of a...
Eloi Benabarre Còrcoles
Design and characterization of a test platform for semiconductor gas sensors
BACHELOR’S DEGRE FINAL PROJECT
Supervised by José Luis Ramírez Falo.
Degree in Industrial Electronics and Automation Engineering.
Tarragona
2017
Confidential Information
This is the public version of the project Design and characterization of a test platform for
semiconductor gas sensors..
For its publication and following the instructions set in the confidential agreement (next
page) about the final degree project, some parts have been deleted from the original version,
such as the Annexes, some figures or names.
For more information:
JLM Innovation GmbH.
Von der Kreuzberg 17
72072 Tübingen, Germany
0 General Index
0 General Index ..................................................................................................................... 4
0.1 Figure Index ............................................................................................................ 7
0.2 Table Index .................................................................................................................. 8
1 Introduction ...................................................................................................................... 10
1.1 Project background ............................................................................................... 10
1.2 State of the art of gas sensors. ................................................................................... 10
2 Objectives ......................................................................................................................... 11
2.1 Procedure ................................................................................................................... 11
3 Used Tools ........................................................................................................................ 11
3.1 EAGLE ...................................................................................................................... 12
3.2 LTSPICE XVII .......................................................................................................... 12
3.3 ATMEL STUDIO 7 ................................................................................................... 13
3.4 QT Designer. ............................................................................................................. 13
3.5 PyCHARM ................................................................................................................ 14
4 Specifications ................................................................................................................... 15
4.1 Sensors compatibility ................................................................................................ 15
4.2 PWM specifications ................................................................................................... 15
4.3 Specifications for the sensors tested .......................................................................... 15
4.4 ADC and DAC specifications.................................................................................... 15
4.5 Cycle specifications ................................................................................................... 16
5 Previous studies ................................................................................................................ 16
5.1 Circuit modelling ....................................................................................................... 16
5.2 Benchmark of voltage references. ............................................................................. 17
5.3 Decoupling digital and analogue lines ...................................................................... 19
5.4 Filter for the output noise. ......................................................................................... 21
5.5 Filter in the sensing circuit. ....................................................................................... 23
5.6 Analog noise. ............................................................................................................. 25
6 Hardware. ......................................................................................................................... 27
6.1 Standard components. ................................................................................................ 27
6.1.1 Microcontroller ................................................................................................... 27
6.1.2 MOSFET channel P. ........................................................................................... 29
6.1.3 Operational amplifier. ......................................................................................... 30
6.1.4 Voltage regulator. ............................................................................................... 30
6.1.5 BME 280. ........................................................................................................... 31
6.2 Sensors. ...................................................................................................................... 32
6.2.1 CC801 ................................................................................................................. 32
6.2.2 CCS803 ............................................................................................................... 33
6.2.3 TGS8100. ............................................................................................................ 34
6.2.4 MICS-2714 ......................................................................................................... 35
6.2.5 MICS-4514 ......................................................................................................... 36
6.2.5 MICS-5524 ......................................................................................................... 37
6.2.6 MICS-5914 ......................................................................................................... 38
6.3 Heater protection calculation ..................................................................................... 39
6.4 Schematic .................................................................................................................. 40
6.5 Layout ........................................................................................................................ 40
6.6 Bill of materials. ........................................................................................................ 40
7 Firmware ........................................................................................................................... 42
7.1 Clock and timers ........................................................................................................ 42
7.1.1 Clock setting. ...................................................................................................... 42
7.1.2 Timer configuration ............................................................................................ 43
7.2 ADC and DAC .......................................................................................................... 44
7.2.1 Initialization ........................................................................................................ 44
7.2.2 Voltage set DAC ................................................................................................. 46
7.2.3 Multiple channels configuration ......................................................................... 46
7.2.4 Multiple channels reading .................................................................................. 46
7.2.5 Single channel configuration .............................................................................. 47
7.2.6 Single channel reading ....................................................................................... 47
7.3 PWM .......................................................................................................................... 48
7.3.1 PWM initialization ............................................................................................. 48
7.3.2 Frequency setting ................................................................................................ 48
7.3.3 Setting the width ................................................................................................. 49
7.3.4 Start the PWM .................................................................................................... 49
7.3.5 Stop the PWM .................................................................................................... 49
7.3.6 Calculate the PWM period ................................................................................. 49
7.4 Conversion functions ................................................................................................. 50
7.4.1 Convert voltage to width of PWM ..................................................................... 50
7.4.2 Convert width of PWM to voltage ..................................................................... 50
7.4.3 Convert a percentage to width of PWM ............................................................. 51
7.4.4 Convert width of PWM to percentage ................................................................ 51
7.5 Heater protection ....................................................................................................... 51
7.5.1 Heater resistance characterization ...................................................................... 51
7.5.2 Code .................................................................................................................... 54
7.7 Commands and parameters ........................................................................................ 55
8 Software ............................................................................................................................ 55
8.1 MiniMOX library ...................................................................................................... 55
8.1.1 Cycles class. ....................................................................................................... 55
8.1.2 Sticks initialization. ............................................................................................ 56
8.1.3 Release the sticks. ............................................................................................... 56
8.1.4 minimox class. .................................................................................................... 56
8.2 Main method. ............................................................................................................. 57
8.3 Calibration software .................................................................................................. 57
8.3.1 DAC calibration method ..................................................................................... 57
8.3.2 Methods. ............................................................................................................. 58
8.4 User interface software .............................................................................................. 58
8.4.1 Measure Thread .................................................................................................. 58
8.4.2 Print Thread ........................................................................................................ 59
8.4.3 Graphic functions ............................................................................................... 59
8.4.3 Methods. ............................................................................................................. 60
9 User manuals .................................................................................................................... 60
9.1 Calibration user interface manual .............................................................................. 60
9.2 Graphic user interface manual ................................................................................... 60
10 Budget ............................................................................................................................. 61
10.1 Unit price. ................................................................................................................ 61
10.2 General budget. ........................................................................................................ 65
11 Further work ................................................................................................................... 71
12 Conclusions .................................................................................................................... 72
13 References ...................................................................................................................... 73
Annex 1 Expected planning
Annex 2 Previous studies data
Annex 3 Schematic
Annex 4 Board layout
Annex 5 Heater resistance characterization data
Annex 6 Calibration manual
Annex 7 Graphic user interface manual
Annex 8 Command and parameters guide
Annex 9 Firmware documentation
Annex 10 Calibration program documentation
Annex 11 Graphic user interface program documentation
Annex 12 Firmware code
Annex 13 Calibration program code
Annex 14 Graphic user interface program code
Annex 15 Executable programs
0.1 Figure Index
Figure 1. EAGLE schematics window. .............................................................................. 12
Figure 2. EAGLE layout window. ...................................................................................... 12
Figure 3. LTSpice XVII window. ....................................................................................... 13
Figure 4. Atmel Studio 7 window....................................................................................... 13
Figure 5. Qt designer window. ........................................................................................... 14
Figure 6. PyCharm window. ............................................................................................... 14
Figure 7. Schematic model of the MOXstick power line ................................................... 17
Figure 8. Benchmark voltage reference R = 390 Ω case. ................................................... 18
Figure 9. Benchmark voltage reference R = 5,6 kΩ case. .................................................. 18
Figure 10. Benchmark voltage reference R = 560 kΩ case. ............................................... 18
Figure 11. On the left, power circuit with decoupling lines. On the right, power circuit
without decoupling lines. ..................................................................................................... 19
Figure 12. Decoupling lines R = 390 Ω case. ..................................................................... 20
Figure 13. Decoupling lines R = 5,6 kΩ case. .................................................................... 20
Figure 14. Decoupling lines R = 560 kΩ case. ................................................................... 20
Figure 15. Schematic power circuit. ................................................................................... 21
Figure 16. Output noise coming from the circuit without filter. ........................................ 22
Figure 17. Schematic power circuit with filter. .................................................................. 22
Figure 18. Output noise coming from the circuit with filter............................................... 23
Figure 19. On left, sensing circuit with filter. On right, sensing circuit without filter. ...... 23
Figure 20. Filter in the sensing circuit R = 390 Ω case . ................................................. 24
Figure 21. Filter in the sensing circuit R = 5,6 kΩ case. .................................................... 24
Figure 22. Filter in the sensing circuit R = 560 kΩ case. ................................................... 24
Figure 23. Schematic power circuit with filter ................................................................... 25
Figure 24. Input analog noise ............................................................................................. 26
Figure 25. Power circuit with the complete set of filters. ................................................... 26
Figure 26. Input analog noise with the filter....................................................................... 27
Figure 27. Pinout/Block diagram of the MCU ATXMEGA128AU [4] ............................. 28
Figure 28. Pinout MOSFET NXP2301P [5] ....................................................................... 29
Figure 29. Pinout operational amplifier AD8604ARUZ [6] .............................................. 30
Figure 30. Pinout voltage regulator LM3480IM3-3.3/NOPB [7]....................................... 30
Figure 31. BME 280 pinout [8] .......................................................................................... 31
Figure 32. I2C connection diagram [8]............................................................................... 31
Figure 33. Block diagram of BME 280 [8]......................................................................... 32
Figure 34. CCS801 electrical characteristics [9] ................................................................ 33
Figure 35. CCS801 performance [9] .................................................................................. 33
Figure 36. CCS803 electrical characteristics [10] .............................................................. 34
Figure 37. CCS803 performance [10] ................................................................................ 34
Figure 38. TGS8100 electrical characteristics [11] ............................................................ 34
Figure 39. TGS8100 performance [11] .............................................................................. 35
Figure 40. MICS-2714 electrical characteristics [12]......................................................... 35
Figure 41. MICS-2714 performance [12] ........................................................................... 36
Figure 42. MICS-4514 electrical characteristics [13]......................................................... 36
Figure 43. MICS-4514 performance [13] ........................................................................... 37
Figure 44. MICS-5524 electrical characteristics [14]......................................................... 37
Figure 45. MICS-5524 performance [14] ........................................................................... 38
Figure 46. MICS-5914 electrical characteristics [15]......................................................... 38
Figure 47. MICS-5914 performance [15] ........................................................................... 38
Figure 48. Clock distribution [4] ........................................................................................ 42
Figure 49. System clock selection and prescalers [4] ......................................................... 43
Figure 50. Timer overview [4]............................................................................................ 48
Figure 51. Measure points schematics. ............................................................................... 52
Figure 52. Power vs duty cycle for the CCS801 sensor ..................................................... 53
Figure 53. Power vs duty cycle for the TGS8100 sensor ................................................... 54
Figure 54. Sensing circuits schematic ................................................................................ 56
Figure 55. Offset and gain errors [16]................................................................................. 57
0.2 Table Index
Table 1. Sensor Compatibility ........................................................................................... 15
Table 2. PWM specifications ............................................................................................. 15
Table 3. PWM specifications for the sensors tested .......................................................... 15
Table 4. ADC and DAC specifications .............................................................................. 16
Table 5. Cycle specifications ............................................................................................. 16
Table 6. Standard deviation of the 3 resistors .................................................................... 19
Table 7. Standard deviation of the 3 resistors. .................................................................... 21
Table 8. Standard deviation of the 3 resistors. ................................................................... 25
Table 9. Main characteristics ATXMEGA128A4U .......................................................... 29
Table 10. Operation time MOSFET NXP2301P ............................................................... 30
Table 11. AD8604ARUZ table .......................................................................................... 30
Table 12. Duty cycle calculations ....................................................................................... 39
Table 13. Heater resistance and current in continuous power consumption...................... 40
Table 14. Resistor and heater Voltage ................................................................................ 40
Table 15. miniMOX bill of materials ................................................................................ 42
Table 16. ADC pin correspondence ................................................................................... 45
Table 17. DAC pin correspondence ................................................................................... 45
Table 18. Channel description. .......................................................................................... 46
Table 19. Case description ................................................................................................. 47
Table 20. CCS801 heater resistance characterization ........................................................ 53
Table 21. TGS8100 heater resistance characterization ...................................................... 54
Table 24. Public variables in the minimox class ............................................................... 56
Table 25. Private variables in the minimox class .............................................................. 56
Table 26. Private methods in the minimox class ............................................................... 56
Table 27. Public methods of minimox class ...................................................................... 57
Table 28. Calibration program methods ............................................................................ 58
Table 29. GUI program methods ....................................................................................... 60
1 Introduction
10
1 Introduction
A chemical sensor can be defined as “a device that transforms chemical information,
ranging from the concentration of a specific sample component to total composition analysis,
into an analytically useful signal. In particular, said chemical information may originate from
a chemical reaction of analyte or from property of the investigated system.” [2].
It has been many years since gas sensors, which are chemical sensor, were a great
promise, in all kind of applications, including security, medical, industrial, food analysis and
many others [1].
Gas sensors operate under a large variety of principles. Low cost gas sensors are typically
not-selective and suffer from large device intervariability and poor stability. However, the
potential applications of gas sensors are numerous and their use has increased during this
last decades. For some operation principles, chemical sensors are mass produced by a group
of companies, but other technologies are manufactured only at the prototype level by some
research groups.
A metal-oxide semiconductor (MOS) sensor is typically composed of a substrate and a
heating element, coated with a sensing material between two electrodes [3]. The heater
element can be a heated filament or a micro-hotplate. This element is necessary for the type
of reactions that take place between the target gas and the material of this sensor. The heater
sets the material at high temperature and facilitates the gas-sensing material reactions and
reduces the time for response and recovery.
The research explosion in metal-oxide semiconductor sensors, which started 20 years
ago, has failed to fulfill most of the promises except for a few applications (e.g. automotive
air quality, lambda sensors, etc.). Many of the research groups that invested heavily in this
field, have found limited success. The challenge of sensing is in fact much larger than was
initially thought.
Although the limited success of this technology there are a few techniques which allow
to have a real measure and get real data. Arrays of MOS sensors or different heaters
excitations with a multivariable data analysis, which involves observation and analysis of
more than one statistical variable at a time, are two examples in which MOS sensors can
work properly.
1.1 Project background
The present project has been developed in the context of an Erasmus internship in JLM
Innovations, a technology company located in Tübingen that develops hardware and
software for data acquisition as well as data analysis tools in the field of chemical sensors.
For this project an existing product of the company has been redesigned to accomplish
new specifications.
1.2 State of the art of gas sensors.
Electronic products that involve low cost chemical sensor technology are still under
development. Specially, applications that involve detecting constituents in liquids as well as
gases may expand rapidly in the future.
Applications for gas sensors can be divided in two categories: those for which it is
necessary to accurately quantify one or more analytes in mixture, and those that require only
a global assessment.
1 Introduction
11
In addition, it is possible to distinguish two types of gas sensing instruments: in one hand,
analytical and sophisticated instruments; these instruments are not typically viable because
the high cost maintenance, the high measure time and the need of sample preparation. And
one the other hand, simple and cheap gas sensors which can run with the minimal
maintenance and sample preparation, are fast doing the measure.
Low cost gas sensors are obviously the convenient devices for some applications, for
which there is a need of a global assessment of the gas sample and not a quantification of
every component in the sample.
The general requirements for low cost sensors can be summarized in five factors. An
ideal sensor would exhibit high levels of these five factors:
Simplicity: simplicity is related to the operational set ups and number of
components in the device to perform the measurements, for example circuitry to
condition the output signal. High simplicity implies sensors’ features such as
small size and high portability.
Speed: due their simplicity, low cost sensors have a high response time when
they are exposed to the target gas. After the exposition, they need a recovery time
before exposing it to a new gas.
Sensitivity: the sensitivity is the minimum magnitude required to produce an
output signal. High sensitive sensors can detect low gas concentrations.
Selectivity: sensors are sensitive to many interferents, gas sensors are generally
very low selective. Such interferents include environmental variables and other
gas species to which the sensor is chemically responsive.
Stability: the lack of stability is an important issue for chemicals sensors. A
sensor with low stability can reduce its lifetime and comprise the LODs by
causing inaccuracy, false alarms and limited detection levels.
2 Objectives
The main goal of this project is to redesign an existent product of this company, the
MOXstick, to make it cheaper and smaller, allowing the new SMD gas sensors to be operated
by the user.
2.1 Procedure
The project has been divided in four parts to achieve this objective:
MOXstick studies: to recognize the different parts of it, know its
firmware and to check his performance
Hardware design: the board to place all the components will be designed
applying all the knowledge and the conclusions of the previous study.
Create and adapt the firmware: the MOXstick firmware will be adapted
to run under the new requirements.
Create the computer software: to be able to operate with the new
product it is necessary to develop a software in an open-source computer
programing language, just like Python.
3 Used Tools
This chapter gives a brief overview of the specific tools which have been used in the
development of this project.
3 Used Tools
12
3.1 EAGLE
EAGLE (Easily Applicable Graphical Layout Editor) is an electronic design automation
(EDA). It includes a schematic editor, for designing circuit diagrams in which parts can be
placed on many sheets and connected via ports. A printed circuit board (PCB) layout editor
allows back annotation to the schematic. Also, it includes computer-aided manufacturing
(CAM) tools.
There are many textual and video tutorials made by the EAGLE community for the
beginners who want to design their own PCB
Figure 1. EAGLE schematics window.
Figure 2. EAGLE layout window.
3.2 LTSPICE XVII
LTspice provides a schematic capture and waveform viewer. It is node-unlimited and
third-party models can be imported. Circuit simulations based on AC, noise and DC analysis
can be plotted as well as Fourier analysis.
LTspice does not generate PCB layouts, but the netlists can be exported into layout
programs, Eagle is an example.
This program is used in many fields, radio frequency electronics, power electronics and
digital electronics are a few disciplines which this program can be used.
3 Used Tools
13
Figure 3. LTSpice XVII window.
3.3 ATMEL STUDIO 7
Atmel studio 7 is an integrated development platform (IDP) for developing and
debugging Atmel ARM and Atmel AVR based microcontroller (MCU) applications. This
IDP gives an easy-to-use environment to write, build and debug applications written in
C/C++ or assembly code. In addition, it includes software libraries inside
Atmel provides tools for programming the devices. In this project the JTAG programmer
has been used. JTAG interface consists of a 4-wire Test Access Port (TAP) controller, which
is compliant with the IEEE 11491.1 standard.
This standard was developed to provide industry an efficient way to test circuit board
connectivity (Boundary Scan).
Figure 4. Atmel Studio 7 window.
3.4 QT Designer.
QT Designer is a tool for designing and build graphical user interfaces (GUIs). It can be
customized with widgets or dialogs in a “what you see is what you get” manner and test
them using different styles and resolutions.
3 Used Tools
14
It is possible to export the code generate by Qt designer to Python by using the Pyside
libraries.
Figure 5. Qt designer window.
3.5 PyCHARM
PyCharm is an integrated development environment (IDE) used in computer
programming. It provides code analysis, graphical debugger and integrated unit tester, in this
project it is used with Python language
Figure 6. PyCharm window.
4 Specifications
15
4 Specifications
The specifications of the miniMOX are the following:
4.1 Sensors compatibility
Manufacturer Model Description / use (according to manufacturer)
CCMOSS CCS801 Indoor air quality
CCS803 Ethanol detection
Figaro TGS8100 Detection of air quality
SGX
MICS-2714 Nitrogen dioxide and leakage detection
MICS-4514 Detection of gasoline exhaust gases
MICS-5524 Carbon monoxide and natural gas leakage detection
MICS-5914 Ammonia detection
Table 1. Sensor Compatibility
4.2 PWM specifications
Minimum effective voltage (V) 0
Maximum effective voltage (V) 3,3
Frequency (KHz) 20,84
Resolution (Bit) 10
Table 2. PWM specifications
4.3 Specifications for the sensors tested
CCS801 TGS8100
Max current (mA) 27,25 8,8
Max power (mW) 54,51 17,59
Nominal power (mW) 33 15
Duty cycle for nominal power 53,07 % 79,86 %
Table 3. PWM specifications for the sensors tested
4.4 ADC and DAC specifications
Time for conversion single channel (ms) 6,25
Time for 4 channels conversion (ms) 25
4 Specifications
16
ADC resolution (bit) 10
DAC resolution (bit) 12
Table 4. ADC and DAC specifications
4.5 Cycle specifications
Maximum steps in a cycle 128
Minimum time for step 25 ms
Maximum time for step 6,4 s
Maximum time for cycle. 13 min and 39 seg (819,2 s)
Table 5. Cycle specifications
5 Previous studies
This project is a redesign of the MOXstick, an existing product of the company. This
section explains the studies done to adapt the MOXstick to accomplish the new
specifications.
The studies are the following:
Benchmark of voltage reference: to reduce possible noise in the measure coming
from the analogical voltage reference it is necessary to study if using an internal
MCU voltage reference in the ADC and DAC, reduces the measurement noise.
Remove decoupling in the power lines: the power line is based on the MOXstick
power line, to reduce space is necessary to remove some components of it, in this
study the analogic decoupling circuit has been removed and has been connected
to the digital circuit to see the effect of this action during the measurements.
Filter for the output noise: to reduce the noise that the miniMOx returns to the
power supply below 0,15 mV.
Filter in the sensing circuit: the sensing circuit is based on the MOXstick, to
reduce space is necessary to remove some components of the sensing circuit, in
this study the output filter of the sensing circuit is removed to see the effects that
has this action.
Filter for the analog noise: the analog line is used in the ADC and DAC voltage
reference, it should be interesting to try to reduce the noise in this line as it can
appear in the measurement.
5.1 Circuit modelling
To simulate the MOXstick power line, and adapt it to the new specifications, is necessary
to do a schematic model of it.
5 Previous studies
17
Figure 7. Schematic model of the MOXstick power line
The figure 7 represents the schematic power circuit of the MOXstick.
The analog part of the MCU has been modelized as a 300 Ω (R7). The digital part has
been modelized as a 1000 Ω (R5) and a voltage source (Noise_1mV_1MHz), which
simulates the noise of the digital signals, a sinusoidal signal which has 1mV of amplitude at
1 MHz.
The LT1587-3.3 is a voltage regulator and it is a pre-build model from Linear
Technology. Two voltage regulators with the same specifications are mounted on the
MOXstick.
PWMs and their capacitor have been added on this simulation, they are used to excite
the heater resistance of the sensor. Their schematic model is a voltage source
(PWM1_3.3V_20.84kHz and PWM2_3.3V_20.84kHz) which gives a square wave between
0 V and 3,3 V with a frequency of 20,84 kHz. The heater impedance has been modelized as
a 200 Ω resistor (R1 and R4). The 44 µF capacitator (C1) acts as a filter for the PWM.
The 0,5 Ω resistor (R2) is placed to measure the noise that returns the board to the power
supply.
The filter at the input of the power line, consists on a 10 µF capacitator (C2), a ferrite
bead that has an impedance of 4700 Ω at 100 MHz (4700ohm_at_100MHz) and a 10nF
capacitator (C3).
The filter for the analogic part consists on a ferrite bead which has an impedance of 1000
Ω at 100 MHz (1000ohm_at_100MHz) and a 1 µF capacitator (C4).
5.2 Benchmark of voltage references.
The voltage reference is used by the analog part of the MCU for its ADC and DAC.
Therefore, if the voltage reference has noise, it will appear in the measure.
To reduce the input lines to the MCU, which can produce noise, it is studied if the internal
bandgap voltage reference is less noisy than the external voltage reference used in the
predecessor project.
5 Previous studies
18
The study consists on measuring three different resistors (390 Ω, 5,6 kΩ and 560 kΩ)
with the MOXstick using the internal bandgap voltage reference and the external voltage
reference.
The steps done to do this study are:
1. With the external voltage reference, measure the three resistors.
2. Update the MOXstick software to use the internal bandgap voltage reference.
3. Measure the three resistors.
4. Compare the results with a graph and with the standard deviation.
Figure 8. Benchmark voltage reference R = 390 Ω case.
Figure 9. Benchmark voltage reference R = 5,6 kΩ case.
Figure 10. Benchmark voltage reference R = 560 kΩ case.
376
378
380
382
1
13
25
37
49
61
73
85
97
10
9
12
1
13
3
14
5
15
7
16
9
18
1
19
3
20
5
21
7
22
9
24
1
25
3
26
5
27
7
28
9
30
1
Impedance (Ω)
Measures
Rnominal = 390 Ω
Int Vref
Ext Vref
5530
5540
5550
5560
5570
1
14
27
40
53
66
79
92
10
5
11
8
13
1
14
4
15
7
17
0
18
3
19
6
20
9
22
2
23
5
24
8
26
1
27
4
28
7
30
0
31
3
32
6
33
9
Impedance (Ω)
Measures
Rnominal = 5,6 kΩ
Int Vref
Ext Vref
520000
540000
560000
580000
600000
1
14
27
40
53
66
79
92
10
5
11
8
13
1
14
4
15
7
17
0
18
3
19
6
20
9
22
2
23
5
24
8
26
1
27
4
28
7
30
0
31
3
32
6
Impedance (Ω)
Measure
Rnominal = 560 kΩ
Int Vref
Ext Vref
5 Previous studies
19
Standard deviation Using internal bandgap votlage Using external reference
R = 390 Ω 502,747 mΩ 626,421 mΩ
R = 5,6 kΩ 1,563 Ω 2,084 Ω
R = 560 kΩ 5,189 kΩ 4,923 kΩ
Table 6. Standard deviation of the 3 resistors
In the figures 8, 9 and 10 are represented the measures which have been obtained from
measuring the different resistance using different voltage references. In the table 6, it is
calculated the standard deviation of the results. The standard deviation using the internal
bandgap is lower in the two cases than using the external reference. Although there is a case
that is better to use an external voltage reference, in this project the internal bandgap voltage
will be used.
5.3 Decoupling digital and analogue lines
To have the analogue circuit isolated from the digital circuit can reduce the noise in the
measures. But to decouple the circuits forces to duplicate certain components.
This study valuates noise at the measures without decoupling the digital and analogue
lines, using only one voltage regulator which feeds the digital and analogue line of the MCU
at the same time. In the figure 11 is represented schematics before the modification and after
the modification. These schematics are used for represent the hardware modifications, in this
point the results are measured.
Figure 11. On the left, power circuit with decoupling lines. On the right, power circuit without decoupling lines.
The study consists on measure three different resistors (390 Ω, 5,6 kΩ and 560 kΩ) using
a MOXstick with a decoupling circuit and a MOXstick without decoupling. Figure 5
represents both schematics.
The steps done to do this study are:
1. Using a MOXstick, measure with the three resistors.
5 Previous studies
20
2. Modify the MOXstick by removing one voltage reference and connecting the
digital circuit with the analogic circuit.
3. Measure with the three resistors.
4. Compare the results with a graph and with the standard deviation.
Figure 12. Decoupling lines R = 390 Ω case.
Figure 13. Decoupling lines R = 5,6 kΩ case.
Figure 14. Decoupling lines R = 560 kΩ case.
370
375
380
385
390
1
13
25
37
49
61
73
85
97
10
9
12
1
13
3
14
5
15
7
16
9
18
1
19
3
20
5
21
7
22
9
24
1
25
3
26
5
27
7
28
9
30
1
Impedance (Ω)
Measures
Rnominal = 390 ΩNodecouplinglines
Decouplinglines
5500
5510
5520
5530
5540
5550
5560
5570
1
13
25
37
49
61
73
85
97
10
9
12
1
13
3
14
5
15
7
16
9
18
1
19
3
20
5
21
7
22
9
24
1
25
3
26
5
27
7
28
9
30
1
Impedance (Ω)
Measures
Rnominal = 5,6 kΩ
Nodecouplinglines
Decouplinglines
350000
400000
450000
500000
550000
600000
1
14
27
40
53
66
79
92
10
5
11
8
13
1
14
4
15
7
17
0
18
3
19
6
20
9
22
2
23
5
24
8
26
1
27
4
28
7
30
0
Impedance (Ω)
Measures
Rnominal = 560 kΩNodecouplinglinesMOXNormalMOX
5 Previous studies
21
Standard deviation No decoupling the lines. Decoupling of the lines.
R = 390 Ω 487,584 mΩ 634,862 mΩ
R = 5,6 kΩ 1,9729 Ω 1,9656 Ω
R = 560 kΩ 2,430 kΩ 5,085 kΩ
Table 7. Standard deviation of the 3 resistors.
In the figures 12, 13 and 14 represent the measures that have been obtained from measuring
the different resistances decoupling the analog and the digital lines and without decoupling
them. In the table 7, it is calculated the standard deviation of the results. The standard
deviations are lower in two cases when there is no decoupling line and it has an insignificant
difference when is higher. The decoupling lines will not be used for this project.
5.4 Filter for the output noise.
The aim of this study is to reduce the noise produced on the board and returns to the
power supply, a computer, battery or mobile phone.
In the figure 15 is showed the schematic power circuit without decoupling lines:
Figure 15. Schematic power circuit.
Figure 16 is the graph of the noise simulated in the “Measure point”:
5 Previous studies
22
Figure 16. Output noise coming from the circuit without filter.
Without filtering the signals, the output noise has a width of approximately 12 mV peak
to peak.
Figure 17 shows the new schematic with the filters on the circuit. To reduce the noise
beyond 0,15 mV it is necessary to isolate the circuits that create noise, for this reason a low
resistor is placed at the entrance of the PWM line, R3 = 4,7 Ω. Placing a resistor instead of
a ferrite bead is because a ferrite bead cannot filter the PWM frequency of 20,48 kHz.
In the digital input, a ferrite beam has been placed because the high frequency of the
noise coming from this circuit. The ferrite beam has an impedance of 1 kΩ at 100 MHz
(1000ohm_at_100MHz).
Figure 17. Schematic power circuit with filter.
The figure 18, is the graph of the noise simulated in the “Measure point” of the figure
17:
5 Previous studies
23
Figure 18. Output noise coming from the circuit with filter.
With the filters placed on the circuit, the noise is reduced up to 0,14 mV peak to peak
5.5 Filter in the sensing circuit.
The aim of this measures is to observe how the noise variates when the output filter is
removed from the sensing circuit
The study consists on measure three different resistors (390 Ω, 5,6 kΩ and 560 kΩ) using
a MOXstick with a filter in the sensing circuit and a MOXstick without the filter. In the
figure 19 are represented both schematics. These schematics are used for represent the
hardware modifications, in this point the results are measured.
Figure 19. On left, sensing circuit with filter. On right, sensing circuit without filter.
The steps done to do this study are:
1. Using a MOXstick without decoupling lines, measure with the three resistors.
2. Modify the MOXstick by removing the capacitator and the resistor.
3. Measure with the three resistors.
4. Compare the results with a graph and with the standard deviation.
5 Previous studies
24
Figure 20. Filter in the sensing circuit R = 390 Ω case .
Figure 21. Filter in the sensing circuit R = 5,6 kΩ case.
Figure 22. Filter in the sensing circuit R = 560 kΩ case.
In the figures 20, 21 and 22 are represented measures that have been obtained from
measuring the different resistances under the conditions previously explained. In the table 8,
it is calculated the standard deviation of the results. Although the measures without filter
378
380
382
384
386
388
390
392
394
1
13
25
37
49
61
73
85
97
10
9
12
1
13
3
14
5
15
7
16
9
18
1
19
3
20
5
21
7
22
9
24
1
25
3
26
5
27
7
28
9
Impedance (Ω)
Measures
Rnominal = 390 Ω
Nofilter
Filter
5500
5510
5520
5530
5540
5550
5560
1
15
29
43
57
71
85
99
11
3
12
7
14
1
15
5
16
9
18
3
19
7
21
1
22
5
23
9
25
3
26
7
28
1
29
5
30
9
Impedance (Ω)
Measures
Rnominal = 5,6 kΩ
Nofilter
Filter
360000
380000
400000
420000
440000
460000
1
15
29
43
57
71
85
99
11
3
12
7
14
1
15
5
16
9
18
3
19
7
21
1
22
5
23
9
25
3
26
7
28
1
29
5
Impedance (Ω)
Measures
Rnominal = 560 kΩ
Nofilter
5 Previous studies
25
have a lower standard deviation in one case, the filter will be placed because of the
magnitude of the sensors resistances which normally are bigger than kΩ magnitude.
Standard deviation Without the filter With the filter
R = 390 Ω 591,958 mΩ 598,194 mΩ
R = 5,6 kΩ 1,7619 Ω 1,5298 Ω
R = 560 kΩ 2,948 kΩ 2,579 kΩ
Table 8. Standard deviation of the 3 resistors.
5.6 Analog noise.
Using the schematic from the point 5.4 Filter for the output noise, it is simulated the
noise in the analog input of the MCU. This analog input is used as a voltage reference for
the ADC and DAC of the MCU, if there is any noise on this line it will appears in the
measure.
Figure 23. Schematic power circuit with filter
Figure 24 is the simulation of the voltage at the “Measure point” of the figure 23, the
ferrite beam reduces the high frequency noise that comes from the digital circuit but not the
low frequency noise coming from the PWM (20,47 kHz).
The noise simulated in this point should be lower than 0,15 µV, but as it is possible to
see in the figure 24 the noise is bigger than 100 µV.
5 Previous studies
26
Figure 24. Input analog noise
To reduce the low frequency noise, it is necessary a low impedance at the entrance of
this line.
Figure 25. Power circuit with the complete set of filters.
5 Previous studies
27
Placing the resistors produces a downgrade of the voltage that the analog input power of
the MCU receives.
Figure 26 simulates the voltage at the “Measure point”, of the figure 25. With the resistor,
the noise is lower than 0,1 µV.
Figure 26. Input analog noise with the filter
6 Hardware.
This section presents the hardware development.
It is divided in 7 points:
Standard components: which equip the miniMOX, are introduced the
components in this point.
Sensor: which can be equipped by the miniMOX, are presented in this point.
Heater protection calculation: it is introduced calculations for protect the sensor
placed in the board.
Bill of materials: it is showed all the components in the miniMOX board.
6.1 Standard components.
In this point, the most important components that compose the miniMOX are explained.
All the components placed in this project have been chosen because they are stand inside
the company.
6.1.1 Microcontroller
The microcontroller is the main part of the board. It is used for storing and executing a
firmware written in the program memory.
6 Hardware
28
Figure 27. Pinout/Block diagram of the MCU ATXMEGA128AU [4]
The figure 27 represents the pinout of the ATXMEGA128A4U-MH is a 16-bit low
power AVR MCU featuring 128kB self-programming flash program memory, 4 kB boot
code section, 8 kB SRAM, 2048-byte EEPROM, external bus interface, 4-channel DMA
controller, 8-channel event system and up to 32 million instructions per second (MIPS)
throughput at 32 MHz clock frequency.
The MCU has 12 analogic pins which can be configured as an output for the DAC or as
an input for the ADC. It also has 18 digital pins which can be used for creating a PWM;
some of these pins can be implemented as a USB interface, a I2C communication interface
or a SPI communication.
This MCU is a standard product in the company used in many different projects. For this
reason, the company has developed several libraries for this MCU during these last years,
which can be used to implement the firmware; an example of this is the bootloader.
For this project, it is used at least 2 pins for the USB, 2 pins for the I2C, 4 pins for the
ADC, 2 for the DAC, 2 for the PWM, 3 for the different LED and one connected to the PWM
power supply as a security check, although it is not currently used for this project it is
connected for further versions.
This MCU has a direct memory access (DMA) feature to write data from the peripheral
devices directly to the memory independently of the processing unit.
The EEPROM of this MCU can save enough data for this project, such the calibration
values and information about the sensor equipped.
In the table 9 shows the main characteristics of the MCU:
Power supply voltage (Vcc) 1,6 - 3,3 V
6 Hardware
29
Analog supply voltage (AVcc) 1,6 - 3,3 V
Clock frequency when Vcc = 3,3 V (MHz) 0 – 32 MHz
Digital pins 18
Analog pins 12
Maximum current in pin IO 20 mA
Flash memory 128 KB
Bootloader section memory 8 KB
SRAM 8 KB
EEPROM 2 KB
Table 9. Main characteristics ATXMEGA128A4U
6.1.2 MOSFET channel P.
A MOSFET is used to drive the PWM. A P channel MOSFET is useful for switching
positive supply of a target circuit on and off. In this case the supply voltage is the same
voltage than the MCU digital voltage; for this reason, there would be placed a security
resistor to avoid an overpower in the sensor which could break it. The resistor calculation is
described in point 6.3 Heater Protection Calculation.
A pull up resistor of 10 KΩ is placed between the gate and the source to avoid that the
MOSFET changes the state when the board is connected to the power supply.
Figure 28. Pinout MOSFET NXP2301P [5]
In the figure 28 it is represented the NXP2301P. It is a P channel MOSFET in a SOT-23
package. This MOSFET has a RDS of 0,1 Ω at VDS = -4,5 V and the power dissipation is 750
mW.
The operation times of this MOSFET are low; they are represented in the table 10:
Turn-on delay time (ns) 7
Rise time (ns) 15
Turn-off delay time (ns) 50
6 Hardware
30
Fall time (ns) 25
Table 10. Operation time MOSFET NXP2301P
6.1.3 Operational amplifier.
The operation amplifier has been placed to act as a voltage follower and separate the
different stages in the sensing circuit.
The sensing circuit includes two voltage followers, as this project can support two
sensors, inside the package should be 4 operational to reduce space and cost.
Figure 29. Pinout operational amplifier AD8604ARUZ [6]
The operational amplifier AD8604 has been placed on this board. It is a quad rail-to-rail,
input and output; single-supply amplifiers featuring very low offset voltage, wide signal
bandwidth, low input bias current and high speed.
The table 11 shows different values of this operational amplifier:
Supply voltage range (V) 2,7 – 5
Slew-rate (V/µs) 5
Bandwidth (MHz) 8,4
Table 11. AD8604ARUZ table
6.1.4 Voltage regulator.
A voltage regulator is used to reduce the voltage from 5 V, that supplies the USB port,
to a voltage that the MCU can work, in this case the voltage should be 3,3 V.
It is important to have a low noise voltage regulator, because this voltage regulator is
connected to the analog circuit and the power circuit, and if there is noise in the analog circuit
the measures coming from the sensor could show this noise.
Figure 30. Pinout voltage regulator LM3480IM3-3.3/NOPB [7]
6 Hardware
31
The LM3480IM3-3.3/NOPB is a quasi-low dropout (LDO) linear voltage regulator in 3
pin SOT-23 package. It features an ensured maximum dropout of 1.2V at 100mA load.
6.1.5 BME 280.
The BME 280 is an integrated environmental sensor with small size and low power
consumption.
Figure 31. BME 280 pinout [8]
It has two power pins one for the digital power (VDDIO), and other for the analog power
(VDD). The CSB pin is used to select the communication interface; the BME 280 supports
I2C and SPI (3-wire/4-wire) digital, serial interface. The communication interface for this
project is the I2C; the pinout needs to be connected as it is represented in the figure 32:
Figure 32. I2C connection diagram [8]
The pin SDO sets the address of the device, in this project this pin is connected to
VDDIO, the address of the BME for the I2C communication interface is: 0x77. The pin SDI
is the data pin of the I2C interface, it is connected to the SDA pin of the MCU and the SCK
is the is the clock pin when the BME is connected in I2C interface, it is connected to the
SCL pin of the MCU. Both lines, the SDA and the SCL, have a pull up resistors of 4,7 KΩ.
The CSB pin is the chip select status; for the I2C interface it is connected to the VDDIO; if it
is not connected to the VDDIO then the SPI interface will be active.
The internal diagram of the BME 280 is described in the figure 33:
6 Hardware
32
Figure 33. Block diagram of BME 280 [8]
6.2 Sensors.
This point introduces the sensors that the miniMOX can equip are introduced. Table 1.
Sensors compatibiliy in section 4 Specifications describes different sensors that the
miniMOX can equip.
In these sensors, the supply voltage for the heater (VH) can be operated in pulsed PWM
mode to reduce the power consumption.
The sensor resistance (RS) is typically determined using a series load resistor (RL). The
RL is different for every sensor.
The response of the sensor is defined as the sensor’s resistance in air (Ra) divided by the
sensor’s resistance at a specific gas concentration level at 50 % relative humidity and 25 ºC
ambient temperature (Rg). Every performance graphs are given as response versus
concentration in ppm.
6.2.1 CC801
The CCS801 sensor is an ultra-low power gas sensor for monitoring indoor air quality
including Carbon Monoxide (CO) and a wide range of Volatile Organic Compounds (VOCs)
such ethanol.
The figure 34 shows the electrical characteristics of the CCS 801 sensor:
6 Hardware
33
Figure 34. CCS801 electrical characteristics [9]
In the figure 35 is represented the response of the CCS801 for different gasses.
Figure 35. CCS801 performance [9]
6.2.2 CCS803
The CCS803 is an ultra-low power MOX gas sensor for monitoring ethanol.
The figure 36 shows the electrical characteristics of the CCS 801 sensor:
6 Hardware
34
Figure 36. CCS803 electrical characteristics [10]
In the figure 37 is represented the typical response range:
Figure 37. CCS803 performance [10]
6.2.3 TGS8100.
The TGS8100 is housed in a surface-mount ceramic package. It requires a heater power
consumption of 15 mW, which makes it suitable for low-power equipment. This sensor, with
MEMS technology, has a high response to low concentrations of gaseous air contaminants
such as cigarette smoke and cooking odours.
The figure 38 shows the electrical characteristics of the TGS8100 sensor:
Figure 38. TGS8100 electrical characteristics [11]
6 Hardware
35
The figure 39 represents response characteristics:
Figure 39. TGS8100 performance [11]
6.2.4 MICS-2714
The MICS-2714 is a robust MEMS sensor for nitrogen dioxide and leakage detection.
The figure 40 shows the electrical characteristics of the MICS-2714 heater:
Figure 40. MICS-2714 electrical characteristics [12]
The figure 41 represents the response performance:
6 Hardware
36
Figure 41. MICS-2714 performance [12]
6.2.5 MICS-4514
The MICS-4514 is a compact MOS sensor with two independent sensing elements on
one package. It is a robust MEMS sensor for the detection of pollution from automobile
exhaust. The package is composed by two sensors; the sensor named RED detects the CO
and the sensor named OX detects the NO2.
The figure 42 shows the electrical characteristics of the MICS-4514 heaters:
Figure 42. MICS-4514 electrical characteristics [13]
The figure 43 represents the response performance:
6 Hardware
37
Figure 43. MICS-4514 performance [13]
6.2.5 MICS-5524
The MICS-5524 is a MEMS sensor for indoor carbon monoxide and natural gas leakage
detection; it is also suitable for indoor air quality monitoring; breath check and early fire
detection.
The figure 44 shows the electrical characteristics of the MICS-5524 heater:
Figure 44. MICS-5524 electrical characteristics [14]
The figure 45 represents the response performance:
6 Hardware
38
Figure 45. MICS-5524 performance [14]
6.2.6 MICS-5914
The MICS-5914 is a MEMS sensor for ammonia detection; it is also suitable for gas leak
detection and indoor and outdoor air quality.
The figure 46 shows the electrical characteristics of the MICS-5914 heater:
Figure 46. MICS-5914 electrical characteristics [15]
The figure 47 represents the response performance:
Figure 47. MICS-5914 performance [15]
6 Hardware
39
6.3 Heater protection calculation
In this point are presented the heater protection calculations. This protection is placed to
avoid injecting to the sensor a higher power than the recommended by the manufacturer. In
the case of giving a higher power than the recommended it could be destroyed.
This protection is only calculated for the sensors CCS 801, TGS8100 and MICS-5914;
because these three sensors have been tested during the development of this project.
It is necessary to check if the protection is needed; by calculating the duty cycle without
this resistance. The equation 1 gives the duty cycle of the PWM:
D = Veff2 / VDD
2 (1)
In table 12 it is calculated the duty cycle with numbers for sensors tested in the project
in the case of not placing the protection resistance:
Sensor Supply voltage (VDD) Recommended
heater voltage (Veff)
Duty Cycle (D)
CCS801 3,3 V 1,4 V 17,99 %
TGS8100 3,3 V 1,8 V 29,75 %
MICS-5914 3,3 V 2,2 V 44,44 %
Table 12. Duty cycle calculations
As we can see in table 3, the duty cycle calculate with the supply voltage is very narrow.
For this reason, for having a wider range of duty cycle in the PWM and take advantage of
the full range of it is necessary to reduce the supply voltage that arrive to the heater of the
sensor.
To calculate the value of the protection resistance is necessary to calculate the heater
resistance when is working with in continuous mode, when width of the PWM is equal to
the period. Using the continuous power consumption given in the datasheet and the
recommended heater voltage, it is possible to calculate the heater resistance when it is
working with the continuous power consumption. The equation 2 gives the resistance with
the power and the recommended heater voltage; the equation 3 gives the current with the
heater resistance and the recommended voltage:
RH = Veff2 / P (2)
IH = Veff / RH (3)
In the table 13 is calculated the resistance of the heater and the current when is working
at the recommended heater voltage:
Sensor Recommended
heater voltage (Veff)
Power
recommended (P)
Heater
resistance (RH)
Current (IH)
CCS801 1,4 V 33 mW 59,39 Ω 23,57 mA
TGS8100 1,8 V 15 mW 216 Ω 8,33 mA
6 Hardware
40
MICS-
5914
2,2 66 mW 73,33 Ω 30 mA
Table 13. Heater resistance and current in continuous power consumption
The resistors placed in the project are oversized because under certain conditions it is
necessary to have a high power in the heater. For calculate the new voltage in the heater
when it is in continuous mode it is necessary to consider the resistor of 3 Ω (Rcomm) in the
input of the power, which filters the noise of the PWM. The equation 4 gives the maximum
voltage in steady state:
NVDD = (VDD · RH) / (Rcomm + RH + RLOAD) (4)
In the table 14 it is shown the resistors placed and the maximum voltage that the heater
sees in continuous mode and the new duty cycle using the equation 1:
Sensor Load Resistor
(RLOAD)
New heater Voltage
(NVDD)
New Duty
Cycle (ND)
CCS801 49,9 Ω 1,745 V 64,33 %
TGS8100 150 Ω 1,93 V 86,82 %
MICS-5914 22 Ω 2,46 V 79,99 %
Table 14. Resistor and heater Voltage
Placing the load resistor guarantees to have a wider range to use the PWM without
overcome the recommended power from the manufacturer. The new duty cycle is a
theoretical calculation. For more safety, there is a limitation on the firmware that avoid the
user to set a width which can give a higher power in the heater than the recommended, it is
calculated for the sensors CCS801 and TGS8100 in point 7.5 Heater protection.
6.4 Schematic
The schematics are divided in two different pages. In the first page of the schematic,
there are the MCU such ADC, the PWM outputs from the MCU or the programmer
connections. In the second page, there are the sensing circuits for every sensor as well as the
PWM driver.
To see the schematic file, see Annex 3. Schematic.
6.5 Layout
The miniMOX board uses two layers due to the easy access to the components as the
board will be mounted by hand.
In the top layer are placed the standard components that all the miniMOX’s are equipped
with, such as the MCU or the BME 280. Also in this layer are placed the CCS sensors pads
and the TGS8100 pads. In the bottom layer, which mostly is the ground of the circuit, are
placed the pads for the SGX and the MOGA sensors.
To see the board layout, see Annex 4. Board Layout.
6.6 Bill of materials.
Table 15 presents all the components that are placed in the board, with the name given
in the project, the package and the quantity of elements per board.
6 Hardware
41
Component Quantity Package Name in the board
MOSFET channel P 2 SOT-23 T1, T2
Resistor 150 Ω 1 0402 Rsen0
Resistor 49,9 Ω 1 0402 Rsen1
Resistor 10 Ω 1 0402 R11
Resistor 2,5 KΩ 3 0402 R1, R2, R3
Resistor 220 KΩ 1 0603 R5
Resistor 20 KΩ 1 0603 R7
Resistor 3 Ω 1 0603 R15
Resistor 330 KΩ 1 0402 R4
Resistor 4,7 KΩ 2 0402 R9, R10
Resistor 5 Ω 1 0402 R16
Resistor 10 KΩ 2 0402 R12, R13
Resistor 1 KΩ 2 0402 R6, R8
Capacitator 100 nF 4 0402 C1, C2, C3, C13
Capacitator 10 nF 2 0402 C4, C8
Capacitator 10 µF 1 0402 C5
Capacitator 4,7 µF 2 0402 C6, C7
Capacitator 47 µF 1 0805 C9
Capacitator 1 µF 3 0402 C11, C12, C14
AD8604 1 TSSOP14 IC2
Ferrite bead 1KΩ at
100 MHz
2 0603 L2, L3
Ferrite bead 2,5KΩ at
100 MHz
1 0603 L1
LM3480 1 SOT23 IC3
SP0503 1 SOT143-R DN1
6 Hardware
42
XMEGA128A4U 1 PW IC1
Green LED 1 0603 LED3
Yellow LED 1 0603 LED2
Red LED 1 0603 LED1
Table 15. miniMOX bill of materials
7 Firmware
This section presents the main parts of the firmware developed for miniMOX. As it is
based on other project it is presented only the modified parts and the new parts.
This section is divided in six different points:
Clocks and timers: explains the settings of the CPU clock and timers’
initialization.
ADC and DAC: explains the ADC and DAC functions.
PWM: explains all functions about the PWM.
Conversion function: explains the functions integrated for doing the conversion
of voltage or percentage to PWM width.
Heater protection: justifies the heater protection by firmware.
Commands and parameters: explains the commands and the parameters that can
be sent to the miniMOX.
7.1 Clock and timers
This point describes the code implemented for setting the clock of the MCU and the
timers used in the Firmware.
7.1.1 Clock setting.
For setting the frequency of the clock in the MCU is important to know how are they
distributed. The figure 1 shows the distribution of the clock in the XMEGA AU controllers:
Figure 48. Clock distribution [4]
7 Firmware
43
As it is represented in the figure 1 the USB module clock selection is independent of and
separate from the main system clock selection and setup are done using the main clock
control.
“The USB module requires a minimum 6MHz clock for USB low speed operation, and a
minimum 48MHz clock for USB full speed operation. It can be clocked from internal or
external clock sources by using the internal PLL, or directly from the 32MHz internal
oscillator when it is tuned and calibrated to 48MHz. The CPU and peripherals clocks must
run at a minimum of 1.5MHz for low speed operation, and a minimum of 12MHz for full
speed operation” [4].
[Confidential]
Code 1. Clock setting.
The code 1 is the code from the clock settings, which calibrates the 32MHz internal
oscillator to 48 MHz; this oscillator is the source for the USB operation.
The PLL is used for multiply by 5 and divide by 4 to have a system clock of 60 MHz.
The figure 49 represents how the prescalers work:
Figure 49. System clock selection and prescalers [4]
Using the MCU prescalers is possible to reduce the clksys to the MCU maximum
frequency of work, which is 32 MHz. Dividing the clksys by 2 in the prescaler A the clkper4,
the clkper2, the clkcpu and the clkper are set in a frequency of 30 MHz.
7.1.2 Timer configuration
For this project are used two timers, except from the PWM timers; these timers are used
for generate an interruption every 25 ms and for triggering the events of the ADC.
The timers are initialized in different functions; the code 2 corresponds the initialization
of the timer that generates an interruption every 25 ms:
[Confidential]
Code 2. 25 ms interrupt generation.
The code starts enabling the timer, and sets the overflow interruption; this means that
when the counter exceeds the period, it will activate the interruption.
The resolution of the timer is 300.000, this means that the clkper is divided by 64.
To set the different parameters during the initialization of this timer it has been calculated
until when the timer should count with the frequency set to have an interruption every 25
ms. The equation 5 calculates the number of increments that are in one second by dividing
the frequency with the resolution. The equation 6 calculates the time for one increment in
the timer:
7 Firmware
44
300.000.000 / 64 = 468.750 tick/s (5)
1 / 468.750 = 2,133 µs/tick (6)
To generate the overflow interruption the counter needs to count from 0 to 11719. The
equation 7 divides the time desired time to call the interruption function by the time for one
increment, calculated in the equation 6, to calculate the number of increments that are needed
to call the interruption function:
25000 / 2,133 = 11720 (7)
The code 3 corresponds to the initialization of the timer for triggering the events in the
four channels of the ADC in equidistant moments:
[Confidential]
Code 3. Event timer initialization
The frequency of the timer must be set at 12,8 KHz as it is calculated in the equation 8
to reduce the noise of the measures; it is necessary to do the 256 measures of the ADC in the
50 Hz, see point 7.2.4 Multiple channel reading for information about the measures.
The equation 9 gives the period of the timer:
50 · 256 = 12800 Hz (8)
1 / 12800 = 78,125 µs (9)
The code starts enabling the event system to fire the events and assigns different channels
to fire the different events. Then it enables the timer. It sets the timer as normal and counting
in the up direction.
The frequency of this timer is half the frequency of the clkper. The equation 10 calculates
the time for one single increment in the timer:
2 / 300.000.000 = 0,00666 µs/tick (10)
The counter of this timer must count from 0 to 1172; the equation 11 calculates the
number of increments for reset de timer:
78,125 / 0,0066 = 1173 (11)
The period of this timer is divided by five due to have 4 events plus the synchronization
of them. The equation 12 gives the time between the triggers:
1173 / 5 = 235 (12)
At the end of the code; it is enabled the different events and the timer.
7.2 ADC and DAC
This point explains the ADC and DAC functions such initialization, set voltage or
measure.
7.2.1 Initialization
The first step to initialize the ADC is to configure the pins of the ADC as an input pins.
In the code 4 it is represented how it is done:
[Confidential]
Code 4. ADC pin configuration.
7 Firmware
45
Every pin initialize corresponds to one pin of the MCU in the table 16 shows the
correspondence:
[Confidential]
Table 16. ADC pin correspondence
It is necessary to clear the default configuration of the ADC; to set only the registers
needed for this project. The ADC module has the following configuration which is
implemented in the code 5:
Signed, 12 – bit results right-adjust.
Internal 1 V voltage reference.
150 KHz maximum clock rate.
Event trigger to start conversions.
Callback function.
[Confidential]
Code 5. ADC configuration.
As this library is standard in this company it is possible to configure the ADC measures
to work with the callback function or directly with the DMA. The DMA have not been
neither created nor modified during the development of this project.
After configuring the ADC is necessary to enable the measures. In point 7.2.3 Multiple
channels configuration and in point 7.2.5 Single channel configuration are explained the
different configurations to do the measures.
In this function the DAC is also initialized. As the configuration of the ADC first is
necessary to define the pins as an output and initialize them as low value, 0 V. the code 6
corresponds to the initialization of the pins for using the DAC:
[Confidential]
Code 6. DAC pins configuration.
Every pin initialize corresponds to one pin of the MCU in the table 17 shows the
correspondence:
[Confidential]
Table 17. DAC pin correspondence
The code 7 corresponds to the configuration of the DACs:
[Confidential]
Code 7. DAC configuration.
The DACs are programed for working in the following way:
The 1 V internal reference.
Value right-adjusted.
Conversions manually trigged.
After configuring the DAC is necessary to enable it. At the end of the function it is called
the function for setting the voltage in the DAC; for more details see the point 7.1.2 Voltage
set DAC.
7 Firmware
46
The default values for calibrate the DAC are not used; for this reason, the calibration
values are read from the EEPROM; the calibration program saves the values in the
EEPROM. For more details check the point 8.2 Calibration Software.
7.2.2 Voltage set DAC
This function sets a new voltage to the DAC. First it waits until the channel is ready and
then it calls the predefined function from the ATMEL libraries to set the new voltage.
This function sets the voltage for only one DAC; for this reason, there are two functions
which are the same but with different channel.
The code 8 sets the DAC for the sensor 1 to the voltage desired:
[Confidential]
Code 8. DAC voltage set.
7.2.3 Multiple channels configuration
This function configures the ADC for reading 4 different channels at the same time. It is
called by the function explained in the point 7.2.4 Multiple channels reading. The code 9
sets the ADC to measure, with four channels, the differential voltage between two pins
configured in the initialization:
[Confidential]
Code 9. Multiple channel configuration
The code 9 sets the new conversion parameters such the measure in signed mode, 12 bits
of resolution right-adjusted and the internal 1 V voltage reference, and to sets the sources in
low impedance. Then it configures the different channels to measure desired pins and finally
it starts the conversion for every channel. As the ADC is in event mode; the measures will
be read when the program requires; for more information see the point 7.2.4 Multiple
channels reading.
The table 18 describes the measure of every channel configured in this function:
[Confidential]
Table 18. Channel description.
7.2.4 Multiple channels reading
This function reads the value from the ADC and oversamples. In this project, 256
measures are oversampled and the total result is divided by 4 to return a signed 15 bits’
value. The code 10 corresponds to the measuring and oversample:
[Confidential]
Code 10. Multiple channel reading
First are created the different variables that are required for this project and data to return
is cleaned. The first 4 conversion are ignored.
In this function is called the function explained in point 7.2.3 Multiple channels
configuration which configures the ADC for reading the four channels of the ADC; for more
information see the point.
In the while loop the values are read from the ADC and added to the last value; this loop
saves and adds 256 times in this project. When count arrives 0 the buffer is right shifted and
saved in the pointer reading buffer.
7 Firmware
47
The function that reads the ADC returns the values of the four ADC channels. For
reading the four channels without losing CPU time is used the DMA.
The code 11 is the code of the function for reading the ADC:
[Confidential]
Code 11. ADC read function
There are two types of readings the ADC value; using the DMA or using the
interruptions. If the DMA is defined it will wait to the flag to read and save the values of the
ADC. If it is not defined it will wait for the different interruptions of the channels to read the
ADC value.
7.2.5 Single channel configuration
This function configures the ADC for reading one channel designed by the user. It is
called by the command for reading a single channel. The code 12 sets the ADC to measure
the differential voltage between two pins configured in the initialization:
[Confidential]
Code 12. Single channel configuration
The code 13 sets the new conversion parameters such the measure in signed mode, 12
bits of resolution right-adjusted and the internal 1 V voltage reference, and to sets the sources
in low impedance. Then it configures the channel. It depends on the case introduced by the
user the pins that this function will configure and finally it starts the conversion for every
channel. As the ADC is in event mode; the measures will be read when the program requires;
for more information see the point 7.2.1 Initialization.
The table 19 describes the different cases that are in this function:
[Confidential]
Table 19. Case description
7.2.6 Single channel reading
This function reads the value from the ADC and oversamples. It is called by the
command for reading a single channel. In this project, 256 measures are oversampled and
the total result is divided by 4 to return a signed 15 bits’ value. The code 13 corresponds to
the measuring and oversample for a single channel:
[Confidential]
Code 13. Single channel reading
First are created the different variables that are required for this project and the return
data is cleaned. The first 10 conversion are ignored. The variable count is set to 256; as this
is an internal library the MODE1_COUNT may change for different projects.
In the while loop the values are read from the ADC and added to the last value; this loop
saves and adds 256 times in this project. When count arrives 0 the buffer is right shifted and
saved in the pointer reading buffer.
In this function the ADC works with interruptions and there is not possibility to work
with the DMA.
7 Firmware
48
7.3 PWM
The PWM has been implemented to control the heaters voltage. In this point are
discussed different functions implemented to create and modify the PWM parameters.
7.3.1 PWM initialization
This function initializes the PWM and the HIRES which is an extension of the timer, it
uses the clkper4 to multiply by 4 the frequency of the timer.
The figure 50 is a representation of the timer; it is possible to see that the HIRES
extensions multiplies by 4 the frequency of the PWM at the output of the timer, for this
reason the HIRES does not require any operation, except the initialization.
Figure 50. Timer overview [4].
The code 14 initializes both PWM and the HIRES.
[Confidential]
Code 14. PWM initialization
The code calls the function of the library provided by ATMEL which initializes the
PWM; this function requires the structure of the PWM, the timer to be used, the channel of
the timer and the starting frequency.
It is necessary to set the pin of the PWM at 3,3 V because if the PWM is not started the
heater resistance must not receive power.
The last function enables the HIRES extension in the selected timer or counter.
7.3.2 Frequency setting
This function changes the frequency of both PWM. Although having different PWM
structures, both PWM have the same channel; so, this function changes both frequencies at
the same time.
The code 15 changes the frequency of both PWM:
[Confidential]
Code 15. PWM frequency setting
This function creates a pointer of the PWM configuration structure and points to the
PWM 1 structure or PWM 2 structure depending on the channel; then it sets the correct clock
prescaler and calculates the period for this frequency. Finally, it sets the new period in the
timer.
7 Firmware
49
7.3.3 Setting the width
This function changes the duty cycle of the PWM by setting a new width in the
waveform. For this reason, before calling this function is necessary to calculate the width
with other functions; for more details see the point 7.6 Conversion functions.
As the PWM does not share the channel, they can have different duty cycle.
The code 16 changes the width in the PWM desired:
[Confidential]
Code 16. PWM width setting
This function creates a pointer of the PWM configuration structure and points to the
PWM 1 structure or PWM 2 structure depending on the channel; then the function writes to
the buffer of the channel the new width.
7.3.4 Start the PWM
This function enables the PWM in the selected channel; PWMs can be started
independently.
The code 17 starts the PWM:
[Confidential]
Code 17. PWM starting function
This function creates a pointer of the PWM configuration structure and points to the
PWM 1 structure or PWM 2 structure depending on the channel and a variable called duty.
This structure is used for checking the duty cycle; in case of not having any duty cycle
defined, to protect the sensor, the function sets the duty cycle to 100%, so the heater does
not receive power.
Then it writes the period on the timer; the period is saved on the structure. It enables
comparison counter for the channel selected. And finally, it enables the timer by setting the
correct clock prescaler.
7.3.5 Stop the PWM
This function disables the PWM in the selected channel; PWMs can be stopped
independently.
The code 18 stops the PWM in the selected channel:
[Confidential]
Code 18. PWM stopping function
This function creates a pointer of the PWM configuration structure and points to the
PWM 1 structure or PWM 2 structure depending on the channel; using the mask saved on
the structure it disables the counter channel. Finally, for setting 0 V in the heater voltage it
sets to 3,3 V the pin in the MCU.
7.3.6 Calculate the PWM period
The function returns the period of the PWM; both periods must be the same due to they
work with the same timer.
The code 19 reads the period of the timer:
7 Firmware
50
[Confidential]
Code 19. Period function.
This function creates a pointer of the PWM configuration structure and points to the
PWM 1 structure or PWM 2 structure depending on the channel and reads the variable period
in the structure.
7.4 Conversion functions
The conversion functions have been used for calculate the width of the PWM from a
voltage or a percentage given.
The duty cycle calculated in these points is the duty cycle which arrives at the heater
resistance. The channel P MOSFET inverts the waveform of the PWM that comes from the
MCU; so, if the MCU has a duty cycle of 70%, the duty cycle that arrives at the heater
resistance is the 30%.
7.4.1 Convert voltage to width of PWM
This function transforms the voltage in mV to width for the PWM; this width calculation
is based on the power transmission; the equation 13 corresponds to the power if the voltage
given was in direct current; where P is the power, VDC is the voltage in direct current, IDC
is the current in direct current and Rheater is the heater resistance:
P = VDC ‧ IDC = VDC2 / Rheater (13)
The equation 14 corresponds to the power when the voltage is given by a PWM; where
P is the power, VPWM is the peak of the voltage pulse, IPWM is the current in pulsed mode,
D is the duty cycle of the PWM and Rheater is the heater resistance:
P = VPWM ‧ IPWM ‧ D = (VPWM2 ‧ D)/ Rheater (14)
The equation 15 calculates the duty cycle; where W is the width of the pulse and T is the
period of the PWM:
D = W / T (15)
For doing the conversion is necessary that the powers from the equation 13 and the
equation 14 are the same; if they are equalled and the duty cycle is replaced by the equation
15 it is possible to calculate the width of the duty cycle:
W = (VPWM2 ‧ T) / VDC
2 (16)
In the code 20 is implemented the equation 16:
[Confidential]
Code 20. Convert voltage to width of PWM function.
The function checkPWMwidth(value, channel) is the firmware protection to avoid the
overpower in the sensor; this function is called when the power_check variable is true, as a
default value; for more details see the point 7.5 Heater protection.
7.4.2 Convert width of PWM to voltage
This function converts the width of the PWM to a voltage in mV. For this function is
used the same principle than the point 7.4.1 Convert voltage to width of PWM, in this case
the VDC is isolated.
VDC = VPWM ‧ sqrt(D) (17)
In the code 21 the equation 17 is implemented; where D is defined in the equation 15:
7 Firmware
51
[Confidential]
Code 21. Convert width of PWM to voltage function
7.4.3 Convert a percentage to width of PWM
This function sets the duty cycle from a percentage; it calculates the percentage from the
period. It is based on the equation 15.
The code 22 is the function implemented:
[Confidential]
Code 22. Convert percentage to width of PWM function.
The function checkPWMwidth(value, channel) is the firmware protection to avoid the
overpower in the sensor; this function is called when the power_check variable is true, as a
default value; for more details see the point 7.5 Heater protection.
To avoid working with float numbers the percentage values are passed to this function
as a number from 0 to 9999. For example, a percentage of 70% is passed as 7000.
7.4.4 Convert width of PWM to percentage
This function calculates the duty cycle in percentage from the width.
[Confidential]
Code 23. Convert width of PWM to percentage function.
To avoid working with float numbers the percentage values are returned from this
function as a number from 0 to 9999.
7.5 Heater protection
This point explains the reason of placing a protection in the firmware. Although placing
a resistor between the MOSFET and the heater resistor, it may be necessary to check if the
power is limited.
The heater protection has only been studied for the CCS801 and the TGS8100.
7.5.1 Heater resistance characterization
To calculate and check if this protection is necessary a heater resistance have been done.
The miniMOX have been programed for executing different duty cycles and with an
oscilloscope the peak of the PWM voltage after the MOSFET and after the impedance
protection have been measured.
The figure 4 is the schematic from the final heater driver; it shows the different points
from which the peak voltage is measured in the board.
7 Firmware
52
Figure 51. Measure points schematics.
The equation 18 calculates the effective voltage; where Veff is the effective voltage, Vpeak
is the peak of the wave and D is the duty cycle (from 0 to 1):
Veff = Vpeak ‧ sqrt(D) (18)
The effective voltage is calculated in both sides of the resistance for protect the heater is
possible to calculate the current in the heater resistance and with the current and the effective
voltage is possible to calculate the heater resistance and the power.
The equation 19 is used for calculate the current in the heater protection resistance; the
equation 20 is used for calculate the impedance of the heater resistor and the equation 21
calculates the power of the heater resistor in mW. The Rprot is the heater protection resistance.
I = (V1eff – V2eff )/ Rprot (19)
Rheater = V2eff / I (20)
P = V2eff ‧ I (21)
These 3 equations have been used for calculate the respective values in the table 20.
Duty
cycle
(%)
V1peak
(V)
V1eff
(V)
V2peak
(V)
V2eff
(V)
Current
(mA)
Rheater
(Ω)
Power
(mW)
0 3,08 0 1,4 0 0 ---- 0
10 3,24 1,024 1,52 0,4806 10,90 44,09 5,23
20 3,24 1,448 1,56 0,6976 15,05 46,33 10,50
30 3,24 1,774 1,6 0,8763 18,00 48,68 15,77
40 3,24 2,049 1,64 1,037 20,27 51,14 21,03
50 3,24 2,29 1,72 1,216 21,53 56,46 26,19
7 Firmware
53
60 3,24 2,478 1,76 1,363 22,35 60,98 30,47
70 3,2 2,677 1,76 1,472 24,14 60,98 35,55
80 3,2 2,86 1,8 1,609 25,09 64,15 40,40
90 3,28 3,111 1,88 1,783 26,61 67,00 47,47
100 3,36 3,36 2 2 27,25 73,38 54,50
Table 20. CCS801 heater resistance characterization
The figure 52 is the graph of the power in the heater resistance versus the duty cycle; the
linear trend line gives a linear characterization of the behaviour of the heater impedance. The
equation 22 is the equation of the trend line:
P = -57,74 ‧ D + 57,75 (22)
Figure 52. Power vs duty cycle for the CCS801 sensor
Considering that all heaters in the CCS801 sensors have the same behaviour it is possible
to determine in which duty cycle the PWM gives the maximum power that the manufacture
recommends.
Using the equation 10 and isolating the duty cycle (D) and setting the power to 33 mW,
which is the recommended by the manufacturer. The maximum duty cycle that the PWM
should have to not overpower the sensor is 53,07 %.
For the TGS8100 the procedure has been the same; using the equations 18, 19, 20 and
21 it is possible to fulfil the table 21:
Duty
cycle
(%)
V1peak
(V)
V1eff
(V)
V2peak
(V)
V2eff
(V)
Current
(mA)
Rheater
(Ω)
Power
(mW)
0 3,08 0 1,24 2,04 0 ---- 0
10 3,2 1,011 1,44 1,745 3,710 122,72 1,68
20 3,16 1,413 1,52 1,645 4,889 139,02 3,32
0
10
20
30
40
50
60
100 90 80 70 60 50 40 30 20 10 0
Power (mW)
Duty cycle (%)
CCS801
Power
Lineal(Power)
7 Firmware
54
30 3,16 1,730 1,6 1,505 5,696 153,84 4,99
40 3,16 1,998 1,64 1,363 6,408 161,84 6,64
50 3,2 2,262 1,72 1,216 6,976 174,32 8,48
60 3,16 2,447 1,76 1,363 7,229 188,57 9,85
70 3,16 2,643 1,8 1,505 7,587 198,52 11,42
80 3,16 2,826 1,84 1,645 7,787 209,09 12,95
90 3,12 2,959 1,84 1,745 8,095 215,62 14,13
100 3,36 3,36 2,04 2,04 8,8 231,81 17,95
Table 21. TGS8100 heater resistance characterization
The figure 53 is the graph of the power in the heater resistance versus the duty cycle; the
linear trend line gives a linear characterization of the behaviour of the heater impedance. The
equation 23 is the equation of the trend line:
P = -16,77 ‧ D + 18,37 (23)
Figure 53. Power vs duty cycle for the TGS8100 sensor
Considering that all heaters in the TGS8100 sensors have the same behaviour it is
possible to determine in which duty cycle the PWM gives the maximum power that the
manufacture recommends.
Using the equation 11 and isolating the duty cycle (D) and setting the power to 15 mW,
which is the recommended by the manufacturer. The maximum duty cycle that the PWM
should have to not overpower the sensor is 79,86%.
7.5.2 Code
The code 24 implements the firmware protection for the in the firmware:
[Confidential]
Code 24. Heater protection code.
0
5
10
15
20
100 90 80 70 60 50 40 30 20 10 0
Power (mW)
Duty cycle (%)
TGS8100Power(mW)
Lineal(Power(mW))
7 Firmware
55
There is a variable which reads, from the EEPROM, the maximum duty cycle in which
the sensor can work. The value is saved during the execution of the calibration program; for
more details see point 8.2 Calibration Software.
Then it compares the duty cycle selected with the maximum duty cycle and returns the
duty cycle selected if this is lower than the maximum duty cycle or in any other case returns
the maximum duty cycle.
7.7 Commands and parameters
For information about the commands and the parameters see Annex 8 Commands and
Parameters Guide.
8 Software
In this section are presented different parts of the computer software. This software has
been developed in Python. The reason of developing the software in Python is because this
project is the standard toolkit in the Sniffest: the machine-olfaction competition and the
data acquisition libraries should be set with a high-level programming language.
The graphic interfaces have been created with QT designer and imported to Python with
the PySide library.
This section is divided in four different points:
miniMOX library: explains library for the miniMOX.
Main method: it is explained the main method which contains the initialization
of the program.
Calibration software: it is an internal program that calibrates the DAC and select
the different sensors placed in the board with their own firmware protection and
the load resistors placed
User interface software: it saves and shows the data of the cycle execution in a
real-time graph. It can be used as an example of how to program the cycles in
the miniMOX during the competiton in Python and using the library.
These two programs use the miniMOX library for communicate and recognize the
miniMOX board.
8.1 MiniMOX library
This point explains the library for using the miniMOX. This library allows the used to
communicate with the board in the Windows or Linux OS.
To run this library in Windows OS is necessary to install the pywinusb library. To run it
in Linux OS, the library libusb1 must be installed in the computer.
The miniMOX library consists of two classes and two methods.
8.1.1 Cycles class.
The cycle configuration has different parameters such as the duration or the heater
voltage.
This class is used as a buffer for sending steps of the heater voltage cycle. It saves the
duration of the step, the heater voltage and the Boolean variable of the percentage or
millivolts mode. This class must be called as: [Confidential].
8 Software
56
8.1.2 Sticks initialization.
This method search in all the USB HID devices with Atmel’s vendor and product ID and
checks if the name matches with “minimox”. Then it creates a miniMOX object for each
device that meets the described characteristics and appends them to the sticks list.
This method must be called as: [Confidential].
8.1.3 Release the sticks.
This method stops the communication with the sticks in the list created by the init_stick()
method.
This method must be called as: [Confidential].
8.1.4 minimox class.
This class has the necessary methods for the communication protocol with the miniMOX
board. It allows the user to calibrate the device, set the cycle and read the data from the cycle
as well as from the memory.
This class must be created as: [Confidential].The report parameter is optional, the default
value is None. The device parameter is the name of the device.
The image 54 is the schematic of the sensing circuits, this image can be helpful to
understand the different parameters described in the tables:
Figure 54. Sensing circuits schematic
The table 24 contains the different public variables which are created with the object
initialization:
[Confidential]
Table 22. Public variables in the minimox class
The table 25 contains the name of the private variables that are used in this library:
[Confidential]
Table 23. Private variables in the minimox class
The table 26 contains the different private methods that has the minimox class:
[Confidential]
Table 24. Private methods in the minimox class
The table 27 contains the public methods in the minimox class.
8 Software
57
[Confidential]
Table 25. Public methods of minimox class
8.2 Main method.
The calibration program and the user interface program uses the minimox library which
is explained in point 8.1 MiniMOX library, the same main method which creates the same
object for show a graphic interface; this object is called mainapp and it is an instance of the
MainApp() class. This class inherits the methods and the data from the Ui_MainWindow
class, which is created with the program QT designer, and the QMainWindow, which is in
the Pyside libraries.
The code 25 is the code implemented for the main method:
[Confidential]
Code 25. Main method.
The object mainapp the connection between the buttons and the code to execute. In each
program are described the different functions which are related to the buttons signals.
8.3 Calibration software
All DAC systems experience gain and offset error. These two analog errors can be caused
by many factors in the DAC and in the external signal path. For an improved accuracy, in
ATMEL XMEGA128A4U is possible to calibrate gain and offset errors in DACs. In this
project the nonlinearity errors has not been considered.
The figure 55 represents these analog errors:
Figure 55. Offset and gain errors [16]
The offset error indicates how well the actual transfer function matches with the ideal
transfer function at a single point. The gain error indicates how well the slope of an actual
transfer function matches the slope of and ideal transfer function. And the full-scale error is
the difference between the actual of the DAC and the ideal full-scale value, this error equals
offset error + gain error [16].
This point is presented the calibration program. This is an internal program and it is used
to calibrate the two DACs that miniMOX have and to select heater protections and load
resistors. The ADC has not been calibrated in this program due the fact of the built-in
linearity calibration.
8.3.1 DAC calibration method
The DAC calibration have been done in two different functions, which are based in the
same method.
8 Software
58
The function that calibrates the offset error sets the output of the DAC channel in the
middle (500 mV) and adjusts the offset calibration value until the measured is as close as
possible to the middle value (Vref / 2) [4].
The function that calibrates the gain error sets the output of the DAC channel at the
maximum value (1000 mV) and adjusts the gain calibration value until the measured output
is as close as possible to the top value (Vref · 4095/4096) [4].
These two functions use the same method for finding the correct offset and the correct
gain calibration. The equation 24 is the equation of this method:
Dist = (Result – Expected)2 (24)
Where Dist is the difference between the two numbers; Result is the value measured, and
Expect is the middle value.
The function that calibrates the offset error, sets the DAC value at the middle and the
parameter to set at 0. Whereas the function that calibrates the gain error, sets the DAC value
at the top and the parameter to set at 0.
The equation 24 is continuously applied and the parameters to set are incremented by 10
units if the difference is bigger than 5 and is incremented by 1 unit if the difference is lower
or equal than 5.
When the result of the equation is lower than 0.05 in the offset error calibration or 0.25
in the gain error calibration then they return the parameter to calibrate.
The code 25 is the method implemented in Python to calibrate the offset error:
[Confidential]
Code 25. Offset error calibration method.
The arguments of this method are:
the object minimox, created with the function init_sticks(); see point 8.1.2 Sticks
initialization for more information.
The channel selects the DAC to calibrate; 0 for calibrating the DAC in the sensor
1 circuit and 1 for calibrating the DAC in the sensor 2 circuit.
8.3.2 Methods.
In the table 28 are presented the methods that are in the mainapp class for the calibration
program.
[Confidential]
Table 26. Calibration program methods
8.4 User interface software
This point is explained the user interface software; the software can be divided in 3 parts.
Two threads and a part of the initialization code are the main part of this program.
This user interface prepares the cycles that the user has introduced, reads the data from
the miniMOX, shows it in two graph, one for each sensor and save it in a text file.
8.4.1 Measure Thread
This thread is created for receive, analyse and save the data from the miniMOX. The
code 26 is the main method of this thread:
8 Software
59
[Confidential]
Code 26. Measure Thread code.
First this method checks if the variable log_file is True or False to enable the program
to write in the selected text file.
It uses the minimox object, which is created during the initialization of this program, to
send to the device the cycle configuration and the start command.
When the cycle is running it calls a method from the minimox object which makes a data
analysis from the data sent by the device. The method described in the code 27 returns the
impedance of sensors by calculating the current of the load resistor with the differential
voltage and then, with the current and the voltage it calculates the impedance of the sensor.
[Confidential]
Code 27. Calc_res method.
When the impedance is calculated; the main method of the thread checks if the data
saving in a text file is enable. If it is enabled, it writes the time of the measure and both
impedances.
This is continuously executed, until the user stops it. When the user press the stop button,
the variable run_script is False and this thread stops the loop. Before this thread stops, it
writes the temperature, pressure and relative humidity in the text file, and close the file, if it
is enabled.
8.4.2 Print Thread
This thread updates the BME 280 data in the graphic user interface every 1 second. It is
done in a different thread because of the necessity of execute the measure thread in a time
lower than 25 ms, due to is the lowest default cycle time (1 step of 1 tick).
The code 28 is the code implemented in the main method of this thread. It uses a method
imported from PySide library (setText) to write the text in the text box. At the end of the
loop there is a waiting of 1 second in this method to update the data every second.
[Confidential]
Code 28. Print thread method.
8.4.3 Graphic functions
In this point are presented functions for represent the graphics. To do the graphic it is
necessary to use the Matplotlib library, which is a Python 2D plotting library; it is possible
to download and install the library following the instructions on the official webpage:
http://matplotlib.org/.
The code 29 is executed during the initialization of the main window, and it creates the
graphic.
[Confidential]
Code 29. Graph initialization.
This code also adds inside the graphic area the two subplots one above the other and sets
the x axis and the y axis with the title.
The method addmpl(fig), which is showed in the code 30, is called for preparing the
graphic and its animation.
8 Software
60
[Confidential]
Code 30. Add Matplotlib graphic.
This method sets a new method which is called every 100 ms to refresh and update the
graphic with the new points. The toolbar for the graph have been hidden.
8.4.3 Methods.
In the table 29 are presented the methods that are in the MainApp object.
[Confidential]
Table 27. GUI program methods
9 User manuals
This section references the user manuals which have been written during the developing
of this project are presented.
9.1 Calibration user interface manual
The calibration user interface manual point is the internal manual for calibrate the DACs
of the device and select the sensors equipped with their resistors.
See Annex 6 Calibration manual for the manual.
9.2 Graphic user interface manual
The graphic user interface manual point is given to the clients that buy the miniMOX
and provides a brief overview on how to use the program.
See Annex 7 Graphic User interface manual for the manual.
10 Budget
61
10 Budget
10.1 Unit price.
Code Ut. Summary Price (€)
Point 1 Hardware
H00 Ut Printed PCB 121,88
Board with 18 miniMOX PCB.
One hundred twenty-one eighty-eight cents
H01 Ut NXP2301P 0,0628
Channel P MOSFET, SOT-23 case, continuous drain current -2 A, drain source
voltage -20 V.
Six cents with twenty-eight
H02 Ut CRCW040249R9FKED 0,0125
49,9 Ω ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power
of 63 mW.
One cents with twenty-five
H03 Ut RC0402FR-07150RL 0,0068
150 Ω ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power
of 63 mW.
Six cents with eight
H04 Ut MC00625W0402110R 0,0014
10 Ω ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power
of 62,5 mW.
Zero cents with fourteen
H05 Ut MC0402X104K160CT 0,0049
100 nF ± 10 % ceramic capacitator, 0402 chip size. Nominal voltage 16 V. X5R
dielectric.
Zero cents with forty-nine
H06 Ut RC0402FR-0710KL 0,0068
10 kΩ ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power
of 62,5 mW.
Zero cents with sixty-eight
10 Budget
62
Code Ut. Summary Price (€)
H07 Ut MC0402B103K160CT 0,0047
10 nF ± 10 % ceramic capacitator, 0402 chip size. Nominal voltage 16 V. X7R
dielectric.
Zero cents with forty-seven
H08 Ut MC0603X106M6R3CT 0,181
10 µF ± 20 % ceramic capacitator, 0603 chip size. Nominal voltage 6,3 V. X5R
dielectric.
Eighteen cents with one
H09 Ut CRCW04021K00FKED 0,0125
1 kΩ ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power
of 63 mW.
One cent with twenty-five
H10 Ut MC0402X105M100CT 0,0186
1 µF ± 20 % ceramic capacitator, 0402 chip size. Nominal voltage 10 V. X5R
dielectric.
One cent with eighty-six
H11 Ut MC00625W0402212K49 0,0011
2,49 kΩ ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power
of 62,5 mW.
Zero cents with eleven
H12 Ut ERJ3RBD2002V 0,121
20 kΩ ± 0,5 % resistor, 0603 chip size. Nominal voltage 50 V and nominal power
of 100 mW.
Twelve cents with one
H13 Ut ERJ3RED2203V 0,06
220 kΩ ± 0,5 % resistor, 0603 chip size. Nominal voltage 50 V and nominal
power of 100 mW.
Six cents
H14 Ut MC00625W040213R0 0,0029
3 Ω ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power of
62,5 mW.
Zero cents with twenty-nine
10 Budget
63
Code Ut. Summary Price (€)
H15 Ut CRG0402J330K 0,0042
330 kΩ ± 5 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power
of 63 mW.
Zero cents with forty-two
H16 Ut MCWR04X4701FTL 0,0031
4,7 kΩ ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power
of 62,5 mW.
Zero cents with thirty-one
H17 Ut GRM155R60J475ME47D 0,0746
4,7 µF ± 20 % ceramic capacitator, 0402 chip size. Nominal voltage 6,3 V. X5R
dielectric.
Seven cents with forty-six
H18 Ut GRM21BR60J476ME15L 0,303
47 µF ± 20 % ceramic capacitator, 0805 chip size. Nominal voltage 6,3 V. X5R
dielectric.
Thirty cents with three
H19 Ut MC00625W040215R10 0,0029
5,1 Ω ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power
of 62,5 mW.
Zero cents with twenty-nine
H20 Ut AD8604ARUZ 1,97
Quadruple operational amplifier, bandwidth 8,4 MHz, Slew rate 5 V/µs, supply
voltage from 2,7 V to 5,5 V and TSSOP case.
One euro ninety-seven cents
H21 Ut BME280 8,338
Environmental sensor (humidity, pressure and temperature) I2C communication
Eight euros thirty-three cents and eight
H22 Ut BLM18BD102SN1D 0,0515
Ferrite bead 1 KΩ ± 25 %, 0603 chip size. DC maximum resistance 0,85 Ω, DC
current rating 100 mA.
Five cents and fifteen
10 Budget
64
Code Ut. Summary Price (€)
H23 Ut MMZ1608A252B 0,0715
Ferrite bead 2,5 KΩ ± 25 %, 0603 chip size. DC maximum resistance 0,8 Ω, DC
current rating 100 mA.
Seven cents fifteen
H24 Ut LM3480IM3-3.3/NOPB 0,714
Quasi low dropout voltage regulator, SOT-23 package, fixed output voltage 3,3
V, output current 100 mA, dropout voltage 900 mV
Seventy-one cents and four
H25 Ut SP0503BAHTG 0,417
ESD protection device, SOT-143 package, operating voltage 5,5 V power
dissipation 225 mW
Forty-one cents and seven
H26 Ut XMEGA128A4U 3,91
16-bit microcontroller, VQFN package.
Three euros ninety-one
H27 Ut KPG-1608CGKC-T 0,076
Green LED (570 nm), direct current 20 mA, direct voltage 2,1 V
Seven cents and six
H28 Ut KPG-1608SURKC-T 0,107
Red LED (630 nm), direct current 20 mA, direct voltage 2 V
Ten cents and seven
H29 Ut KPG-1608SYKC-T 0,15
Yellow LED (590 nm), direct current 20 mA, direct voltage 2,05 V
Fifteen cents
H30 Ut Figaro TGS8100 10,80
SMD low power gas sensor for detection of air contaminants
Ten euros eighty cents
H31 Ut CCMOS CCS801 6,841
SMD low power gas sensor for indoor air quality.
Six euros eighty-four cents with one
10 Budget
65
Code Ut. Summary Price (€)
H32 Ut ZX20-B-SLDC 0,162
Micro USB B Plug cover
Sixteen cents with two
H33 Ut ZX20-B-5S 0,678
Micro USB 2.0 type B plug with vertical mounting
Sixty-seven cents with eight
Point 2 Man-hour budget
Code Ut. Summary Price (€)
L01 Hr Man-hour 20,00
Twenty euros
10.2 General budget.
Code Ut. Summary Quantity Price (€) Total (€)
Point 1 Hardware
H00 Ut Printed PCB
Board with 18 miniMOX PCB.
1 121,88 121,88
One hundred twenty-one euros eighty-eight cents
H01 Ut NXP2301P
Channel P MOSFET, SOT-23 case, continuous drain current -2 A, drain source
voltage -20 V.
40 0,0628 2,512
Two euros fifty-one cents with two
H02 Ut CRCW040249R9FKED
49,9 Ω ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power
of 63 mW.
20 0,0125 0,25
Twenty-five cents
10 Budget
66
Code Ut. Summary Quantity Price (€) Total (€)
H03 Ut RC0402FR-07150RL
150 Ω ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power of
63 mW.
20 0,0068 1,36
One euro thirty-three cents
H04 Ut MC00625W0402110R
10 Ω ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power of
62,5 mW.
20 0,0014 0,028
Two cents with eight
H05 Ut MC0402X104K160CT
100 nF ± 10 % ceramic capacitator, 0402 chip size. Nominal voltage 16 V. X5R
dielectric.
80 0,0049 3,92
Three euros ninety-two cents
H06 Ut RC0402FR-0710KL
10 kΩ ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power of
62,5 mW.
40 0,0068 2,72
Two euros seventy-two cents
H07 Ut MC0402B103K160CT
10 nF ± 10 % ceramic capacitator, 0402 chip size. Nominal voltage 16 V. X7R
dielectric.
40 0,0047 0,188
Eighteen cents with eight
H08 Ut MC0603X106M6R3CT
10 µF ± 20 % ceramic capacitator, 0603 chip size. Nominal voltage 6,3 V. X5R
dielectric.
20 0,181 3,62
Three euros sixty-two cents
10 Budget
67
Code Ut. Summary Quantity Price (€) Total (€)
H09 Ut CRCW04021K00FKED
1 kΩ ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power of
63 mW.
20 0,0125 0,25
Twenty-five cents
H10 Ut MC0402X105M100CT
1 µF ± 20 % ceramic capacitator, 0402 chip size. Nominal voltage 10 V. X5R
dielectric.
60 0,0186 1,116
One euro eleven cents with six
H11 Ut MC00625W0402212K49
2,49 kΩ ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power
of 62,5 mW.
60 0,0011 0,066
Six cents with six
H12 Ut ERJ3RBD2002V
20 kΩ ± 0,5 % resistor, 0603 chip size. Nominal voltage 50 V and nominal power
of 100 mW.
20 0,121 2,42
Two euros forty-two cents
H13 Ut ERJ3RED2203V
220 kΩ ± 0,5 % resistor, 0603 chip size. Nominal voltage 50 V and nominal power
of 100 mW.
20 0,06 1,20
One euro twenty cents
H14 Ut MC00625W040213R0
3 Ω ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power of
62,5 mW.
20 0,0029 0,058
Five cents with eight
10 Budget
68
Code Ut. Summary Quantity Price (€) Total (€)
H15 Ut CRG0402J330K
330 kΩ ± 5 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power
of 63 mW.
20 0,0042 0,084
Eight cents with four
H16 Ut MCWR04X4701FTL
4,7 kΩ ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power
of 62,5 mW.
40 0,0031 0,124
Twelve cents with four
H17 Ut GRM155R60J475ME47D
4,7 µF ± 20 % ceramic capacitator, 0402 chip size. Nominal voltage 6,3 V. X5R
dielectric.
40 0,0746 2,984
Two euros ninety-eight cents with four
H18 Ut GRM21BR60J476ME15L
47 µF ± 20 % ceramic capacitator, 0805 chip size. Nominal voltage 6,3 V. X5R
dielectric.
20 0,303 6,06
Six euros six cents
H19 Ut MC00625W040215R10
5,1 Ω ± 1 % resistor, 0402 chip size. Nominal voltage 50 V and nominal power of
62,5 mW.
20 0,0029 0,058
Five cents with eight
H20 Ut AD8604ARUZ
Quadruple operational amplifier, bandwidth 8,4 MHz, Slew rate 5 V/µs, supply
voltage from 2,7 V to 5,5 V and TSSOP case.
18 1,97 35,46
Thirty-five euros forty-six cents
10 Budget
69
Code Ut. Summary Quantity Price (€) Total (€)
H21 Ut BME280
Environmental sensor (humidity, pressure and temperature) I2C communication
18 8,338 150,084
One hundred fifty euros eight cents with four
H22 Ut BLM18BD102SN1D
Ferrite bead 1 KΩ ± 25 %, 0603 chip size. DC maximum resistance 0,85 Ω, DC
current rating 100 mA.
40 0,0515 2,06
Two euros six cents
H23 Ut MMZ1608A252B
Ferrite bead 2,5 KΩ ± 25 %, 0603 chip size. DC maximum resistance 0,8 Ω, DC
current rating 100 mA.
20 0,0715 1,43
One euro forty-three cents
H24 Ut LM3480IM3-3.3/NOPB
Quasi low dropout voltage regulator, SOT-23 package, fixed output voltage 3,3 V,
output current 100 mA, dropout voltage 900 mV
18 0,714 12,852
Twelve euros eighty-five cents with two
H25 Ut SP0503BAHTG
ESD protection device, SOT-143 package, operating voltage 5,5 V power
dissipation 225 mW
18 0,417 7,506
Seven euros fifty cents with six
H26 Ut XMEGA128A4U
16-bit microcontroller, VQFN package.
18 3,91 70,38
Seventy euros thirty-eight cents
10 Budget
70
Code Ut. Summary Quantity Price (€) Total (€)
H27 Ut KPG-1608CGKC-T
Green (570 nm) LED, direct current 20 mA, direct voltage 2,1 V
20 0,076 1,52
One euro fifty-two cents
H28 Ut KPG-1608SURKC-T
Red (630 nm) LED, direct current 20 mA, direct voltage 2 V
20 0,107 2,14
Two cents fourteen cents
H29 Ut KPG-1608SYKC-T
Yellow LED (590 nm), direct current 20 mA, direct voltage 2,05 V
20 0,15 3,00
Three euros
H30 Ut Figaro TGS8100
SMD low power gas sensor for detection of air contaminants
18 10,80 194,40
One hundred ninety-four euros forty cents
H31 Ut CCMOS CCS801
SMD low power gas sensor for indoor air quality.
18 6,841 123,138
One hundred twenty-three euros thirty cents with
eight
H32 Ut ZX20-B-SLDC
Micro USB B Plug cover
20 0,162 3,24
Three euros twenty-four cents
10 Budget
71
Code Ut. Summary Quantity Price (€) Total (€)
H33 Ut ZX20-B-5S
Micro USB 2.0 type B plug with vertical mounting
20 0,678 13,56
Thirty euros fifty-six cents
Total Point 1 Hardware…………………………………………………772,19
Seven hundred seventy-two euros nineteen cents
Point 2 Man-hour budget
Code Ut. Summary Quantity Price (€) Total (€)
L01 Hr Man-hour
600 20,00 12.000
Twelve thousand euros
Total Point 2 Man-hour budget…………………………………………………12.000
Twelve thousand euros
Total Project cost………………………………………………………12.772,19
Twelve thousand seven hundred seventy-two euros nineteen cents
11 Further work
This project can be developed further in a near future. In this section is presented some
advises to continue this project.
To characterizes the heater resistors of the different new sensors equipped, during
the developing of project only two heater resistors have been characterized.
To develop a mobile phone software; it is necessary to develop some software
for a mobile phone, preferable to Android or IOS, due to the aim of this device
is to have a small and portable gas sensor.
To study the possibility to develop a new board model which have an EEPROM
to save the data measured from the sensor. This study implies to develop a new
firmware which can send the data to the EEPROM with the I2C communication
protocol, save the data during the cycle execution and send it to the computer or
mobile phone when it is required.
12 Conclusion
72
12 Conclusions
The goal of this project was to release a new product based on an existent product of the
company. The miniMOX is smaller, cheaper, can be equipped with several SMD gas sensor
and can be programed by the user with a high-level program language.
This product and part of this documentation will be used during the Sniffest: the
machine-olfaction competition. This competition is organized by International Symposium
On Olfaction and Electronic Nose which takes part at the end May in Montreal, Canada. The
Universitat Rovira I Virgili participates in this competition with a team.
Although the studies done before the design of the schematic, there are still some
hardware limitations in the measure due to the noise that appears in the data and which
reduces the measure resolution.
During the development of this project, a lot of new knowledge have been acquired.
Apart from the knowledge regarding on the different applications used, it has been necessary
to learn Python and to depth the knowledge with C, microcontrollers, data analysis, circuit
simulation and study and hardware design. All this knowledge has been acquired with an
independent and autonomous learning.
References
73
13 References
[1] Clifford, P., Tuma, D., 1983. Characteristics of semiconductor gas sensors i. steady state gas response. Sensors
and Actuators 3, 233-254.
[2] A. Hulanicki, S. Glab and F., 1991.Ingman. Chemical sensors: definitions and classification. Vol. 63, Issue 9, pp.
1247-1250.
[3] Liu, X., Cheng, S., Liu, H., Hu, S., Zhang, D., Ning, H., 2012. A survey on gas sensing Technology. Sensors 12
(7), 9635-9665.
[4] http://www.atmel.com/images/Atmel-8387-8-and16-bit-AVR-Microcontroller-XMEGA-A4U_Datasheet.pdf
[online] [Free Access] 20/12/2016
[5] http://www.nxp.com/documents/data_sheet/NX2301P.pdf [online] [Free Access] 20/12/2016
[6] http://www.analog.com/media/en/technical-documentation/data-sheets/AD8601_8602_8604.pdf [online] [Free
Access] 20/12/2016
[7] http://www.ti.com/lit/ds/symlink/lm3480.pdf [online] [Free Access] 20/12/2016
[8] https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME280_DS001-11.pdf [online] [Free
Access] 16/12/2016
[9] http://www.ccmoss.com/sites/default/files/documents/CC-000015-DS-11-Datasheet%20for%20CCS801.pdf
[online] [Free Access] 14/12/2016
[10] http://www.ccmoss.com/sites/default/files/documents/CC-000017-DS-11-Datasheet%20for%20CCS803.pdf
[online] [Free Access] 15/12/2016
[11] http://www.figarosensor.com/products/docs/TGS8100%280914%29.pdf [online] [Free Access] 15/12/2016
[12] http://www.sgxsensortech.com/content/uploads/2014/08/1107_Datasheet-MiCS-2714.pdf
[online] [Free Access] 15/12/2016
[13] http://www.sgxsensortech.com/content/uploads/2014/08/0278_Datasheet-MiCS-4514-rev-16.pdf
[online] [Free Access] 15/12/2016
[14] http://www.sgxsensortech.com/content/uploads/2014/07/1084_Datasheet-MiCS-5524-rev-8.pdf
[online] [Free Access] 15/12/2016
[15] http://www.sgxsensortech.com/content/uploads/2014/07/1108_Datasheet-MiCS-5914.pdf
[online] [Free Access] 15/12/2016
[16] https://www.maximintegrated.com/en/app-notes/index.mvp/id/641 [online] [Free Access] 30/12/2016