'Sparrow_TPS1.bas
'Dit 100 ms = 0, Dah 300 ms = 1, Low Bit first
$regfile = "attiny13.dat"
$crystal = 1200000
$hwstack = 8
$swstack = 4
$framesize = 4
Led1 Alias Portb.1
Led2 Alias Portb.3
S1 Alias Pinb.0
S2 Alias Pinb.2
Config Portb = &B000011010
Dim D As Byte
Dim T As Byte
Dim B As Byte
Dim C As Byte
Dim A As Byte
Dim Addr As Byte
Dim Eebyte As Byte
Dim Dat As Byte
Dim Kom As Byte
Dim Adrhi As Byte
Dim Adrlo As Byte
Dim Adrret As Byte
'Dim Prog As Byte
Dim Dd As Word
Dim Times(16) As Word
Dim Delaytime As Word
Dta:
Data 1% , 2% , 5% , 10% , 20% , 50% , 100% , 200% , 500% , 1000% , 2000% , 5000% , 10000% , 20000% , 30000% , 60000%
Declare Sub Receivebinary
Declare Sub Sendbinary
' Timer 0 is configured for Sound at OC0B / PB1
Config Timer0 = Pwm , Prescale = 8 , Compare B Pwm = Clear Up
If S1 = 0 Then
Receivebinary
A = 0
Do
Led2 = 1
Receivebinary
D = C * 16
Led2 = 0
Receivebinary
C = C And 15
D = D + C
Writeeeprom D , A
A = A + 1
Loop Until D = 255
'Else
' Dat = &H12 : Writeeeprom Dat , 0 'Dout=2
' Dat = &H29 : Writeeeprom Dat , 1 '1000 ms
' Dat = &H18 : Writeeeprom Dat , 2 'Dout=8
' Dat = &H29 : Writeeeprom Dat , 3 '1000 ms
' Dat = &H34 : Writeeeprom Dat , 4 'Adr = Adr - 4
End If
A = 0
Do
Readeeprom Eebyte , A
If Eebyte < 255 Then
Led2 = 1
C = Eebyte / 16
Sendbinary
Waitms 500
Led2 = 0
C = Eebyte And 15
Sendbinary
A = A + 1
Waitms 500
End If
Loop Until Eebyte = 255
Addr = 0
Do
Readeeprom Eebyte , Addr
Addr = Addr + 1
Dat = Eebyte And 15
Kom = Eebyte / 16
If Kom = 1 Then '1: Direkte Portausgabe
Portb = Dat Or &B11100101
End If
If Kom = 2 Then
Restore Dta
Delaytime = Lookup(dat , Dta)
Waitms Delaytime '2: Wartezeit
End If
If Kom = 3 Then '3: Sprung - relativ
Addr = Addr - 1
Addr = Addr - Dat
End If
If Kom = 4 Then
A = Dat
End If
Loop
Sub Receivebinary
C = 0
B = 1
Do
Do
Loop Until S1 = 0
Pwm0b = 80
T = 0
Do
Waitms 10
T = T + 1
Loop Until S1 = 1
Pwm0b = 0
Waitms 10
If T > 15 Then
C = C + B
End If
Shift B , Left
T = 0
Do
Waitms 10
T = T + 1
Loop Until S1 = 0 Or T > 25
Loop Until T > 25
End Sub
Sub Sendbinary
Do
B = C And 1
If B = 1 Then
Pwm0b = 80
Waitms 300
Else
Pwm0b = 80
Waitms 100
End If
Pwm0b = 0
Waitms 100
Shift C , Right
Loop Until C = 0
End Sub
'Sparrow_TPS2.bas
'Dit 100 ms = 0, Dah 300 ms = 1, Low Bit first
$regfile = "attiny13.dat"
$crystal = 1200000
$hwstack = 8
$swstack = 4
$framesize = 4
Led1 Alias Portb.1
Led2 Alias Portb.3
S1 Alias Pinb.0
S2 Alias Pinb.2
Config Portb = &B000011010
Dim D As Byte
Dim T As Byte
Dim B As Byte
Dim C As Byte
Dim A As Byte
Dim Addr As Byte
Dim Eebyte As Byte
Dim Dat As Byte
Dim Kom As Byte
Dim Adrhi As Byte
Dim Adrlo As Byte
Dim Adrret As Byte
'Dim Prog As Byte
Dim Dd As Word
Dim Times(16) As Word
Dim Delaytime As Word
Dta:
Data 1% , 2% , 5% , 10% , 20% , 50% , 100% , 200% , 500% , 1000% , 2000% , 5000% , 10000% , 20000% , 30000% , 60000%
Declare Sub Receivebinary
Declare Sub Sendbinary
' Timer 0 is configured for Sound at OC0B / PB1
' Config Timer0 = Pwm , Prescale = 8 , Compare B Pwm = Clear Up
If S1 = 0 Then
Receivebinary
A = 0
Do
Led2 = 1
Receivebinary
D = C * 16
Led2 = 0
Receivebinary
C = C And 15
D = D + C
Writeeeprom D , A
A = A + 1
Loop Until D = 255
End If
Addr = 0
Do
Readeeprom Eebyte , Addr
Addr = Addr + 1
Dat = Eebyte And 15
Kom = Eebyte / 16
If Kom = 1 Then '1: Direkte Portausgabe
Led1 = Dat.0
Led2 = Dat.1
Portb.4 = Dat.2
End If
If Kom = 2 Then
Restore Dta
Delaytime = Lookup(dat , Dta)
Waitms Delaytime '2: Wartezeit
End If
If Kom = 3 Then '3: Sprung - relativ
Addr = Addr - 1
Addr = Addr - Dat
End If
If Kom = 4 Then
A = Dat
End If
If Kom = 5 Then
If Dat = 2 Then C = A
End If
If Kom = 8 Then
Adrhi = Dat 'Oberes Nibble der Adresse
End If
If Kom = 9 Then
Addr = Adrhi * 16 'Springe absolut 0...255
Addr = Addr + Dat
End If
If Kom = 10 Then
C = C - 1
C = C And 15
If C > 0 Then 'C-mal
Addr = Adrhi * 16 'Springe absolut 0...255
Addr = Addr + Dat
End If
End If
If Kom = 12 Then
If Dat = 4 Then
If S1 = 1 Then Addr = Addr + 1
End If
If Dat = 5 Then
If S2 = 1 Then Addr = Addr + 1
End If
End If
Loop
Sub Receivebinary
C = 0
B = 1
Do
Do
Loop Until S1 = 0
' Pwm0b = 80
T = 0
Do
Waitms 10
T = T + 1
Loop Until S1 = 1
' Pwm0b = 0
Waitms 10
If T > 15 Then
C = C + B
End If
Shift B , Left
T = 0
Do
Waitms 10
T = T + 1
Loop Until S1 = 0 Or T > 25
Loop Until T > 25
End Sub
'ATtiny13 Sparrow_Bot1.bas
$regfile = "attiny13.dat"
$crystal = 1200000
$hwstack = 8
$swstack = 4
$framesize = 4
Config Portb = &B000011010
Led1 Alias Portb.1
Led2 Alias Portb.3
S1 Alias Pinb.0
S2 Alias Pinb.2
Led1 = 0
Led2 = 0
Do
Led1 = 1
Led2 = 1
Waitms 500
Led1 = 0
Led2 = 0
Waitms 500
Led1 = 1
Waitms 500
Led1 = 0
Waitms 500
Loop
End