OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 2767|回复: 4

有人做过pruse sensor 开源心率传感器的开发吗?

[复制链接]

3

主题

10

帖子

0

精华

新手上路

积分
49
金钱
49
注册时间
2018-3-5
在线时间
7 小时
发表于 2018-4-17 13:25:30 | 显示全部楼层 |阅读模式
1金钱
这段代码测量  用了什么原理去检测心率的?
void TIM3_IRQHandler(void)
{
        uint16_t runningTotal=0;
        uint8_t i;
        uint16_t Num;
       
        if(TIM_GetITStatus(TIM3,TIM_IT_Update)!=RESET)
        {
               
                Signal = ADC_GetConversionValue(ADC1)/4;     // read the Pulse Senso  
                sampleCounter += 2;                          // keep track of the time in mS with this variable   
                Num = sampleCounter - lastBeatTime;          // monitor the time since the last beat to avoid noise          
               
                //  find the peak and trough of the pulse wave
                if(Signal < thresh && Num > (IBI/5)*3)                         // avoid dichrotic noise by waiting 3/5 of last IBI
                {  
                        if (Signal < T)                                       // T is the trough   
                        {
                                        T = Signal;                           // keep track of lowest point in pulse wave
                        }
                }

                if(Signal > thresh && Signal > P)                               // thresh condition helps avoid noise      thresh ì&#245;&#188;tóD&#214;úóú±ü&#195;a&#212;&#235;ò&#244;
                {       
                        P = Signal;                                     // P is the peak   P ê&#199;ò&#187;&#184;&#246;&#188;a·&#229;
                }                                                 // keep track of highest point in pulse wave  &#184;ú×ù&#194;&#246;2&#171;2¨μ&#196;×&#238;&#184;&#223;μ&#227;


                //  NOW IT'S TIME TO LOOK FOR THE HEART BEAT
                // signal surges up in value every time there is a pulse
                if (Num > 250)                                 // avoid high frequency noise  
    {
                        if ( (Signal > thresh) && (Pulse == false) && (Num > (IBI/5)*3) )
                        {        
                                        Pulse = true;                               // set the Pulse flag when we think there is a pulse
                                        IBI = sampleCounter - lastBeatTime;         // measure time between beats in mS   
                                        lastBeatTime = sampleCounter;               // keep track of time for next pulse       

                                        if(secondBeat)                        // if this is the second beat, if secondBeat == TRUE
                                        {      
                                                secondBeat = false;                  // clear second Beat flag  
                                                for(i=0; i<=9; i++)                 // seed the running total to get a realisitic BPM at startup  
                                                {       
                                                        rate[i] = IBI;                     //rate[0]-rate[9]
                                                }
                                        }

                                        if(firstBeat)                         // if it's the first time we found a beat, if firstBeat == TRUE  
                                        {      
                                                firstBeat = false;                   // clear firstBeat flag               
                                                secondBeat = true;                   // set the second beat flag       
                                                return;                              // IBI value is unreliable so discard it  IBI
                                        }   

                                        // keep a running total of the last 10 IBI values
                                        // runningTotal = 0;                                  // clear the runningTotal variable      
                                        for(i=0; i<=8; i++)                    // shift data in the rate array               
                                        {   
                                                rate[i] = rate[i+1];                  // and drop the oldest IBI value
                                                runningTotal += rate[i];              // add up the 9 oldest IBI values       
                                        }

                                        rate[9] = IBI;                          // add the latest IBI to the rate array
                                        runningTotal += rate[9];                // add the latest IBI to runningTotal                       
                                        runningTotal /= 10;                     // average the last 10 IBI values                        
                                        BPM = 60000/runningTotal;               // how many beats can fit into a minute? that's BPM
                                        QS = true;                              // set Quantified Self flag  
                                        // QS FLAG IS NOT CLEARED INSIDE THIS ISR
                        }                       
                }


                if (Signal < thresh && Pulse == true)   // when the values are going down, the beat is over
                {
                        Pulse = false;                         // reset the Pulse flag so we can do it again               
                        amp = P - T;                           // get amplitude of the pulse wave                               
                        thresh = amp/2 + T;                    // set thresh at 50% of the amplitude                       
                        P = thresh;                            // reset these for next time                                                               
                        T = thresh;
                }

                if (Num > 2500)                        // if 2.5 seconds go by without a beat
                {        
                        thresh = 512;                          // set thresh default  
                        P = 512;                               // set P default       
                        T = 512;                               // set T default       
                        lastBeatTime = sampleCounter;          // bring the lastBeatTime up to date   
                        firstBeat = true;                      // set these to avoid noise                                               
                        secondBeat = false;                    // when we get the heartbeat back                       
                }

        }
        TIM_ClearITPendingBit(TIM3,TIM_IT_Update);
}

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

3

主题

10

帖子

0

精华

新手上路

积分
49
金钱
49
注册时间
2018-3-5
在线时间
7 小时
 楼主| 发表于 2018-4-17 14:04:45 | 显示全部楼层
回复

使用道具 举报

16

主题

92

帖子

0

精华

高级会员

Rank: 4

积分
767
金钱
767
注册时间
2017-5-11
在线时间
100 小时
发表于 2018-4-17 15:48:17 | 显示全部楼层
这个官方手册上面讲的很清楚,怎么计算的也有,官网地址:https://pulsesensor.com/
回复

使用道具 举报

3

主题

10

帖子

0

精华

新手上路

积分
49
金钱
49
注册时间
2018-3-5
在线时间
7 小时
 楼主| 发表于 2018-4-18 09:39:39 | 显示全部楼层
way7539512 发表于 2018-4-17 15:48
这个官方手册上面讲的很清楚,怎么计算的也有,官网地址:https://pulsesensor.com/

要登陆外网才可以看的吗???????????????
回复

使用道具 举报

16

主题

92

帖子

0

精华

高级会员

Rank: 4

积分
767
金钱
767
注册时间
2017-5-11
在线时间
100 小时
发表于 2018-4-18 16:53:42 | 显示全部楼层
laokin 发表于 2018-4-18 09:39
要登陆外网才可以看的吗???????????????

应该是的,我用流量上去很慢,有时候还进不去
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-8 04:44

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表