EXG

This module defines a PacketStreamReader for reading packets from an Olimex-EKG-EMG shield.

Details describing how an Olimex-EKG-EMG shield packet is organized are below:

///////////////////////////////////////////////
////////// Packet Format Version 2 ////////////
///////////////////////////////////////////////
// 17-byte packets are transmitted from Olimexino328 at 256Hz,
// using 1 start bit, 8 data bits, 1 stop bit, no parity.

// Minimial Transmission Speed
// A sample is taken every 8ms (ie. 125 samples per second)
// 125 samples/s * sizeof(Olimexino328_packet) = 2,125 bytes per second
// 2125 bytes per second = 17,000 bits per second.
// 2.125 kBps (I think we can manage that :)
// 7,650 kB per hour ~ 7.5M MB per hour

struct Olimexino328_packet
{
  uint8_t   sync0;          // = 0xa5
  uint8_t   sync1;          // = 0x5a
  uint8_t   version;        // = 2 (packet version)
  uint8_t   count;          // packet counter. Increases by 1 each packet.
  uint16_t  data[6];        // 10-bit sample (= 0 - 1023) in big endian (Motorola) format.
  uint8_t   switches;       // State of PD5 to PD2, in bits 3 to 0.
};
class olimex.exg.PacketStreamReader(serial)

Instantiations of this class are iterators and can be passed to the next() function to retrieve the next available Olimex-EKG-EMG packet.

For example:

serial = serial.Serial(port, 115200)
reader = PacketStreamReader(serial)
packet = next(reader)

Previous topic

olimex-ekg-emg

Next topic

GUI

This Page