【项目源起】 学校化学老师要参加省优质课比赛,其中设计了一个化学实验演示环节,其目的是让学生感受到化学反应中能量的变化和分布情况。于是他想请我帮忙设计一个热成像装置,能够以图形化的方式展示化学反应中能量的变化和分布情况,让能量可视化。于是就有了下面这个作品…… 【项目展示】 热成像装置具有两种显示模式:图形化显示模式(如图2)和数字矩阵显示模式(如图3)。 【功能简介】 (1)感测温度:通过非接触探测红外能量,并将其转换为电信号,进而将数据传到显示屏幕上。 (2)热能成像:将接收到的能量数据,以8*8像素色块的形式显示出来。 (3)模式切换:该系统有两种显示模式:分别为数字矩阵模式和图像模式,可以在两种模式之间进行切换。 【硬件材料】 表1项目器材清单 其中AMG8833热成像模块具备分别率为 8X8,同时支持 arduino 或者树莓派,I2C 接口,供电为 3-5 伏,紧凑,尺寸小,容易集成。传感器可以测量的温度范围是 0-80 摄氏度,准确度为 2.5 摄氏度,可以从 7 米外到测到一个人,10hz 的刷新率,是做热成像时不错的选择。 另外显示端我们使用的是1.44’TFT_LCD,总体来说这款显示屏,满足了基本的图形化显示需求,但从显示的分别率来说有些低,热成像显示时像素的颗粒感比较重。
【制作过程】1
1.结构设计 我们将本次作品结构的外形结构设计为一个相机(来自雷宇社区,我修改了部分结构,懒!),使用雷宇激光的LaserMaker绘制结构图。整个结构我们将其分为三个部分:镜头部分、机身部分和机身前后盖板。镜头部分用于放置AMG8833热成像模块,机身部分内置主控器和显示屏。 镜头部分: 3.电路连线 4代码编写
-
- #include <Adafruit_GFX.h> // Core graphics library
- #include <Adafruit_ILI9341.h>
- #include <SPI.h>
-
- #include <Wire.h>
- #include <Adafruit_AMG88xx.h>
-
- #ifdef ESP8266
- #define STMPE_CS 16
- #define TFT_CS 0
- #define TFT_DC 15
- #define SD_CS 2
- #endif
- #ifdef ESP32
- #define STMPE_CS 32
- #define TFT_CS 15
- #define TFT_DC 33
- #define SD_CS 14
- #endif
- #if defined(__AVR__) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
- #define STMPE_CS 6
- #define TFT_CS 9
- #define TFT_DC 10
- #define SD_CS 5
- #endif
- #ifdef TEENSYDUINO
- #define TFT_DC 10
- #define TFT_CS 4
- #define STMPE_CS 3
- #define SD_CS 8
- #endif
- #ifdef ARDUINO_STM32_FEATHER
- #define TFT_DC PB4
- #define TFT_CS PA15
- #define STMPE_CS PC7
- #define SD_CS PC5
- #endif
- #ifdef ARDUINO_FEATHER52
- #define STMPE_CS 30
- #define TFT_CS 13
- #define TFT_DC 11
- #define SD_CS 27
- #endif
-
- //Comment this out to remove the text overlay
- #define SHOW_TEMP_TEXT
-
- //low range of the sensor (this will be blue on the screen)
- #define MINTEMP 20
-
- //high range of the sensor (this will be red on the screen)
- #define MAXTEMP 28
-
- //the colors we will be using
- const uint16_t camColors[] = {0x480F,
- 0x400F,0x400F,0x400F,0x4010,0x3810,0x3810,0x3810,0x3810,0x3010,0x3010,
- 0x3010,0x2810,0x2810,0x2810,0x2810,0x2010,0x2010,0x2010,0x1810,0x1810,
- 0x1811,0x1811,0x1011,0x1011,0x1011,0x0811,0x0811,0x0811,0x0011,0x0011,
- 0x0011,0x0011,0x0011,0x0031,0x0031,0x0051,0x0072,0x0072,0x0092,0x00B2,
- 0x00B2,0x00D2,0x00F2,0x00F2,0x0112,0x0132,0x0152,0x0152,0x0172,0x0192,
- 0x0192,0x01B2,0x01D2,0x01F3,0x01F3,0x0213,0x0233,0x0253,0x0253,0x0273,
- 0x0293,0x02B3,0x02D3,0x02D3,0x02F3,0x0313,0x0333,0x0333,0x0353,0x0373,
- 0x0394,0x03B4,0x03D4,0x03D4,0x03F4,0x0414,0x0434,0x0454,0x0474,0x0474,
- 0x0494,0x04B4,0x04D4,0x04F4,0x0514,0x0534,0x0534,0x0554,0x0554,0x0574,
- 0x0574,0x0573,0x0573,0x0573,0x0572,0x0572,0x0572,0x0571,0x0591,0x0591,
- 0x0590,0x0590,0x058F,0x058F,0x058F,0x058E,0x05AE,0x05AE,0x05AD,0x05AD,
- 0x05AD,0x05AC,0x05AC,0x05AB,0x05CB,0x05CB,0x05CA,0x05CA,0x05CA,0x05C9,
- 0x05C9,0x05C8,0x05E8,0x05E8,0x05E7,0x05E7,0x05E6,0x05E6,0x05E6,0x05E5,
- 0x05E5,0x0604,0x0604,0x0604,0x0603,0x0603,0x0602,0x0602,0x0601,0x0621,
- 0x0621,0x0620,0x0620,0x0620,0x0620,0x0E20,0x0E20,0x0E40,0x1640,0x1640,
- 0x1E40,0x1E40,0x2640,0x2640,0x2E40,0x2E60,0x3660,0x3660,0x3E60,0x3E60,
- 0x3E60,0x4660,0x4660,0x4E60,0x4E80,0x5680,0x5680,0x5E80,0x5E80,0x6680,
- 0x6680,0x6E80,0x6EA0,0x76A0,0x76A0,0x7EA0,0x7EA0,0x86A0,0x86A0,0x8EA0,
- 0x8EC0,0x96C0,0x96C0,0x9EC0,0x9EC0,0xA6C0,0xAEC0,0xAEC0,0xB6E0,0xB6E0,
- 0xBEE0,0xBEE0,0xC6E0,0xC6E0,0xCEE0,0xCEE0,0xD6E0,0xD700,0xDF00,0xDEE0,
- 0xDEC0,0xDEA0,0xDE80,0xDE80,0xE660,0xE640,0xE620,0xE600,0xE5E0,0xE5C0,
- 0xE5A0,0xE580,0xE560,0xE540,0xE520,0xE500,0xE4E0,0xE4C0,0xE4A0,0xE480,
- 0xE460,0xEC40,0xEC20,0xEC00,0xEBE0,0xEBC0,0xEBA0,0xEB80,0xEB60,0xEB40,
- 0xEB20,0xEB00,0xEAE0,0xEAC0,0xEAA0,0xEA80,0xEA60,0xEA40,0xF220,0xF200,
- 0xF1E0,0xF1C0,0xF1A0,0xF180,0xF160,0xF140,0xF100,0xF0E0,0xF0C0,0xF0A0,
- 0xF080,0xF060,0xF040,0xF020,0xF800,};
-
- Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
-
- Adafruit_AMG88xx amg;
- unsigned long delayTime;
- float pixels[AMG88xx_PIXEL_ARRAY_SIZE];
- uint16_t displayPixelWidth, displayPixelHeight;
-
- void setup() {
- delay(500);
- Serial.begin(9600);
- Serial.println(F("AMG88xx thermal camera!"));
-
- tft.begin();
- tft.fillScreen(ILI9341_BLACK);
-
- displayPixelWidth = tft.width() / 8;
- displayPixelHeight = tft.width() / 8; //Keep pixels square
-
- tft.setRotation(0);
-
- bool status;
-
- // default settings
- status = amg.begin();
- if (!status) {
- Serial.println("Could not find a valid AMG88xx sensor, check wiring!");
- while (1);
- }
-
- Serial.println("-- Thermal Camera Test --");
- delay(100); // let sensor boot up
-
- }
-
- void loop() {
- //read all the pixels
- amg.readPixels(pixels);
-
- for(int i=0; i<AMG88xx_PIXEL_ARRAY_SIZE; i++){
-
- int colorTemp;
- if(pixels[i] >= MAXTEMP) colorTemp = MAXTEMP;
- else if(pixels[i] <= MINTEMP) colorTemp = MINTEMP;
- else colorTemp = pixels[i];
-
- uint8_t colorIndex = map(colorTemp, MINTEMP, MAXTEMP, 0, 255);
-
- colorIndex = constrain(colorIndex, 0, 255);
- //draw the pixels!
- tft.fillRect(displayPixelHeight * floor(i / 8), 40 + displayPixelWidth * ((AMG88xx_PIXEL_ARRAY_SIZE - i - 1) % 8),
- displayPixelHeight, displayPixelWidth, camColors[colorIndex]);
-
- #ifdef SHOW_TEMP_TEXT
- tft.setCursor( displayPixelHeight * floor(i / 8) + displayPixelHeight/2 - 12,
- 40 + displayPixelWidth * ((AMG88xx_PIXEL_ARRAY_SIZE - i - 1) % 8) + displayPixelHeight/2 - 4);
- tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1);
- tft.print(pixels[i],1);
- #endif
-
- }
- }
复制代码
复制代码
5.设备组装 第一步:安装镜头。 安装机身
安装前后面板
6.系统测试 7.改进与提升 本次制作过程中,为了节省制作周期,结构件是从网上找的模型,并对其进行修改。但还是忘记了电池仓,以至于供电外置。另外由于电子件后续需要复用,所以没有对电子件电路连接进行合理的优化设计,而只是简单的连接,使得显示屏的结构设计时。
|