Your task this week is to build a photoplethysmograph. A plethysmograph is a device that measures the amount of blood in part of the body. A photoplethsymograph does this optically. The output of your photoplethysmograph will be the four LED's on your PIC board. At the end of the project you will have your design fabricated onto a PCB. There is a lot of design involved in this lab (which means a lot of missteps and errors along the way -- such is the nature of design). Don't wait until the last minute to do the work.
If you are ambitious you can add software to calculate heart rate and display it on an LCD (liquid crystal display) -- a photoplethsymographic cardiotachometer. However the software to do this is fairly involved.
In theory the photoplethysmograph is simple - it measures the variation in amount of light passing through your finger caused by the pulsatile nature of blood flow. You will place a light source on one side of your finger, and a light sensitive resistor, a Cadmium Sulfide (CdS) cell, on the other side. By monitoring variations in resistance of the CdS cell you get an indication of blood flow in your finger. A simple block diagram of such a system is shown below.
The light passes through the finger and is attenuated a certain amount depending upon how much blood is in the finger. As the amount of light striking the CdS cell varies, so does its resistance. This changing resistance must be transduced, amplified and filtered. The output of the amplifier is sent to an A/D convertor, and finally to the PIC. The relative amount of fluid in the finger should be displayed on the four LEDs. Much fluid (little light) should have all LED's on. Little fluid (much light) should correspond to all LED's off.
The next several sections discuss each of the blocks in the diagram to give you some idea on how to proceed.
Transduction, Amplification, and Filtration
The A/D convertor has limited resolution, so it is first necessary to create a signal of appropriate amplitude (0-5 V). You can use what you've learned over the course of the semester, but there is an added difficulty in that the signal we are trying to generate is from 0 to 5 volts, it never goes negative. In addition, since this device will be battery powered we only have 0-5 V (or 0-9V) to supply our op-amps. You should read the page on single supply design.
The CdS cell changes resistance in response to light. To work with this signal requires that it is transduced into a voltage. Two ways of doing this are shown. The actual values of resistance will have to be worked out.
In the diagrams below, virtual ground is depicted by a green symbol with thick lines, ground by a black symbol.
Method 1 Method 2 Note: Limited voltage gain from this stage. Note: 1) Amplifier may act as load on CdS cell circuit.
2) Can modify op-amp circuit to do filtering as well as amplification.
Virtual Ground Physical Ground
Don't feel limited to these methods, there are many other ways to do this.
Amplifier and Filters
The signal we are trying to observe consists of very small variations (changes in light intensity due to blood flow into or out of the finger), superimposed on a large constant signal (average light flowing through finger). It is only the time varying part of the signal that you would like to amplify, if you were to amplify the signal as it is the DC (constant) part of the signal would saturate the amplifier before you got any decent amplification of the AC (time varying) part. To get rid of the DC signal you can use a high-pass filter. To ensure the signal you are interested in (the photoplethysmograph) is not obliterated by the filter you want to make sure that the cutoff frequency for the filter is below about 1 Hz (a typical heart rate). If high frequency (>10 Hz) noise seems to be a problem, you can use a band pass filter. Refer to the Filter Lab, and the Introduction to Filters, to refresh you memory on how filters can be built. You probably don't need anything as complex as the switched capacitor filter. Remember that most of the filter equations were in terms of radian frequency, w, not Hz frequency, f. We normally speak of Hz frequencies (cycles per second). Recall that w=2pf.
The A/D Convertor
The analog signal from the amplification stage must be digitized before it is read into the PIC microcontroller. For this we use an A/D convertor. The A/D convertor that you built in a previous lab is too insensitive (only 4 voltage levels), so we will use a dedicated chip from National Instruments, the ADC0831 that has 8 bit (256 level) resolution. I have developed some sample code to help you to make easy use of the device.
If you want to try to extend the scope of the project you can add software that will display the time between heartbeats on an LCD display. We are using a serial LCD driver from Wirz Electronics. The data sheet is here. I have developed some sample code to help you to make easy use of the device.
There is a connector on the boards with the ZIF sockets for the serial LCD.
Your completed circuit should have the six LED's lighting up in relation to how much blood is in your finger. The LED's should go through one cycle for each of your cardiac cycles. If you are ambitious, you should time each cycle and display the results on the LCD.
Some things to consider:
- Work steadily, this project will probably not be completed in just a few days.
Build the circuit in stages, and make sure each is working perfectly before continuing. If you are not sure if part of your circuit is working, it probably isn't. Continuing without fixing the problem will just waste your time.
Remember that when debugging the circuit you should should connect a 14 pin ribbon cable to the daughter board (w/ ZIF socket), and a 16 pin ribbon cable to the breadboard. Refer to description in lab 5.
The size of the signal coming from you amplifier will vary from person to person, finger to finger, with temperature, etc... To compensate for this you should have the A/D convertor perform an autoranging process so that you can make full use of your output (4 LED's).
You should wait a few seconds after power up to begin collecting data from the A/D to allow the circuitry to come to equilibrium (capacitors charging, etc.)
Take data for a few seconds, and record the high and low values of A/D output.
Use these high and low values to set the range on your output (4 LED's), rather than just using them to represent 0-5 volts.
If you want, you could set up your circuit to reactivate the autoranging process whenever you push the button.
If you decide to use the LCD controller, there is a connector for it on the daughter board (the 10 pin socket on the right of the board).
When you design your new board, include a 16 pin connector. Both boards will then fit inside your case, connected by a short 16 pin cable.
There is a counter on the PIC that can be used for timing.
You can set the value of the timer with the "SET_RTCC(x)" command, where x is an 8 bit integer. RTCC stands for real-time clock counter.
- You can read the value of the timer with the command "x=GET_RTCC()".
- You can set the rate at which the counter increments with the "SETUP_COUNTERS(rtcc_state,ps_state)". Where rtcc_state should be INTERNAL -- this makes the source for the counter an internal 1 MHz clock. The variable ps_state can be either RTCC_DIV_2, RTCC_DIV_4, RTCC_DIV_8, RTCC_DIV_16, RTCC_DIV_32, RTCC_DIV_64, RTCC_DIV_128, or RTCC_DIV_256. This determines how fast the counter increments. If you set the pre-scaler to 2 (RTCC_DIV_2), the 1 MHz clock is divided by 2 and the counter increments at 500kHz. If you set the pre-scacler to RTCC_DIV_256, the counter increments at 3906 Hz (3906 Hz=1MHz/256).
So, to set the counter you could enter :
- If you use the timer, you need to calibrate the internal oscillator.
- All of the components you need for your PCB layout in EdWin should be in the "A_Swat" libraries on the computers in room 309. If you need any that aren't there, let me know.
- When you lay out the opamps that come more than 1 to a package, it is important that EDWin knows that you want all the op-amps to be in the same package. When you put the op-amps into the design (with "Create Component" from the capture program, the first op-amp should use "OPAMP" as its symbol (there is a box for it in the "Create Component" dialog box). For the other op-amps, you should use the symbol "OPAMPA". This will give you one op-amp that has power attached to it, and other symbols without power. If you need more than 4 op-amps (you shouldn't), you will need to put another "OPAMP" symbol on your schematic.
- Get the whole circuit built and working before starting on the PC board.
To Turn in:
- Document your design process, what worked, what didn't, explain your design choices.
- Turn in your finalized design.
- Include data that verifies that the circuits work as expected.
- Demonstrate your working circuit to me.