2022年8月22日 星期一

簡易紫外光光譜儀(LED type) 組裝

  簡易紫外光光譜儀(LED type) 組裝

    一起DIY一台簡易紫外光光譜儀吧!


所需材料:

   深紫外線LED燈珠:20-25mW,波長分別有250nm、265nm、270nm、290nm、
                                   300nm、365nm。
   UV傳感器:型號 MCU-GUVA-S12S
   液晶顯示面板:TFT觸摸彩色SPI串口液晶屏顯示模塊
   麵包板電源:3.3V 5V 12V多路输出
   最小系統板:STM32F103C8T6 Blue Pill板

上層

    


下層

---------------------------------------------------------------------

操作

1.首先將樣品放置於0號PE袋內

2.將儀器電源開啟,開啟光源,再將樣品至於樣品檢測處,開始檢測,可依序箭頭指示方向一路檢測。


3.記錄螢幕顯示之數值變化,並與標準品比較,製出線性圖形即可定量或定性分析囉!
   螢幕顯示之數值為未換算前的穿透係數,需自行換算數值呦!


-----------------------------------------------------------------------------------------------------------------------------

程式碼如下

static const uint8_t toppyen[] PROGMEM = {   //stm32 可

  B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11111100, B10000000, B00000010, B10011111, B11111111, B11110000, 

  B11111111, B11111111, B00000000, B00000000, B00000000, B00111111, B11111111, B11110000, 

  B11111111, B11110000, B01111110, B00001111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11101111, B11111110, B10111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B10111111, B11111100, B00011111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11111000, B10111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11111000, B01111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11110000, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11100101, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11100011, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11010111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11101111, B11111111, B11111111, B11111111, B11111111, B11111001, B11111110, B11110000, 

  B11100011, B11111111, B11000011, B11100000, B01100000, B00110001, B11111100, B01110000, 

  B11100111, B11111111, B10000000, B11100000, B00100000, B00011011, B11111110, B01110000, 

  B11111111, B11111111, B00111000, B01100011, B01100011, B00011011, B11111110, B11110000, 

  B11111111, B11111110, B00111110, B11100011, B00000011, B00010011, B11111111, B11110000, 

  B11111111, B11110111, B01111110, B10100010, B00100010, B00010011, B11111111, B11110000, 

  B11111111, B11100110, B01111110, B00100000, B00100000, B00110011, B11111111, B11110000, 

  B11111111, B11000110, B01111110, B00101010, B11100000, B01110011, B11111111, B11110000, 

  B11111111, B11001110, B11111100, B01100111, B11100011, B11110011, B11111111, B11110000, 

  B11111111, B01001111, B10010110, B01100111, B11100011, B11110011, B11111111, B11110000, 

  B11111111, B00001111, B00000000, B11101011, B11100011, B11110011, B11110111, B11110000, 

  B11111110, B00111111, B11010011, B11111111, B11111111, B11111111, B11100111, B11110000, 

  B11111100, B00011111, B11111111, B11111111, B11111111, B11111111, B11100111, B11110000, 

  B11111001, B00111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111101, B00111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11110101, B01111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11110101, B00111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11110101, B00111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111001, B00011111, B11111111, B11111111, B11011111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

  B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000, 

};

//

#include "SPI.h"

#include "Adafruit_GFX_AS.h"

#include "Adafruit_ILI9341_STM.h"

#define TFT_DC PA15//9

#define TFT_CS PA8//PA3//10

#define TFT_RST PC15//10

//mosi PA7//sck PA5 //led 3.3v //miso PA6

//Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC);

//sdi(TFT) T-DIN sD-mosi PA7,

//sck(TFT) T-clk SD-sck PA5 ,

//sdo(TFT) T-DO  sD-miso PA6;

//led(TFT) 3.3v,

Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC, TFT_RST);

//#include <XPT2046_Touchscreen.h>

//#define CS_PIN  PB8

//#define TIRQ_PIN  PC14//2

//XPT2046_Touchscreen ts(CS_PIN);

//XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN);

//#include <SD.h>

//const int chipSelect = PB9;//PB10;//4;

int analogInPin0 = PA0;int sensorValue0 = 0;//255nm ,250-260

