8075 views|6 replies

820

Posts

2

Resources
The OP
 

Max30102 heart rate blood oxygen sensor measuring heart rate problem [Copy link]

Recently I am using max30102 as a heart rate and blood oxygen sensor and using STM32F103 for control. There are many versions of the code on the Internet.

I found several STM32 versions. After debugging, I can only measure blood oxygen. The blood oxygen value measured by the watch is 100. The sensor I made can also measure it relatively accurately, but the heart rate test is basically inaccurate, with a very large fluctuation. See the video below for details. I roughly looked at the configuration of the manual registers and the development process on the Internet, but did not find the problem.

Has anyone encountered a similar problem? After debugging for a long time, I can only measure blood oxygen. The chip has an interrupt pin, which is valid at low level. I have tried it with and without interrupts before, and it seems that there is no difference. The following is part of the code with interrupts:

中断配置部分:
//-----------------------------------------------------------------
// void GPIO_EXTInterrupt_Configuration(void)
//-----------------------------------------------------------------
//
// 函数功能: 外中断输入I/O配置
// 入口参数: 无
// 返 回 值: 无
// 注意事项:  PA.6----EXTI_IN
//-----------------------------------------------------------------
void GPIO_EXTInterrupt_Configuration(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	// 开启PA时钟和I/O复用时钟
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO,ENABLE);   //低速使用APB1高速为APB2
	// 使用PA.6上拉输入
	GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_6;																	 
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 	
	
  GPIO_Init(GPIOA, &GPIO_InitStructure);
}

//-----------------------------------------------------------------
// void EXTInterrupt_Mode_Configuration(void)
//-----------------------------------------------------------------
//
// 函数功能: 外中断的配置
// 入口参数: 无
// 返 回 值: 无
// 注意事项:
//-----------------------------------------------------------------
void EXTInterrupt_Mode_Configuration(void)
{
	EXTI_InitTypeDef EXTI_InitStructure;
	// PA.6与中断线6相映射
	GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource6);          
	// PA.6对应中断线6//外中断//下降沿触发中断
	EXTI_InitStructure.EXTI_Line=EXTI_Line6;                            
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;									
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;							
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);	 	
	
}

//-----------------------------------------------------------------
// void NVIC_Configuration(void)
//-----------------------------------------------------------------
//
// 函数功能: 配置外中断嵌套中断向量
// 入口参数: 无
// 返 回 值: 无
// 注意事项: 
//-----------------------------------------------------------------
void NVIC_Configuration(void)
{
	NVIC_InitTypeDef NVIC_InitStructure;
  // 设置NVIC中断分组2,其中2位抢占优先级,2位响应优先级
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);												
  // 选择外部中断通道//抢占优先级0//子优先级0
  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;							//外部中断线通道使能
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;				//先占优先级
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;							//副优先级			
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;                 //
  NVIC_Init(&NVIC_InitStructure);
}




Wait for the interrupt to generate a low level before reading the data

Here is the debugging effect:


Finally, let me talk about the problem. The heart rate cannot be measured accurately (it has almost never been accurate). I don’t know what went wrong yet. Let me collect some ideas here.

This post is from Sensor

Latest reply

You can try to open a separate test, because if you want to measure two data at the same time, you need to measure them alternately, because the red light is used for blood oxygen and the green light is used for heart rate.   Details Published on 2021-6-3 13:20
 
 

1942

Posts

2

Resources
2
 

Blood oxygen and heart rate should not be measured at the same time?

This post is from Sensor

Comments

Yes, the data sheet says so. It's strange that the data I got from the side is not accurate.  Details Published on 2021-6-3 12:37
 
 
 

1022

Posts

0

Resources
3
 

Can measure simultaneously.

This post is from Sensor
Personal signatureچوآن شـين
 
 
 

693

Posts

7

Resources
4
 

Heart rate data needs to be processed by FFT. It is necessary to collect data of a certain length for FFT transformation.

This post is from Sensor

Comments

This has an algorithm file. Things like calculations should all be in the algorithm file.  Details Published on 2021-6-3 12:38
 
 
 

820

Posts

2

Resources
5
 
w494143467 posted on 2021-6-3 11:33 Blood oxygen and heart rate should not be measured at the same time, right?

Yes, the data sheet says so. It's strange that the data I got from the side is not accurate.

This post is from Sensor

Comments

You can try to open a separate test, because if you want to measure two data at the same time, you need to measure them alternately, because the red light is used for blood oxygen and the green light is used for heart rate.  Details Published on 2021-6-3 13:20
 
 
 

820

Posts

2

Resources
6
 
bqgup posted on 2021-6-3 11:38 Heart rate data needs to be processed by FFT operation. It is necessary to collect data of a certain length for FFT transformation

This has an algorithm file. Things like calculations should all be in the algorithm file.

This post is from Sensor
 
 
 

1942

Posts

2

Resources
7
 
1nnocent posted on 2021-6-3 12:37 Yes, the data sheet says it, but it is strange that the data I got once is not accurate

You can try to open a separate test, because if you want to measure two data at the same time, you need to measure them alternately, because the red light is used for blood oxygen and the green light is used for heart rate.

This post is from Sensor
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list