The whole network only this one: industrial pressure sensor design and implementation (Mandarin semiconductor HC32L136)

table of Contents

1. Project Overview

2, Module Introduction

2.1, NSA2862 things dedicated bridge sensor chip conditioner

2.2, Metallux ME501 / ME505 ceramic pressure sensor

3, driving principle

4, project realization


Based on recent Metallux ME501 / ME505 ceramic pressure sensor module and NSA2862 things Conditioning chip design an industrial pressure sensor, and the use of Mandarin semiconductor HC32L136 MCU achieve control, special projects will share ideas and experiences to our friends, the whole network is currently only this one, a lot of support ~

1. Project Overview

Sensors based on this project Metallux ME501 / ME505 ceramic pressure sensor module and a micro-nano core chip conditioning NSA2862 things, the microcontroller UW semiconductor HC32L136, under the premise of ensuring high performance, standby and wake-up support, with ultra-low power consumption, can work for 10 years without having to replace the battery, it can be used in large-scale smart city, industrial networking and other areas.

Measurement, calibration, evaluation and design of the project is satisfied here with reference to the core microelectronic sensor solutions achieve, no way, industrial sensor design is to burn ah.

2, Module Introduction

2.1, NSA2862 things dedicated bridge sensor chip conditioner

NSA2862 is designed for an introduction of networking applications for resistive type or a voltage sensor, e.g. piezoresistive pressure sensor, thermocouple, RTD and other ultra-low power sensor signal conditioning ASIC. NSA2862 integrated measuring channel main signal 24 and auxiliary temperature measurement channel 24, sensor calibration logic, the constant current source circuit such as two-way, support I2C, SPI or OWI output. Built-in MCU, NSA2862 zero point of the sensor support, the sensitivity of the second order non-linear calibration drift calibration and the highest temperature of the third order, the calibration accuracy can be achieved within 0.1%, which is a set of calibration coefficients stored in the EEPROM, chip architecture follows shows:

As shown in FIG parameter characteristics:

  • Low standby power: <100nA
  • Built low drift voltage reference
  • 1X ~ 256X precision variable gain instrumentation amplifier
  • A main signal of 24-bit ADC measurements
  • 24-bit ADC for temperature measurement
  • Support built temperature sensor and an external temperature sensor
  • Dual current source output
  • 1X ~ 8X ADC digital gain
  • ODR various settings, support 50 / 60Hz power frequency suppression
  • Based on the universal sensor calibration logic of internal MCU
  • EEPROM, multiple-time programmable
  • Support SPI and I2C interfaces, and OWI
  • Package: TSSOP20
  • Operating temperature range: -40 ℃ ~ 105 ℃

Chip functional diagram is shown below:

2.2, Metallux ME501 / ME505 ceramic pressure sensor

 A pressure sensor for measuring the pressure sensor is generally sensitive to an atmosphere in which a gas or liquid device, the main control unit generally used for feedback to achieve precise control system. A pressure sensor as the door type sensors in the automotive, industrial, appliances, consumer electronics and other industries have a wide range of different applications. The pressure sensor used to distinguish from sensing principles, including the following categories:

  • Silicon piezoresistive technology
  • Technical ceramic resistor
  • Micro glass melting technology
  • Ceramic capacitor technology

Silicon piezoresistive technology implemented by piezoresistive properties of the semiconductor, the semiconductor material piezoresistive properties depending on the kind of materials, doping concentration, and the crystal grain and other factors. The technique can be implemented using a semiconductor process, it has a small size, high output, low cost, high sensitivity signal output advantage. Deficiencies mainly in the low tolerance of the media, poor temperature characteristics and poor long-term stability and the like. Common in the low-voltage measuring range, as 5kPa ~ 700kPa. Industry has been improved through a special silicon piezoresistive technology packaging process tolerance of the media program, such as oil-filled, back pressure and other techniques, but also bring significant cost increase problems.

