У кого есть наработки или библиотека приема не RC5 кодировки.
Например http://www.getchip.net/posts/071-preobr … ov-v-uart/ у человека есть но на Algoritm Builder.
Прием Bascom не RC5 кодировки
Сообщений 1 страница 5 из 5
Поделиться12013-02-10 11:48:49
Поделиться22013-02-11 12:09:16
NEC
$regfile = "m32def.dat"
$crystal = 8000000
$hwstack = 36
$swstack = 36
$framesize = 40
Config Lcdpin = Pin , Rs = Portc.7 , E = Portc.6 , Db4 = Portc.5 , Db5 = Portc.4 , Db6 = Portc.3 , Db7 = Portc.2
Config Lcd = 24 * 2
Cursor Off
Cls
Locate 1 , 4
Lcd "NEC DECODER"
Locate 2 , 4
Lcd "BASCOM-AVR"
Wait 1
Config Timer0 = Timer , Prescale = 256 '8000000/256=31250 Hz
Config Int1 = Falling 'Interruption on Falling
Stop Timer0
Enable Timer0
Enable Int1
Enable Interrupts
On Timer0 Tikers 'work on timer
On Int1 Infrared 'work on interruption
Dim Got As Bit
Dim Tik As Word 'counter of teaks of timer
Dim Byt As Byte 'counter accepted bit
Dim Repeat_flag As Bit 'flag of repetition
Dim Start_flag As Bit 'flag of start condition
Dim Address_1 As Byte 'direct byte of address
Dim Command_1 As Byte 'direct byte of command
Dim Address_0 As Byte 'indirect byte of address
Dim Command_0 As Byte 'indirect byte of command
Dim Summa As Word
Dim Address_nec As Byte , Command_nec As Byte
Cursor Off 'Switch Off cursor
'################################################################################################################
Do 'Main cycle
If Got = 1 Then
Cls
Locate 1 , 1
Lcd "ADDRESS " ; Address_nec
Locate 2 , 1
Lcd "COMMAND " ; Command_nec 'Lcd ADDRESS and COMMAND
Reset Got
End If
Waitms 10 'Delay 10 en
Loop
End 'End of main cycle
'################################################################################################################
Tikers: 'work on timer
Timer0 = 253 '31250/(256-253)=10416,66 Hz (96 een)
Incr Tik
If Tik >= 1200 Then 'if 1200 teaks, have thrown all in source condition
Tik = 0
Repeat_flag = 0
Start_flag = 0
Address_1 = 255
Command_1 = 255
Address_0 = 0
Command_0 = 0
Address_nec = 255
Command_nec = 255
Stop Timer0
End If
Return
'################################################################################################################
Infrared: 'work on interruption
Start Timer0
If Tik >= 139 And Tik < 150 Then 'if has happenned from 139 before 150 teaks - "START"
Address_nec = 1
Repeat_flag = 0
Start_flag = 1
Address_1 = 255
Command_1 = 255
Address_0 = 0
Command_0 = 0
End If
If Tik >= 116 And Tik < 139 Then 'if has happenned from 116 before 138 teaks - "REPETITION"
Address_nec = 0
Repeat_flag = 1
Start_flag = 0
End If
If Tik >= 22 And Tik < 116 And Start_flag = 1 Then 'if has happenned from 22 before 115 teaks - have taken "1"
Incr Byt
If Byt < 9 Then
Shift Address_1 , Left
Address_1 = Address_1 + 1
End If
If Byt >= 9 And Byt < 17 Then
Shift Address_0 , Left
Address_0 = Address_0 + 1
End If
If Byt >= 17 And Byt < 25 Then
Shift Command_1 , Left
Command_1 = Command_1 + 1
End If
If Byt >= 25 Then
Shift Command_0 , Left
Command_0 = Command_0 + 1
End If
End If
If Tik >= 10 And Tik < 22 And Start_flag = 1 Then 'if has happenned from 10 before 21 teaks - have taken "0"
Incr Byt
If Byt < 9 Then
Shift Address_1 , Left
End If
If Byt >= 9 And Byt < 17 Then
Shift Address_0 , Left
End If
If Byt >= 17 And Byt < 25 Then
Shift Command_1 , Left
End If
If Byt >= 25 Then
Shift Command_0 , Left
End If
End If
Tik = 0
If Byt = 32 Then
Address_nec = Address_1
Command_nec = Command_1
Set Got
Address_1 = 255
Command_1 = 255
Byt = 0
Repeat_flag = 0
Start_flag = 0
Stop Timer0
End If
ReturnПоделиться32013-02-11 20:54:30
При приеме нестандратных кодов нужно всего то отличать их друг от друга. Садитесь на прерывание от и считайте количество импульсов. Чаще всего это дает нужный эффект - при нажатии на разные кнопочки будут разные циферки. Попадаются пульты передающие повтор (длительное нажатие) отдельным кодом. Это делает боле сложной обработку, надо запоминать принятый код и понимать, что идет не новый код, а повтор.
Исходник поищу, но там очень примитивно все.
Поделиться42013-02-11 23:53:37
При приеме нестандратных кодов нужно всего то отличать их друг от друга. Садитесь на прерывание от и считайте количество импульсов. Чаще всего это дает нужный эффект - при нажатии на разные кнопочки будут разные циферки. Попадаются пульты передающие повтор (длительное нажатие) отдельным кодом. Это делает боле сложной обработку, надо запоминать принятый код и понимать, что идет не новый код, а повтор.
Исходник поищу, но там очень примитивно все.
Если возможно исходники выложите?
Поделиться52013-02-12 23:05:36
ищите по моим сообщениям в теме FastAVR
синтаксис схож (Баском их него вырос), поэтому проблем не будет понимании алгоритма