圣龙扬特-AVR电子

标题: bascom 2262软解码 [打印本页]

作者: 赵彬    时间: 2013-2-28 12:13
标题: bascom 2262软解码
本帖最后由 赵彬 于 2013-2-28 12:21 编辑

用扫描引脚的方法来做的解码,硬件没做远距离测试,也没有在强干扰环境测试。能给大家的只是一种思路。.
$regfile = "m8def.dat"
$crystal = 6000000
$baud = 4800
Config Pinc.1 = Input : Portc.1 = 1
Config Pinc.4 = Input : Portc.4 = 1
Portc.4 = 0
Config Timer1 = Timer , Prescale = 8
Config Pind.2 = Output
Counter1 = &HFFDB
Config Watchdog = 512
Portd.2 = 1
Dim Dsq As Word
Dim Tbm As Word
Dim A(24) As Byte
Dim B(24)as Byte
Dim C(16)as Eram Byte
Dim G As Byte
Dim I As Byte
Dim X As Byte
Dim Kmc As Byte
Dim Zmc As Byte
Dim Bkmc As Byte
Dim Bzmc As Byte
Dim Mc As Byte
Dim Kmcwcz As Byte
Dim Zmcwcz As Byte
Dim Mcpd As Byte
Dim Imc As Byte
Dim Kmcwcf As Byte
Dim Zmcwcf As Byte
Dsq = 0
Tbm = 0
G = 0
Enable Interrupts
Enable Ovf1
On Timer1 T1
Start Timer1

Start Watchdog
Kaishi:
Tbm = 0
Do
If Pinc.1 = 1 Then
Do
Loop Until Pinc.1 = 0
Tbm = 0
Do
Loop Until Pinc.1 = 1
Tbm = Dsq
Dsq = 0
If Tbm >= 67 And Tbm <= 170 Then
Gosub Jiema
End If
End If
Loop
Return

T1:
Counter1 = &HFFDB
Incr Dsq
Incr Tbm

Return
Jiema:
Reset Watchdog
For I = 1 To 24
Do
Loop Until Pinc.1 = 0
If G = 0 Then
A(i) = Dsq
Dsq = 0
End If
If G = 1 Then
B(i) = Dsq
Dsq = 0
End If
Do : Loop Until Pinc.1 = 1
Dsq = 0
Next
Reset Watchdog
G = G + 1
If G = 2 Then
G = 0
End If
Reset Watchdog
If G = 1 Then Goto Kaishi
Gosub Shujuchuli
Return
Shujuchuli:
Kmc = Max(a(24))
Zmc = Min(a(24))
Bkmc = Max(b(24))
Bzmc = Min(b(24))
Mcpd = Zmc * 4
If Zmc >= 1 And Kmc <= Mcpd And Kmc > Zmc Then
  Reset Watchdog
Zmcwcz = Zmc + 1
Kmcwcz = Kmc + 1
Kmcwcf = Kmc - 1
Zmcwcf = Zmc - 1
For Mc = 1 To 24
If A(mc) >= Kmcwcf And A(mc) <= Kmcwcz Then
A(mc) = 1
End If
If A(mc) >= Zmcwcf And A(mc) <= Zmcwcz Then
A(mc) = 0
End If
If B(mc) >= Kmcwcf And B(mc) <= Kmcwcz Then
B(mc) = 1
End If
If B(mc) >= Zmcwcf Or B(mc) <= Zmcwcz Then
B(mc) = 0
End If
Next
Reset Watchdog
For Imc = 1 To 24
'Print "A" ; Imc ; "=" ; A(imc) ;
'Waitms 100
'Print "B" ; Imc ; "=" ; B(imc) ; "  " ;
If A(imc) <> B(imc) Then
Goto Kaishi
End If
Next
'Print 100
Gosub Jm
End If

Return

Xuexi:
For X = 1 To 16
C(x) = A(x)
Waitms 10
Next
Print "xue xi wan cheng"
Portc.4 = 1
Reset Watchdog
Waitms 300
Goto Kaishi
Return

Jm:
Print "ZDZ=" ; Kmc ;
Waitms 100
Reset Watchdog
Print "ZXZ=" ; Zmc ;
Return


作者: ba1731    时间: 2013-2-28 14:15
表四鄙人纯属随机路过。。。顺带帮顶。。。
作者: 铜河    时间: 2013-3-1 14:43
这个不错~~~




欢迎光临 圣龙扬特-AVR电子 (http://avr.cnta.net/) Powered by Discuz! X2.5