久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3996|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

MAX30102空氣質(zhì)量監(jiān)測模塊STM32源程序與資料

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:802483 發(fā)表于 2020-7-13 11:58 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
空氣質(zhì)量監(jiān)測模塊芯片數(shù)據(jù)手冊、電路圖及測試程序

電路原理圖如下:


功能實現(xiàn):采用STM32F103C8T6小板,驅(qū)動血氧心率傳感器max30102,實現(xiàn)PPG信號采集,并將計算的心率和血氧值顯示在0.96寸OLED和串口上。
軟件實現(xiàn):ST標(biāo)準(zhǔn)庫3.5
硬件連接:
MAX30102:
    VCC<->3.3V
    GND<->GND
    SCL<->PB7
    SDA<->PB8
    IM<->PB9
0.96inch OLED :
    VCC<->3.3V
    GND<->GND
    SCL<->PA5
    SDA<->PA6
    RST<->PA3
    DC<->PA4
    CS<->PA2
USB-TTL:
    5V<->5V
    GND<->GND
    RXD<->PA9
    TXD<->PA10

單片機源程序如下:
  1. #include "led.h"
  2. #include "delay.h"
  3. #include "sys.h"
  4. #include "usart.h"
  5. #include "max30102.h"
  6. #include "myiic.h"
  7. #include "algorithm.h"
  8. #include "oled.h"

  9. uint32_t aun_ir_buffer[500]; //IR LED sensor data
  10. int32_t n_ir_buffer_length;    //data length
  11. uint32_t aun_red_buffer[500];    //Red LED sensor data
  12. int32_t n_sp02; //SPO2 value
  13. int8_t ch_spo2_valid;   //indicator to show if the SP02 calculation is valid
  14. int32_t n_heart_rate;   //heart rate value
  15. int8_t  ch_hr_valid;    //indicator to show if the heart rate calculation is valid
  16. uint8_t uch_dummy;

  17. #define MAX_BRIGHTNESS 255

  18. void dis_DrawCurve(u32* data,u8 x);

  19. int main(void)
  20. {
  21.         //variables to calculate the on-board LED brightness that reflects the heartbeats
  22.         uint32_t un_min, un_max, un_prev_data;  
  23.         int i;
  24.         int32_t n_brightness;
  25.         float f_temp;
  26.         u8 temp_num=0;
  27.         u8 temp[6];
  28.         u8 str[100];
  29.         u8 dis_hr=0,dis_spo2=0;

  30.         NVIC_Configuration();
  31.         delay_init();                     //延時函數(shù)初始化         
  32.         uart_init(115200);                 //串口初始化為115200
  33.         LED_Init();
  34.         
  35.         //OLED
  36.         OLED_Init();
  37.         OLED_ShowString(0,0,"  initializing  ",16);
  38.         OLED_Refresh_Gram();//更新顯示到OLED         

  39.         max30102_init();

  40.         printf("\r\n MAX30102  init  \r\n");

  41.         un_min=0x3FFFF;
  42.         un_max=0;
  43.         
  44.         n_ir_buffer_length=500; //buffer length of 100 stores 5 seconds of samples running at 100sps
  45.         //read the first 500 samples, and determine the signal range
  46.     for(i=0;i<n_ir_buffer_length;i++)
  47.     {
  48.         while(MAX30102_INT==1);   //wait until the interrupt pin asserts
  49.         
  50.                 max30102_FIFO_ReadBytes(REG_FIFO_DATA,temp);
  51.                 aun_red_buffer[i] =  (long)((long)((long)temp[0]&0x03)<<16) | (long)temp[1]<<8 | (long)temp[2];    // Combine values to get the actual number
  52.                 aun_ir_buffer[i] = (long)((long)((long)temp[3] & 0x03)<<16) |(long)temp[4]<<8 | (long)temp[5];   // Combine values to get the actual number
  53.             
  54.         if(un_min>aun_red_buffer[i])
  55.             un_min=aun_red_buffer[i];    //update signal min
  56.         if(un_max<aun_red_buffer[i])
  57.             un_max=aun_red_buffer[i];    //update signal max
  58.     }
  59.         un_prev_data=aun_red_buffer[i];
  60.         //calculate heart rate and SpO2 after first 500 samples (first 5 seconds of samples)
  61.     maxim_heart_rate_and_oxygen_saturation(aun_ir_buffer, n_ir_buffer_length, aun_red_buffer, &n_sp02, &ch_spo2_valid, &n_heart_rate, &ch_hr_valid);
  62.         
  63.         while(1)
  64.         {
  65.                 i=0;
  66.         un_min=0x3FFFF;
  67.         un_max=0;
  68.                
  69.                 //dumping the first 100 sets of samples in the memory and shift the last 400 sets of samples to the top
  70.         for(i=100;i<500;i++)
  71.         {
  72.             aun_red_buffer[i-100]=aun_red_buffer[i];
  73.             aun_ir_buffer[i-100]=aun_ir_buffer[i];
  74.             
  75.             //update the signal min and max
  76.             if(un_min>aun_red_buffer[i])
  77.             un_min=aun_red_buffer[i];
  78.             if(un_max<aun_red_buffer[i])
  79.             un_max=aun_red_buffer[i];
  80.         }
  81.                 //take 100 sets of samples before calculating the heart rate.
  82.         for(i=400;i<500;i++)
  83.         {
  84.             un_prev_data=aun_red_buffer[i-1];
  85.             while(MAX30102_INT==1);
  86.             max30102_FIFO_ReadBytes(REG_FIFO_DATA,temp);
  87.                         aun_red_buffer[i] =  (long)((long)((long)temp[0]&0x03)<<16) | (long)temp[1]<<8 | (long)temp[2];    // Combine values to get the actual number
  88.                         aun_ir_buffer[i] = (long)((long)((long)temp[3] & 0x03)<<16) |(long)temp[4]<<8 | (long)temp[5];   // Combine values to get the actual number
  89.         
  90.             if(aun_red_buffer[i]>un_prev_data)
  91.             {
  92.                 f_temp=aun_red_buffer[i]-un_prev_data;
  93.                 f_temp/=(un_max-un_min);
  94.                 f_temp*=MAX_BRIGHTNESS;
  95.                 n_brightness-=(int)f_temp;
  96.                 if(n_brightness<0)
  97.                     n_brightness=0;
  98.             }
  99.             else
  100.             {
  101.                 f_temp=un_prev_data-aun_red_buffer[i];
  102.                 f_temp/=(un_max-un_min);
  103.                 f_temp*=MAX_BRIGHTNESS;
  104.                 n_brightness+=(int)f_temp;
  105.                 if(n_brightness>MAX_BRIGHTNESS)
  106.                     n_brightness=MAX_BRIGHTNESS;
  107.             }
  108.                         //send samples and calculation result to terminal program through UART
  109.                         if(ch_hr_valid == 1 && n_heart_rate<120)//**/ ch_hr_valid == 1 && ch_spo2_valid ==1 && n_heart_rate<120 && n_sp02<101
  110.                         {
  111.                                 dis_hr = n_heart_rate;
  112.                                 dis_spo2 = n_sp02;
  113.                         }
  114.                         else
  115.                         {
  116.                                 dis_hr = 0;
  117.                                 dis_spo2 = 0;
  118.                         }
  119.                                 printf("HR=%i, ", n_heart_rate);
  120.                                 printf("HRvalid=%i, ", ch_hr_valid);
  121.                                 printf("SpO2=%i, ", n_sp02);
  122.                                 printf("SPO2Valid=%i\r\n", ch_spo2_valid);
  123.                 }
  124.         maxim_heart_rate_and_oxygen_saturation(aun_ir_buffer, n_ir_buffer_length, aun_red_buffer, &n_sp02, &ch_spo2_valid, &n_heart_rate, &ch_hr_valid);
  125.                
  126.                 //顯示刷新
  127.                 LED0=0;
  128.                 if(dis_hr == 0)  //**dis_hr == 0 && dis_spo2 == 0
  129.                 {
  130.                         sprintf((char *)str,"HR:---        ");//**HR:--- SpO2:---
  131.                 }
  132.                 else{
  133.                         sprintf((char *)str,"HR:%3d        ",dis_hr);//**HR:%3d SpO2:%3d
  134.                 }
  135.                 OLED_ShowString(0,0,str,16);
  136.                 OLED_Fill(0,23,127,63,0);
  137.                 //紅光在上,紅外在下
  138.                 dis_DrawCurve(aun_red_buffer,20);
  139.                 dis_DrawCurve(aun_ir_buffer,0);
  140.                 OLED_Refresh_Gram();//更新顯示到OLED         
  141.         }
  142. }

  143. void dis_DrawCurve(u32* data,u8 x)
  144. {
  145.         u16 i;
  146.         u32 max=0,min=262144;
  147.         u32 temp;
  148.         u32 compress;
  149.         
  150.         for(i=0;i<128*2;i++)
  151.         {
  152.                 if(data[i]>max)
  153. ……………………

  154. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
MAX30102測試資料完整版.7z (1.07 MB, 下載次數(shù): 97)

評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 黄视频在线网站 | 国产成人精品区一区二区不卡 | 亚洲黄色国产 | 一区视频 | 国产精品视频在线播放 | 久久国产视频播放 | 欧美精品一区二区三区在线 | 久久在线视频 | 国产亚洲精品精品国产亚洲综合 | 国产精品视屏 | 欧美黄色一级毛片 | 精品一区二区三区不卡 | 日韩欧美国产综合 | 大久 | 国产精品一区二区无线 | 国产精品完整版 | 日日夜夜精品免费视频 | 久久久久久天堂 | 国产精品日韩欧美 | 蜜桃视频一区二区三区 | 欧美精品一区二区三区在线播放 | 久久69精品久久久久久国产越南 | 国精产品一品二品国精在线观看 | 欧美日韩专区 | 成人一区二区三区在线 | 欧美日韩国产一区二区三区 | 国产精品96久久久久久 | 超碰天天 | 久久国产精品免费一区二区三区 | 亚洲午夜小视频 | 欧美一区二区免费 | 国产日韩欧美一区二区 | 丝袜 亚洲 欧美 日韩 综合 | 日韩a在线 | 国产乱码精品一区二区三区中文 | 黄色欧美在线 | 国产va | 日韩精品 电影一区 亚洲 | 最新av在线网址 | 毛片在线免费播放 | 国产一区二区三区久久久久久久久 |