Вы находитесь на странице: 1из 10

For more products visit our website http://www.sunrom.

com

Document: Datasheet

Date: 10-Apr-13

Model #: 1181

ECG Sensor
View, plot or process ECG signals through this
board. Just hold the board with two thumbs and
you start getting output in analog as well as pulse
output. The sensor is battery operated and the
outputs from sensor are optocoupled to get clean
ECG signals.
Interfacing with PC or microcontroller is very
simple without any external components.
We provide PC software with source code written
in VB.NET to plot the signal.
We also provide sample C code for AT89S52 in
keil compiler to quick start your application.

Products Page: www.sunrom.com/p-1256.html

Interfacing Pin Details


Pin Pin Name
P
Pulse Output

Analog Serially Out

Positive Pull up
Voltage

Ground

Details
Active high Pulse signal as onboard LED blinks on each
heart beat. Can connect directly to any microcontroller pin.
Time between two high going pulses can be used to
calculate heart beat.
BPM(Beats per minute) = 60,000/Time in ms between two
high going pulses
Outputs serial data. 1 byte every 5ms. The serial byte
containing analog level from 0-255 for particular time.
Usually connected to RXD pin of microcontrollers or RS232.
Voltage input from +3V to +5V for internal optocoupler pull
ups. Same voltage level is output at P and S pins.
For Example
MCU is operated at 3V then this pin has to be at 3V.
Ground level of power supply for optocoupler ground.
If using microcontroller this pin has to be board ground

Specifications
Name
Working Voltage

Typ
3V DC

Pull up Voltage required at + pin


Output Reading Rate Every
Analog output(0-255) as
UART baud rate (8 bit data, no parity, 1 stop bit)

3-5
5
1
4800

Unit
CR2032 battery provided
with product
V DC
Mili Seconds(ms)
Byte every 5 ms
bps

Board Details
Optocouplers to isolate board from external
circuits for clean ECG signals

Pulse LED indicating heart beat

ON/OFF Switch

Serial Analog + Pulse


Output

3V Battery
CR2032

Processor
implementing Digital
FIR filtering

Thumb Pads
For Sensing

Instrumentation
Amplifier IC

Sunrom Technologies

Your Source for Embedded Systems

Visit us at www.sunrom.com

Oscilloscope View
To test you can connect the sensor to oscilloscope as below.
ECG SENSOR

P or S signals to scope to view

+5V

Oscilloscope

GND

+5V Regulated
power Supply

1) Pulse output view on P pin


Notice the pulse frequency is around 1Hz, that is for a normal person heart beat.
Shown below in yellow dotted vertical lines.

2) Serial data view on S pin


Notice the byte of serial data is repeated every 5ms, The yellow dotted vertical lines are
markers showing time difference of 5ms between two bytes.

Sunrom Technologies

Your Source for Embedded Systems

Visit us at www.sunrom.com

Block Diagram
The sensor consists of mainly below parts.
The first is instrumentation amplifier with high CMRR(Common Mode Rejection Ration) to remove
the noise induced from body and amplify the difference beween right and left body parts. The left
and right thumbs are input as signal detection of ECG.
The analog amplified ECG voltage is fed to processor to pass through digital FIR filters. High pass
and low pass filters are implemented to get ECG signal of proper range. The processor converts
these signals to analog output in serial format and pulse output. The serial data is 1 byte every 5
mili-second. Each byte can be from 0-255 indicating an analog value of the signal. The pulse output
is also fed to onboard LED to indicate the heart beat and same is output through optocoupler.
Board uses two optocouplers to isolate the board from external voltages since any little noise from
external source can be amplified as noise. So to get clean ECG signal the board is operated from
3V battery isolated from external supplies.

Instrumentation
Amplifier for
ECG Signals

Digital FIR Filter


processor

Analog Output

Optocoupler
output for
Analog Serial

Pulse output
calculated from
Analog output
by detecting the
peak.

Optocoupler
output for Pulse

Pulse LED

Related Links
More about ECG basics http://en.wikipedia.org/wiki/Electrocardiography
Google for Digital FIR filter This board uses digital FIR filter method to get clean ECG signals.
https://www.google.co.in/search?q=Digital+FIR+Filters

Sunrom Technologies

Your Source for Embedded Systems

Visit us at www.sunrom.com

PC Software Plotting
If you wish to plot the sensor signal on PC then we have provided software in Visual Basic.NET with
source code.
Download software+source from this link http://www.sunrom.com/files/1181.zip
Connect the sensor to PC using details given on next pages and run software as below

