⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 switch_mode.c

📁 电能表源码
💻 C
字号:
/*************************************************************************************

	文件类型:拉合闸控制模块
	文件作用:
	修改权限:
	文件相关:
	
	创 建 人:chenbo
	创建日期:2008.06.21
	当前版本:Ver0.1
	
	版本信息:Ver0.1					GeminiKQ

**************************************************************************************/
#include "Tiger.h"
#include "typemeter.h"

//===================================================================
//函数功能:初始化拉合闸模块
//===================================================================
void Ini_switchmode(void)
{ End_switch                             //默认输出低电平
  time_plusswitch=0;               
}

//===================================================================
//函数功能:开始合闸操作
//====================================================================
void Switch_starton(void)
{ Start_onswitch
  time_plusswitch=0;
  delay_cftime=0;
  timocount_cf=0;
}

//===================================================================
//函数功能:开始拉闸操作
//====================================================================
void Switch_startoff(void)
{ Start_0ffswitch
  time_plusswitch=0;
}

//===================================================================
//函数功能:结束拉合闸操作
//====================================================================
void Swithc_end(void)
{
  End_switch
}

//=================================================================
//函数功能:判拉合闸状态
//返回值:0合闸 1 拉闸
//=================================================================
unsigned char pan_onandoff(void)
{ unsigned char value;
  
  return value;
}
//====================================================================
//函数功能:开合闸控制模块
//
//====================================================================
void Switch_mode(void)
{ unsigned char temp_sta;
//  unsigned int currnt;
  if(flag_runswitchmode==1)
     { flag_runswitchmode=0;
       Read_datafromID(0xc302);                   //读取拉合闸状态
       temp_sta=wr_buff[0];

      /*  
       Read_datafromID(0xc200);                   //读取电流有效值
  	   currnt=value_hex_from_2bcd(wr_buff);       //只判断整数 
       if(currnt>=(type_Ib/2))                    //>=0.5Ib
           temp_sta&=0xfb;
       else
           temp_sta|=0x04;
        */
       if(delay_cftime<195)                       //>=0.5Ib
          temp_sta&=0xfb;
       else
           temp_sta|=0x04;
       if(pan_onandoff()==1)                      //判当前拉合闸状态
           temp_sta|=0x02;                        //拉闸状态
       else
           temp_sta&=0xfd;                        //合闸状态
       wr_buff[0]=temp_sta;                       //保存状态字
       Write_datafromID(0xc302);
     /*
       if((temp_sta&0x03)==0x02)
           Switch_starton();                         //合闸操作
       if((temp_sta&0x07)==0x05)
           Switch_startoff();                        //拉闸操作
	   */
     }

  if(time_plusswitch>8)                         //80ms
     Swithc_end();                               //结束操作
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -