Yes, I am using a breadboard. Do you think it is possible that maybe that area of the breadboard is messed up?
Could it be a training problem for the transmitter/receiver also?
Last edited by oneohthree; - 19th April 2007 at 05:17.
Hello oneohthree,
I just trashed 4 breadboards due to corrosion. The contacts also wear out too. I really got tired of fighting to get even simple things to work, Oscillator sometimes wouldn't run, poor connections, bad things happen when components like PIC lose grounds too, anyway its worthwhile to check.
JS
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
And you STILL DID NOT put those semicolons....
Also I would choose a different setup for the serin command. Maybe with a time out and a wait character.This would require the Serin2 though...
Ioannis
P.S. Also why don't you try simple things first, like send one character then two and see what happens. After that try the manchester encoding and if succesful try the CRC or checksum. Take it step by step. You program is too long to follow and debug. About this routines (manchester and CRC) there are link on this forum. Do a search and find. One is Melanies and one is mine.
Last edited by Ioannis; - 19th April 2007 at 09:37.
The serial out I plan to use at transmitter:
serout PORTB.2, n2400, [ "A" , encode2 ]
The serial in I plan to use at receiver:
serin2 PORTB.0, n2400, [WAIT("A"),BIN8 encode1] 'take in data at pin 0 and place in encoded1
I discover that this does not work so I reverted back to my old code which sometimes works and sometimes doesn't. It's either a serin problem, serout problem or a transmitter/receiver problem. I will also try to change the breadboard to see if it helps.
Last edited by oneohthree; - 19th April 2007 at 19:43.
I cleaned up my microcontroller codes. I am doing serout only once this time with 4 $55 and 1 $aa in the preamble. The problem now is my PIC to PIC communication works perfectly with a wire. But when I connected them to the TLP-315 and RLP-315 transmitter and receiver pairs it either does not work or works intermittently. I told the receiver to count for $55 four times. I am using a breadboards. On one breadboard I have a 315 MHz receiver and 434 MHz transmitter and the other breadboard I have a 315 MHz transmitter and 434 MHz receiver. After I get this problem fixed I will be putting it on a PCB. I have been trying all different combinations for the past week but it seems like my 315 MHz receivers are not working like they should.
I do not know what is wrong I am basically doing the same thing in both links but one link works while the other does not. My link from 434 mhz transmitter to 434 mhz receiver is working but my link from 315 mhz transmitter to 315 Mhz receiver is working intermittently. I am using both PIC16F84A and PIC16F88. Is this a PIC problem or a RF module problem.
Transmitter
'IEEE Encoding
'Transmitter Code
Include "Modedefs.bas"
trisb = 0
main:
u var byte : counter var byte : encode var byte : u = %1000
'u is the byte containing the input in binary, counter is a byte that describes the amount of bits to encode
'encode is the variable holding the encoded value
'Manchester encoding
For counter = 0 to 3
If u.0[counter]=0 Then
encode.0[counter*2]=0 : encode.0[counter*2+1]=1 'If it is a zero make the first bit 0 and second bit 1
Else
encode.0[counter*2]=1 : encode.0[counter*2+1]=0 'If not then make first bit 1 and second bit 0
EndIf
Next counter :
write 0, encode 'Write to EEPROM Location 0
High 1 'High on Port B Pin 1
Pause 1000 'Pause
Low 1 'Low on Port B Pin 1
serout PORTB.0, n2400, [ $55 , $55 ,$55, $55, $aa , encode ]: 'send out preamble and encoded from Port B Pin 0
goto main
Receiver (434 to 315)
Include "Modedefs.bas"
ct55 var byte: encoded1 var byte: s var byte: counter var byte: e var byte: action var byte:
encoded var byte: encoded2 var byte: action2 var byte: B0 var bit: B1 var bit: B0=1: B1=0
s=0: e=0: encoded1=0: counter = 0: action=0: action2=0: encoded=0: encoded2=0:
Main:
Clr:
s=0: e=0: encoded1=0: action=0: action2=0: encoded=0: encoded2=0
Maina:
ct55=0 'counter for $55 is zero
Wait55:
serin PORTB.0, n2400, encoded1
If encoded1 = $55 Then
ct55 = ct55 + 1
If ct55 = 4 Then goto Waitaa
Else
goto Maina
Endif
goto Wait55
Waitaa:
serin PORTB.0, n2400, encoded1
If encoded1 <> $aa Then goto Maina
serin PORTB.0, n2400, encoded1
write 0, encoded1
For counter = 0 to 3 : s.0[counter] = encoded1.0[counter*2]:Next counter
write 1,s
e = s:
If ((e.3=B0) and (e.2=B1)) Then
goto L3
Else
write 2, s
goto Clr
Endif
L3:
If((s.1=0) and (s.0=0)) Then
action=s:
action.1=1
write 3, action
High 6
Pause 1000
Low 6
For counter = 0 to 3
If action.0[counter]=0 Then
encoded.0[counter*2]=0 : encoded.0[counter*2+1]=1
Else
encoded.0[counter*2]=1 : encoded.0[counter*2+1]=0
Endif
Next counter:
write 8, encoded
Low 4
For counter = 0 to 4
Pause 400
High 4
Pause 400
Low 4
Next counter:
'For counter = 0 to 5
serout PORTB.2, n2400, [$55,$55,$55,$55,$aa, encoded]
goto Clr
'Next counter:
Endif
If ((s.1=0) and (s.0=1)) Then
action2 = s: action2.1 = 1:
write 4, action2
High 5
Pause 2000
Low 5
For counter = 0 to 3
If action2.0[counter]=0 Then
encoded2.0[counter*2] = 0: encoded2.0[counter*2+1] = 1
Else
encoded2.0[counter*2] = 1: encoded2.0[counter*2+1] = 0
Endif
Next counter:
write 9, encoded2
Low 4
For counter = 0 to 4
Pause 400
High 4
Pause 400
Low 4
Next counter
Low 1
For counter = 0 to 10
Pause 400
High 1
Pause 400
Low 1
Next counter:
'For counter = 0 to 5
serout PORTB.2, n2400, [$55,$55, $55, $55,$aa, encoded2]
goto Clr
'Next counter
Endif
End
Receiver code (315 Link)
Include "Modedefs.bas"
ct55 var byte: encoded1 var byte: s var byte: counter var byte: e var byte:
s = 0: e = 0: encoded1 = 0: counter = 0:
Main:
Maina:
ct55=0 'counter for $55 is zero
Wait55:
serin PORTB.0, n2400, encoded1
If encoded1 = $55 Then ct55 = ct55 + 1
If ct55 = 4 Then
goto Waitaa
Else
goto Wait55
Endif
'goto Wait55
Waitaa:
serin PORTB.0, n2400, encoded1
If encoded1 <> $aa Then goto Maina
serin PORTB.0, n2400, encoded1
write 0, encoded1
For counter = 0 to 3 : s.0[counter] = encoded1.0[counter*2]: Next counter
write 1,s
If (s.1=1) Then
goto L4
Else
write 2,s
High 2
Pause 1000
Low 2
goto Maina
Endif
L4:
e = s
write 3, e
High 1
Pause 1000
Low 1
serout PORTB.3, n2400, [e]
goto Maina
End
Last edited by oneohthree; - 20th April 2007 at 04:48.
Delete the colon from the Next counter command!
You do not need to count the preamble bytes. Just wait for the start character, $AA, and grab the next character
I think here you have error in decoding the manchester. I suggest thew following:
I have no time to follow the rest of your code now. Please try the suggested encoding for the transmission and see how it goes for one direction. Then try it on the other direction and make sure you have good RF com.
Ioannis
Last edited by Ioannis; - 20th April 2007 at 07:53.
Bookmarks