Ceramic resistor thick film printing process technology Wheatstone bridge printed surface of the ceramic structure, the use of a varistor effect, to achieve the medium pressure signal converted into a voltage signal. Ceramic resistor technology moderate cost, simple process and other advantages, currently there are many manufacturers providing a ceramic resistive pressure sensor core. However, the low sensitivity signal output technique, is defined in the range typically 500kPa ~ 10MPa, and a conventional hollow structure, the diaphragm pressure alone, anti-overload difference, when the overload pressure medium to be measured, there will be a resistance sensor ceramic diaphragm rupture, medium risk of leakage.

Glass micro-melting technique using a high temperature sintering process, in conjunction with silicon strain gauges and stainless steel. Silicon strain gauges of the four equivalent resistors of the Wheatstone bridge, when the other side has a steel diaphragm pressure medium, stainless steel diaphragm deformation caused by electrical changes produce small bridge-shaped pressure change proportional to voltage signal. Glass micro-melting process difficult to achieve and costly. The main advantage is well tolerated medium, strong anti-overload, and is generally suitable for high pressure UHP range, such as 10MPa ~ 200MPa, more limited application.

Ceramic capacitors ceramic technology uses fixed base and the movable ceramic diaphragm structure, the movable diaphragm by way of a sealing glass paste and the like and the base together. Between the inner electrode pattern is printed, thereby forming a variable capacitance after, the pressure on the diaphragm when the medium is subjected to change consequent change in capacitance therebetween, converts the signal conditioning chip by conditioning the output to the subsequent use. Ceramic capacitor technique with a modest cost, wide measuring range, good temperature characteristics, consistency, and long-term stability and other advantages. Internationally widely used in automotive and industrial process control and other fields, namely the United States and Switzerland Sensata E + H represented. Since the capacitance signal is different from the resistance of the signal, a signal processing circuit for higher requirements, the sensor design requires the chip capacitor and the signal conditioning ASIC considered synergistic, currently the only Suzhou core Microelectronics satisfied simultaneously provide complete solutions to integrate the two Program.

As a ceramic capacitor pressure sensor, a major technical route, ceramic ring consists of three parts, ceramics and ceramic diaphragm plate, has a corrosion resistance, impact resistance, good media compatibility advantages. Metallux ME501 / ME505 sensor technology works ceramic resistor, which is adjustable by the laser thermal compensation resistor PTC, the use of ceramic ensures high linearity across the entire measurement range, the minimum hysteresis, the sensor structure is shown below:

 Sensor technical characteristics as follows:

3, driving principle

This project microcontroller UW HC32L136 driving semiconductor chip based sensor conditioning NSA2862 I2C communication protocol, two-wire bidirectional I2C is a synchronous serial bus, which uses a clock line and a data line of the two devices connected to the bus between transmit messages, it provides a simple and efficient method of data exchange between devices. Each of the devices connected to the bus has a unique address, any device may be used as a host or as a slave, but at the same time allowing only one host. I2C is a standard multi-master bus with a true sense of the collision detection mechanism and arbitration mechanisms that can simultaneously request the use of the control bus arbitration mechanism to avoid data collisions and protect data across multiple hosts. I2C bus controller, I2C bus can meet a variety of transmission modes, and supports all communication with I2C bus.

I2C standard transmission protocol generally comprises four parts: Start (S) or repeated START signal (Sr), and to read and write slave address bits, the data transmission stop signal (P). FIG I2C transmission protocol is as follows:

When the bus is idle (SCL and SDA lines remain high), SDA line from high to low occurrence signal indicating that the start signal is generated on the bus. When there is no signal between the two stop start signal, the repeat start signal that is generated. With this method the host to communicate at different transmission directions from a machine or to another machine from the same (e.g.: read from the write device to the slave device) without releasing the bus. When the SCL line is high, the SDA line occur from low to high signal, is defined as the stop signal. Bus master issues a stop signal to the data transfer is completed. FIG START and STOP conditions are as follows:

