# rsr232 connection and decoding

I use an ECG recorder connected to my PC throu the rs232 port.

The recorder sends a continuous stream of data.

I need to read and decode the data from the recorder to analyze them with some routines that I've done.

As I have no experience with rs232 programming and decoding I hope someone can help me.

Of course I will pay according to the programmer request.

Now I write all the information I have (from the producer of the ECG recorder):

------------------------

The recorder samples the channels at 300 Hz and 10 bits.

The communicazione is by RSR232 simplex, at 8 data bits, no parity. The baurate is 57600.

DTR must be ON.

Per sample, two bytes are sent with the following content:

fisrt byte: 0 D6 D5 D4 D3 D2 D1 D0

second byte: 1 BR D9 D8 D7 C2 C1 C0

where Dn is the nth databit of the sample, and Cn is the nth databit of the channel number.

BR changes state at every zero-crossing of the AC mains, if detected. Note that the number C is one higher (mod 8) then the actual channel.

To record an ECG:

1. synchronize with the incoming data bytes by waiting until a byte is received which has a 0 at bit position 7, this is the first byte of a given sample. Let the two bytes belonging to the same sample be in[0] and in[1].

2. determine the channel number:

channel = (in[1]-1) & 0x07

3. determine the sampled data:

sample=((in[1] & 0x38) < < 4) + in[0]

4. store the sample somewhere for at least one cycle. Repeat steps 2 and 3 until a sample has been read from each channel. Let the eight samples be chan[0] through chan[7].

5 determine the ECG leads from the channels, according to the table below:

1 chan[7]-chan[6]

2 512-chan[6]

3 512-chan[7]

4 chan[6]-256-chan[7]/2

5 chan[7]-256-chan[6]/2

6 512-chan[6]+chan[7]/2

7 chan[0]-(chan[6]+chan[7]+512)/3

8 chan[1]-(chan[6]+chan[7]+512)/3

9 chan[2]-(chan[6]+chan[7]+512)/3

10 chan[3]-(chan[6]+chan[7]+512)/3

11 chan[4]-(chan[6]+chan[7]+512)/3

12 chan[0]-(chan[6]+chan[7]+512)/3

--------------------

Dario Barbieri

## Deliverables

1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.

## Platform

Windows XP

VB6 service pack 5.

( 19 comentários ) Italy

ID do Projeto: #3029714

## Concedido a:

timarheit

See private message.

\$29.75 USD em 14 dias
(32 Comentários)
4.7

## 2 freelancers are bidding on average \$40 for this job

nikflipflop

See private message.

\$51 USD in 14 dias
(4 Comentários)
2.7