dangomushi115 が 2021年02月28日13時44分14秒 に編集
コメント無し
本文の変更
作ったもの(概要) ==== 宝石の種類を鑑別(判別)するための分光光度計を作りました。 ![キャプションを入力できます](https://camo.elchika.com/6a4076dfe8f41e7afc1367e6876faec5d23864c3/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f64656562373232302d363835322d346431322d386135332d3333636537633337323032362f39306565613637612d376236322d346138332d616431662d346636623862643230343930/) 背景 ==== 宝石の中には、一見同じ石に見える石が多々あります。例えば、「赤い石」の代表的なものとして、1月の誕生石である「ガーネット」や7月の誕生石である「ルビー」などが挙げられます。このような、見た目の似ている石であっても、一般的に石につけられる値段は全く異なります。そのため、特に高価な宝石の場合、鑑別機関に依頼して宝石の鑑別(※)を行って、宝石が偽物や別の宝石でないことを証明してもらう必要があります。 ※:ダイヤモンド以外の宝石の種類を特定してもらうことを鑑別、ダイヤモンドの品質等を特定してもらうことを鑑定といいます。 宝石の鑑別では、各種測定装置を使って、宝石の色、屈折率、比重、、、、など様々な指標により宝石の種類を特定します。しかしながら、宝石の各種指標を測定するための測定装置は、定量的な数値を出力できるものは非常に高価(数十万円~)です。また、宝石の色や屈折率など、光に関わるパラメータを簡易的に調べる機材(分光器や屈折計など)の中には比較的安価なものもありますが、定量的な数値を出力する機能がなく使用する人が肉眼で判断する必要があるなど、機材の使用に技術が要求されるものが大半です。
そこで、今回は2021/2/28現在、秋月電子通商で18000円で入手できる浜松ホトニクスの[マイクロ分光器 C12880MA](https://akizukidenshi.com/catalog/g/gM-12673/)を使用して、ポータブルな分光光度計を作成することにしました。
そこで、今回は2021/2/28現在、秋月電子通商で18000円で入手できる浜松ホトニクスの[マイクロ分光器 C12880MA](https://akizukidenshi.com/catalog/g/gM-12673/)を使用して、ポータブルな分光光度計(※)を作成することにしました。 ※:宝石は、宝石の種類に応じて、光の吸光度が異なります。一般的に光の吸光度は、すべての波長で一定となる宝石はまれであり、特定の波長の光はよく透過するが特定の波長の光は吸収する、といった性質を持つことが多いです。この吸光度の違い(=光源と宝石の透過光のスペクトル分布の違い)を見ることで、宝石の種類を特定することができます。
作成した分光光度計の機能の詳細 ==== 作成した分光光度計は下図の通り、左側のM5Stack Basic+M5Faces(ゲームパッドパネル)からなる操作部分と、右側のマイクロ分光器C12880MAからなる測定部に分かれています。測定部の宝石トレーに宝石を入れ、宝石の上に光源を設置して、M5StackのA/Cボタンを押すことで、光源から発され宝石を透過した光を測定することができます。 ![作成した分光光度計](https://camo.elchika.com/2830f73233d841d335af5ec9766aeb821a194472/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f64656562373232302d363835322d346431322d386135332d3333636537633337323032362f62333064613230372d343237332d343933302d613461322d303535366536626339363736/) 作成した分光光度計は、2種類のスペクトルを表示できるようになっています。M5StackのAボタンを押すと参照光(光源の光)、Cボタンを押すと宝石を透過した透過光の測定を行います。画面には、常にこの参照光と透過光のスペクトルが表示されます。下図は、電球色のペンライトでアレキサンドライトを測定した時のM5Stackの画面です。画面左下に黄色い四角が表示されていますが、これが参照光(電球色のペンライト)の色を表しています(R:255、G:242、B26と、黄色っぽい光であることが分かります)。また、画面右下に表示されている赤い四角は、宝石を透過した透過光の色を表しています。画面上部のグラフは、参照光・透過光それぞれの測定値(スペクトル)をグラフで表示しています。 また、測定したスペクトルは、M5Faces(ゲームパッドパネル)のスタートボタンを押すことで、シリアル通信によりPC等に送信することも可能です。 なお、一般のご家庭では、センサの測定感度のキャリブレーション等ができないため、測定値を物理的・絶対的に解釈することは困難です。あくまでも - 特定の波長の光が含まれているのか - ある波長の光に比べ、別の波長の光が強いか/弱いか が何となくわかる、くらいの解釈をすることとなります。 ![電球色のペンライトでアレキサンドライトを測定した時の画面](https://camo.elchika.com/364b8808130ec4581afd9a46432f100db9c5b341/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f64656562373232302d363835322d346431322d386135332d3333636537633337323032362f62383564313933372d663930322d343039392d626235632d353538613038343539346237/) 作成した分光光度計の使い方の例 ==== 作成した分光光度計を使って、下記に示す4種類の宝石の種類を判別してみます。 1. ガーネット(赤い石) 1. ルビー(赤い石、紫外線を当てると赤く蛍光する) 1. トルマリン(緑の石) 1. アレキサンドライト(白色LED下で緑、電球や太陽光の下で赤くなるカラーチェンジ効果を持つ石) ![キャプションを入力できます](https://camo.elchika.com/7eb190c349fa7db0e327835074c40489b086d987/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f64656562373232302d363835322d346431322d386135332d3333636537633337323032362f31353930633162622d313762342d343837642d623937372d643336663961646534323366/) まず最初に、赤い石(ルビー・ガーネット)を判別してみます。これらはともに赤い石ですが、ルビーの赤い色を生む原因であるCr3+の特徴から、判別することができます。すなわち、ルビーは下記に示す2つのグラフの通り、白色LEDや紫外線LEDを当てた時、690nm付近にピークが存在するという特徴を持っています(参照光には含まれない波長の光です)。 ![キャプションを入力できます](https://camo.elchika.com/3050aa905682a363bb8f18202e6907ea52a099d7/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f64656562373232302d363835322d346431322d386135332d3333636537633337323032362f36326566633237382d376135362d343937642d623634352d343265383963636139646261/) ![キャプションを入力できます](https://camo.elchika.com/f557dcb2e579b9687d4f6d3d20fca62c70c67b29/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f64656562373232302d363835322d346431322d386135332d3333636537633337323032362f35666362303036342d623332332d346532642d626237342d386461626638663832363063/) 次に、白色LED下で緑色の石(トルマリン・アレキサンドライト)を判別してみます。白色LED下でトルマリンとアレキサンドライトを測定すると、下記のようなスペクトルを示します。 ![キャプションを入力できます](https://camo.elchika.com/2b1d039c7ed015cd8ad61d648d31681c2e138de8/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f64656562373232302d363835322d346431322d386135332d3333636537633337323032362f66323162663762382d636133372d343063302d613266372d346639333561666333343432/)
一方、電球色のペンライトを用いてスペクトルを測定すると、以下のようになります。アレキサンドライトが650~700nmあたりの赤い光の強度が強く出ていることが分かります。このグラフ単体ではわかりづらいですが、電球色のペンライトの光を当てると、トルマリンは緑色に見えるのに対し、アレキサンドライトは赤色に見えます(今回作成した分光光度計は、測定したスペクトルから光の色を判定する機能を有しており、実際に本データを測定した際、目で見た色と同じような色が判定されていました)。以上のように、本分光光度計を使用することで、カラーチェンジ効果を定量的に測定できました。
一方、電球色のペンライトを用いてスペクトルを測定すると、以下のようになります。アレキサンドライトが650~700nmあたりの赤い光の強度が強く出ていることが分かります。このグラフ単体ではわかりづらいですが、電球色のペンライトの光を当てると、トルマリンは緑色に見えるのに対し、アレキサンドライトは赤色に見えます(今回作成した分光光度計は、測定したスペクトルから光の色を判定する機能を有しており、実際に本データを測定した際、目で見た色と同じような色が判定されていました)。以上のように、本分光光度計を使用することで、カラーチェンジ効果(光源のスペクトル分布によって、石の色が変わる効果)を定量的に測定できました。
![キャプションを入力できます](https://camo.elchika.com/ff6c0ddaf2f95be0c11558884f4f0a14b688c167/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f64656562373232302d363835322d346431322d386135332d3333636537633337323032362f33346237326134662d636661342d346265392d616238632d383735353166636334656630/) 前置きが長くなりましたが、さっそく分光光度計の作り方を説明していきたいと思います。 材料 ==== 材料は下記の通りです。オプションと記載しているM5Facesは、なくても主要な機能を実現することができます。 | 品名|参考URL|備考| |:-:|:---|:---| | M5Stack Basic | [秋月電子通商商品ページ](https://akizukidenshi.com/catalog/g/gM-16008/) | 必須、Gray等も可 | | マイクロ分光器C12880MA | [秋月電子通商商品ページ](https://akizukidenshi.com/catalog/g/gM-12673/) |必須 | |トランジスタ 2SC1815L-GR-T92-K| [秋月電子通商商品ページ](https://akizukidenshi.com/catalog/g/gI-06477/) |必須 | | 抵抗(100Ω)×3個| | 必須 | | M5 Facesボトムベース | [マルツ商品ページ](https://www.marutsu.co.jp/pc/i/2177890/) | オプション | | M5Stack Faces用ゲームパッドパネル | [マルツ商品ページ](https://www.marutsu.co.jp/GoodsDetail.jsp?q=M5Faces%20%E3%82%B2%E3%83%BC%E3%83%A0%E3%83%91%E3%83%83%E3%83%89%E3%83%91%E3%83%8D%E3%83%AB&salesGoodsCode=2190004&shopNo=3) | オプション | 作り方(ハードウェア) ==== 下図の通り、マイクロ分光器C12880MAとM5Stackを接続します。なお、マイクロ分光器のケースと各ピンがショートしないよう、接続方法には注意をしましょう。 ※:お高いセンサなので、センサを壊さないよう十分に注意して接続することをお勧めします。特にセンサの扱いについてこの記事では記載していない重要事項等もありますので、**念のため、必ず**センサの[データシート](https://www.hamamatsu.com/jp/ja/product/type/C12880MA/index.html)を確認してから接続するようにしましょう。 ![キャプションを入力できます](https://camo.elchika.com/1cccf2f019c55f176b16a2420968ea3e07b776f3/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f64656562373232302d363835322d346431322d386135332d3333636537633337323032362f33626564373839612d343132312d343165312d613466302d333061353732623435663734/) 上記のような部品をプリント基板を使って実装した様子が下記の通りです。なお、上記には記載していない部品(不要な部品等)も実装されています。今回作成したケースは、センサにホコリ等がつかないよう、合成石英レンズでセンサと外界を分離しています(石英は紫外・赤外光の領域でも透過率が高く、ちゃんとした分光光度計で液体の試料を測るための容器としても使用されています)。 ![キャプションを入力できます](https://camo.elchika.com/0aaa669203ed468f4c2ec25d2a37cd5c6cf92dcb/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f64656562373232302d363835322d346431322d386135332d3333636537633337323032362f64633161373739302d356538392d343534302d626536632d316232333862303335616431/) このままだと、宝石(小さい・高価)の透過光をうまくセンサに当てることができないため、宝石を置くトレーや外装を3DCAD+3Dプリンタで作成します。参考までに、今回作成したケースの三面図を下記に示します。 ![キャプションを入力できます](https://camo.elchika.com/0ea0b2729d400df09cfbf29cb3fe61e5e12e6f3d/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f64656562373232302d363835322d346431322d386135332d3333636537633337323032362f64383461356231652d346336662d343636302d613531302d383531346631356635623830/) なお、重要なのはセンサと宝石、ライトの位置関係ですので、それらが一直線上に並ぶよう、注意してケースを作成しましょう。なお、今回作成したケース(下図)は、センサをホコリ等から保護するために**合成石英レンズ**を設置しています。合成石英レンズは紫外・赤外領域を含め光の透過率がおおむね一定(※)ですので、宝石のスペクトル測定には影響を与えないようです(と信じています)。センサと合成石英レンズの距離が、レンズの焦点距離よりも十分に離れるよう設計しました(半球の焦点距離は、おおよそ半球の半径の2倍程度のようです)。 ※:ちゃんとした分光光度計で液体の試料を測定する際、石英セル(石英でできた容器)を用いて液体の試料を格納します。手芸用の合成石英レンズが本当に光学的な性質に優れているかは不明ですが・・・ ![キャプションを入力できます](https://camo.elchika.com/1754dcc199635ada72f4dde43640bda3892cc75e/687474703a2f2f73746f726167652e676f6f676c65617069732e636f6d2f656c6368696b612f76312f757365722f64656562373232302d363835322d346431322d386135332d3333636537633337323032362f64633532346336642d613936352d346333352d383334352d633766393263393066383238/) 作り方(ソフトウェア) ==== メインのプログラムおよびC12880MAを扱うためのプログラムを下記に示します。Arduinoの新規ファイルを作成してメインのプログラムを書き込み、「C12880ma.h」「C12880ma.cpp」「CMF.h」を追加してください。また、各自の環境に合わせて、下記のように対応してください。 - メインのプログラムの 18~23行目の値(C12880MAの波長補正係数)を、C12880MAの購入時に付属している検査成績書の値に変更する - M5Facesのゲームパッドパネルを**使用しない**場合、メインのプログラムの104行目、111~169行目の処理を削除する - M5Facesのゲームパッドパネルを**使用する場合**、M5Stackのサンプルプログラム「Snake_Gameboy」に含まれる「GameboyInput.h」「GameboyInput.cpp」を追加する ```arduino:メインの処理 #include <M5Stack.h> #include "C12880ma.h" #include "GameboyInput.h" //M5Facesのゲームパッドパネル用 //画面の描画などに関わる値の定義 #define margin_horizontal (320-PIXCEL_NUM)/2 //グラフエリアの両サイドの余白 #define margin_top 10 //グラフエリアの上の余白 #define margin_bottom 40 //グラフエリアの下の余白 #define spectrum_height 20 //横軸のバーの高さ #define box_width 100 //凡例の幅 #define offset_horizontal_data 32 //凡例と画面の両サイドとのオフセット量(水平方向) #define offset_text 10 //凡例の上に表示する文字列のオフセット量(高さ方向) #define BG_Screen_Color TFT_DARKGREY //画面の背景色 #define BG_Gragh_Color TFT_BLUE //グラフエリアの背景色 //C12880MAの波長補正係数を設定。 //各自のC12880MAに合わせて、購入時に付属している検査成績書の値を記入すること。 double pA0 = 3.151967282e2; double pB1 = 2.694097456; double pB2 =-1.215980535e-3; double pB3 =-7.262924282e-6; double pB4 = 8.346217814e-9; double pB5 = 5.853501591e-12; //コンストラクタ。CLK、ST、及びVideo信号の接続されたピン番号、及びC12880MA購入時に付属している、検査成績書の値を記入すること。 C12880MA c12880ma(16,17,36,pA0,pB1,pB2,pB3,pB4,pB5); struct Spectrum_Data Ref,Trans;//参照光と透過光に関する情報を格納するためのオブジェクト int delay_time_microsecond;//Clock幅。この値を変更することで、蓄積時間を制御する。 #define MAX_Delay_Time_Microsecond 300 //クロック幅の最大値 #define MIN_Delay_Time_Microsecond 3 //クロック幅の最小値 #define Step_Ratio_Delay_Time 10 //クロック幅の増加比率 #define Step_Delay_Time 1 //クロック幅の増加数 //グラフのY軸方向の値を計算する関数。Y軸方向に描画したい変数とグラフの最大値を入力する。 int graph_Y(int data,int max_value){ int top_Y=margin_top; int bottom_Y=240-spectrum_height-margin_bottom; if(max_value>0){ return bottom_Y+data*(top_Y-bottom_Y)/max_value; } else{ return bottom_Y; } } //画面表示を更新する関数 void update_screen(){ M5.Lcd.fillRect(margin_horizontal,margin_top,PIXCEL_NUM,240-margin_top-spectrum_height-margin_bottom,BG_Gragh_Color);//グラフエリアの塗りつぶし for(int i=1;i<PIXCEL_NUM;i++){ //CIEで定義されたRGBの波長あたりに縦線を示す //赤 if (abs(c12880ma.i_lamdas[i]-700)<3){ M5.Lcd.drawLine(i+margin_horizontal,graph_Y(0,0),i+margin_horizontal,margin_top,TFT_BLACK); } //緑 if (abs(c12880ma.i_lamdas[i]-546)<3){ M5.Lcd.drawLine(i+margin_horizontal,graph_Y(0,0),i+margin_horizontal,margin_top,TFT_BLACK); } //青。なお、436[nm]だと、ちょっと紫っぽいあたりに線が出てくる。 if (abs(c12880ma.i_lamdas[i]-436)<3){ M5.Lcd.drawLine(i+margin_horizontal,graph_Y(0,0),i+margin_horizontal,margin_top,TFT_BLACK); } } //折れ線グラフを描画する。 for(int i=1;i<PIXCEL_NUM;i++){ M5.Lcd.drawLine(i-1+margin_horizontal,graph_Y(Ref.data[i-1],Ref.max_value),i+margin_horizontal,graph_Y(Ref.data[i],Ref.max_value),Ref.color); M5.Lcd.drawLine(i-1+margin_horizontal,graph_Y(Trans.data[i-1],Trans.max_value),i+margin_horizontal,graph_Y(Trans.data[i],Trans.max_value),Trans.color); } //凡例の表示 M5.Lcd.setTextColor(BLACK, BG_Screen_Color); //文字色設定と背景色設定 //凡例(参照光):測定したスペクトルから光の色を計算し、その色の四角形で塗りつぶし&RGB値を表示する M5.Lcd.fillRect(offset_horizontal_data,240-margin_bottom/2,box_width,margin_bottom/2,Ref.color); M5.Lcd.setCursor(offset_horizontal_data, 240-margin_bottom/2-offset_text); M5.Lcd.printf("R:%3d G:%3d B:%3d" ,Ref.R,Ref.G,Ref.B); //凡例(透過光):測定したスペクトルから光の色を計算し、その色の四角形で塗りつぶし&RGB値を表示する M5.Lcd.fillRect(320-offset_horizontal_data-box_width,240-margin_bottom/2,box_width,margin_bottom/2,Trans.color); M5.Lcd.setCursor(320-offset_horizontal_data-box_width, 240-margin_bottom/2-offset_text); M5.Lcd.printf("R:%3d G:%3d B:%3d" ,Trans.R,Trans.G,Trans.B); //クロック幅の表示の更新。クロック幅∝蓄積時間。 M5.Lcd.setTextColor(BLACK, BG_Gragh_Color); //文字色設定と背景色設定 M5.Lcd.setCursor(230, margin_top); M5.Lcd.printf("Gain:%3d[us]" ,delay_time_microsecond); } //横軸代わりのカラーバーを表示する void init_screen(){ M5.Lcd.fillScreen(BG_Screen_Color);//背景色を指定 M5.Lcd.fillRect(margin_horizontal,margin_top,PIXCEL_NUM,240-margin_top-spectrum_height-margin_bottom,BG_Gragh_Color);//グラフエリアの塗りつぶし //各波長における単波長光の色で、横軸のメモリ代わりのバーを描く。 for(int i=0;i<PIXCEL_NUM;i++){ M5.Lcd.drawLine(i+margin_horizontal,240-margin_bottom-spectrum_height,i+margin_horizontal,240-margin_bottom,c12880ma.calc_color(i)); } update_screen(); } //----------------- void setup() { M5.begin(); GameboyInput.begin();//M5Facesのゲームパッドパネルを使う場合、この処理を記述する。 init_screen();//画面の初期化。 } void loop() { delay_time_microsecond=c12880ma.get_delay_time_microsecond(); //M5Facesのゲームパッドパネルの入力に応じた処理。 switch(GameboyInput.getActivity()) { case GAMEBOY_KEY_NONE ://操作なし break; case GAMEBOY_KEY_START ://スタートボタン //測定値をシリアル通信で送信する Serial.print("WaveLength[nm]"); for(int i=0;i<(PIXCEL_NUM);i++){//各画素の波長を送信 Serial.print(","); Serial.print(c12880ma.i_lamdas[i]); } Serial.print("\nReference light"); for(int i=0;i<(PIXCEL_NUM);i++){//参照光の値を送信 Serial.print(","); Serial.print(Ref.data[i]); } Serial.print("\nTransmitted Light"); for(int i=0;i<(PIXCEL_NUM);i++){//透過光の値を送信 Serial.print(","); Serial.print(Trans.data[i]); } Serial.print("\n"); break; case GAMEBOY_KEY_SELECT ://セレクトボタン break; case GAMEBOY_KEY_A ://Aボタン break; case GAMEBOY_KEY_B ://Bボタン break; case GAMEBOY_KEY_UP ://↑のとき、delay_time_microsecondをStep_Ratio_Delay_Time倍する delay_time_microsecond*=Step_Ratio_Delay_Time; if(delay_time_microsecond>MAX_Delay_Time_Microsecond){ delay_time_microsecond=MAX_Delay_Time_Microsecond; } update_screen(); break; case GAMEBOY_KEY_RIGHT ://→のとき、delay_time_microsecondをStep_Delay_Time増やす delay_time_microsecond+=Step_Delay_Time; if(delay_time_microsecond>MAX_Delay_Time_Microsecond){ delay_time_microsecond=MAX_Delay_Time_Microsecond; } update_screen(); break; case GAMEBOY_KEY_DOWN ://↓のとき、delay_time_microsecondを1/Step_Ratio_Delay_Time倍する delay_time_microsecond/=Step_Ratio_Delay_Time; if(delay_time_microsecond<MIN_Delay_Time_Microsecond){ delay_time_microsecond=MIN_Delay_Time_Microsecond; } update_screen(); break; case GAMEBOY_KEY_LEFT ://←のとき、delay_time_microsecondをStep_Delay_Time減らす delay_time_microsecond-=Step_Delay_Time; if(delay_time_microsecond<MIN_Delay_Time_Microsecond){ delay_time_microsecond=MIN_Delay_Time_Microsecond; } update_screen(); break; } c12880ma.set_delay_time_microsecond(delay_time_microsecond); //M5Stackのボタン入力に応じた処理 if (M5.BtnB.wasPressed()){//Bボタンで画面の更新(何もしない) update_screen(); } if (M5.BtnA.wasPressed()){ //Aボタンで参照光の測定 c12880ma.read_data(Ref); update_screen(); } if (M5.BtnC.wasPressed()){ //Cボタンで透過光の測定 c12880ma.read_data(Trans); update_screen(); } M5.update(); } ``` ```arduino:C12880ma.h #ifndef _C12880MA_H_ #define _C12880MA_H_ #include <M5Stack.h> #include <math.h> #include "CMF.h" using std::pow ; #define PIXCEL_NUM 288//C12880MAの画素数 //測定結果を格納するための構造体 struct Spectrum_Data{ uint8_t R,G,B; uint16_t color; int data[PIXCEL_NUM]; int max_value; void update_max(); }; //分光光度センサC12880MAを扱うためのクラス class C12880MA{ private: double pA0,pB1,pB2,pB3,pB4,pB5;//波長補正係数 int delay_time_microsecond=3;//クロック幅[μs] int CLK_pin,ST_pin,Video_pin;//クロックとスタートパルスとビデオ信号のピン番号 void clock_high_low(int pin_num);//クロックのようなものを作るメソッド uint8_t gamma_correction(double RGB_value);//RGBそれぞれのガンマ補正をするメソッド uint16_t XYZ_to_Color(double X,double Y,double Z);//XYZ→RGB変換、ガンマ補正をして、16bitのカラーコードを返すメソッド int calc_lamda(int pix_num);//画素の位置から波長を計算するメソッド。f(pix)=λ double calc_weight(int pix_num);//隣接する画素との波長の差(みたいなもの)dλ/d(pix)をもとに重みを求めるメソッド void calc_measured_color(Spectrum_Data &data);//スペクトル(分光分布)から色を計算するメソッド public: int i_lamdas[PIXCEL_NUM];//各画素位置に対応した光の波長の配列 //コンストラクタ。CLK、ST、及びVideo信号の接続されたピン番号、及びC12880MA購入時に付属している、検査成績書の値を記入すること。 C12880MA(int _CLK_pin,int _ST_pin,int _Video_pin,double _pA0,double _pB1,double _pB2,double _pB3,double _pB4,double _pB5); //スペクトルを測定するメソッド。引数にSpectrum_Data型のオブジェクトを指定して、スペクトルの配列と色情報を測定・格納する。 void read_data(Spectrum_Data &data); uint16_t calc_color(int pix_num);//単波長の光の色を計算するメソッド。画素位置を入力とする int get_delay_time_microsecond();//蓄積時間を取得する関数 void set_delay_time_microsecond(int value);//蓄積時間をセットする関数 }; #endif // _C12880MA_H_ ``` ```arduino:C12880ma.cpp #include "C12880ma.h" void Spectrum_Data::update_max(){ max_value=0; for(int i=0;i<PIXCEL_NUM;i++){ if (data[i]>max_value){ max_value=data[i]; } } } //クロックのようなものを作るメソッド void C12880MA::clock_high_low(int pin_num){ digitalWrite(pin_num,1); delayMicroseconds(delay_time_microsecond); digitalWrite(pin_num,0); } //RGBそれぞれのガンマ補正をするメソッド uint8_t C12880MA::gamma_correction(double RGB_value){ double tmp_value; //ガンマ補正 if(RGB_value<0.0031308){ tmp_value=12.92*RGB_value; } else{ tmp_value=1.055*pow(RGB_value,(1/2.4))-0.055; } //値を0~1に修正する if(tmp_value>1){ tmp_value=1.0; } else if(tmp_value<0){ tmp_value=0; } return uint8_t(tmp_value*255); } //XYZ→RGB変換、ガンマ補正をして、16bitのカラーコードを返すメソッド uint16_t C12880MA::XYZ_to_Color(double X,double Y,double Z){ uint16_t color_value=TFT_BLACK;//例外になる領域は、とりあえず黒で描画する //XYZ→xyzの変換を行う double sum_XYZ=X+Y+Z; if(sum_XYZ!=0){ double x=X/sum_XYZ; double y=Y/sum_XYZ; double z=Z/sum_XYZ; if(y!=0){//xyz→XYZの変換を行う X=x/y; Y=1.0; Z=z/y; //xyz→RGBの変換を行う uint8_t R=gamma_correction(3.241*X-1.5374*Y-0.4986*Z); uint8_t G=gamma_correction(-0.9692*X+1.876*Y+0.0416*Z); uint8_t B=gamma_correction(0.0556*X-0.204*Y+1.057*Z); color_value=( ((R>>3)<<11) | (G>>2)<<5 | B>>3 );//R、Bを5bit、Gを6bitになるようビットシフトする } } return color_value; } //画素の位置から波長を計算するメソッド。f(pix)=λ int C12880MA::calc_lamda(int pix_num){ //画素数から波長を計算する。最後の「+0.5」は、値を四捨五入して整数値を返すため。 return int(pA0+pB1*pix_num+pB2*pow(pix_num,2.0)+pB3*pow(pix_num,3.0)+pB4*pow(pix_num,4.0)+pB5*pow(pix_num,5.0)+0.5); } //隣接する画素との波長の差(みたいなもの)dλ/d(pix)をもとに重みを求めるメソッド //画素の位置によってセンサの波長方向の分解能が変わるので、画素と波長の関数を画素方向で微分して重みとして扱う。 double C12880MA::calc_weight(int pix_num){ return 1.0/(pB1+2.0*pB2*pix_num+3.0*pB3*pow(pix_num,2.0)+4.0*pB4*pow(pix_num,3.0)+5.0*pB5*pow(pix_num,4.0)); } //スペクトル(分光分布)から色を計算するメソッド void C12880MA::calc_measured_color(Spectrum_Data &data){ //以下の処理で例外処理に該当する場合、色はとりあえず黒にしておく data.color=TFT_BLACK; data.R=0; data.G=0; data.B=0; //XYZの値を計算する double X=0.0; double Y=0.0; double Z=0.0; //等色関数とスペクトルの測定値と重みをXYZについてそれぞれ掛け合わせて足す //なお、dλ/d(pix)を重みとする。 for(int i=0;i<PIXCEL_NUM;i++){ if (i_lamdas[i]>=390 and i_lamdas[i]<=830){//可視光領域だったら X+=calc_weight(i)*data.data[i]*CMF_390_830_X[i_lamdas[i]-390]; Y+=calc_weight(i)*data.data[i]*CMF_390_830_Y[i_lamdas[i]-390]; Z+=calc_weight(i)*data.data[i]*CMF_390_830_Z[i_lamdas[i]-390]; } } //XYZ→xyzの変換を行う double sum_XYZ=X+Y+Z; if(sum_XYZ!=0){ double x=X/sum_XYZ; double y=Y/sum_XYZ; double z=Z/sum_XYZ; if(y!=0){//xyz→XYZの変換を行う X=x/y; Y=1.0; Z=z/y; //xyz→RGBの変換を行う data.R=gamma_correction(3.241*X-1.5374*Y-0.4986*Z); data.G=gamma_correction(-0.9692*X+1.876*Y+0.0416*Z); data.B=gamma_correction(0.0556*X-0.204*Y+1.057*Z); data.color=( ((data.R>>3)<<11) | (data.G>>2)<<5 | data.B>>3 );//R、Bを5bit、Gを6bitになるようビットシフトする } } } //単波長の光の色を計算するメソッド。画素位置を入力とする uint16_t C12880MA::calc_color(int pix_num){ uint16_t color_value=TFT_BLACK;//可視光領域外の部分は、とりあえず黒で描画する if (i_lamdas[pix_num]>=390 and i_lamdas[pix_num]<=830){//その画素位置が可視光領域だったら //等色関数から単波長の光の色(XYZ表色系)を計算する double X=CMF_390_830_X[i_lamdas[pix_num]-390]; double Y=CMF_390_830_Y[i_lamdas[pix_num]-390]; double Z=CMF_390_830_Z[i_lamdas[pix_num]-390]; color_value=XYZ_to_Color(X,Y,Z); } return color_value; } //コンストラクタ。CLK、ST、及びVideo信号の接続されたピン番号、及びC12880MA購入時に付属している、検査成績書の値を記入すること。 C12880MA::C12880MA(int _CLK_pin,int _ST_pin,int _Video_pin,double _pA0,double _pB1,double _pB2,double _pB3,double _pB4,double _pB5){ CLK_pin=_CLK_pin; ST_pin=_ST_pin; Video_pin=_Video_pin; pinMode(CLK_pin,OUTPUT); //CLKのピンを出力モードにする pinMode(ST_pin,OUTPUT); //STのピンを出力モードにする pA0 =_pA0; pB1 =_pB1; pB2 =_pB2; pB3 =_pB3; pB4 =_pB4; pB5 =_pB5; for(int i=0;i<PIXCEL_NUM;i++){ i_lamdas[i]=calc_lamda(i);//画素位置と波長の関係を調べておく } Serial.begin(115200);//デバッグ用 } //スペクトルを測定するメソッド。引数にSpectrum_Data型のオブジェクトを指定して、スペクトルの配列と色情報を測定・格納する。 void C12880MA::read_data(Spectrum_Data &data){ const int thp_ST=6;//スタートパルスhigh期間。6以上なら何でもOK const int Video_delay = 87; //Video取り込み開始までのクロック数 digitalWrite(ST_pin,1);//STをhighにする for(int i=0;i<(thp_ST);i++){//スタートパルスhigh期間分クロック clock_high_low(CLK_pin); } digitalWrite(ST_pin,0);//STをlowにする for(int i=0;i<(Video_delay);i++){//Video取り込み開始までのクロック数分クロック clock_high_low(CLK_pin); } for(int i=0;i<(PIXCEL_NUM);i++){//ここからVideo信号を取り込む clock_high_low(CLK_pin); data.data[i]=analogRead(Video_pin); } for(int i=0;i<(PIXCEL_NUM);i++){//読み込んだデータを、補正する if ((i_lamdas[i]>=340)and(i_lamdas[i]<=850)){ data.data[i]= (int)(data.data[i]*100/Relative_Sensitivity_340_850[i_lamdas[i]-340]); } } data.update_max(); //測定結果を使用して、色を計算する calc_measured_color(data); } //蓄積時間を取得するメソッド int C12880MA::get_delay_time_microsecond(){ return delay_time_microsecond; } //蓄積時間をセットするメソッド void C12880MA::set_delay_time_microsecond(int value){ delay_time_microsecond=value; } ``` ```arduino:CMF.h //CIE 1931 XYZ等色関数の配列。 //1nm単位で390nm~830nmまでの等色関数の値をXYZそれぞれに格納した。 //λ=a[nm](aは390以上830以下の整数)の等色関数の値は、CMF_390_830_X[a-390]となる。 //なお、等色関数の値は下記のサイトの値を使用した。 //http://cvrl.ioo.ucl.ac.uk/cmfs.htm const double CMF_390_830_X[]={0.003769647,0.004532416,0.005446553,0.006538868,0.007839699,0.009382967,0.011206080,0.013349650,0.015856900,0.018772860,0.022143020,0.026012850,0.030430360,0.035443250,0.041096400,0.047429860,0.054473940,0.062236120,0.070700480,0.079825130,0.089538030,0.099748480,0.110401900,0.121456600,0.132874100,0.144621400,0.156646800,0.168790100,0.180832800,0.192521600,0.203572900,0.213753100,0.223134800,0.231924500,0.240389200,0.248852300,0.257589600,0.266499100,0.275353200,0.283892100,0.291824600,0.298920000,0.305299300,0.311203100,0.316904700,0.322708700,0.328819400,0.334924200,0.340545200,0.345168800,0.348255400,0.349415300,0.348907500,0.347174600,0.344670500,0.341848300,0.339024000,0.335992600,0.332427600,0.328015700,0.322463700,0.315622500,0.307820100,0.299477100,0.290977600,0.282664600,0.274796200,0.267431200,0.260584700,0.254274900,0.248525400,0.243303900,0.238341400,0.233325300,0.227961900,0.221978100,0.215173500,0.207561900,0.199218300,0.190229000,0.180690500,0.170715400,0.160447100,0.150024400,0.139570500,0.129192000,0.118985900,0.109061500,0.099514240,0.090418500,0.081828950,0.073768170,0.066194770,0.059063800,0.052342420,0.046008650,0.040061540,0.034543730,0.029490910,0.024921400,0.020839810,0.017235910,0.014079240,0.011345160,0.009019658,0.007097731,0.005571145,0.004394566,0.003516303,0.002887638,0.002461588,0.002206348,0.002149559,0.002337091,0.002818931,0.003649178,0.004891359,0.006629364,0.008942902,0.011902240,0.015569890,0.019976680,0.025046980,0.030675300,0.036749990,0.043151710,0.049785840,0.056685540,0.063916510,0.071543520,0.079629170,0.088214730,0.097269780,0.106750400,0.116619200,0.126846800,0.137406000,0.148247100,0.159307600,0.170518100,0.181802600,0.193109000,0.204508500,0.216116600,0.228065000,0.240501500,0.253544100,0.267130000,0.281135100,0.295416400,0.309811700,0.324167800,0.338431900,0.352578600,0.366583900,0.380424400,0.394098800,0.407697200,0.421348400,0.435200300,0.449420600,0.464161600,0.479439500,0.495218000,0.511439500,0.528023300,0.544869600,0.561889800,0.579013700,0.596188200,0.613378400,0.630589700,0.647922300,0.665486600,0.683378200,0.701677400,0.720411000,0.739449500,0.758628500,0.777788500,0.796775000,0.815453000,0.833738900,0.851549300,0.868786200,0.885337600,0.901158800,0.916527800,0.931824500,0.947452400,0.963838800,0.981259600,0.999295300,1.017343000,1.034790000,1.051011000,1.065522000,1.078421000,1.089944000,1.100320000,1.109767000,1.118438000,1.126266000,1.133138000,1.138952000,1.143620000,1.147095000,1.149464000,1.150838000,1.151326000,1.151033000,1.150002000,1.148061000,1.144998000,1.140622000,1.134757000,1.127298000,1.118342000,1.108033000,1.096515000,1.083928000,1.070387000,1.055934000,1.040592000,1.024385000,1.007344000,0.989526800,0.971121300,0.952325700,0.933324800,0.914287700,0.895279800,0.876015700,0.856160700,0.835423500,0.813556500,0.790456500,0.766436400,0.741877700,0.717121900,0.692471700,0.668160000,0.644269700,0.620845000,0.597924300,0.575541000,0.553729600,0.532541200,0.512021800,0.492207000,0.473122400,0.454741700,0.436871900,0.419312100,0.401898000,0.384498600,0.367059200,0.349716700,0.332630500,0.315934100,0.299737400,0.284118900,0.269105300,0.254707700,0.240931900,0.227779200,0.215243100,0.203301000,0.191927600,0.181098700,0.170791400,0.160984200,0.151657700,0.142793600,0.134373700,0.126380800,0.118797900,0.111608800,0.104797500,0.098348350,0.092245970,0.086475060,0.081019860,0.075865140,0.070996330,0.066399600,0.062062250,0.057974090,0.054125330,0.050506000,0.047106060,0.043914110,0.040914110,0.038090670,0.035430340,0.032921380,0.030556720,0.028341460,0.026280330,0.024374650,0.022623060,0.021019350,0.019546470,0.018187270,0.016927270,0.015754170,0.014658540,0.013635710,0.012682050,0.011793940,0.010967780,0.010199640,0.009484317,0.008816851,0.008192921,0.007608750,0.007061391,0.006549509,0.006071970,0.005627476,0.005214608,0.004831848,0.004477579,0.004150166,0.003847988,0.003569452,0.003312857,0.003076022,0.002856894,0.002653681,0.002464821,0.002289060,0.002125694,0.001974121,0.001833723,0.001703876,0.001583904,0.001472939,0.001370151,0.001274803,0.001186238,0.001103871,0.001027194,0.000955749,0.000889126,0.000826954,0.000768935,0.000714943,0.000664859,0.000618542,0.000575830,0.000536505,0.000500184,0.000466501,0.000435139,0.000405830,0.000378373,0.000352689,0.000328720,0.000306400,0.000285658,0.000266411,0.000248546,0.000231953,0.000216530,0.000202185,0.000188834,0.000176394,0.000164790,0.000153954,0.000143827,0.000134357,0.000125514,0.000117271,0.000109598,0.000102469,0.000095847,0.000089683,0.000083927,0.000078537,0.000073476,0.000068716,0.000064253,0.000060083,0.000056201,0.000052599,0.000049263,0.000046166,0.000043282,0.000040587,0.000038061,0.000035688,0.000033460,0.000031371,0.000029414,0.000027582,0.000025870,0.000024267,0.000022766,0.000021360,0.000020041,0.000018804,0.000017644,0.000016557,0.000015539,0.000014588,0.000013699,0.000012867,0.000012089,0.000011362,0.000010681,0.000010044,0.000009446,0.000008885,0.000008356,0.000007858,0.000007387,0.000006944,0.000006527,0.000006135,0.000005768,0.000005425,0.000005104,0.000004804,0.000004522,0.000004259,0.000004013,0.000003782,0.000003564,0.000003360,0.000003168,0.000002986,0.000002815,0.000002654,0.000002502,0.000002359,0.000002224,0.000002098,0.000001979,0.000001867,0.000001762}; const double CMF_390_830_Y[]={0.000414616,0.000502833,0.000608499,0.000734444,0.000883739,0.001059646,0.001265532,0.001504753,0.001780493,0.002095572,0.002452194,0.002852216,0.003299115,0.003797466,0.004352768,0.004971717,0.005661014,0.006421615,0.007250312,0.008140173,0.009079860,0.010056080,0.011064560,0.012105220,0.013180140,0.014293770,0.015450040,0.016640930,0.017853020,0.019070180,0.020273690,0.021448050,0.022600410,0.023747890,0.024912470,0.026121060,0.027399230,0.028749930,0.030169090,0.031651450,0.033190380,0.034779120,0.036414950,0.038095690,0.039818430,0.041579400,0.043370980,0.045171800,0.046954200,0.048687180,0.050336570,0.051876110,0.053322180,0.054706030,0.056063350,0.057433930,0.058851070,0.060308090,0.061786440,0.063265700,0.064723520,0.066147490,0.067572560,0.069049280,0.070632800,0.072383390,0.074359600,0.076593830,0.079114360,0.081953450,0.085148160,0.088726570,0.092660080,0.096897230,0.101374600,0.106014500,0.110737700,0.115511100,0.120312200,0.125116100,0.129895700,0.134629900,0.139330900,0.144023500,0.148737200,0.153506600,0.158364400,0.163319900,0.168376100,0.173536500,0.178804800,0.184181900,0.189655900,0.195210100,0.200825900,0.206482800,0.212182600,0.218027900,0.224158600,0.230730200,0.237916000,0.245870600,0.254602300,0.264076000,0.274249000,0.285068000,0.296483700,0.308501000,0.321139300,0.334417500,0.348353600,0.362960100,0.378227500,0.394135900,0.410658200,0.427759500,0.445399300,0.463539600,0.482137600,0.501143000,0.520497200,0.540138700,0.560020800,0.580097200,0.600317200,0.620625600,0.640939800,0.661077200,0.680813400,0.699904400,0.718089000,0.735159300,0.751182100,0.766314300,0.780735200,0.794644800,0.808207400,0.821381700,0.834070100,0.846171100,0.857579900,0.868240800,0.878306100,0.887990700,0.897521100,0.907134700,0.916994700,0.926929500,0.936673100,0.945948200,0.954467500,0.961983400,0.968439000,0.973828900,0.978151900,0.981410600,0.983666900,0.985208100,0.986381300,0.987535700,0.989022800,0.991081100,0.993491300,0.995917200,0.998020500,0.999460800,0.999993000,0.999755700,0.998983900,0.997912300,0.996773700,0.995735600,0.994711500,0.993553400,0.992115600,0.990254900,0.987859600,0.984932400,0.981503600,0.977603500,0.973261100,0.968476400,0.963136900,0.957106200,0.950254000,0.942456900,0.933689700,0.924289300,0.914670700,0.905233300,0.896361300,0.888306900,0.880846200,0.873644500,0.866375500,0.858720300,0.850429500,0.841504700,0.832010900,0.822015400,0.811586800,0.800787400,0.789651500,0.778205300,0.766473300,0.754478500,0.742247300,0.729822900,0.717252500,0.704581800,0.691855300,0.679100900,0.666284600,0.653359500,0.640280700,0.627006600,0.613514800,0.599849400,0.586068200,0.572226100,0.558374600,0.544553500,0.530767300,0.517013000,0.503288900,0.489595000,0.475944200,0.462395800,0.449015400,0.435862200,0.422989700,0.410415200,0.398035600,0.385730000,0.373390700,0.360924500,0.348286000,0.335570200,0.322896300,0.310370400,0.298086500,0.286116000,0.274482200,0.263195300,0.252262800,0.241690200,0.231480900,0.221637800,0.212162200,0.203054200,0.194312400,0.185922700,0.177827400,0.169965400,0.162284100,0.154739700,0.147308100,0.140016900,0.132901300,0.125991300,0.119312000,0.112882000,0.106711300,0.100805200,0.095166530,0.089795940,0.084690440,0.079840090,0.075233720,0.070860610,0.066710450,0.062773600,0.059041790,0.055507030,0.052161390,0.048996990,0.046005780,0.043178850,0.040507550,0.037983760,0.035599820,0.033348560,0.031223320,0.029217800,0.027326010,0.025542230,0.023861210,0.022278590,0.020790200,0.019391850,0.018079390,0.016848170,0.015691880,0.014604460,0.013580620,0.012615730,0.011706960,0.010856080,0.010064760,0.009333376,0.008661284,0.008046048,0.007481130,0.006959987,0.006477070,0.006027677,0.005608169,0.005216691,0.004851785,0.004512008,0.004195941,0.003902057,0.003628371,0.003373005,0.003134315,0.002910864,0.002701528,0.002505796,0.002323231,0.002153333,0.001995557,0.001849316,0.001713976,0.001588899,0.001473453,0.001367022,0.001268954,0.001178421,0.001094644,0.001016943,0.000944727,0.000877517,0.000815044,0.000757076,0.000703376,0.000653705,0.000607805,0.000565344,0.000526005,0.000489506,0.000455597,0.000424055,0.000394686,0.000367318,0.000341794,0.000317974,0.000295744,0.000275056,0.000255864,0.000238114,0.000221745,0.000206671,0.000192747,0.000179832,0.000167802,0.000156557,0.000146017,0.000136154,0.000126945,0.000118367,0.000110393,0.000102991,0.000096118,0.000089733,0.000083797,0.000078274,0.000073133,0.000068341,0.000063870,0.000059694,0.000055789,0.000052135,0.000048722,0.000045538,0.000042574,0.000039819,0.000037259,0.000034875,0.000032648,0.000030561,0.000028602,0.000026758,0.000025029,0.000023414,0.000021909,0.000020513,0.000019219,0.000018018,0.000016899,0.000015853,0.000014872,0.000013951,0.000013085,0.000012273,0.000011512,0.000010800,0.000010134,0.000009510,0.000008926,0.000008378,0.000007864,0.000007382,0.000006929,0.000006505,0.000006108,0.000005737,0.000005390,0.000005065,0.000004762,0.000004478,0.000004212,0.000003962,0.000003729,0.000003509,0.000003302,0.000003107,0.000002922,0.000002748,0.000002585,0.000002431,0.000002287,0.000002152,0.000002026,0.000001907,0.000001797,0.000001693,0.000001596,0.000001505,0.000001419,0.000001339,0.000001263,0.000001191,0.000001123,0.000001059,0.000000999,0.000000942,0.000000889,0.000000839,0.000000791,0.000000747,0.000000705}; const double CMF_390_830_Z[]={0.018472600,0.022211010,0.026698190,0.032069370,0.038478320,0.046097840,0.055119530,0.065752570,0.078221130,0.092760130,0.109609000,0.129007700,0.151204700,0.176444100,0.204951700,0.236924600,0.272512300,0.311782000,0.354706400,0.401147300,0.450836900,0.503416400,0.558636100,0.616273400,0.676098200,0.737882200,0.801301900,0.865557300,0.929579100,0.992129300,1.051821000,1.107509000,1.159527000,1.208869000,1.256834000,1.305008000,1.354758000,1.405594000,1.456414000,1.505960000,1.552826000,1.595902000,1.635768000,1.673573000,1.710604000,1.748280000,1.787504000,1.826609000,1.863108000,1.894332000,1.917479000,1.930529000,1.934819000,1.932650000,1.926395000,1.918437000,1.910430000,1.901224000,1.889000000,1.871996000,1.848545000,1.817792000,1.781627000,1.742514000,1.702749000,1.664439000,1.629207000,1.597360000,1.568896000,1.543823000,1.522157000,1.503611000,1.486673000,1.469595000,1.450709000,1.428440000,1.401587000,1.370094000,1.334220000,1.294275000,1.250610000,1.203696000,1.154316000,1.103284000,1.051347000,0.999178900,0.947395800,0.896622200,0.847398100,0.800157600,0.755237900,0.712787900,0.672519800,0.634097600,0.597243300,0.561731300,0.527492100,0.494880900,0.464258600,0.435884100,0.409931300,0.386426100,0.365056600,0.345481200,0.327409500,0.310593900,0.294810200,0.279819400,0.265410000,0.251408400,0.237675300,0.224121100,0.210748400,0.197583900,0.184657400,0.172001800,0.159691800,0.147941500,0.136942800,0.126827900,0.117679600,0.109497000,0.102094300,0.095279930,0.088900750,0.082835480,0.077009820,0.071440010,0.066154360,0.061171990,0.056504070,0.052151210,0.048095660,0.044317200,0.040797340,0.037519120,0.034468460,0.031637640,0.029019010,0.026603640,0.024381640,0.022340970,0.020464150,0.018734560,0.017137880,0.015661740,0.014296440,0.013037020,0.011878970,0.010817250,0.009846470,0.008960687,0.008152811,0.007416025,0.006744115,0.006131421,0.005572778,0.005063463,0.004599169,0.004175971,0.003790291,0.003438952,0.003119341,0.002829038,0.002565722,0.002327186,0.002111280,0.001915766,0.001738589,0.001577920,0.001432128,0.001299781,0.001179667,0.001070694,0.000971862,0.000882253,0.000801023,0.000727388,0.000660635,0.000600115,0.000545242,0.000495485,0.000450364,0.000409446,0.000372335,0.000338674,0.000308140,0.000280437,0.000255300,0.000232486,0.000211777,0.000192976,0.000175902,0.000160395,0.000146306,0.000133503,0.000121866,0.000111286,0.000101663,0.000092910,0.000084945,0.000077694,0.000071092,0.000065079,0.000059601,0.000054607,0.000050054,0.000045902,0.000042113,0.000038654,0.000035497,0.000032612,0.000029976,0.000027567,0.000025363,0.000023347,0.000021502,0.000019813,0.000018265,0.000016847,0.000015546,0.000014354,0.000013259,0.000012254,0.000011332,0.000010484,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000}; //分光感度特性のグラフをもとに、感度を補正するための配列。正確なキャリブレーションができないため、データシートのグラフをもとにそれっぽい値を作成した。 const double Relative_Sensitivity_340_850[]={54.20285846,54.8794054,55.55595234,56.11997971,56.6828394,57.24569908,57.9587263,58.67675984,59.36860667,60.0278457,60.68708472,61.51481672,62.35629423,63.06500818,63.74117465,64.4317734,65.28799481,66.14421622,66.88806684,67.59570818,68.20565527,68.70311719,69.2005791,70.43844858,71.2672269,72.42016805,73.06132086,73.67816913,74.25860598,75.3968254,76.22267357,76.91713751,77.74069852,78.80837649,78.80073366,80.52276563,81.07918145,81.51200078,82.05076237,83.01343424,83.96325607,84.62085076,85.27844544,85.93546979,86.59100157,87.24653334,88.11767821,89.13419045,88.6455331,89.22342316,89.87113606,90.51884895,91.16656184,91.7659287,92.20149631,92.63706393,93.07263154,93.49818431,93.91454508,94.33090584,94.7472683,95.1636458,95.578994,95.75621114,95.93342829,96.11064544,96.28786259,96.4314641,96.53781281,96.64416152,96.75051023,96.76591554,96.76254725,96.75917896,96.75581067,96.75244238,96.69839323,96.61788094,96.53736865,96.45685636,96.34660495,96.22024763,96.09389031,95.967533,95.84117568,95.73020428,95.62188766,95.51357104,95.40525442,95.2969378,95.14875962,94.95317161,94.75758361,94.56484598,94.42406394,94.2832819,94.14249985,94.01230632,93.9039999,93.79569348,93.68738706,93.57908065,93.47949809,93.40617444,93.3328508,93.25952715,93.19796119,93.20247813,93.20699507,93.21151201,93.21602895,93.24981953,93.32107537,93.39233122,93.46358707,93.53484291,93.70466655,93.87818133,94.05169612,94.22561681,94.42547788,94.62533895,94.82520002,95.0250611,95.25714267,95.49804792,95.73895317,95.95029875,96.15370548,96.35711221,96.59745087,96.85779087,97.11813088,97.36989372,97.60661535,97.84333698,98.04247351,98.20558843,98.36870336,98.53181828,98.6949332,98.83478368,98.96631409,99.0978445,99.22937491,99.35076018,99.44988459,99.54900901,99.64813342,99.74725784,99.7395355,99.72157966,99.70362382,99.68566798,99.66771214,99.64975629,99.63180045,99.61384461,99.59588877,99.51206892,99.37348578,99.23490265,99.09631951,98.95773638,98.81915325,98.49380968,98.15452005,97.81523042,97.47731491,97.15093455,96.82455419,96.26657195,95.73097678,95.43440653,95.13783629,94.52330019,93.91268925,93.39286313,92.87303701,92.43030701,92.02349707,91.55974548,90.88485482,90.32136753,89.8188034,89.36806147,88.94961569,88.3023941,87.54423291,86.95740655,86.3705802,85.85993996,85.37749074,84.89504151,84.46292576,84.15551662,83.84810748,82.77998776,82.21273517,81.69410364,81.44505154,81.19599943,80.94694733,80.58340462,79.99657826,79.52705581,79.31827865,79.10950148,78.90072432,78.64779087,78.25296065,77.96522828,77.81430073,77.66337318,77.51244563,77.36932611,77.2790361,77.18874609,77.09845608,77.00816606,76.96112599,76.93880887,76.91649174,76.89417462,76.87185749,76.91019102,76.95169664,76.99320225,77.03470786,77.09713709,77.16409707,77.23105704,77.29801702,77.364977,77.45123155,77.54353183,77.6358321,77.72810876,77.80366597,77.87922318,77.9547804,78.03033761,78.10524945,78.17971505,78.25418066,78.32864626,78.39651717,78.43456068,78.47260419,78.51064769,78.5486912,78.55390613,78.510354,78.46680186,78.42324973,78.36589443,78.284773,78.20365157,78.12253013,78.02482203,77.87579847,77.72677492,77.57775136,77.42872781,77.25026831,77.04908472,76.8707483,76.8707483,76.85093319,76.57855121,76.30616923,76.03378725,75.7990132,75.59298782,75.38696244,75.18093706,74.94743592,74.71240453,74.47737315,74.26211279,74.05270899,73.84330519,73.5855104,73.31840749,73.05130458,72.8098509,72.57576637,72.34168184,72.08166159,71.81213838,71.52373792,71.19440513,70.86507233,70.57556694,70.30794134,70.04031575,69.82734979,69.65225058,69.47715137,69.30205216,69.04969228,68.72549498,68.40129769,67.95326555,67.58636364,67.36363636,67.14090908,66.87890658,66.5574705,66.2363213,65.95359056,65.67085981,65.37451304,65.04806656,64.72162008,64.28959147,63.88736208,63.65018396,63.41300584,63.17373662,62.84625705,62.51877749,62.19129793,61.86381837,61.52799928,61.16453503,60.80107078,60.43760652,60.07414227,59.71067802,59.32692694,58.94239935,58.55787177,58.17334418,57.79132622,57.41063966,57.0299531,56.64926655,56.28729496,55.93307809,55.57886123,55.22464436,54.86950247,54.48660199,54.1037015,53.72080101,53.33790053,52.98495519,52.63601601,52.28707683,51.93813766,51.59370692,51.26270416,50.9317014,50.60069863,50.26969587,49.93869311,49.56983492,49.17921418,48.78859345,48.39797271,48.00735197,47.69933114,47.40330071,47.10727029,46.81123987,46.51520944,46.19762655,45.72452022,45.25141389,44.77830756,44.48580002,44.20643447,43.92706892,43.64770338,43.36833783,43.02527701,42.55827341,42.09126981,41.65607259,41.35300554,41.04993849,40.74687143,40.44380438,40.14073733,39.81606024,39.48737533,39.15869042,38.83000551,38.51229161,38.20897477,37.90565793,37.60234109,37.29902425,36.984234,36.6660748,36.3479156,36.0297564,35.71159719,35.39572391,35.07989453,34.76406515,34.44823576,34.13416925,33.82765801,33.52114678,33.21463555,32.90812432,32.60346136,32.30160854,31.99975572,31.6979029,31.39605008,31.10492579,30.82083233,30.53673886,30.2526454,29.96855194,29.68837107,29.41379438,29.13921769,28.864641,28.59006432,28.31548763,28.0549006,27.79742318,27.53994575,27.28246833,27.02499091,26.77092415,26.52866006,26.28639598,26.0441319,25.80186781,25.55960373,25.32112681,25.09534742,24.86956803,24.64378864,24.41800926,24.19222987,23.96645048,23.73739583,23.50769201,23.27798819,23.04828438,22.81858056,22.58887674,22.35687203,22.12193516,21.8869983,21.65206143,21.41712456,21.18218769,20.94709062,20.70860374,20.47011685,20.23162997,19.99314308,19.7546562,19.51616932,19.29432407,19.07977493,18.86522579,18.65067665,18.43612751,18.22157837,18.00613001,17.78805322,17.56997642,17.35189962,17.13382283,16.91574603,16.69766923,16.48552744,16.28036633,16.07520522,15.8700441,15.66488299,15.45972188,15.25456077,15.05310084,14.86198813,14.67087542,14.47976271,14.28864999,14.09753728,13.90642457,13.71531185,13.5365882,13.36406278,13.19153737,13.01901196,12.84648655,12.67396114,12.50143572,12.32891031,12.16029131,12.00232359,11.84435587,11.68638816,11.52842044,11.37045272,11.212485,11.05451728,10.89654956,10.7573908,10.63953361,10.52167642,10.40381924,10.28596205}; ``` 終わりに ==== 宝石コレクターなので、様々な宝石を、複数個ずつ持っていますが、「本当にこれルビーなの?」というような疑念がずっとありましたが、今回作った分光光度計を使うと、「どうも本当にルビーっぽいな?」という程度には確信を持てるようになりました。 また、この分光光度計で、植物を育てるライトが本当に植物の光合成に必要な波長を備えているのか、サンゴ育成用の照明にサンゴが光合成するのに必要な波長の光(紫外線領域を含む)が含まれているのか、など、宝石の鑑別以外にも様々活用しています。