When the start signal is generated, the host transmits the first byte of the immediate data: the data transmission direction 7 Address + write bit, write bit controls the slave (0: Write; 1: read). It addressed by the host by chance from the 9th SCL clock cycle as a response SDA low.

 During data transfer, a clock pulse SCL transmitting a data bit, and the SDA line low only when may vary as SCL. FIG upper I2C bus transmission as follows:

Chinese Semiconductor component may be implemented I2C 8-bit bidirectional data transmission, the transmission rate in standard mode can reach up to 100Kbps and 400Kbps high-speed mode, up to 1Mbps in ultra high-speed mode, and can operate in four modes: host mode, the host receive mode, the slave receive mode, the slave transmit mode. There is also a special broadcast mode, a call mode, which mode of operation is similar to slave receive mode.

China Semiconductor HC32L136 I2C controller supports the following features:

  • Support master transmission / reception, the slave transmission / reception four operating modes
  • Supports standard (100Kbps) / Fast (400Kbps) / high-speed (1Mbps) three operating rate
  • Supports 7-bit addressing
  • Noise filtering support
  • Support broadcast address
  • Supports interrupt status query function

I2C functional block as shown below:

The project host mode used for data sending and receiving a communication, the master closed, synchronous transmission mode data is shown below (a more detailed description can be found in User's Manual):

4, project realization

Step 1: Identify slave address (pressure sensor address), NSA2862 I2C device address of the following table:

Step 2: Configuration HC32L136 I2C function module, where the communication needs to pay attention to the electrical characteristics of I2C pins NSA2862 the following table:

I2C GPIO configuration code is shown below: 

///< IO端口配置
void App_PortCfg(void)
{
    stc_gpio_cfg_t stcGpioCfg;
    
    DDL_ZERO_STRUCT(stcGpioCfg);
    
    Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE);   //开启GPIO时钟门控 
    
    stcGpioCfg.enDir = GpioDirOut;                           ///< 端口方向配置->输出    
    stcGpioCfg.enOD = GpioOdEnable;                          ///< 开漏输出
    stcGpioCfg.enPu = GpioPuEnable;                          ///< 端口上拉配置->使能
    stcGpioCfg.enPd = GpioPdDisable;                         ///< 端口下拉配置->禁止
    
    Gpio_Init(GpioPortB,GpioPin8,&stcGpioCfg);               ///< 端口初始化
    Gpio_Init(GpioPortB,GpioPin9,&stcGpioCfg);
    
    Gpio_SetAfMode(GpioPortB,GpioPin8,GpioAf1);              ///< 配置PB08为SCL
    Gpio_SetAfMode(GpioPortB,GpioPin9,GpioAf1);              ///< 配置PB09为SDA
}

I2C configuration code is as follows:

///< I2C 模块配置
void App_I2cCfg(void)
{
    stc_i2c_cfg_t stcI2cCfg;
    
    DDL_ZERO_STRUCT(stcI2cCfg);                            ///< 初始化结构体变量的值为0
    
    Sysctrl_SetPeripheralGate(SysctrlPeripheralI2c0,TRUE); ///< 开启I2C0时钟门控
    
    stcI2cCfg.u32Pclk = Sysctrl_GetPClkFreq();             ///< 获取PCLK时钟
    stcI2cCfg.u32Baud = 100000;                            ///< 100K
    stcI2cCfg.enMode = I2cMasterMode;                      ///< 主机模式
    stcI2cCfg.bGc = FALSE;                                 ///< 广播地址应答使能关闭
    I2C_Init(M0P_I2C0,&stcI2cCfg);                         ///< 模块初始化
}

 Step 3: receiving write driver functions, the host receives the state shown in FIG follows:

Receiving driver code as follows: 

