論文中で必要とする電子部品等は下記から入手可能です。
秋月電子
スイッチサイエンス
RS
Arduinoを用いた電子工作の参考サイト
ブレッドボードの使い方
Arduino 日本語リファレンス
アナログ回路の基礎
参考になる文献・書籍
・神崎 康宏(2012)Arduinoで計る,測る,量る : 計測したデータをLCDに表示,SDカードに記録,無線/インターネットに送る方法を解説 CQ出版
https://ci.nii.ac.jp/ncid/BB08696362
・鈴木 哲哉(2014)ボクのArduino工作ノート 改訂版 ラトルズ
https://ci.nii.ac.jp/ncid/BB1457169X
・増田正・大路駿介 (2020). PT・OT・アスリートのためのプログラミングとマイコン電子工作入門 (1) プログラミングとマイコンを用いた電子工作. バイオメカニズム学会誌, 44, 48-52.
https://www.jstage.jst.go.jp/article/sobim/44/1/44_48/_pdf/-char/ja
・増田正, & 大路駿介. (2020). PT・OT・アスリートのためのプログラミングとマイコン電子工作入門 (2) Arduino® マイコンと電子回路の活用. バイオメカニズム学会誌, 44(2), 119-123.
https://www.jstage.jst.go.jp/article/sobim/44/2/44_119/_pdf/-char/ja
論文中で紹介されたプログラムを掲載します。
ECG測定に用いたプログラム(Arduino)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <Wire.h> //I2C通信ライブラリ #include <Adafruit_ADS1X15.h> //ADS1015ライブラリ Adafruit_ADS1015 ads; //ADS1015クラスのインスタンス化 void setup ( void ) { Serial.begin ( 115200 ); //シリアル通信開始 // ADS1015 gain 2/3 input range +/- 6.144V ads.begin(); //ADS1015通信開始 } void loop ( void ) { int16_t results; //AD変換結果 results = ads.readADC_Differential_0_1(); //差動入力 float multiplier = 3.0 F; // デフォルトゲイン(2/3倍)における係数 Serial.print (results * multiplier); //得られたデジタル値をmvに換算しシリアルモニタに表示 Serial.print ( ",4000,1000" ); Serial.println (); //シリアルモニタ改行 delay ( 0 ); } |
EMG測定に用いたプログラム(Arduino)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <Wire.h> #include <Adafruit_ADS1X15.h> Adafruit_ADS1015 ads; void setup ( void ) { Serial.begin ( 115200 ); // ADS1015 gain 16x input +/- 0.256V ads.setGain(GAIN_SIXTEEN); //ゲインを16倍に設定 ads.begin(); } void loop ( void ) { int16_t results; results = ads.readADC_Differential_0_1(); //差動入力 float multiplier = 0.125 F; //ゲイン16倍時の係数 Serial.print (results * multiplier); Serial.print ( ",100,-100" ); Serial.println (); delay ( 0 ); } |
SCC測定に用いたプログラム(Arduino)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <Wire.h> #include <Adafruit_ADS1X15.h> Adafruit_ADS1015 ads; void setup ( void ) { Serial.begin ( 115200 ); // ADS1015 gain 8x input +/- 0.512V ads.setGain(GAIN_EIGHT); //ゲインを8倍に設定 ads.begin(); } void loop ( void ) { int16_t results1,results2; results1 = ads.readADC_Differential_0_1(); //差動入力 float multiplier = 0.25 F; //ゲイン8倍時の係数 Serial.print (results1 * multiplier); Serial.print ( "," ); Serial.print ( "194," ); //24k Ohm = 42uS Serial.print ( "-7," ); //1M Ohm = 1uS Serial.println (); delay ( 200 ); } |
SCLおよびSCR測定に用いたプログラム(Arduino)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include <Wire.h> #include <Adafruit_ADS1X15.h> Adafruit_ADS1015 ads; void setup ( void ) { Serial.begin ( 115200 ); // ADS1015 gain 2x input +/- 2.048V ads.setGain(GAIN_TWO); ads.begin(); } void loop ( void ) { int16_t results1,results2; results1 = ads.readADC_Differential_0_1(); //作動入力 results2 = ads.readADC_Differential_2_3(); float multiplier = 1.0 F; Serial.print (results1 * multiplier); Serial.print ( "," ); Serial.print (results2 * multiplier); Serial.print ( "," ); Serial.print ( "1111," ); //24k Ohm = 42uS Serial.print ( "-41," ); //1M Ohm = 1uS Serial.println (); delay ( 200 ); } |
EMGの無線計測に用いたプログラム(Arduino)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #include "BluetoothSerial.h" //BT通信ライブラリ #include <Wire.h> #include <Adafruit_ADS1X15.h> Adafruit_ADS1015 ads; BluetoothSerial SerialBT; //BluetoothSerial クラスのインスタンス化 long t1,t0; //時間管理用変数 int cnt = 0 ; //加算回数 int16_t results; float multiplier = 0.125 F; float mv,average,sum; //平均値算出用変数 void setup ( void ) { pinMode ( 10 , OUTPUT ); //内蔵赤色LEDを出力モードに digitalWrite ( 10 , LOW ); //内蔵赤色LEDを点灯 Serial.begin ( 115200 ); SerialBT.begin( "EMG32" ); //Bluetooth device name Wire.begin( 32 , 33 ); //32端子をSDA,33端子をSCLとしてI2C通信開始 // ADS1015 gain 16x input +/- 0.256V ads.setGain(GAIN_SIXTEEN); ads.begin(); } void loop ( void ) { results = ads.readADC_Differential_0_1(); //作動入力 mv = abs (results * multiplier); //筋電位の絶対値を得る sum + = mv; cnt + + ; t0 = t1; t1 = millis () / 10 ; //10ms間隔で平均mV数を表示 if (t1 ! = t0){ average = sum / cnt; SerialBT.print(average); SerialBT.print( ",100,0" ); SerialBT.println(); sum = 0 ; cnt = 0 ; } } |
SCCをWi-Fi経由でサーバーに送信するプログラム(Arduino)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #include <WiFi.h> //Wifiライブラリ #include <WiFiMulti.h> //複数のアクセスポイントを管理するためのクラス #include <HTTPClient.h> //HTTP通信ライブラリ #include <Wire.h> #include <Adafruit_ADS1X15.h> WiFiMulti wifiMulti; //WiFiMultiクラスのインスタンス化 Adafruit_ADS1015 ads; void setup ( void ) { pinMode ( 10 , OUTPUT ); digitalWrite ( 10 , LOW ); Serial.begin ( 115200 ); Wire.begin( 32 , 33 ); //I2C connection ads.setGain(GAIN_EIGHT); // ADS1015 gain 8x ads.begin(); delay ( 4000 ); //4秒待機した後に通信開始 wifiMulti.addAP( "MySSID" , "MyPassword" ); //WiFiアクセスポイントの登録 } void loop ( void ) { int16_t results; float multiplier = 0.25 F; float SC; results = ads.readADC_Differential_0_1(); //作動入力 SC = results * multiplier; if ((wifiMulti.run() = = WL_CONNECTED)) { //登録したアクセスポイントに接続 HTTPClient http; //HTTPClientをインスタンス化 Serial.print ( "[HTTP] begin...\n" ); URL + = "?SC=" + String(SC); http.begin(URL); //HTTP通信開始 Serial.print ( "[HTTP] GET...\n" ); Serial.println (URL); int httpCode = http.GET(); //URLをGET方式でリクエスト if (httpCode > 0 ) { Serial.printf( "[HTTP] GET... code: %d\n" , httpCode); if (httpCode = = HTTP_CODE_OK) { //通信に成功したら String payload = http.getString(); //通信結果をpayloadへ格納 Serial.println (payload); } } else { //失敗したらエラーとコードを表示 Serial.printf( "[HTTP] GET... failed, error: %s\n" , http.errorToString(httpCode).c_str()); } http.end(); //HTTP通信終了 } delay ( 1000 ); //1秒ごとに繰り返す } |
Wifi経由受信したSCCデータをサーバーに記録するプログラム(PHP)
1 2 3 4 5 6 7 8 9 10 11 | <? $SCval = $_GET [ 'SC' ]; //Arduinoから送られたデータを受け取る $timestr = strftime ( "%Y%m%d_%H%M%S" ); //タイムスタンプ作成 if ( $SCval != "" ){ $fp = fopen ( "SCdata.csv" , "a" ); //追加形式でファイル開く fprintf ( $fp , "%s,%s\n" , $timestr , $SCval ); //タイムスタンプとデータを保存 fclose( $fp ); //ファイル閉じる echo "saved SC value!" ; //Arduino側へ文字列送信 } ?> |