打印
[STM32F4]

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

[复制链接]
2286|39
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
本帖最后由 wangjiahao88 于 2018-6-25 10:18 编辑

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

关于呼吸机。有PIC的方案,TI的方案,我们这里用的时STM32F4制作的
评论
breez 2020-3-23 15:25 回复TA
厉害!请问楼主是在高校研究学习呢?还是在公司做产品开发? 
沙发
wangjiahao88|  楼主 | 2018-6-25 13:37 | 只看该作者
计算机截图1

1.png (26.47 KB )

1.png

使用特权

评论回复
板凳
wangjiahao88|  楼主 | 2018-6-25 13:38 | 只看该作者
计算机截图2

2.png (262.45 KB )

2.png

使用特权

评论回复
地板
wangjiahao88|  楼主 | 2018-6-25 13:38 | 只看该作者
计算机截图3

3.png (371.97 KB )

3.png

使用特权

评论回复
5
wangjiahao88|  楼主 | 2018-6-25 13:38 | 只看该作者
计算机截图4

4.png (363.65 KB )

4.png

使用特权

评论回复
6
wangjiahao88|  楼主 | 2018-6-25 13:39 | 只看该作者
未完待续!...

使用特权

评论回复
7
wangjiahao88|  楼主 | 2018-6-25 13:41 | 只看该作者
压差变送器资料1

低压差变送器.png (212.59 KB )

低压差变送器.png

使用特权

评论回复
8
wangjiahao88|  楼主 | 2018-6-25 13:41 | 只看该作者
压差变送器资料2

低压差变送器2.png (139.28 KB )

低压差变送器2.png

使用特权

评论回复
9
wangjiahao88|  楼主 | 2018-6-25 13:42 | 只看该作者
压差变送器资料3

低压差变送器3.png (160.84 KB )

低压差变送器3.png

使用特权

评论回复
10
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;
}

使用特权

评论回复
11
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;
}

使用特权

评论回复
12
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;
}

使用特权

评论回复
13
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;
}

使用特权

评论回复
14
wangjiahao88|  楼主 | 2018-6-25 13:44 | 只看该作者
程序读写4

低压差变送器4.png (139.29 KB )

低压差变送器4.png

使用特权

评论回复
15
wangjiahao88|  楼主 | 2018-6-25 13:46 | 只看该作者
IIC 时序1

低压差变送器5.png (111.28 KB )

低压差变送器5.png

低压差变送器5.png (111.28 KB )

低压差变送器5.png

使用特权

评论回复
16
wangjiahao88|  楼主 | 2018-6-25 13:47 | 只看该作者
未完待续...

使用特权

评论回复
17
wangjiahao88|  楼主 | 2018-6-25 13:48 | 只看该作者
欢迎大家 一起探讨!

使用特权

评论回复
18
mmuuss586| | 2018-6-25 14:58 | 只看该作者
不错,感谢分享;

使用特权

评论回复
19
wangjiahao88|  楼主 | 2018-6-26 12:21 | 只看该作者
SM9541_read:
函数如下:

使用特权

评论回复
20
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 */

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

462

主题

7477

帖子

29

粉丝