/**
 ******************************************************************************
 ** \brief  主机接收函数
 **
 ** \param u8Addr从机内存地址,pu8Data读数据存放缓存,u32Len读数据长度
 **
 ** \retval 读数据是否成功
 **
 ******************************************************************************/
 en_result_t I2C_MasterReadData(M0P_I2C_TypeDef* I2CX,uint8_t u8Addr,uint8_t *pu8Data,uint32_t u32Len)
{
    en_result_t enRet = Error;
    uint8_t u8i=0,u8State;
    
    I2C_SetFunc(I2CX,I2cStart_En);
    
    while(1)
    {
        while(0 == I2C_GetIrq(I2CX))
        {}
        u8State = I2C_GetState(I2CX);
        switch(u8State)
        {
            case 0x08:                                 ///< 已发送起始条件,将发送SLA+W
                I2C_ClearFunc(I2CX,I2cStart_En);
                I2C_WriteByte(I2CX,I2C_SLAVEADDR);
                break;
            case 0x18:                                 ///< 已发送SLA+W,并接收到ACK
                I2C_WriteByte(I2CX,u8Addr);            ///< 发送从机内存地址
                break;
            case 0x28:                                 ///< 已发送数据,接收到ACK, 此处是已发送从机内存地址u8Addr并接收到ACK
                I2C_SetFunc(I2CX,I2cStart_En);         ///< 发送重复起始条件
                break;
            case 0x10:                                 ///< 已发送重复起始条件
                I2C_ClearFunc(I2CX,I2cStart_En);
                I2C_WriteByte(I2CX,I2C_SLAVEADDR|0x01);///< 发送SLA+R,开始从从机读取数据
                break;
            case 0x40:                                 ///< 已发送SLA+R,并接收到ACK
                if(u32Len>1)
                {
                    I2C_SetFunc(I2CX,I2cAck_En);       ///< 使能主机应答功能
                }
                break;
            case 0x50:                                 ///< 已接收数据字节,并已返回ACK信号
                pu8Data[u8i++] = I2C_ReadByte(I2CX);
                if(u8i==u32Len-1)
                {
                    I2C_ClearFunc(I2CX,I2cAck_En);     ///< 已接收到倒数第二个字节,关闭ACK应答功能
                }
                break;
            case 0x58:                                 ///< 已接收到最后一个数据,NACK已返回
                pu8Data[u8i++] = I2C_ReadByte(I2CX);
                I2C_SetFunc(I2CX,I2cStop_En);          ///< 发送停止条件
                break;
            case 0x38:                                 ///< 在发送地址或数据时,仲裁丢失
                I2C_SetFunc(I2CX,I2cStart_En);         ///< 当总线空闲时发起起始条件
                break;
            case 0x48:                                 ///< 发送SLA+R后,收到一个NACK
                I2C_SetFunc(I2CX,I2cStop_En);          ///< 发送停止条件
                I2C_SetFunc(I2CX,I2cStart_En);         ///< 发送起始条件
                break;
            default:
                I2C_SetFunc(I2CX,I2cStart_En);         ///< 其他错误状态,重新发送起始条件
                break;
        }
        I2C_ClearIrq(I2CX);                            ///< 清除中断状态标志位
        if(u8i==u32Len)                                ///< 数据全部读取完成,跳出while循环
        {
                break;
        }
    }
    enRet = Ok;
    return enRet;
}

 Step 4: preparation of a drive transmission function, the host sends a state diagram is shown below: 

Drive transmission code as follows:  

/**
 ******************************************************************************
 ** \brief  主机发送函数
 **
 ** \param u8Addr从机内存地址,pu8Data写数据,u32Len写数据长度
 **
 ** \retval 写数据是否成功
 **
 ******************************************************************************/
