Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
You are viewing an older revision! See the latest version
Homepage
Information
tg_201410s6_Plethysmographs トランジスタ技術 2014年 10月号 第6章のソフトウェア
Program for Section 6 in October. 2014 issue of the Transistor Gijutsu
(Japanese electrical technology magazine)
概要¶
このプログラムは、
- 脈波データ取得(A-Dサンプリング、ハイパスフィルタ)
- 脈拍数の算出(パルス検出、LEDおよび同期音出力、移動平均処理)
を行うPulseRateクラスと、それらをUSBシリアル通信でホストへ送信するmain関数で構成されています。
PulseRate.h, PulseRate.cpp¶
- A-Dサンプリング - 100 SPS
- ハイパスフィルタ - 遮断周波数0.1Hz、1次バターワースフィルタ
- パルス検出 - 脈波を微分処理、5point移動平均して速度脈波を求め、
それを包絡線検波した波形を、速度脈波が再び超える点をパルス開始とする - LED、同期音出力 - パルス同期LED(10ms)、圧電サウンダ出力(1kHz、10ms)
- 移動平均処理 - 直近5拍分の平均値を脈波として算出
main.cpp¶
- PulseRateクラスのインスタンスを生成
- 処理開始メソッドを実行
- メインループ - ポーリングにより、脈波データ、脈拍数データの完了フラグが返されたら、
USBシリアル通信経由で、ホストへ送信する
シリアル通信フォーマット¶
- 4byte固定長パケット方式
- 脈波データパケット、脈拍数データパケットの2種類
| 脈波データパケット | 脈拍数データパケット | |
| 0x00 | パケットヘッダ(固定値0xAA) | パケットヘッダ(固定値0xAA) |
| 0x01 | 波形番号(0 - 99繰り返し) | 脈拍数ID(固定値0xBB) |
| 0x02, 0x03 | 脈波データ(singed, 2byte) | 脈拍数データ(20 - 300, 2byte) |
Description¶
This contains PulseRate class and main function.
PulseRate class:
- Acquiring pulse waveform (A-D sampling, high pass filter)
- Calculate pulse rate (Detecting pulse, Sync. LED and buzzer, moving averaging)
Main function:
- Send pulse waveform and rate to host via USB serial class.
PulseRate.h, PulseRate.cpp¶
- A-D sampling - 100 SPS
- High pass filter - Cut off frequency 0.1Hz, first order butterworth
- Detecting pulse - Calculating velocity pulse waveform by derivation and moving averaging (5point).
Moreover, calculating threshold waveform like envelope demodulator.
Detecting point the velocity waveform pass over the threshold waveform as starting pulse. - Sync. LED, buzzer - Synchronous pulse LED(10ms), piezo sounder(1kHz, 10ms)
- Moving averaging - Calculating pulse rate averaging the previous 5 pulse.
main.cpp¶
- Generating an instance of PulseRate class
- Executing start procedure method
- Main loop - sending pulse waveform data and pulse rate data via USB serial interface when detecting ready in return value.
Packet format for USB serial interface¶
- Packet size: 4 bytes(fixed)
- Two types of packets, pulse waveform packet and pulse rate packet
| Pulse waveform packet | Pulse rate packet | |
| 0x00 | Packet header (0xAA (fixed))) | Packet header (0xAA (fixed)) |
| 0x01 | Sampling number (0 - 99) | Pulse rate ID (0xBB (fixed)) |
| 0x02, 0x03 | Pulse waveform data (singed, 2byte) | Pulse rate data (20 - 300, 2byte) |