int analogInPin1 = PA1;int sensorValue1 = 0;//267.5nm,265-270,

int analogInPin2 = PA2;int sensorValue2 = 0;//275nm ,270-280

int analogInPin3 = PA3;int sensorValue3 = 0;//295nm ,290-300,

int analogInPin4 = PA4;int sensorValue4 = 0;//305nm ,300-310

int analogInPin5 = PB0;int sensorValue5 = 0;//365nm,

int sum0;int sum1;int sum2;

int sum3;int sum4;int sum5;

int numAverage =50;

//#include <Wire.h>


void tftShow(){

  tft.fillScreen(ILI9341_BLUE);                        //Background


  tft.fillRect(0, 0, 320, 30, ILI9341_RED);            //頂條底

  tft.setCursor(60, 5);

  tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(3);//頂條word

  tft.println("UA Spectrum");


  tft.fillRect(10, 40, 80, 30, ILI9341_GREEN);           //itm1 小label 1

  tft.setCursor(20, 55);                   

  tft.setTextColor(ILI9341_BLACK);  tft.setTextSize(1);//itm1 小label word

  tft.println("250-260nm");                            


  tft.fillRect(120, 40, 80, 30, ILI9341_GREEN);           //itm2 小label 2

  tft.setCursor(130, 55);                   

  tft.setTextColor(ILI9341_BLACK);  tft.setTextSize(1);//itm2 1小label word

  tft.println("265-270nm");  


  tft.fillRect(230, 40, 80, 30, ILI9341_GREEN);           //itm3 小label 3

  tft.setCursor(240, 55);                   

  tft.setTextColor(ILI9341_BLACK);  tft.setTextSize(1);//itm3 1小label word

  tft.println("270-280nm");  


  tft.fillRect(10, 145, 80, 30, ILI9341_GREEN);           //itm4 小label 1

  tft.setCursor(20, 160);                   

  tft.setTextColor(ILI9341_BLACK);  tft.setTextSize(1);//itm4 1小label word

  tft.println("290-300nm");  


  tft.fillRect(120, 145, 80, 30, ILI9341_GREEN);           //itm5 小label 1

  tft.setCursor(130, 160);                   

  tft.setTextColor(ILI9341_BLACK);  tft.setTextSize(1);//itm5 1小label word

  tft.println("300-310nm");  


  tft.fillRect(230, 145, 80, 30, ILI9341_GREEN);           //itm6 小label 1

  tft.setCursor(240, 160);                   

  tft.setTextColor(ILI9341_BLACK);  tft.setTextSize(1);//itm6 1小label word

  tft.println("365-365nm");  

  

  //tft.drawBitmap(180, 180, toppyen, 60, 40, ILI9341_RED); //Toppy Mark  

}


void runShow(){

  tft.fillRect(10, 75, 80, 70, ILI9341_RED);           //itm1 小label 1

  tft.setCursor(30, 100);                   

  tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(2);//itm1 小label word

  tft.println(sensorValue0);                            


  tft.fillRect(120, 75, 80, 70, ILI9341_RED);           //itm2 小label 2

  tft.setCursor(140, 100);                   

  tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(2);//itm2 1小label word

  tft.println(sensorValue1);  


  tft.fillRect(230, 75, 80, 70, ILI9341_RED);           //itm3 小label 3

  tft.setCursor(250, 100);                   

  tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(2);//itm3 1小label word

  tft.println(sensorValue2);  


  tft.fillRect(10, 175, 80, 70, ILI9341_RED);           //itm4 小label 1

  tft.setCursor(30, 200);                   

  tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(2);//itm4 1小label word

  tft.println(sensorValue3);  


  tft.fillRect(120, 175, 80, 70, ILI9341_RED);           //itm5 小label 1

  tft.setCursor(140, 200);                   

  tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(2);//itm5 1小label word

  tft.println(sensorValue4);  


  tft.fillRect(230, 175, 80, 70, ILI9341_RED);           //itm6 小label 1

  tft.setCursor(250, 200);                   

  tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(2);//itm6 1小label word

  tft.println(sensorValue5);  

}


