qq_42451281
爱喝姜壮奶
2019-04-20 19:15

甲醛传感器ZE08与ZIGbee串口调试是否有冲突。

  • 人工智能

1.甲醛传感器设置为主动上传模式与ch340进行串口调试没有显示数据。
2.甲醛传感器接51单片机可以通过串口调试助手和lcd观察数据,但在51上接一个zigbee模块的tx、vcc端口,甲醛传感器就无法正常工作。

51代码:
/*******************************************************************
*******************STC89C52单片机,11.0592M晶振,1602液晶显示
***********************第一行显示ppb,第二行显示单位mg/m3
********************** mg/m3 = ppm*M气体分子量/22.4 →

************************ mg/m3≈ppm*1.3392857≈ppb*0.0013392857
********************* ze08甲醛模组pin6串联330欧电阻接P30 (也可以不接)
********************************************************************/
#include
#include
#include"delay.h"
#include"1602.h"

#define uchar unsigned char
#define uint unsigned int

uchar code table[]={"0123456789"};
uchar UART_Upload[9]; // Upload上传 accord主动
uint ppb_h,ch2o,ch2o_m;
uchar accord;
void init()
{
ppb_h=0;
}
void init_ser()
{
SCON=0x50; //SCON: 方式1, 8-bit UART
TMOD=0x20; //TMOD: timer 1,方式2, 8-bit 自动重装
PCON=0x00; //SMOD=1;串口波特率加倍
TH1=0xfd; //
TL1=0xfd; //波特率:9600 11.0592MHz

TR1=1;//开定时器1

TI=0;
RI=0;   
EA=1; //    //开总中断  
ES=1;      //串行口中断开  

}
void main()
{
LCD_Init();
delayms(5);
LCD_Clear();
delayms(5);
init_ser();
init();
while(1)
{
LCD_Write_String(0,0,"CH2O:");
LCD_Write_String(9,0,"ppb");
LCD_Write_String(11,1,"mg/m3");
LCD_Write_String(6,1,".");

    LCD_Write_Char(5,0,table[ch2o/1000]);
    LCD_Write_Char(6,0,table[ch2o%1000/100]);
    LCD_Write_Char(7,0,table[ch2o%100/10]);
    LCD_Write_Char(8,0,table[ch2o%10]);

    LCD_Write_Char(5,1,table[ch2o_m/10000]);
    LCD_Write_Char(7,1,table[ch2o_m%10000/1000]);
    LCD_Write_Char(8,1,table[ch2o_m%1000/100]);
    LCD_Write_Char(9,1,table[ch2o_m%100/10]);
    LCD_Write_Char(10,1,table[ch2o%10]);
}

}
void serial () interrupt 4
{
uchar temp_ppb;
if(RI==1)
{
RI=0;
UART_Upload[accord]=SBUF; //串口接收一个数据
accord++;
if(accord>8) //九个数据为一组
{
accord=0;
}

if(accord==0) //接收一组数据后进行一次校验和
{ //校验7为数据位的和取反加一等于校验值
temp_ppb=~(UART_Upload[1]+UART_Upload[2]+UART_Upload[3]+UART_Upload[4]+UART_Upload[5]+UART_Upload[6]+UART_Upload[7])+1; //校验和
if(temp_ppb=UART_Upload[8])
{
ch2o=UART_Upload[4]*256+UART_Upload[5];
ch2o_m=ch2o*13.392857;
}

}

}

}


```请教一下大神有什么解决方法
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

0条回答