-
Serial Wireless
I know there is a simple solution for this, but I can not find it.
I have two 16F676 both running on external 4Mhz oscillators. A TXM-433-LR-S and a RXM-433-LR-S.
I know the RF is working as I can send a "HIGH" and receive a "HIGH" and blink a LED.
I know the serial works, send a signal and blink a LED.
Problem is when serial is sent with RF.
I am using hyper-terminal to monitor the receiver. With wires I will see what I send and with out wires the first few characters will be garbage with the remaining correct.
Code:
SERIN2 PORTC.4,16468,[WAIT("9"),DEC net]
So I only want the last one.
Send
Code:
DEFINE OSC 4
Asm
ERRORLEVEL -306
Endasm
include "modedefs.bas"
ANSEL=%00000000
CMCON=7
PAUSE 2000
LOOP:
IF PORTC.1 = 1 THEN
SEROUT2 PORTC.4,16468,[DEC 01010101,DEC 9,DEC 3,10,13]
HIGH PORTC.5
PAUSE 100
LOW PORTC.5
PAUSE 100
ELSE
SEROUT2 PORTC.4,16468,[DEC 010101,DEC 9,DEC 5,10,13]
PAUSE 200
ENDIF
GOTO LOOP
END
Receive
Code:
DEFINE OSC 20
Asm
ERRORLEVEL -306
Endasm
include "modedefs.bas"
ANSEL=%00000000
CMCON=7
net VAR WORD
PAUSE 2000
LOOP:
SERIN2 PORTC.4,16468,[WAIT("9"),DEC net]
IF net = 3 THEN
HIGH PORTC.5
PAUSE 100
LOW PORTC.5
PAUSE 100
ELSE
LOW PORTC.5
PAUSE 200
ENDIF
GOTO LOOP
END
The last few characters are always the same with or with out wires on hyper-terminal.
Why is the WAIT not working with RF.
Tried different bauds, nothing.
Tried different preambles, nothing.
-
Quote:
Originally Posted by
mackrackit
Send
Code:
SEROUT2 PORTC.4,16468,[DEC 01010101,DEC 9,DEC 3,10,13]
SEROUT2 PORTC.4,16468,[DEC 010101,DEC 9,DEC 5,10,13]
You're going to have problems with those two lines. DEC 01010101 will try to send out the number '1 million, 10 thousand, one hundred and one'. Use BIN 01010101 instead of DEC, or just make it easy and use '$55' instead. Also, instead of sending 'DEC 3' or 'DEC 5', just send '3' or '5' and change the receive code to match.
Quote:
Receive
Code:
SERIN2 PORTC.4,16468,[WAIT(9),net]
Try that change also and see what happens.
-
Hi Skimask,
Tried your suggestions. Works with wires but not RF.
Read http://www.picbasic.co.uk/forum/show...light=wireless
Tried sending $55 five times in a row, with the next line sending $66, or DEC 3,or 3. I know $66 is not 3, also changed receiver to match. All works with wires, Not with RF.
Hyper-terminal shows that the data I want is there with wires of RF. The first "training" is garbled with RF but the last two or three characters are correct.
PIC will not pick up the last character with RF.
Repeating myself, over and over, hoping to see my blunder.
Hyper-terminal is showing the training in one column and the data I want in another.
Wires:
UUUUU heart shape
RF:
TUU heart shape
UU heart shape
PUU heart shape
@UU heart shape
-
try serout...("UUUUU~~SYNCH",YourData)
SERIN ...(WAIT("SYNCH"),YourData)
don't forget Those UU are there only to balance the slicers, so not revealant to receive, ~~ here is just another character, You could still wait for only a part of SYNCH, let's say NCH.
9600 could be a bit fast for testing, try 4800 or even 2400. When something work, you may need to increase and use some character pacing.
For safety sake, on your transmitter, se the pin as output, clear it (=0) and add a few millisecond delay (~50) at the top of your code.
In conjunction of a pull-down resistor on your receiver side as well.
-
Thank you!!!!!!!!!!!!!!!!
SERIN did the trick.
Now I need to figure out why.