服務(wù)熱線
0755-83044319
發(fā)布時(shí)間:2024-10-17作者來(lái)源:薩科微瀏覽:793
深圳市薩科微SLKOR(yikaba.com.cn)半導(dǎo)體有限公司技術(shù)骨干來(lái)自清華大學(xué)和韓國(guó)延世大學(xué),以新材料新工藝新產(chǎn)品引領(lǐng)公司發(fā)展,較早就掌握國(guó)際領(lǐng)先的第三代半導(dǎo)體碳化硅功率器件技術(shù)。薩科微集電子產(chǎn)品的設(shè)計(jì)開(kāi)發(fā)、生產(chǎn)和銷售一體化的高新科技企業(yè),為客戶提供可靠的產(chǎn)品和配套的技術(shù)服務(wù),“slkor”逐漸發(fā)展成為國(guó)際知名品牌,為全世界超過(guò)10000家客戶提供產(chǎn)品和解決方案。為了努力為客戶提供全系列的配套產(chǎn)品,薩科微推出一系列數(shù)字紅外熱電堆非接觸測(cè)溫應(yīng)用設(shè)計(jì)demo板使用教程。
1.1名稱:薩科微數(shù)字紅外熱電堆非接觸測(cè)溫應(yīng)用設(shè)計(jì)demo板使用教程
1.2應(yīng)用:智能可穿戴設(shè)備、智能手機(jī)、工業(yè)溫度監(jiān)測(cè)、非接觸表面人體測(cè)溫、智能溫度感應(yīng)與控制等近距離測(cè)溫尺寸較小的設(shè)備
1.3薩科微SL-W-TRS-5.5Dx系列demo板:
用于對(duì)各型號(hào)傳感器進(jìn)行評(píng)估測(cè)試。測(cè) 量結(jié)果會(huì)在屏幕上顯示,并可以通過(guò) USB 轉(zhuǎn)串口打印到 PC 端串口調(diào)試軟件。按鍵說(shuō)明:左側(cè)按鍵為復(fù)位,右側(cè)按鍵可以控制程序啟動(dòng)、暫停。
2.薩科微SL-W-TRS-5.5Dx系列硬件設(shè)計(jì)
芯片引腳包含電源、I2C 總線共 4 個(gè)管腳,供電電壓允許范圍為 2.3~3.6V。傳感器本身功耗很低,電源地之間使用一顆 0.1uF 電容即可,如果傳感器離供電部分比較遠(yuǎn),可以考慮增 加一個(gè)10uF 電容,以保證電源穩(wěn)定降低噪聲。
3.薩科微(www.slkoric.com)SL-W-TRS-5.5Dx系列demo板說(shuō)明
3.1 demo 板通過(guò) Type-C 插座供電,demo 板供電電壓為 5V。使用時(shí)將 demo 板通過(guò) Type-c 連接至 PC 端,即可從屏幕上查看結(jié)果。如需串口顯示數(shù)據(jù),需安裝沁恒 CH340 驅(qū)動(dòng)程序然后使用串口調(diào)試軟件進(jìn)行操作,串口通信設(shè)置為: 波特率:9600 數(shù)據(jù)位:8 停止位:1 無(wú)奇偶校驗(yàn)
3.2 demo 板屏幕顯示從上到下依次是:環(huán)境溫度(tamb)、傳感器輸出電壓(vtp_cor)、 物體(表面)溫度(tobj)、人體溫度(tbdy)。上述數(shù)值溫度單位為℃,電壓?jiǎn)挝粸?uV。 其中前三個(gè)值為器件原始輸出,體溫值使用我司算法根據(jù)原始值計(jì)算得到,僅供參考,用戶可以根據(jù)需要使用自家體溫算法來(lái)處理數(shù)據(jù)。
串口顯示效果
3.薩科微SL-W-TRS-5.5Dx系列demo板程序示例
//////////////////////////////////////////////////////////////////////////////////////////////////////
// main.c
//////
#define FOR_CUSTOMER
#ifdef FOR_CUSTOMER
#include "drv_uart.h"
#include "drv_i2c.h"
#include "drv_key.h"
#include "oled/oled.h"
#include "trs55d.h"
extern void SystemCoreClockUpdate(void);
extern void delay_ms(int cnt);
int main(void)
{
uint8_t key;
uint8_t run = 0x01;
SystemCoreClockUpdate();
if (SysTick_Config(SystemCoreClock / 1000))
while(1);
uartInit();
drv_i2c_init();
drv_key_init();
OLED_Init();
OLED_Refresh();
OLED_Clear();
OLED_ShowString(8,0,"Tamb:",16,1);
OLED_ShowString(8,16,"Vtp:",16,1);
OLED_ShowChinese(8,32,0,16,1);
OLED_ShowChinese(24,32,2,16,1);
OLED_ShowChinese(40,32,3,16,1);
OLED_ShowChinese(8,48,1,16,1);
OLED_ShowChinese(24,48,2,16,1);
OLED_ShowChinese(40,48,3,16,1);
OLED_Refresh();
uartSendString("SL-W-TRS-5.5Dx Demo program\r\n");
while(1) {
key = drv_key_read();
while(drv_key_read());
if (key) {
run = (run)?0:1;
}
if (run) {
TRS55D_read();
OLED_Refresh();
}
delay_ms(20);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
//trs55d.h
//////
#ifndef _TRS55D_H_
#define _TRS55D_H_
#include
#define TRS55D_NORMAL_Tobj_MSB_R 0x10
#define TRS55D_NORMAL_Tobj_CSB_R 0x11
#define TRS55D_NORMAL_Tobj_LSB_R 0x12
#define TRS55D_NORMAL_TEMP_MSB_R 0x16
#define TRS55D_NORMAL_TEMP_CSB_R 0x17
#define TRS55D_NORMAL_TEMP_LSB_R 0x18
#define TRS55D_NORMAL_DATA1_MSB_R 0x19
#define TRS55D_NORMAL_DATA1_CSB_R 0x1A
#define TRS55D_NORMAL_DATA1_LSB_R 0x1B
#define TRS55D_NORMAL_DATA2_MSB_R 0x1C
#define TRS55D_NORMAL_DATA2_CSB_R 0x1D
#define TRS55D_NORMAL_DATA2_LSB_R 0x1E
#define TRS55D_RAW_DATA1_MSB_R 0x22
#define TRS55D_RAW_DATA1_CSB_R 0x23
#define TRS55D_RAW_DATA1_LSB_R 0x24
#define TRS55D_RAW_DATA2_MSB_R 0x25
#define TRS55D_RAW_DATA2_CSB_R 0x26
#define TRS55D_RAW_DATA2_LSB_R 0x27
#define TRS55D_RAW_TEMP_MSB_R 0x28
#define TRS55D_RAW_TEMP_CSB_R 0x29
#define TRS55D_RAW_TEMP_LSB_R 0x2A
#define ADDR_TRS55D 0xFE //(0x7F << 1)
#define _STATUS_DRDY_ 0x01 void TRS55D_read(void);
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////////
// trs55d.c
//////
#include
#include "drv_i2c.h"
#include "trs55d.h"
#include "body_temp.h"
extern uint8_t uartSendString(const char* buf);
extern void OLED_ShowString(uint8_t x,uint8_t y, const char *chr,uint8_t size1,uint8_t mode);
extern void OLED_ShowBNum(uint8_t x,uint8_t y,float num,uint8_t len,
uint8_t size2,uint8_t mode); uint8_t TRS55D_IIC_Read(uint8_t addr_dev, uint8_t addr_reg,
uint8_t *buf, uint16_t count)
{
uint8_t ret;
uint8_t ackflag;
uint16_t i = 0;
drv_i2c_start();
drv_i2c_select_dev(addr_dev,DRV_I2C_OPWR);
drv_i2c_writebyte(addr_reg);
drv_i2c_start();
drv_i2c_select_dev(addr_dev,DRV_I2C_OPRD);
for(i = 0; i < count; i ++) { ackflag = (i < (count-1)) ? 1:0; buf[i]
= drv_i2c_readbyte(ackflag);
}
drv_i2c_stop();
return ret;
}
void TRS55D_IIC_Write(uint8_t addr_dev, uint8_t addr_reg, uint8_t *buf, uint16_t count)
{
uint16_t i = 0;
drv_i2c_start();
drv_i2c_select_dev(addr_dev,DRV_I2C_OPWR);
drv_i2c_writebyte(addr_reg);
for (i = 0; i < count; i ++)
{ drv_i2c_writebyte(buf[i]);
}
drv_i2c_stop();
}
typedef union{
int16_t i16;
uint16_t u16;
struct {
uint8_t u8l;
uint8_t u8h;
}un;
}uu16_t;
typedef union{
int32_t i32;
struct {
uint8_t u8b0;
uint8_t u8b1;
uint8_t u8b2;
uint8_t u8b3;
}un;
}uu32_t;
static char buffer[264];
uu32_t tobj, tamb_cal;
uu32_t vtp_cor;
float vtp_uv_f = 0.0;
float vtp_cor_f = 0.0;
float tambf = 0.0; float tobjf = 0.0;
float tbdyf = 0.0;
void TRS55D_read(void)
{
uint8_t rbuf[4];
uint8_t raddr,rdat;
uint8_t waddr = 0x0, wdat = 0x0;
int timeout=0;
waddr = 0x30;
wdat = 0x09;
TRS55D_IIC_Write(ADDR_TRS55D, waddr, &wdat,1);
//start conversion delay_ms(100);
// waite for conversion over
raddr = 0x03;
do {
TRS55D_IIC_Read (ADDR_TRS55D, raddr, &rdat,1);
} while(((rdat == 0xFF) || (!(rdat & 0x30))) && timeout++ < 200);
raddr = 0x02;
do {
TRS55D_IIC_Read (ADDR_TRS55D, raddr, &rdat,1);
} while(((rdat == 0xFF) || (!(rdat & 0x0B))) && timeout++ < 200);
// voltage value after calibration
raddr = TRS55D_NORMAL_DATA1_MSB_R;
TRS55D_IIC_Read (ADDR_TRS55D, raddr,&rbuf[0],3);
vtp_cor.un.u8b2 = rbuf[0];
vtp_cor.un.u8b1 = rbuf[1];
vtp_cor.un.u8b0 =rbuf[2];
if (vtp_cor.un.u8b2 & 0x80) { vtp_cor.un.u8b3 = 0xFF;
}else {
vtp_cor.un.u8b3 = 0x00;
// vtp after corrected
}
vtp_cor_f = (float)vtp_cor.i32/524288.0;
vtp_cor_f *= 1000;
// ambient temperature value after calibration
raddr = TRS55D_NORMAL_TEMP_MSB_R;
TRS55D_IIC_Read (ADDR_TRS55D,raddr,&rbuf[0],3);
tamb_cal.un.u8b2 = rbuf[0];
tamb_cal.un.u8b1 =rbuf[1];
tamb_cal.un.u8b0 =rbuf[2];
tambf = (float)tamb_cal.i32 / 16384.0; // ambient temperature
// object(surface) temperature after calibration
raddr = TRS55D_NORMAL_Tobj_MSB_R;
TRS55D_IIC_Read (ADDR_TRS55D,raddr,&rbuf[0],3);
tobj.un.u8b2 = rbuf[0]; tobj.un.u8b1 = rbuf[1];
tobj.un.u8b0 =rbuf[2]; tobjf = (float)tobj.i32 / 16384.0;
// object(surface) temperature
// get bodytemp
tbdyf = get_body_temp(tambf,tobjf); // get bodytemp
// display on uart sprintf(buffer, "tamb = %.2f, vtp_cor = %.2f, tobj = %.2f, tbdy = %.2f\r\n",\ tambf, vtp_cor_f, tobjf, tbdyf); uartSendString(buffer);
// display on oled
float vals[4] = {tambf, vtp_cor_f, tobjf, tbdyf+0.05};
OLED_ShowBNum (64, 0, vals[0], 4, 16, 1); // Tamb
OLED_ShowBNum (48, 16, vals[1], 6, 16, 1); // vtp
OLED_ShowString(112,16, "uv",16, 1);
OLED_ShowBNum (64, 32, vals[2], 4, 16, 1); // Tobj
OLED_ShowBNum (64, 48, vals[3], 4, 16, 1); // Tbdy
}
友情鏈接:站點(diǎn)地圖 薩科微官方微博 立創(chuàng)商城-薩科微專賣 金航標(biāo)官網(wǎng) 金航標(biāo)英文站
Copyright ?2015-2024 深圳薩科微半導(dǎo)體有限公司 版權(quán)所有 粵ICP備20017602號(hào)-1