Biomedical Engineering Reference
In-Depth Information
2. When input buffer filling reaches predefined (user programmable) threshold
value, then it generates an 'event,' which triggers the corresponding MATLAB
callback functions using 'bytes-available event';
3. Data are picked up from buffer using necessary command in MATLAB.
For transferring data bytes to the outside world, an exact reverse sequence is
executed, as stated below:
1. From computer memory, data byes are sent to the output buffer of the USART
using commands in MATLAB;
2. The USART continuously transmits the data bytes to the external device using
the TD line;
3. An 'OutputEmpty' event is generated when the output buffer goes empty,
triggering the corresponding event described by 'BytesAvailableFcn' and
'OutputEmptyFcn.' The calling function loads the next block of data to the
USART for delivery to the external device.
A typical session for using serial port objects involves the following steps to be
initiated using software instructions:
1. Creating a serial port object using 'serial' creation function.
2. Opening the port.
3. Setting the following properties related to the serial port functions:
• Baud rate
• Parity
• Data bits
• Stop bits
• Input buffer size
• 'ReadAsyncMode' which describes manual/automatic mode for reading the
port for data availability
• 'BytesAvailableFcn' describes the function which will be called every time an
event described by 'BytesAvailableFcnMode' property is generated
• 'BytesAvailableFcnCount' describes the number of bytes which when avail-
able in the input buffer will generate the callback event.
4. Picking up (or deliver) the data bytes available in the buffer in (or from) a data
array.
5. Closing the port.
The incoming data to the PC serial port are sequentially stored in a text file.
These data are in the range 0-255, i.e., 8-bit quantization. To enable data storage
in actual ECG sample, a conversion formula is used as
Search WWH ::




Custom Search