Тест связи ASK передатчика SAWR-A и приемника RX3400-A
Код
'TX для передатчика
Dim Junk As Byte
Dim Synch As Byte
Dim Temp1 As Byte
Dim Temp2 As Byte
Config Porta.0 = Output 'TX индикатор
Junk = 126
Synch = 127
Temp1 = 0
Temp2 = 255
Wait 5
Do
'имитация, temp1/2 случайный вывод температуры 0.0 - 100.9
Temp1 = Rnd(100)
Temp2 = Rnd(9)
Porta.0 = 1 'индикация TX
Gosub Xmit
Porta.0 = 0
'задержка посылки 50ms
Waitms 50
Loop
End
Xmit:
Open "comd.6:4800,8,N,1,inverted" For Output As #1
Baud #1 , 4800
Print #1 , Junk : Waitms 25
Print #1 , Synch : Waitms 25
Print #1 , Temp1 : Waitms 25
Print #1 , Temp2 : Waitms 25
Close #1
Return
'RX для приемника
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
Dim Synch As Byte
Dim Junk As Byte
Dim Temp1 As Byte
Dim Temp2 As Byte
Start1:
Cls
Locate 1 , 1
Lcd "out of Synch"
Baud #2 , 4800
Start2:
Open "comd.5:4800,8,n,1,inverted" For Input As #2
Input #2 , Junk : Waitms 20
Input #2 , Synch
If Synch <> 127 Then Goto Start1
Waitms 20
Input #2 , Temp1 : Waitms 20
Input #2 , Temp2 : Waitms 20
Close #2
Cls
Locate 1 , 1 : Lcd "Temp :" ; Temp1 ; "." ; Temp2 'вывод принятой температуры
Waitms 20
Goto Start2
End