通用遥控编码2262与1527解说
通用遥控主频常为433MHz与315MHz
编码为NRZ格式
数据形式通常以1527与2262为居多;
传输数率: 1Kb/s左右
宽占空比约:1000us,窄占空比约:300us
1 以下是1527数据形式: 2 3 D55Dxx 4 5 键1:1101 0101 0101 1101 0000 0001 6 7 键2:1101 0101 0101 1101 0000 0010 8 键3:1101 0101 0101 1101 0000 0100 9 键4:1101 0101 0101 1101 0000 1000 10 ... 11 12 最大为16个键值,即最后4bit为键值,1-4键为基础键值,其他都为ID值。 13 14 以下是2262数据形式: 15 16 D55Dxx 17 18 键1:1101 0101 0101 1101 0000 0011 19 20 键2:1101 0101 0101 1101 0000 1100 21 22 键3:1101 0101 0101 1101 0011 0000 23 24 键4:1101 0101 0101 1101 1100 0000 25 26 ... 27 28 最大为16个键值,即最后8bit为键值,1-4键为基础键值,其他都为ID值。
这种键值是没有加密的,传送的都是明文,所以保密性不高,通常用于遥控开关,家具等。当用到安全比较高的场合,这种编码就不可靠了。往往针对这些,我们需要用到其他编码以及数据组合形式。例如曼切斯特编码,has,xxtea,aes等加密方式进行通信。
1 /*--------------------------------------------------------- 2 ** RF Data Format: NRZ decoder 3 ** 1B = 1000usH+300usL; 0B = 300usH+1000usL; T = 1300us 4 ** Package interval=10msL 5 ** ASM Modulation 6 ** Designed by Milo lu 7 -----------------------------------------------------------*/ 8 void Intp5_IQR_callback_Handle(void) 9 { 10 static uint8_t bits_of_byte; 11 static uint32_t one_byte,last_id; 12 uint8_t IO_State; 13 IO_State = PORT_GetBit(ASK_INPUT_PORT,ASK_INPUT_PIN); 14 15 if(IO_State !=0 ) // Low to high transition 16 { 17 // Low state time is Longer than 1.7ms,OR Paraser busy, data crash, retry again 18 if((TAR_50us >= 34)||(DATA_RECEIVED.long_value!=0) || (RF_Delay!=0) || (g_bool_battery_unplug==true)) 19 { 20 START_RX = 0; 21 } 22 TAR_50us = 0; 23 } 24 else // High to low transition 25 { 26 if(!START_RX) // The first header doesn't receive 27 { 28 if((TAR_50us > 14)&&(TAR_50us < 34)) // 1.7ms > T > 0.7ms 29 { 30 one_byte = 1; 31 bits_of_byte = 1; 32 START_RX = 1; 33 } 34 else if((TAR_50us >4)&&(TAR_50us< 12)) //0 600us > T > 200us 35 { 36 one_byte = 0; 37 bits_of_byte = 1; 38 START_RX = 1; 39 } 40 } 41 else // The second header received, 42 { // start to get RF data 43 if((TAR_50us >4)&&(TAR_50us< 12)) //0 600us > T > 200us 44 { 45 one_byte <<=1; 46 bits_of_byte++; 47 } 48 else if((TAR_50us > 14)&&(TAR_50us < 34)) // 1.7ms > T > 0.7ms 49 { 50 one_byte<<=1; 51 one_byte+=1; 52 bits_of_byte++; 53 } 54 else 55 { 56 START_RX = 0x00; // data crash, retry again 57 } 58 if(bits_of_byte >= 24) // got one byte, got id 59 { 60 if((last_id != one_byte)&&(f0LearnMode & flag.flag0)) 61 { 62 last_id = one_byte; 63 } 64 else //at least 2 times get the same id 65 { 66 DATA_RECEIVED.long_value = one_byte; //load RF data 67 } 68 #if ask_debug 69 printf("DATA_RECEIVED.long_value=%04x\n",DATA_RECEIVED.long_value); 70 #endif 71 START_RX = 0x00; // Receiving repeat 72 one_byte = 0; 73 bits_of_byte = 0; 74 } 75 } 76 TAR_50us = 0; 77 } 78 } 79 80 81 /*==================================== 82 function name: timerA_callback_handle 83 discription: about 50us increase 84 parameters: none 85 return: none 86 ======================================*/ 87 void timerA_callback_handle(void) 88 { 89 TAR_50us++; 90 } 91 //-------------------- end of file ---------------------