Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Tagged as

Go to top

ECG recording, storing, filtering and recognition

, 14 Apr 2004
Full open code project for making driver and application software for ECG medical measurements.
ecg_dsp_src.zip
drvECG_1
drvECG_1.clw
drvECG_1.def
drvECG_1.dsp
drvECG_1.dsw
drvECG_1.exp
drvECG_1.ilk
drvECG_1.lib
res
Ecg_1
ECG_1.clw
ECG_1.dsp
ECG_1.dsw
ECG_DRAW.obj
ECG_Statistic_View.lib
ECG_VIEW.exp
ECG_VIEW.ilk
ECG_VIEW.lib
TestOCX.ocx
drvECG_1.exp
drvECG_1.ilk
drvECG_1.lib
resource.hm
res
ECG_1.ico
bitmap1.bmp
bmp00001.bmp
setup.bmp
ECG_Statistic_View
ECG_Statistic_View.clw
ECG_Statistic_View.def
ECG_Statistic_View.dsp
ECG_Statistic_View.dsw
res
ECG_VIEW
ECG_DRAW.obj
ECG_VIEW.APS
ECG_VIEW.clw
ECG_VIEW.def
ECG_VIEW.dll
ECG_VIEW.dsp
ECG_VIEW.dsw
ECG_VIEW.exp
ECG_VIEW.lib
res
testrecord2.zip
georgi.ecg
test_file1.zip
test_file1.ecg
// MCP3002.cpp: implementation of the MCP3002 class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MCP3002.h"
#include "MultimediaTimer.h"
#include "ADC3002.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//Delcare out timer function
//Function must be static
static	void TimerFunction(void* obj,UINT idEvent);
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

MCP3002::MCP3002()
{

}

MCP3002::~MCP3002()
{

}

void TimerFunction(void* obj,UINT idEvent)
{
	//This is our timer actevated function
	//First get a pointer to class functions
	MCP3002* mcp = (MCP3002*) obj;
	//Activate class functions
	mcp->HandleTimer(idEvent);

}

void MCP3002::HandleTimer(UINT nIDEvant)
{
	//This function is activated from MM timer events
	//Because we need to make 5000 samples do them 
	if(i_mmcount<=5000)
	{
		//GetADC Samples
		Channel_0[i_mmcount] = ADC_Ch_0();
		Channel_1[i_mmcount] = ADC_Ch_1();
		//update counter
		i_mmcount++;
	}

	//After we have done all samples stop sampling and MM timer
	if(i_mmcount>5000)
	{
		MMT_Stop();//Stop MMTimer
		DoEndNotification();//Make a notification to the program
	}

}
void MCP3002::MMT_Stop()
{
	//This function stops the MM timer
	Sleep(10);
	TEnd = CTime::GetCurrentTime();
	//Stop timer
	MMTimer.StopTimer();
	Sleep(10);
}

void MCP3002::MMT_Start(unsigned short LPT)
{
	//This function sets the LPT type
	//Zero the counter and after this stop the timer
	//Now it can be restarted and do samples
	i_mmcount = 0;
	LPT_PORT = LPT;
	//If MMTimer alredy runs stop it now!
	MMT_Stop();
	//Before start timer get the time moment
	TStart = CTime::GetCurrentTime();
	//Do timer event any 2 msec = 500Hz +- 2Hz
	MMTimer.StartTimer(this,2,10,TimerFunction);

}

unsigned short MCP3002::ADC_Ch_0()
{
	return adc3002.GetChanne_0(LPT_PORT,10);

}

unsigned short MCP3002::ADC_Ch_1()
{
	return adc3002.GetChanne_1(LPT_PORT,10);

}

void MCP3002::SetEndSampleNotification(void *obj, EndSampleNotification endnotification)
{
	//Sets the end sample notification event
	//so it will be activated after sampling period
	object = obj;
	//See declaration of EndSampleNotification
	EndNotification = endnotification;

}

void MCP3002::DoEndNotification()
{
	//This function activates a function and pass a parameters
	//to in our class
	int len;
	len = 5000;
	//activates a function EndNotification see declaretion
	EndNotification(object,&Channel_0[0],&Channel_1[0],len,TStart,TEnd);

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Georgi Petrov
Instructor / Trainer
Bulgaria Bulgaria
PhD, Cum Laude in digital automation systems
M.S. in Telemommunication management
B.S. in Telecommunication systems engineering
Programming: CUDA, C/C++, VHDL
Software and Hardware development and consulting:
data acquisition, image processing, medical instrumentation

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 15 Apr 2004
Article Copyright 2003 by Georgi Petrov
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid