From EE122B, Introduction to Biomedical Electronics, at Stanford University
Taught by Professor Greg Kovacs, Spring 2014
The problem:
Stress is a pervasive part of the modern fast-paced life. Additionally, there is a growing body of scientific research indicating that the elevated, semi-permanent stress levels many of us face are leading to a variety of health problems. By some, stress is being considered an epidemic.
The idea:
What if we could quickly detect and ameliorate stressful conditions continuously throughout the day? An electronic stress detection system could enable just that. We will present a prototype of an Arduino based stress detection system that uses heart rate, respiration rate, and skin conductance to detect stress.
NB: This lab contains electronics in contact with the human body, which is potentially very dangerous. Never put any un-isolated electronics (drawing power from the wall) in contact with your body. All electronics in this lab must be driven from a 9V battery to ensure safety.
Block diagram:
This stress detector involves three different blocks all connected to analog inputs 0-2 on an Arduino UNO (R3).
The photoplethysmography (PPG) circuit ascertains the user's heart rate.
The thermistor, when placed right below the user's nostril, ascertains the user's breathing rate.
The galvanic skin response (GSR) circuit ascertains the user's skin conductance level - a measurement loosely coupled with perspiration indicative of stressful conditions.
Components:
This project involves some standard components like:
It also involves some less standard components such as:
2N3904 BJT, or other transistor (1)
LM7805, or other 5V regulator (1)
The 9V batteries are necessary for electrical isolation from wall power, and the unusual ICs are for the careful signal conditioning necessary to make the PPG work. We used a Vernier skin temperature sensor for the thermistor, but any model should do.
A photoplethysmogram (PPG) is a measurement of blood volume by light. By measuring how much light passes through, for example, a finger, you can get a relative measurement of how much blood was in the finger. The more blood there is, the less light gets through. By tracking blood volume over time, you can calculate the heart rate of the user.
The circuit for the PPG consists of three main blocks. Those are the LED driver circuit, the photosensor circuit, and the signal conditioning circuit.
Shared Components:
1. PPG finger clip
2. Breadboard
3. Resistors and capacitors
4. Wire
5. Batteries
6. LM7805 Regulator
Note that the LED and photosensor mentioned are built into the PPG finger clip. This clip is very useful and makes measurements easier, but one could also make their own with discrete LED’s and photosensors.
LED Driver Circuit:
Components:
1. LTC1043CN Switched Capacitor Building Block
2. 2N3904 BJT
This circuit is responsible for driving the LED, pulsing it at 2 kHz and 50% duty cycle. The switched capacitor building block takes care of generating the pulsing signal, which is used to drive the BJT which pulls down a current through the LED. The resistors are current-limiters and crucial to operation. Without them the BJT or the LED will blow. The frequency of the signal is set by an external capacitor. We found that 2.2 nF works well, but you might have to tweak that number to get it just right. It's important to get this signal close to 2 kHz as we will use this clock later to set the cutoff for a filter
Photosensor Circuit:
Components:
1. LT1056 op-amp
When struck with light, the photosensor acts as a current source. The op-amp is configured as a bandwidth-limited transimpedance amplifier, providing a voltage to the signal conditioning circuit. When there are different amounts of blood volume in the finger the photosensor will detect different amounts of light, thus providing a changing signal in sync with blood pulses.
Signal Conditioning Circuit:
Components:
1. LTC1043 Switched Capacitor Building Block
2. LT1167CN8 Instrumentation Amplifier
3. LT1112 Dual Op-Amp
4. LTC1064 8th order Butterworth Low-Pass Filter
The first stage of the signal conditioning circuit is the sample-and-hold instrumentation amplifier. During each clock cycle, the switched capacitor building block will switch its output to each of the instrumentation amp inputs. Those inputs have small capacitors for the purpose of holding their value until they get updated the next clock cycle. During the ON part of the clock cycle, the LTC1043CN will push the photosensor signal to one output, and during the OFF part of the clock cycle it will push the value to the other input. This provides a base value of the ambient light for the instrumentation amp to compare the LED light value to, improving the SNR. It is important to have the power rails of the instrumentation amp properly decoupled. A lot of 2 kHz noise can come into it from the LTC1043 clock generator, which would be amplified by this stage if not properly decoupled.
The next stage of the signal conditioning circuit is a high-pass filter with a cutoff of .1Hz on one of the op-amps of the LT1112. This acts as a DC-blocker, making the signal easier to work with in the rest of the signal path.
The stage after that is an 8th order Butterworth low-pass filter with a cutoff frequency of 20Hz. This stage with remove the 2 kHz oscillation in the signal that came from the LED modulation. Pin 10 of the LTC1064 is set to the negative rail, which sets the cut-off frequency of the filter to 1/100 of its clock frequency. This is why it was important to properly set the clock frequency earlier, so the filter would have the proper cut-off.
The final stage is a simple low-pass Sallen-Key filter on the second op-amp of the LT1112. With a cut-off frequency of 100 Hz, it gets rid of the small amount of clock noise that comes from the LTC1064 itself. At the output of this filter you will have a very clean and clear signal from which you can measure the heart rate!
The initial testing of this circuit was done with +- 7.5V rails (the maximum the LTC1043 can handle), but for operation with the Arduino analog pin we had to switch it to 5V rails. The circuit still operates well at this power.
The operation of the respiration circuit is simple in concept, and we maintained that principle of simplicity in our design. We measure the temperature of the air directly outside a person's nostril. As the user breathes in, cool air gets sucked into the nose, lowering the temperature on the sensor. As the user breathes outs, warm air from inside the person comes out, increasing the temperature. By tracking this temperature we can ascertain the user's breathing rate.
To get a reading, we use the thermistor in a voltage divider circuit. As the resistance of the thermistor changes, so does the output voltage of the divider. This signal is low-pass filtered in order to get rid of noise. This filter can have a very low cutoff-frequency, since a person's breathing rate will be in the order of single-digit Hz. The respiration circuit also included a feedback amplifier and high pass filter. The temperature voltage signal was amplified with a gain of 100 and then a high pass filter was used to remove the DC component of the signal. A 0.1Hz cutoff 2-pole Sallen Key filter was used for this purpose.
This signal was then put into one of the Arduino's analog pins. Again, because of the voltage limitations of the Arduino's analog pins it is important to run this with a single-ended power supply of 5V. This ensures that we will not exceed the ratings for the pin.
Galvanic Skin Response is a method of measuring the electrical conductance of the skin. This value varies depending on moisture from sweating on the skin. Sweating can be correlated to physiological stress and hence skin conductance from the GSR can be used to detect this stress.
The following components are required in building a GSR circuit:
The main design of the GSR circuit was based on the feedback gain of through an operational amplifier circuit. As the GSR is measuring the skin impedance across the two leads, the skin resistance itself forms one of the resistors in the op-amp feedback loop. This is seen in the above circuit. Since the circuit does pass DC current into the body it is necessary to ensure the current value is low and that all circuit elements are isolated when connecting to the body. Therefore, a voltage divider is used to obtain a smaller voltage going into the reference signal of the op-amp. This reference signal goes through a voltage buffer before going to the non-inverting terminal of the GSR op-amp. The 9V battery voltage is stepped down to 5V using a voltage regulator in order to be compatible with the arduino analog input pins.
The file attached to this page contains the Arduino code for running the StressTester. Open the "StressTest.ino" master file. The sketch should open, with 3 other tabs - ppg2, respiration, and gsr. Each contains the code responsible for sampling and processing the analog input from the three subcircuits.
Remember, this code expects:
A0: PPG input
A1: GSR input
A2: respiration input
The PPG and Respiration code each contain state machines searching for the rising edges on their respective signals. These rising edges are timestamped and used to calculate a frequency. Depending on the technology employed, it may be necessary to adjust the thresholds used.
Attached is the code for graphing the output from the stress detector. This will require you to have Processing installed. The code will plot the PPG frequency, respiration frequency, and GSR level. At a certain point, the graph will change from green output to red output - indicating a stressful condition.
Now you're ready to get into the thick of things.There is no universal reading that indicates a stressful condition. Most stress detection is attempted via a machine learning algorithm with a lot of data to process, or a calibration process for each user. Play around with the readings you get from different people under different conditions. Use the data you get to adjust the thresholds indicating a stressful condition has taken place. It may be an arbitrary level for each signal, or a function of all three.
Happy stress detecting.