• 大小: 18.7MB
    文件类型: .7z
    金币: 1
    下载: 0 次
    发布日期: 2023-07-25
  • 语言: 其他
  • 标签: LabVIEW  

资源简介

LabVIEW虚拟仪器从入门到测控应用130例 源程序

资源截图

代码片段和文件信息

/******************************************************************
** 单片机与TC35I短信模块通信
** 功能:单片机通过DS18B20检测温度,并通过GSM模块发送到指定手机
** 晶 振  频 率:11.0592M
** 线路->单片机实验开发板B
******************************************************************/
    #include  
    #include

    sbit PS0=P2^4;//数码管小数点后第1位    
    sbit PS1=P2^5;//数码管个位    
    sbit PS2=P2^6;//数码管十位    
    sbit PS3=P2^7;//数码管百位
    sfr  P_data=0x80;//P0口为显示数据输出口

    sbit P_K_L=P2^2;//键盘列

    sbit DQ=P3^6;//DS18B20数据接口
sbit P_L=P0^0;//测量指示

   
unsigned char *send_data;

void delay(unsigned int);//延时函数
    void DS18B20_init(void);   //DS18B20初始化
unsigned int get_temper(void);    //读取温度程序 
void DS18B20_write(unsigned char in_data); //DS18B20写数据函数
unsigned char DS18B20_read(void);////读取数据程序  
unsigned int htd(unsigned int a); //进制转换函数
void display(unsigned int a);//显示函数
void send_ascii(unsigned char *b);//发送ascii数据 
void send_hex(unsigned char b);//发送hex数据

float temp;//温度寄存器
bit DS18B20; // 18B20存在标志1---存在 0---不存在
    
unsigned char tab[10]={0xfc0x600xda0xf20x660xb60xbe0xe00xfe0xf6};//字段转换表
    
void main(void)
    {
    unsigned int atempc=0;                                                         
        TMOD=0x20;           //定时器1--方式2
        TL1=0xfd;             
        TH1=0xfd;            //11.0592MHZ晶振,0xfd对应波特率为96000xfa对应波特率为4800  
        SCON=0x50;           //方式1        
        TR1=1;               //启动定时

temp=get_temper();//这段程序用于避开刚上电时显示85的问题
for(a=0;a<2000;a++) 
        delay(500);

while(1)
{
    int a;
    temp=get_temper();//测量温度
    for(a=0;a<100;a++)//显示兼有延时的作用
    display(htd(temp));
if(c>10)
{
    send_ascii(“at+cmgf=1“);//以文本的形式发送
    send_hex(0x0d);
        for(a=0;a<600;a++)//显示兼有延时的作用
        display(htd(temp));
    send_ascii(“at+cmgs=\“158********\““);//发送到指定号码
    send_hex(0x0d); ;
    for(a=0;a<600;a++)//显示兼有延时的作用
        display(htd(temp));   
    send_ascii(“The temperture is “);//发送短信
    send_hex(0x30+((htd(temp)>>8)&0x0f));
    send_hex(0x30+((htd(temp)>>4)&0x0f));
    send_ascii(“.“); 
    send_hex(0x30+(htd(temp)&0x0f));
    send_ascii(“ degree now.“); 
    send_hex(0x1a);
    send_hex(0x0d);
    c=0;
    }
c++;
}
    }

/****************************DS18B20读取温度函数**************************/
/*函数原型:void get_temper(void)
/*函数功能:DS18B20读取温度
/*输入参数:无
/*输出参数:无
/*调用模块:
/**********************************************************************/
unsigned int get_temper(void)
{
    unsigned char kT_signT_LT_H;
DS18B20_init();   //DS18B20初始化 
    if(DS18B20)    //判断DS1820是否存在?若DS18B20不存在则返回
{
            DS18B20_write(0xcc);    // 跳过ROM匹配
            DS18B20_write(0x44);  //发出温度转换命令
    DS18B20_init();   //DS18B20初始化 
        if(DS18B20)    //判断DS1820是否存在?若DS18B20不存在则返回
    {
                DS18B20_write(0xcc

评论

共有 条评论