Reading wireless RF data
Posted: 07 July 2012, 0:07 AM
Hi!
I'm working on a project controlling wireless RF switches (Nexa) from zbasic using simple Rf sender/reciever TWS 434/RWS 434. I've got the sending code part to work using information from the net and I can control the 230V switches nearly to 100%. In short pulses are send as shown below :
12-bit code for House/Unit A1 ON 000000000111
12-bit code for House/Unit A1 OFF 000000000110
xxxx____ 4-bit House code
||||xxxx________ 4-bit Unit code
||||||||xxx_____ 3-bit Unknown code = '011'
|||||||||||x____ 1-bit Activation code 1=ON 0=OFF
a logic '0' is: 360 us high, 1070 us low, 360 us high, 1070 us low
a logic '1' is :360 us high, 1070 us low,1070 us high,360 us low
STOP/SYNC is : 360 us high, 1250 us low after each 12-bit packet
I know this issue have been discussed earlier to some extent but I'm unsure what method to use reading data from reciever. My approach sofar is to use the linear output on the reciever to trig an interrupt and this seems to work ok. I then use InputCapture to read data on the data out pin on the reciever. Data read in looks like 'garbage'
and is inconsistent between readings
Incoming data 'ON'
3531
20682
7964
7051
6490
26950
1333
8470
12389
27606
1733
65535
Incoming data 'OFF'
6035
1589
10689
10995
2125
7565
2979
9999
3690
28251
1135
65535
Can someone give me a hint what approach to use . Below is essential part of code for reading data
Regards Håkan
I'm working on a project controlling wireless RF switches (Nexa) from zbasic using simple Rf sender/reciever TWS 434/RWS 434. I've got the sending code part to work using information from the net and I can control the 230V switches nearly to 100%. In short pulses are send as shown below :
12-bit code for House/Unit A1 ON 000000000111
12-bit code for House/Unit A1 OFF 000000000110
xxxx____ 4-bit House code
||||xxxx________ 4-bit Unit code
||||||||xxx_____ 3-bit Unknown code = '011'
|||||||||||x____ 1-bit Activation code 1=ON 0=OFF
a logic '0' is: 360 us high, 1070 us low, 360 us high, 1070 us low
a logic '1' is :360 us high, 1070 us low,1070 us high,360 us low
STOP/SYNC is : 360 us high, 1250 us low after each 12-bit packet
I know this issue have been discussed earlier to some extent but I'm unsure what method to use reading data from reciever. My approach sofar is to use the linear output on the reciever to trig an interrupt and this seems to work ok. I then use InputCapture to read data on the data out pin on the reciever. Data read in looks like 'garbage'
and is inconsistent between readings
Incoming data 'ON'
3531
20682
7964
7051
6490
26950
1333
8470
12389
27606
1733
65535
Incoming data 'OFF'
6035
1589
10689
10995
2125
7565
2979
9999
3690
28251
1135
65535
Can someone give me a hint what approach to use . Below is essential part of code for reading data
Code: Select all
Public RWS_434_TaskStack (1 To 30) As Byte
RWS_434_Ready = False
CallTask RWS_434_checkdata,RWS_434_TaskStack
'
Sub Main
Do
If RWS_434_Ready Then 'data avaliable
Debug.print "Incoming data"
Call Read_RWS_434
'Call Test
End If
Call Delay(2.0)
Loop
End Sub
Public RWS_434_Ready as Boolean
Public Sub RWS_434_checkdata()
Do
RWS_434_Ready = True
Call WaitForInterrupt(zxPinRisingEdge, 0) 'pin 6 on zx24p Pin 14, int 6 on ZX 1281e
Loop
End Sub
Public Sub Read_RWS_434()
Dim pd(1 to 12) as UnsignedInteger
Dim x As Integer
'useInputCapture uses pin 12 on zx24p
' Port C Bit 1 must be an input
Call PutPin(12, zxInputTriState)
Call InputCapture(pd, UBound(pd), 1)
For X = 1 To 12
Debug.print pd(x)
Next
RWS_434_Ready = False
End Sub