en_result_t I2C_MasterWriteData(M0P_I2C_TypeDef* I2CX,uint8_t u8Addr,uint8_t *pu8Data,uint32_t u32Len)
{
    en_result_t enRet = Error;
    uint8_t u8i=0,u8State;
    I2C_SetFunc(I2CX,I2cStart_En);
    while(1)
    {
        while(0 == I2C_GetIrq(I2CX))
        {;}
        u8State = I2C_GetState(I2CX);
        switch(u8State)
        {
            case 0x08:                               ///< 已发送起始条件
                I2C_ClearFunc(I2CX,I2cStart_En);
                I2C_WriteByte(I2CX,I2C_SLAVEADDR);   ///< 从设备地址发送
                break;
            case 0x18:                               ///< 已发送SLA+W,并接收到ACK
                I2C_WriteByte(I2CX,u8Addr);          ///< 从设备内存地址发送
                break;
            case 0x28:                               ///< 上一次发送数据后接收到ACK
                I2C_WriteByte(I2CX,pu8Data[u8i++]);  ///< 继续发送数据
                break;
            case 0x20:                               ///< 上一次发送SLA+W后,收到NACK
            case 0x38:                               ///< 上一次在SLA+读或写时丢失仲裁
                I2C_SetFunc(I2CX,I2cStart_En);       ///< 当I2C总线空闲时发送起始条件
                break;
            case 0x30:                               ///< 已发送I2Cx_DATA中的数据,收到NACK,将传输一个STOP条件
                I2C_SetFunc(I2CX,I2cStop_En);        ///< 发送停止条件
                break;
            default:
                break;
        }
        if(u8i>u32Len)
        {
            I2C_SetFunc(I2CX,I2cStop_En);            ///< 此顺序不能调换,出停止条件
            I2C_ClearIrq(I2CX);
            break;
        }
        I2C_ClearIrq(I2CX);                          ///< 清除中断状态标志位
    }
    enRet = Ok;
    return enRet;
}

  Step 5: To verify I2C communication is successful, to perform the read data register NSA2862 idle 0X55 0XCF in and read out the idle address register as shown below:

Verify sample code as follows:  

uint8_t u8Senddata[2] = {0x00,0x55};
uint8_t u8Recdata[1]={0x00};

///< 向I2C总线发起开始信号
I2C_SetFunc(M0P_I2C1,I2cStart_En); 
///< 写数据
I2C_MasterWriteData(M0P_I2C0,0x30,&u8Senddata[0],1);  
I2C_MasterWriteData(M0P_I2C0,0xCF,&u8Senddata[1],1);  
delay1ms(100);

///< 读数据
I2C_MasterReadData(M0P_I2C0,0xCF,u8Recdata,1);    

///< 串口打印
for(int i=0;i<1;i++)
{
  Uart_SendDataIt(M0P_UART1,u8Recdata[i]); //启动UART1发送数据
  delay1ms(3); 
}

Oscilloscope to view the results, running clock signal waveforms as follows:

Running data signal waveform is shown below: 

Serial output results as shown below: 

DESCRIPTION I2C can achieve normal data read and write.

Step 6: reading pressure sensor values, the register address in the table below:

The code reading sensor values ​​as follows:

uint8_t u8Senddata[2] = {0x00,0x40};
uint8_t u8Recdata[4]={0x00};

///< 向I2C总线发起开始信号
I2C_SetFunc(M0P_I2C1,I2cStart_En);      
///< 写入寄存器启动使RAW_P=0
I2C_MasterWriteData(M0P_I2C0,0x30,&u8Senddata[0],1);  
I2C_MasterWriteData(M0P_I2C0,0xA5,&u8Senddata[1],1);  
delay1ms(100);

///< 读取经过校正的传感器数据
I2C_MasterReadData(M0P_I2C0,0x06,u8Recdata,1);  
I2C_MasterReadData(M0P_I2C0,0x07,u8Recdata+1,1);    
I2C_MasterReadData(M0P_I2C0,0x08,u8Recdata+2,1);   

for(int i=0;i<3;i++)
{
  Uart_SendDataIt(M0P_UART1,u8Recdata[i]); //启动UART1发送数据
  delay1ms(3); 
}

Oscilloscope to view the results, running clock signal waveforms as follows:

Running data signal waveform is shown below: 

Serial output results as shown below: 

Data is 0X014ADD ME501 pressure value (two's complement) after calibration.

Published 160 original articles · won praise 8331 · Views 860,000 +

Guess you like

Origin blog.csdn.net/m0_38106923/article/details/104610640