当前位置:网站首页>STM32 MCU uses ADC function to drive finger heartbeat detection module
STM32 MCU uses ADC function to drive finger heartbeat detection module
2022-07-23 22:11:00 【wanglong3713】
One 、 Module introduction
A treasure or a lot , Twoorthree yuan each , Here's the picture .
The module adopts ultra bright infrared LED And phototransistor to detect the pulse of the finger , Place your finger between the transmitter and receiver , Blood pressure changes with the pulse , The light received by the receiving end will change accordingly , Therefore, it can be used to detect heartbeat .
Two 、STM32MX Cube To configure
use STM32F103C8T6 Minimum system board ,STM32MX Cube Configure the system and automatically generate code .
stay ADC1 in , We choose IN1 passageway , namely PA1 Pin , Other configurations are shown in the figure , Basically, the default configuration , There is no need to choose . When all configuration is complete , Generate engineering code , This article will not introduce in detail .
3、 ... and 、 Main code
ADC The initialization code for is in MX_ADC1_Init() in , Generated main Function will automatically call :
MX_ADC1_Init();
It's going on AD On conversion , You need to call HAL_ADC_Start(&hadc1) The function starts to convert , We don't use interrupts , adopt while (HAL_ADC_PollForConversion(&hadc1,10) != HAL_OK) To wait for the conversion to complete , And then through HAL_ADC_GetValue(&hadc1) Function to obtain AD value ,HAL_ADC_Stop(&hadc1) Function ends the conversion . Each of the above processes 10ms Do it once , Sampling frequency 100Hz.
HAL_ADC_Start(&hadc1);
while (HAL_ADC_PollForConversion(&hadc1,10) != HAL_OK)// Wait for the conversion to complete
{
}
HeartBeat_RawData = HAL_ADC_GetValue(&hadc1);//RAW_DATA_LENGTH Is the number of data saved
HAL_ADC_Stop(&hadc1);
printf("%d\n", HeartBeat_RawData);
In the above code printf Function to print data to serial port . see , You need to write your own code , Not many lines .
Four 、 Running effect

The above figure is through the serial port drawing software VOFA+ The original drawing AD The graph of values , It can be seen that the data is messy , The green line in the figure below is the effect after simple filtering :
5、 ... and 、 summary
1. Actual test findings , This module has a great impact on the environment , Day 、 night , turn on the light 、 Turning off the lights will have a great impact on the data , And data often drift ;
2. Just read the data , Simple filtering , From the time domain diagram , I can't find any rules ;
3. If it's just for learning ADC Use , You can use this module to practice , These data can also be used to learn the filtering algorithm 、 Fourier transform, etc , But I want to use it to detect the heartbeat more accurately , I still don't recommend .
边栏推荐
- Neo4j application
- Real time monitoring of MySQL database changes_ Synchronize data_ Learn about canal_--- Canal work notes 001
- Description and implementation of throttling and anti shake
- What are the product life cycle, common project functions, and information flow
- Sudoku written for once and for all
- Still worrying about xshell cracking, try tabby
- Taoying collects goods in batches. How to save the babies that have not been uploaded and then import them later
- Interval DP chain stone merging
- How can I open an account to buy financial products with a 6% income?
- SQL injection attack
猜你喜欢

Storage structure and management disk. It's a bit like installing Win98. You need to partition and format the hard disk first

大淘营批量采集商品,如何将未上传的宝贝保存下来等后面再导入采集上传

Uniapp uses canvas to write a circular progress bar

U++ learning notes control object scale

Principle and implementation of hash table, unordered set and mapping

性能测试知识应用于实战
![[golang learning notes] is parameter transfer in go language value transfer or reference transfer](/img/79/57b28d0e6501132c347f7e7c0516b3.png)
[golang learning notes] is parameter transfer in go language value transfer or reference transfer

U++ learning notes tsubclassof()

Cookies and sessions

实验设计
随机推荐
Uniapp uses canvas to write a circular progress bar
U++学习笔记 TSubclassOf()
Ali onedate's layered thought
[hiflow] Tencent cloud's new generation of automation assistant, which I used to complete the enterprise epidemic prompt (no code)
[golang learning notes] concurrency basis
众邦科技又一潜心力作 —— 陀螺匠 OA 系统
人生总需要一点激情
Pulsar open source message queue_ Understand pulsar --- pulsar work notes 001
How does MySQL prepare SQL (solve the problem that in query SQL preprocessing can only query one record)
欧氏聚类(API)及其单木分割
Wangxuegang video coding -- mediacodec coding and decoding
PCL出错:error C2589“(“:“::“右边的非法标记)
软件体系结构期末复习六十题
【AcWing】周赛
DBSCAN点云聚类
SQL injection attack
MVVM和MVVMLight简介及项目开发(一)
U++ 学习笔记 控制物体Scale
University database creation and query practice -- database table design
【golang学习笔记】包(package)的使用