Wire worked by not wireless
Dear Gurus,
Below is the code I am using to build a wireless data transfer, I started by building a wired connection and it worked very fine but once I go wireless nothing works.
Any idea, hint, help is greatly appreciated.
Thanks,
Mankan
'************************************************* ***************
'* Name : Receiver.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2006 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 5/10/2006 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
INCLUDE "modedefs.bas"
'@DEVICE PIC16F628, WDT_ON
'@DEVICE PIC16F628, BOD_ON
'@DEVICE PIC16F628, PROTECT_OFF
'@DEVICE PIC16F628, MCLR_ON
DEFINE OSC 4
DEFINE NO_CLRWDT
'* Variable declarations
Header var BYTE
Counter VAR BYTE
Packet VAR BYTE
End_Of_Data VAR BYTE
counterA VAR BYTE
ErrorFlag var bit
MyData var byte
ManchesterWord Var WORD
Temp_Byte var byte[5]
Temp_Word var WORD[5]
x VAR BYTE
send_word VAR WORD
SYNCH VAR byte
SYNCH=$C6
CMCON = 7
VRCON = 0
TRISB.1 = 1
INPUT PORTB.1
PORTB.1 = 1
pause 10
Loop:
Header = 0
HIGH PORTB.6
'SERIN PORTB.1,N300,[SYNCH],Header,Counter,Packet,End_Of_Data
'SERIN PORTB.1,N300,[SYNCH],ManchesterWord.lowbyte,ManchesterWord.highbyte
SERIN PORTB.1,N300,[SYNCH],send_word.lowbyte,send_word.highbyte
Temp_Word[0] = send_word
For x=1 to 4
SERIN PORTB.1,N300,300,Loop,send_word.lowbyte,send_word. highbyte
Temp_Word[x] = send_word
next x
for x=0 to 4
ManchesterWord = Temp_Word[x]
GOSUB DecodeManchester
Temp_Byte[x] = MyData
next x
Low PORTB.6
Header = Temp_Byte[0]
PAUSE 100
if Header = 96 THEN
gosub GLOW_PIN7
if Counter = 2 Then
gosub glow_pass
ENDIF
endif
goto loop
TimeOut:
call GLOW_TIMEOUT
goto loop
GLOW_PASS:
HIGH PORTB.5
PAUSE 50
LOW PORTB.5
PAUSE 50
RETURN
GLOW_PIN7:
HIGH PORTB.7
PAUSE 50
LOW PORTB.7
PAUSE 50
RETURN
GLOW_TIMEOUT:
HIGH PORTB.6
PAUSE 500
LOW PORTB.6
PAUSE 500
RETURN
DecodeManchester:
ErrorFlag=0
For counterA=0 to 7
if ManchesterWord.1=0 then
MyData.7=0
If ManchesterWord.0=0 then ErrorFlag=1
else
MyData.7=1
If ManchesterWord.0=1 then ErrorFlag=1
endif
ManchesterWord=ManchesterWord>>2
if counterA<7 then MyData=MyData>>1
next counterA
return
/**********END OF Receiver*********************/
/**********Start of Transmitter*********************/
'************************************************* ***************
'* Name : Transmitter.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2006 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 5/2/2006 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
INCLUDE "modedefs.bas"
DEFINE OSC 4
DEFINE NO_CLRWDT
CMCON = 7
VRCON = 0
TRISB.2 = 0
Header VAR BYTE
End_Of_Data con 24
SYNCH VAR byte
SYNCH=$C6
'* Variable declarations
Counter VAR BYTE
Packet VAR BYTE
counterA VAR BYTE
MyData var byte
Temp_Byte var byte[5]
Temp_Word var WORD[5]
ManchesterWord Var WORD
x VAR BYTE
send_word VAR WORD
Header = 96
pause 10
OUTPUT PORTB.2
PORTB.2 = 0
OUTPUT PORTB.4
PORTB.4 = 0
OUTPUT PORTB.5
PORTB.5 = 0
Counter = 2
Packet = 78
Temp_Byte[0] = 96
Temp_Byte[1] = 16
Temp_Byte[2] = 26
Temp_Byte[3] = 36
Temp_Byte[4] = 46
start:
pause 1000
MyData = Header
for x=0 to 4
MyData = Temp_Byte[x]
gosub EncodeManchester
Temp_Word[x] = ManchesterWord
nEXT X
'SEROUT PORTB.2,N300,[126, SYNCH,Header, Counter, Packet, End_Of_Data]
'SEROUT PORTB.2,N300,[126, SYNCH,ManchesterWord.lowbyte, ManchesterWord.highbyte]
SEROUT PORTB.2,N300,[1263, SYNCH]
for x=0 to 4
send_word = Temp_Word[x]
PAUSE 1
SEROUT PORTB.2,N300,[send_word.lowbyte, send_word.highbyte]
next x
CALL GLOW_LED
goto Start
GLOW_LED:
HIGH PORTB.5
PAUSE 50
LOW PORTB.5
PAUSE 50
RETURN
EncodeManchester:
ManchesterWord = 0
for counterA=0 to 7
if MyData.0 = 0 then
ManchesterWord.14=1
else
ManchesterWord.15=1
endif
if CounterA<7 then ManchesterWord = ManchesterWord>>2
MyData=MyData>>1
Next CounterA
return
/************END OF TX****************/
Probably not software related
I'm not one of the most experienced people on this forum but I have made successful links with PIC's without wires. Can you tell us what you are using in the way of hardware? If your code works with wires, your code should work without wires. Have you ever done a wireless link with PIC's before?
Chris
Wired worked but not Wireless..
Hello Chris,
I followed your suggestion and I added a pull-up resistor but nothing improved. Any other suggestions.
I am planning to look at the txmitted code pattern.
-Mankan
What is the other way to test a RF link?
Hello,
Is the other way to test a RF link? Like using PulsIn and wait for the RF pulse on a particular pin.
Just to make sure that link works.
Thanks,
Mankan
I found this, but wire works not wireless
Hello,
I am making a Tx port pin High/Low for some duration of time and then on the receiver side, I am just using PULSIN to check the pulse.
I found that transmission and reception is very fine and this brings to the opinion that SERIN command has some problem.
Am I correct? Is there any other way of implementing SERIN for sending RF data?
Thanks for you support.
Mankan