Help with prop-prop wireless Serial Comms
djh82uk
Posts: 193
Hi Guys
Ive been working on this for quite a while. Basically I have 1 "master" prop board that has a numeric keypad and VGA output. Basically you type in a 3 digit number and press enter, that 3 digit is transmitted in serial via a 315MHZ TX board.
The 3 digit number relates to a relay (there can be upto 999 of them), the receiving boards ignore the 3 digit number if it is not the one that deals with that number (board one uses 001 - 030, board two uses 031 - 061 etc). It then either switches on a relay or does some pwm or whatever is required for that pin.
At the moment I have 1 transmitter board, and a receiver baord that displays the received number on a display so that I can get it woring and debug it.
Now the receiving board receives a signal but it does not correspond to what I entered. If I type 555, I get a dec value of 128, if I type 123, I get a Dec value of 128.
If I receive it as a string then I get wired characters (like greek symbols)
Now I am using the simple serial object to xmit, and the BS2_function serial function to receive, as that the only way I can get it to receive anything at all.
I am xmitting and receiving at 2400bps, im not using any resistors, just have the i/o pin connected directly to the TX/RX pin.
Any ideas?
Below is the trsnmitters I use:
http://www.coolcomponents.co.uk/catalog/product_info.php?cPath=25&products_id=186
Here is the Master (xmit) code:
Here is the Slave (receive) code:
Ive been working on this for quite a while. Basically I have 1 "master" prop board that has a numeric keypad and VGA output. Basically you type in a 3 digit number and press enter, that 3 digit is transmitted in serial via a 315MHZ TX board.
The 3 digit number relates to a relay (there can be upto 999 of them), the receiving boards ignore the 3 digit number if it is not the one that deals with that number (board one uses 001 - 030, board two uses 031 - 061 etc). It then either switches on a relay or does some pwm or whatever is required for that pin.
At the moment I have 1 transmitter board, and a receiver baord that displays the received number on a display so that I can get it woring and debug it.
Now the receiving board receives a signal but it does not correspond to what I entered. If I type 555, I get a dec value of 128, if I type 123, I get a Dec value of 128.
If I receive it as a string then I get wired characters (like greek symbols)
Now I am using the simple serial object to xmit, and the BS2_function serial function to receive, as that the only way I can get it to receive anything at all.
I am xmitting and receiving at 2400bps, im not using any resistors, just have the i/o pin connected directly to the TX/RX pin.
Any ideas?
Below is the trsnmitters I use:
http://www.coolcomponents.co.uk/catalog/product_info.php?cPath=25&products_id=186
Here is the Master (xmit) code:
Somebody said...
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
VAR
long keypressed1
long keypressed2
long keypressed3
long keypressed4
long keys
long one_ms
OBJ
text : "vga_text"
kb : "keyboard"
serial : "Simple_Serial"
'bs2 : "bs2_functions"
PUB start | i
serial.init(-1, 8, 2400)
one_ms := clkfreq / 1_000
'start the vga terminal
text.start(16)
'start the keyboard
kb.start(26, 27)
'BS2.start (2,3) ' Initialize BS2 Object timing, Rx and Tx pins for DEBUG
capture
pub capture
repeat
text.out($00)
text.str(string(" Sigmatronics.co.uk"))
text.out(13)
text.out(13)
text.str(string(" Relay Control System"))
text.out(13)
text.out(13)
text.str(string(" Enter the 3-digit number that"))
text.str(string(" corresponds to the output that"))
text.str(string(" you wish to toggle and press"))
text.str(string(" 'Enter' "))
text.out(13)
text.out(13)
text.out(13)
text.str(string(" Output Number:"))
keypressed1 := kb.getkey
case keypressed1
$df, $2a, $2b, $2d, $2e, $2f : capture
OTHER : text.out(keypressed1)
keypressed2 := kb.getkey '
case keypressed2
$df, $2a, $2b, $2d, $2e, $2f : capture
OTHER : text.out(keypressed2)
keypressed3 := kb.getkey
case keypressed3
$df, $2a, $2b, $2d, $2e, $2f : capture
OTHER : text.out(keypressed3)
keypressed4 := kb.getkey
case keypressed4
$df, $2a, $2b, $2d, $2e, $2f : capture
if keypressed4 == 13
waitcnt((500 * one_ms) + cnt)
send
else
text.out($00)
text.str(string(" Sigmatronics.co.uk"))
text.out(13)
text.out(13)
text.str(string(" You Typed Too Many Digits"))
text.out(13)
text.out(13)
text.str(string(" Try Again"))
waitcnt((1500 * one_ms) + cnt)
capture
pub send
'Activating Relay
text.out($00)
text.str(string(" Sigmatronics.co.uk"))
text.out(13)
text.out(13)
text.out($0C)
text.str(string(" Relay Control System"))
text.out(13)
text.out(13)
text.str(string(" Activating Relay:"))
text.out(keypressed1)
text.out(keypressed2)
text.out(keypressed3)
keys := keypressed1 & keypressed2 & keypressed3
'BS2.Serout_Str(8,@keys,2400,1,8)
serial.str (keys)
'serial.tx(keypressed1)
'serial.tx(",")
'serial.tx(keypressed2)
'serial.tx(",")
'serial.tx(keypressed3)
waitcnt((1500 * one_ms) + cnt)
capture
'text.str(13)
'text.str(string(" key pressed in hex:"))
'text.hex(keypressed1,3)
'text.hex(keypressed2)
'text.hex(keypressed3)
'waitcnt((1000 * one_ms) + cnt)
Here is the Slave (receive) code:
Somebody said...
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
VAR
byte rxbyte
long one_ms
Byte myString[noparse][[/noparse]50]
OBJ
text : "vga_text"
serial : "Simple_Serial"
bs2 : "bs2_functions"
PUB start | i
'serial.init(0, -1, 2400)
one_ms := clkfreq / 1_000
'start the vga terminal
text.start(16)
BS2.start (2,3) ' Initialize BS2 Object timing, Rx and Tx pins for DEBUG
capture
pub capture
rxbyte :=1
repeat
text.out($00)
text.str(string(" Waiting"))
'waitcnt((3000 * one_ms) + cnt)
'rxbyte := serial.rx
BS2.Serin_Str(0,@myString,2400,1,8)
text.out(13)
text.out(mystring)
text.out(13)
waitcnt((2000 * one_ms) + cnt)
capture
Comments
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
How do I implement it?
Ive had a quick look, but nothing relating to usable code
DJH
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
encod_r:
For i=0 TO 7
IF mydata.0=0 Then
encoded.0[noparse][[/noparse]i*2]=0
encoded.0[noparse][[/noparse]i*2+1]=1
Else
encoded.0[noparse][[/noparse]i*2]=1
encoded.0[noparse][[/noparse]i*2+1]=0
EndIF
Next i
Return
Rec_r:
For i=0 TO 7
IF encoded.0[noparse][[/noparse]i*2]=0 Then
IF encoded.0[noparse][[/noparse]i*2+1]=1 Then
mydata.0=0
EndIF
Else
mydata.0=1
EndIF
Next
Return
I leave it up to you to convert it into Spin, which is plenty fast enough.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH
Post Edited (James Michael Huselton) : 5/25/2009 4:14:14 PM GMT
I get wrong data, but it is consistently the same, so is it not just a case of bad coding on my part?
DJH
The code as posted is as simple as it gets. I wrote it from memory. You need to convert the algorithm to Spin.
Incoming to the routine is mydata array containing the data to be encoded/decoded.
Outgoing from the routine is the encoded array (Manchester-encoded array) to be output.
Array element access is .o for an individual array element.
On output, the encoded array needs to be twice the size of the mydata array, since each byte of the mydata array expands to be two bytes of the encoded array.
On input, the incoming data stream of the encoded array is compressed to a single byte output of the mydata array.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH
Post Edited (James Michael Huselton) : 5/25/2009 5:38:14 PM GMT
I have added atatchments for the two spin files.
Im not upto the level of doing that manchester code
I also have a set of these, there more complicated to get working (ive not been able to do it yet) but would they make it easier?
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&ssPageName=STRK:MEWNX:IT&item=350185921907
Thanks
DJH
Any thoughts on wether those transceivers in my last post would be better?
Thanks
DJH