Source code opened in Visual Basic .NET which is part of Microsoft Visual Studio

Sunrom Technologies

Your Source for Embedded Systems

Visit us at www.sunrom.com

Connecting to PC in two ways


1) Interfacing with RS232 PCs Serial Port
If you wish to interface the module with RS232 level like a PC serial port you can connect as below.
MAX232 and sensor will require external +5V to operate.

S
P
+
-

U9
ECG Sensor SUNROM#1181

VCC

4
3
2
1

C16
100n

P2
DB9-CONN-F
1
6
2
7
3
8
4
9
5

3
2

C+

C2+

C1-

C2-

GND

C13
10uF 16V

V+

+
C14
10uF 16V

V-

14
8
13
7
4

+
C12
10uF 16V

5
6

15

T1OUT
R2IN
R1IN
T2OUT

VCC

T1IN
R2OUT
R1OUT
T2IN

VCC

16

U6
MAX232
11
9
12
10

You can also use our


Max232 Board Model 1104

C15
10uF 16V

VCC

http://www.sunrom.com/p
http://www.sunrom.com/p-245.html

RS232 INTERFACING

2) Interfacing to USB Port

RX-IN
TX-OUT
GND
+5V

U11
USB to Serial Board SUNROM#1151/1192

1151 model plugs in directly to USB


port of PC

1
2
3
4

4
3
2
1

S
P
+
-

U10
ECG Sensor SUNROM#1181

You can use our


USB to Serial Board
Model 1151 or 1192

http://www.sunrom.com/p
http://www.sunrom.com/p-244.html

USB INTERFACING

Similar model to above but needs a


USB A-B
B Type cable

Our USB to Serial TLL will appear as virtual serial port on PC


PC.
Software to Plot ECG signal will connect to this serial port.
Note: the ECG sensor is powered from USB board itself.
No external supply is required.

Sunrom Technologies

Your Source for Embedded Systems

http://www.sunrom.com/p
http://www.sunrom.com/p-1145.html

Visit us at www.sunrom.com

VCC

31

P3.0/RXD
P3.1/TXD
P3.2/INT0
P3.3/INT1
P3.4/T0
P3.5/T1
P3.6/WR
P3.7/RD

EA/VPP

C9
33p

XTAL1

RST

19

R1
10K

10
11
12
13
14
15
16
17

S
P
+
-

U4
ECG Sensor SUNROM#1181

4
3
2
1

21
22
23
24
25
26
27
28

SERIAL

VCC

29
30

XTAL2

PSEN
ALE/PROG

+
C8
10uF 16V

P2.0/A8
P2.1/A9
P2.2/A10
P2.3/A11
P2.4/A12
P2.5/A13
P2.6/A14
P2.7/A15

Y1

18

VCC

P1.0/T2
P1.1/T2EX
P1.2
P1.3
P1.4/SS
P1.5/MOSI
P1.6/MISO
P1.7/SCK

GND

The RXD pin of MCU will go to S pin of


ECG sensor. Start reading each byte
through RXD pin at 4800 baud rate. A byte
will arrive every 5 mili-second containing
the analog value of 8 bit. You can now plot
it on LCD or do some calculation about
heart beat. If you plot the incoming values
on graphics LCD you will get an ECG
signal.

1
2
3
4
5
6
7
8

P0.0/AD0
P0.1/AD1
P0.2/AD2
P0.3/AD3
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7

20

You can use any microcontroller like 8051,


AVR, PIC or such. Just configure your
microcontroller to communicate at 4800
baud rate.

39
38
37
36
35
34
33
32

TTL UART INTERFACING


C1
100n

40

U2
AT89S52

You can interface the sensor directly


microcontroller pins since the level of
module is at level of input decided by + pin.
If +pin of sensor is at 3V then the output of
P(Pulse) or S(Serial) is at 3V. If +pin of
sensor is at 5V then the output of P(Pulse)
or S(Serial) is at 5V.

VCC

Interfacing with microcontroller


through UART to plot ECG signal

11.0592

C10
33p

Same way we are providing software on PC


side also which plots the same signal by
reading serial data. It is recommended that you
use PC software first and check before moving
to MCU side programming.
Ground & +5V Power Supply between sensor
and MCU should be connected.
Full keil project with source code and compiled
HEX file can be downloaded from here
http://www.sunrom.com/files/1181-keil-s52.zip

Sunrom Technologies

Your Source for Embedded Systems

Visit us at www.sunrom.com

Calculating Heart Beat from Pulse Output