void setup() {

pinMode(analogInPin0, INPUT_ANALOG);

pinMode(analogInPin1, INPUT_ANALOG);

pinMode(analogInPin2, INPUT_ANALOG);

pinMode(analogInPin3, INPUT_ANALOG);

pinMode(analogInPin4, INPUT_ANALOG);

pinMode(analogInPin5, INPUT_ANALOG);

  //pinMode(btn,INPUT_PULLUP);

  Serial.begin(9600);

  Serial.println("ILI9341 Test!"); 

  tft.begin();

  tft.setRotation(1);

  tftShow();

//SPI.setModule(2);//此何行決定***

//  if (!SD.begin(chipSelect)) {

//    Serial.println("Card failed, or not present");

//    while (1);

//  }  

//ts.begin();

//ts.setRotation(0);//3 

}


void loop(void) {

  for(int i=0;i<numAverage;i++){

      sensorValue0 = analogRead(analogInPin0);

      sum0 += sensorValue0;

      delay(10);

     }

  sensorValue0 = sum0/numAverage;


  for(int i=0;i<numAverage;i++){

      sensorValue1 = analogRead(analogInPin1);

      sum1 += sensorValue1;

      delay(10);

     }

  sensorValue1 = sum1/numAverage;


  for(int i=0;i<numAverage;i++){

      sensorValue2 = analogRead(analogInPin2);

      sum2 += sensorValue2;

      delay(10);

     }

  sensorValue2 = sum2/numAverage;


  for(int i=0;i<numAverage;i++){

      sensorValue3 = analogRead(analogInPin3);

      sum3 += sensorValue3;

      delay(10);

     }

  sensorValue3 = sum3/numAverage;


  for(int i=0;i<numAverage;i++){

      sensorValue4 = analogRead(analogInPin4);

      sum4 += sensorValue4;

      delay(10);

     }

  sensorValue4 = sum4/numAverage;


  for(int i=0;i<numAverage;i++){

      sensorValue5 = analogRead(analogInPin5);      

      sum5 += sensorValue5;

      delay(10);

     }

  sensorValue5 = sum5/numAverage;


runShow();

Serial.print(sensorValue0);Serial.print("  ");

Serial.print(sensorValue1);Serial.print("  ");

Serial.print(sensorValue2);Serial.print("  ");

Serial.print(sensorValue3);Serial.print("  ");

Serial.print(sensorValue4);Serial.print("  ");

Serial.print(sensorValue5);Serial.println("  ");

sensorValue0 = 0; sensorValue1 = 0; sensorValue2 = 0;

sensorValue3 = 0; sensorValue4 = 0; sensorValue5 = 0;

sum0 = 0; sum1 = 0; sum2 = 0;

sum3 = 0; sum4 = 0; sum5 = 0;

delay(40);


/* 

  if(Serial.available()) {

    // get the new byte:

    char inChar = (char)Serial.read();

    if (inChar == '1'){

      //run();

    }else if(inChar == '2'){

             tft.fillScreen(ILI9341_BLUE);

             tft.println("TRY");

    }else if(inChar == '3'){

             tftShow();

    }  else if(inChar == '4'){

             //tftShow2();

    } 

  }


  if (ts.touched()) {

    delay(400);

    TS_Point p = ts.getPoint();

    p.x = map(p.x ,3800,0,0,240);

    p.y = map(p.y ,0,3800,0,320);

    if(p.x >10 && p.x <60 && p.y >10 && p.y<60) {

      tft.drawRect(50, 50, 50, 50, ILI9341_RED);

      tft.drawRect(120, 120, 50, 50, ILI9341_WHITE);

    }

    if(p.x >80 && p.x <130 && p.y >80 && p.y<130) {

      tft.drawRect(50, 50, 50, 50, ILI9341_WHITE);

      tft.fillRect(120, 120, 50, 50, ILI9341_RED);

    }

    Serial.print("Pressure = ");

    Serial.print(p.z);

    Serial.print(", x = ");

    Serial.print(p.x);

    Serial.print(", y = ");

    Serial.print(p.y);

    delay(30);

    Serial.println();

  }

*/

}

1 則留言:

  1. 我是一名高中學生,我們也想自製分光光度計來檢測植物光合色素的數值,所以想請問一下,麵包板的線路是如何連結,以及其他線路分別是如何連結的?謝謝

    回覆刪除