[STM32F4] 关于STM32涉及呼吸机的模型参考<原创,请勿随意转发>

[复制链接]
3027|39
 楼主| wangjiahao88 发表于 2018-6-25 10:16 | 显示全部楼层 |阅读模式
本帖最后由 wangjiahao88 于 2018-6-25 10:18 编辑

关于STM32涉及呼吸机的模型...~~~~~~~~~~~~~~~~~~~
现在关于家用呼吸机,用在了很多家庭,同时也服务了很多人。

关于呼吸机。有PIC的方案,TI的方案,我们这里用的时STM32F4制作的

评论

厉害!请问楼主是在高校研究学习呢?还是在公司做产品开发?  发表于 2020-3-23 15:25
 楼主| wangjiahao88 发表于 2018-6-25 13:37 | 显示全部楼层
计算机截图1
1.png
 楼主| wangjiahao88 发表于 2018-6-25 13:38 | 显示全部楼层
计算机截图2
2.png
 楼主| wangjiahao88 发表于 2018-6-25 13:38 | 显示全部楼层
计算机截图3
3.png
 楼主| wangjiahao88 发表于 2018-6-25 13:38 | 显示全部楼层
计算机截图4
4.png
 楼主| wangjiahao88 发表于 2018-6-25 13:39 | 显示全部楼层
未完待续!...
 楼主| wangjiahao88 发表于 2018-6-25 13:41 | 显示全部楼层
压差变送器资料1
低压差变送器.png
 楼主| wangjiahao88 发表于 2018-6-25 13:41 | 显示全部楼层
压差变送器资料2
低压差变送器2.png
 楼主| wangjiahao88 发表于 2018-6-25 13:42 | 显示全部楼层
压差变送器资料3
低压差变送器3.png
 楼主| wangjiahao88 发表于 2018-6-25 13:42 | 显示全部楼层
/*
* Example Code for pressure reading from I2C bus
* Used microcontroller: Microchip PIC24FV32KA302
* This code is not complete! Basic I2C functions have to be added
*
*/
//Read byte from I2C bus; send master ACK-bit
char i2c_read_ack(void) //does not reset bus!!!
{
int i = 0;
char data = 0;
//set I2C module to receive
I2C1CONbits.RCEN = 1;
//if no response, break
while (!I2C1STATbits.RBF)
{
i++;
if (i > 2000) break;
}
//get data from I2CRCV register
data = I2C1RCV;
//set ACK to high
I2C1CONbits.ACKEN = 1;
//wait before exiting
Delay(10);
//return data
return data;
}
 楼主| wangjiahao88 发表于 2018-6-25 13:42 | 显示全部楼层
//Read byte from I2C bus; don't send master ACK-bit
char i2c_read_nack(void) //does not reset bus!!!
{
int i = 0;
char data = 0;
//set I2C module to receive
I2C1CONbits.RCEN = 1;
//if no response, break
while (!I2C1STATbits.RBF)
{
i++;
if (i > 2000) break;
}
//get data from I2CRCV register
data = I2C1RCV;
//set ACK to low
I2C1CONbits.ACKEN = 0;
//wait before exiting
Delay(10);
//return data
return data;
}
 楼主| wangjiahao88 发表于 2018-6-25 13:43 | 显示全部楼层
//Read digital pressure value
unsigned int I2CreadP_digital(void)
{
// Two bytes have to be read
unsigned char i2c_byte1 =0;
unsigned char i2c_byte2 =0;
/*****
*
* The two most significant bits of the first byte are status bits!
* They don't contain pressure value information.
*
* Encoding of status bits:
* 00: Normal operation, good data packet
* 01: Device in Command Mode
* 10: Stale data: Data that has already been fetched since
* the last measurement cycle.
* 11: Diagnostic condition exists *
*
* For further information see Datasheet of ASIC ZSC31014
*
*******/
unsigned char status =0;
int digital_Pressure =0;
unsigned char i2c_relevant_bits = 0;
// Initialize I2C Connection
i2c_init();
// Start I2C Communication
i2c_start();
// Send Slave Adress+Read-Bit; wait for slave ACK-Bit
send_i2c_byte(0b10100001);
//Read first byte + sending ACK-Bit
//the two MSBs of this byte are status bits!!
i2c_byte1 = i2c_read_ack();
//Read second byte without sending ACK-Bit
i2c_byte2 = i2c_read_nack();
//extract status bits from first byte
strncpy(status, i2c_byte1, 2);
//extract relevant bits for pressure value from first byte
strcpy(i2c_relevant_bits, i2c_byte1 + 2);
//calculate digital pressure value
digital_Pressure = i2c_relevant_bits * 256 + i2c_byte2;
return digital_Pressure;
}
 楼主| wangjiahao88 发表于 2018-6-25 13:43 | 显示全部楼层
// Reading of actual decimal pressure value
double I2CreadP_decimal(double P_min, double P_max)
//Range setup with P_min and P_max
{
//read digital pressure value
unsigned int digital_Pressure = I2CreadP_digital();

//constant for digital analog conversion DAC = (2^14)-1
int DAC = 16383;
//calculate proportional pressure value of P_range
double prop_P_range = digital_Pressure/DAC;
/* calculate decimal pressure value out of
* proportional pressure and given range setup */
double decimal_Pressure = prop_P_range*(P_max-P_min)+P_min;
return decimal_Pressure;
}
 楼主| wangjiahao88 发表于 2018-6-25 13:44 | 显示全部楼层
程序读写4
低压差变送器4.png
 楼主| wangjiahao88 发表于 2018-6-25 13:46 | 显示全部楼层
IIC 时序1
低压差变送器5.png
低压差变送器5.png
 楼主| wangjiahao88 发表于 2018-6-25 13:47 | 显示全部楼层
未完待续...
 楼主| wangjiahao88 发表于 2018-6-25 13:48 | 显示全部楼层
欢迎大家 一起探讨!
mmuuss586 发表于 2018-6-25 14:58 | 显示全部楼层
不错,感谢分享;
 楼主| wangjiahao88 发表于 2018-6-26 12:21 | 显示全部楼层
SM9541_read:
函数如下:
 楼主| wangjiahao88 发表于 2018-6-26 12:22 | 显示全部楼层
#ifndef __I2C_EE_H
#define        __I2C_EE_H

#include "stm32f4xx.h"

extern unsigned int presshigh,presslow;

extern void SM9541_read(void);
extern void ee_Delay(__IO uint32_t nCount);         //简单的延时函数

#endif /* __I2C_EE_H */
您需要登录后才可以回帖 登录 | 注册

本版积分规则

500

主题

7585

帖子

31

粉丝
快速回复 在线客服 返回列表 返回顶部