The sensor has two types of output first is analog and another is pulse. The pulse output is
calculated from the analog output by monitoring the analog waveform and when it detects a peak in
last 100 samples average value then the on board LED is made on and same pulse output is made
through optocoupler. This pulse output signal can directly be fed to microcontroller pins.
To calculate heart beat from pulse output you can see below details.
Heart beat output signal from sensor is as below.
T2-T1 = t (Time between two high going pulse)

5V level

T1

BPM(Beats per Minute)=60000/Time t in ms

T2

0V level
LED ON each high level

LED OFF when output low

Following shows how a digital pulse is output based on analog values.

Sunrom Technologies

Your Source for Embedded Systems

Visit us at www.sunrom.com

Sample Application: Digital Heart Beat Monitor


Lets use the pulse output and build a digital heart beat monitor. When the board is hold with two
thumb pads, it displays the beats per minute (BPM) rate. Connect Pulse output from sensor to the
Microcontroller.
VCC

1
2
3
4
5
6
7
8
31

P3.0/RXD
P3.1/TXD
P3.2/INT0
P3.3/INT1
P3.4/T0
P3.5/T1
P3.6/WR
P3.7/RD

EA/VPP

C9
33p

XTAL1
19

RST

GND

R1
10K

20

C8
10uF 16V

VCC

PULSE

29
30

XTAL2

PSEN
ALE/PROG

10
11
12
13
14
15
16
17

S
P
+
-

40

P1.0/T2
P1.1/T2EX
P1.2
P1.3
P1.4/SS
P1.5/MOSI
P1.6/MISO
P1.7/SCK

P2.0/A8
P2.1/A9
P2.2/A10
P2.3/A11
P2.4/A12
P2.5/A13
P2.6/A14
P2.7/A15

U4
ECG Sensor SUNROM#1181

Y1

18

VCC

P0.0/AD0
P0.1/AD1
P0.2/AD2
P0.3/AD3
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7

21
22
23
24
25
26
27
28

4
3
2
1

39
38
37
36
35
34
33
32

C1
100n

VCC

U2
AT89S52

PULSE OUTPUT INTERFACING

11.0592

C10
33p

The pulse signal is applied to the P3.7 input of U2 that is AT89S52 (Can be any 8051 type) which is
monitored by the program whenever this input goes high. Internally to U2, there is a counter which
counts how many 1ms intervals there are between two high going heart beat pulses. This number is
then divided by 60,000 and the result is the pulse rate. Lets see how we come to this value of
60,000 for dividing. For example, if the pulse rate is 60 BPM (beats per minute) there will be a pulse
every second. The duration of one heart beat will be one seconds or 1000 x 1ms. Dividing 60,000
by 1000 will give the correct result of 60 which is shown on the display. If there is invalid result
(BPM>200) it is invalid and waits for next cycle.
Sample code of this application is shown on next page.

Sunrom Technologies

Your Source for Embedded Systems

Visit us at www.sunrom.com

// Compiler: Keil, Target Chip AT89S52 or similar


sbit SENSOR = P3^7; //sensor is connected to this pin, can be any other pin also
unsigned int beatms; //Calculate time between two high going pulses in ms
float bpm; // Beats per minute calculated from beatms variable above
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=Delay x Milisecond
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
void delay_ms(unsigned int x)
// delays x msec (at fosc=11.0592MHz)
{
unsigned char j=0;
while(x-- > 0)
{
for (j=0; j<125; j++){;}
}
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// -=-=-=-=- Main Program -=-=-=-=-=-=-=
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void main()
{
// -=-=- Intialize variables -=-=-=
beatms=0; // will store duration between two pulses
// -=-=- Program Loop -=-=-=
while(1)
{
while(SENSOR==0);// wait for high pulse from sensor
delay_ms(10); // 10ms delay so that it does not listen to any noise
beatms = 10; // start counting beatms from 10ms since we have delay above
while(SENSOR==1)// wait until signal is high
{
delay_ms(1); //wait 1msec
beatms++;
//keep incrementing counter each 1ms
}
while(SENSOR==0) //keep looping till signal goes back high, wait for next
{
delay_ms(1); //wait 1msec
beatms++;
//keep incrementing counter each 1ms
}
// beatms variable will now have time in ms between two high edge pulse
bpm = (float)60000/beatms; // see document of #1181 for this calculation
if(bpm > 200)
{
// Invalid, Wait for next cycle
} else {
// Display reading in BPM, print variable BPM to LCD Display or Serial port.
}
}
}

10

Sunrom Technologies

Your Source for Embedded Systems

Visit us at www.sunrom.com