资源简介
解决433遥控器远距离控制设备,或者遥控器电池电量低时控制设备的过程中,出现杂波影响遥控器灵敏度的问题,这可提高用户体验。

代码片段和文件信息
#include “RF433.h“
/***************************************************
一个字码由 同步码 + 地址码 + 数据码 组成
遥控器的编码芯片不同(不同遥控器),需修改:
#define _start_us_min 80 //同步码用到
#define _start_us_max 120
#define _num0_us_min 15 //数据“0”用到
#define _num0_us_max 25
#define _num1_us_min 3 //数据“1”用到
#define _num1_us_max 14
*******************************************************/
/*************解码函数**********
//如果不需要对码注释下面这一段
Temp_addrh=(RF_data>>8);//地址码
Temp_addrl=(RF_data>>16);//
if((j!=2)&&(Temp_RF_Key==0x08))//对码,开关键
{
RF_Value_Cnt++;
if((j==1)&&(time_duima<40000)) //40000*0.05ms=2s (长按)对码
{
if(RF_Value_Cnt>20)
{
EA=0;
RF_Value_Cnt=0;
j=2;
time_duima=60020;
Address_l=Temp_addrl;
Address_h=Temp_addrh;
Write_Memory(); //写入存储
FLASH_FLAG=1; //对码成功标志
EA=1;
}
}
}
if(Address_l==Temp_addrl && Address_h==Temp_addrh)
*************************/
#define RF_Dat P23
uint16_t time_duima = 6100;
uchar timecnt1 timecnt0;
bit Jump_flag;
bit start_flag;
uchar cntint;
ulong RF_data;
uchar Temp_addrl = 0;
uchar Temp_addrh = 0;
uchar Address_l Address_h; //地址码
uint RF_Key;
extern unsigned short int flag_S;
bit flash_1S;
void soft_decode(void); //译码函数
void soft_count(void) //接受码计数函数
{
if (time_duima < 6005)time_duima++;
if (!RF_Dat) //低电平
{
timecnt0++;
if (Jump_flag && timecnt0>=1)//timecnt0>=1的作用是低电平滤波,当433信号为高电平时出现了低电平杂波,
//一般杂波的持续时间不会大于50us,我们就把低于50us的低电平视为杂波,
//当然这个可以根据不同遥控器的情况把这个50us改为其他不会影响到程序解码的时间
{
Jump_flag = 0; //Jump_flag由0→1代表 低→高 跳变
}
}
else if (RF_Dat) //高电平
{
if (!Jump_flag && timecnt1>=1)//timecnt1>=1的作用是高电平滤波处理,防止在远处控制时出现高电平杂波,
//只有高于50us的高电平才是有效的高电平
{
Jump_flag = 1; //Jump_flag由1→0代表 高→低 跳变
soft_decode();
timecnt1 = 0;
timecnt0 = 0;
}
timecnt1++;
}
}
#define _120_us_min 2
#define _120_us_max 5
#define _360_us_min 6
#define _360_us_max 12
#define _3700_us_min 70//70
#define _3700_us_max 200//120
uint8_t g_RF_reset = 0;
extern uint8_t g_Save_Flag;//存储标志位
extern uint8_t g_u8twinkle_flag;
void soft_decode(void) //接受码处理函数
{
static uint8_t RF_reset_cnt = 0;
uint Temp_RF_Key = 0;
if (!start_flag)
{
if ((timecnt0 > _3700_us_min) && (timecnt0 < _3700_us_max)) //数据头
{
start_flag = 1;
cntint = 0;
Temp_RF_Key = 0;
RF_data = 0;
RF_reset_cnt = 0;
}
else
{
if(RF_reset_cnt++ > 50)
{
g_RF_reset = 1;//复位标志位,用了键值清零即可(消重复按键)
RF_Key = 0;//复位要清键值。
}
}
}
else if (start_flag == 1 && cntint < 24)
{
if ((timecnt0 >= _360_us_min) && (timecnt0 <= _360_us_max)) //数据 0
{
RF_data = RF_data << 1;
cntint++;
}
else if ((timecnt0 >= _120_us_min) && (timecnt0 <= _120_us_max)) //数据 1
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 703 2020-07-02 11:14 RF433.h
文件 88725 2020-10-16 09:36 无线433软件滤波.docx
文件 4317 2020-10-16 09:07 RF433.c
- 上一篇:Qt界面美化
- 下一篇:无线433判断遥控器按键弹起.zip
相关资源
- VisualStudioUninstaller vs卸载工具
- 组态王驱动开发包3.0.0.7(中文)
- 多窗口后台鼠标连点器
- 使用选择性重传协议实现UDP可靠通信
- VC 获得文件属性 获取文件的创建时
- 读者写者问题(读者优先,写者优先
- 用VC 编写的仿QQ聊天室程序源代码
- 外点法程序
- 外罚函数程序
- qt-电子点菜系统
- 推箱子及人工智能寻路C 源代码
- 自己写的航空订票系统c 版--数据结构
- 数据结构实验魔王语言
- MUSIC算法c 实现
- C 餐厅叫号系统(QT平)
- 国际象棋c 完整版
-
ob
jectARX给Auto CAD加工具条 - 画图程序MFC/VC/VC CRectTracker 串行化
- MFC网络编程实例
- c 课程设计 职工信息管理系统
- VC 游戏编程—附源代码
- IpHlpApi.h&IpHlpApi.lib
- 清华大学 c 郑莉 ppt课件
- c 程序判断离散数学中命题公式
- 多项式求和(数据结构C 版)
- vc 6.0开发的流程图编辑器
- VC 天空盒(skyBox)实现(附源代码)
- c MFC 画多边形
- 用C 实现的对网络上的ARP数据包进行
- Microsoft基本类库 (MFC)(C 库)
评论
共有 条评论