Click here to Skip to main content
15,881,898 members
Articles / Programming Languages / C++

ECG recording, storing, filtering and recognition

Rate me:
Please Sign up or sign in to vote.
4.72/5 (110 votes)
14 Apr 200411 min read 728.4K   38.4K   156  
Full open code project for making driver and application software for ECG medical measurements.
// ADC3002.cpp: implementation of the ADC3002 class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ADC3002.h"
#include "conio.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

ADC3002::ADC3002()
{

}

ADC3002::~ADC3002()
{

}

unsigned short ADC3002::GetChanne_0(unsigned short lpt_port, byte bitrate)
{
	D = 0;
	_outp(lpt_port,(0xff));//start
	_outp(lpt_port,(0xfe));//CS goes lol
	_outp(lpt_port,(0xfc));//clk 0 start bit ->

	_outp(lpt_port,(0xfe));//clk 1 sgl/dif set 0xfe/0xfa
	_outp(lpt_port,(0xfc));//clk 0 sgl/dif ->  oxfc/0xf8
	////////
	_outp(lpt_port,(0xfe));//clk 1 odd/sing set 1
	_outp(lpt_port,(0xfc));//clk 0 odd/sig -> 1

	////
	//set channel 0
	_outp(lpt_port,(0xfa));//clk 1 & MSBF=0 set
	_outp(lpt_port,(0xf8));//clk 0 & MSBF=0 ->
//	//set channel 1
//	_outp(0x378,0xfe);//clk 1 & MSBF=0 set
//	_outp(0x378,0xfc);//clk 0 & MSBF=0 ->
	///////////////////
	_outp(lpt_port,(0xfa));//clk 1 & Null Bit set
	_outp(lpt_port,(0xf8));//clk 0 & Nul Bit ->
	
		//channel 1
	for(int i = 0;i<bitrate;i++)
	{
		_outp(lpt_port,(0xfe));//clk 1
		_outp(lpt_port,(0xfc));//clk 0
		E = (_inp(lpt_port+1) & 128);
		//E=!(_inp(0x378+1) & 128);
		//E =!E;//
		//check for new lpt_ports
		E = E>>7;//inverts signal
		//E = ~E;
		//E = (_inp(0x378)&0x80);//for bi directional lpt_ports
		D = D | E;
		D = D<<1;
	}
	D = D>>1;
	return D;

}

unsigned short ADC3002::GetChanne_1(unsigned short lpt_port, byte bitrate)
{
	D = 0;
	_outp(lpt_port,(0xff));//start
	_outp(lpt_port,(0xfe));//CS goes lol
	_outp(lpt_port,(0xfc));//clk 0 start bit ->

	_outp(lpt_port,(0xfe));//clk 1 sgl/dif set 0xfe/0xfa
	_outp(lpt_port,(0xfc));//clk 0 sgl/dif ->  oxfc/0xf8
	////////
	_outp(lpt_port,(0xfe));//clk 1 odd/sing set 1
	_outp(lpt_port,(0xfc));//clk 0 odd/sig -> 1

	////
	//set channel 0
//	_outp(lpt_port,(0xfa));//clk 1 & MSBF=0 set
//	_outp(lpt_port,(0xf8));//clk 0 & MSBF=0 ->
//	//set channel 1
	_outp(0x378,0xfe);//clk 1 & MSBF=0 set
	_outp(0x378,0xfc);//clk 0 & MSBF=0 ->
	///////////////////
	_outp(lpt_port,(0xfa));//clk 1 & Null Bit set
	_outp(lpt_port,(0xf8));//clk 0 & Nul Bit ->
	
		//channel 1
	for(int i = 0;i<bitrate;i++)
	{
		_outp(lpt_port,(0xfe));//clk 1
		_outp(lpt_port,(0xfc));//clk 0
		E = (_inp(lpt_port+1) & 128);
		//E=!(_inp(0x378+1) & 128);
		//E =!E;//
		//check for new lpt_ports
		E = E>>7;//inverts signal
		//E = ~E;
		//E = (_inp(0x378)&0x80);//for bi directional lpt_ports
		D = D | E;
		D = D<<1;
	}
	D = D>>1;
	return D;

}


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


Written By
Systems Engineer
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

Comments and Discussions