PDA

View Full Version : PIC 2 PIC communication



Mario
- 3rd October 2005, 16:02
I am using PIC to PIC communication with the help wireless module TLP/RLP 434A pair from laipac.com. I verified my output from serial transmition from PIC on the oscilloscope using this code.
………………………
' TX code
' OSC 4M
TRISB=%10000000
While portb.7 =1
Serout2 0,16780,($55,$55,"A",170)
wend
End
……………………..
My RF component can be viewed using spectrum analyzer and I realize that my transmitter block including PIC and TLP 434A working fine. But in the receiver (RLP 434A) digital and analog output I got garbage.

So Finally, I decided not to overrun the receiver so I didn't use while in the following code:
……………………
' TX code
' OSC 4M
TRISB=%10000000
Serout2 0, 16780, [$55,$55,"A",170]
End
…………………..

But also it is not succeeded…………!!!!!!!!
Here my code for RX
……………………
' TX code
' OSC 4M
TRISA=0
Mydata var byte
PORTA=0
Pause 1000
Serin2 0, 16780, [wait ("A"),Mydata ]
PORTA = Mydata
Pause 2000
End

I appreciate any kind of help……………………….

mikem
- 24th October 2005, 19:03
Mario,


Your serin and serout commands are setup for a basic stamp, particularly your baud rates are wrong. You need to read the Pbasic manual and select the proper ones for Melabs Pbasic or Pbasic pro.
Try changing them to the following.

Serout2 0,N2400,($55,$55,"A",170)
Serin2 0, N2400, [wait ("A"),Mydata ]


Mike

Kamikaze47
- 3rd November 2005, 07:42
I'm attempting the same thing with RF PIC-PIC serial communication. Any chance you could clear up a few things for me?

what is the reason for sending ($55,$55,"A",170) instead of just your data? I take it your data in this case is 170? Also, why is the sent data in curved brackets () and the recieved in square brackets []?

Thanks

Mario
- 5th March 2006, 19:24
I'm attempting the same thing with RF PIC-PIC serial communication. Any chance you could clear up a few things for me?

what is the reason for sending ($55,$55,"A",170) instead of just your data? I take it your data in this case is 170? Also, why is the sent data in curved brackets () and the recieved in square brackets []?

Thanks
This $55 just to make you receiver (wake up) ready to receive your valuable data ,so the receiver will wait until it reach to "A" then save whatever you send in the variable....

actually ,the correct bracket is [] for pic basic pro and () for basic one

ChrisMicro
- 17th March 2006, 01:53
Why using SerOut2 and SerIn2?
The following code works perfect in RF applications, I construct my own transmitter with a BFR92A with a saw resonator and a RR3 receiver module with a range of up to 300M, your qualifier "A" or any other character is adequate handshaking.
Transmitter:
SerOut PORTA.6,N1400,["A",data,data,.....]
Receiver:
SerIn PORTA.5,N1400,["A"],B0,B1,B2,.... ' depending on how many bites you want to receive

mister_e
- 17th March 2006, 01:55
If it was as this simple... Manchester and any other method would never exist ;)

It will depend of tons of elements.. this is why i hate RF stuff.

Try to keep your lady Happy without any 'Preamble' and good method... May work sometimes...

ChrisMicro
- 17th March 2006, 02:23
It is that simple and it works every time (klokslag) here is one of those learning opportunities, keep your leads short!

mister_e
- 17th March 2006, 16:46
In ideal weather, environement it always work... But those ideal conditions are not 100% guarantee... or i live in a really bad country and MUST absolutely move to another to ensure all those Thousands RF-Stuff i design will always work... problem-free by using your method.

OUfs at least i'd never had to spend more than 50 000$ for any IFR spectrum Analyser/Signal Generator and such to analyse/record any site we install those units... I'm just too familiar with RF to know what may happen or not.

Even worst when you analyse a site for a TV or Music show with over 30 RF frequency to match together in any condition...

Just kidding Chris, don't take it too hard.

ChrisMicro
- 18th March 2006, 08:09
Yes Steve I agree with you, where there is modulation, FM or AM but at 1400 baud who is worried about QRM or frequency drift and with a solid state antenna (PCB loop) that $50,000 spectrum analyzer will only pick up the first harmonic.

PS PS I send my data in a 5X loop one of the streams will be received

ChrisMicro
- 18th March 2006, 12:10
Mario
If you still get garbage try the following
Transmitter:
SerOut PORTA.6,N1400,["A",data,data,.....]
Receiver:
SerIn PORTA.5,T1400,["A"],B0,B1,B2,.... '
Check on your scope if the output of your receiver is the same polarity as the input of your transmitter, if its not you will get garbage

Mario
- 20th March 2006, 20:08
If it was as this simple... Manchester and any other method would never exist ;)

It will depend of tons of elements.. this is why i hate RF stuff.

Try to keep your lady Happy without any 'Preamble' and good method... May work sometimes...

If there are many (tons) thing i have to take in consideration to transmite one byte using my TX /Rx ......
can you specify what these factor to make this thing work.

1- Do I need another chip or assistance in addition to PIC16f84A (or just I connect the module directly to pic).
2- Is it a programing (code) problem.
3-Even when I send 170 decimal which is 0101 0101 in binary (easy for reciver to detect) I'm not receiving any thing.

by the way I try also to use HT12E /HT12D encoder decoder but it didn't work.

ChrisMicro
- 21st March 2006, 01:43
Hi Mario, check your digital output on your receiver with a scope, if there is an output and if the polarity is the same as the input of the transmitter, if I had your E-mail addy then I can send you some schematics with sample code or if you can get to my site, I have some samples there, ask Melanie how to get there (sorry for the poor English)

Mario
- 21st March 2006, 13:59
Hi Mario, check your digital output on your receiver with a scope, if there is an output and if the polarity is the same as the input of the transmitter, if I had your E-mail addy then I can send you some schematics with sample code or if you can get to my site, I have some samples there, ask Melanie how to get there (sorry for the poor English)


my e-mail address ( [email protected] ) thanks alot

smeet
- 26th April 2006, 03:29
Hi I am trying to send packets of data using HSErout instead of SErout......The reason being when I try to use serout .. my A/d conversion is not as responsive as in Hserout.


This is the code I am trying to use.. Pls tell me if this is the right approach or not...

hserout ["SYNC",B2] using UART and I have also tried software using
serout2 PORTB.6,T1200,["SYNC",B2]

here B2 stores the A/d results...

for serin :

the hardware code is

HSERIN 1,Main,[wait ("SYNC"),B0]
and software is SERIN2 PORTB.4,T1200,10,Main,[wait ("SYNC"),B0]


Pls reply as I need to get it done today thanks

ChrisMicro
- 27th April 2006, 01:24
Hi smeet
What chip are you using? I believe you are doing an a/d conversion and try to send the conversion.
How many bites are you trying to send at a time? you can put your bites in an array var. and then send it, if you let me have your Email then I can send you a sample or two and do you realy need to use the UART?
Here is a 20 bite array sample:
First define the array as folow:
L1 VAR BYTE[20]
SerOut PORTA.6,N1200,["A",L1[0],L1[1],L1[2],L1[3],L1[4],L1[5],L1[6],L1[7],L1[8],L1[9],L1[10],L1[11],L1[12],L1[13],L1[14],L1[15],L1[16],L1[17],L1[18],L1[19]]
SerIn PORTA.5,N1200,3000,label,["A"],L1[0],L1[1],L1[2],L1[3],L1[4],L1[5],L1[6],L1[7],L1[8],L1[9],L1[10],L1[11],L1[12],L1[13],L1[14],L1[15],L1[16],L1[17],L1[18],L1[19]

smeet
- 28th April 2006, 02:55
Hi ,

i am using PIC 16F877A... Ill attach my code hre... Im basically trying to send my A/d bits using a 418 Mhz transmitter... If I do not use HEROUt it really slows down my code as I am not using interrupts... I have not used interrupts bfore and need to get this code working in a day.. I d really appreciate your help... Im attaching my transmission and reception code here... Im trying Manchester encoding here and then transmit those 16 bits... I understand that I can send only 8 bits at a time so do u suggest I serout 2 array byte and serin two at the other end... I noticed you have added N1200 instead of T1200... CAn i use T1200..

My email is [email protected]

Part of the Code for serout :

A: Pause 5
If ADCON0.2 = 1 Then A

B0 = ADRESH>>4
B0=B0<<4
ADRESH = 0
' PORTD=B0

ADCON0 = %00111001
Pause 5
ADCON0.2 = 1

B: pause 5
if ADCON0.2 = 1 Then B

B1 = ADRESH >> 4

ByteIn = B0+B1

PORTD = ByteIn

GOSUB Encode

'hserout [B2]
hserout ["A",Manch] // I guess I went wrong here... Can I split Manch as 2 bytes c0 and c1 and use Hserout
'serout2 PORTB.6,N1200,["A",B2]
PAUSE 5

GOTO Main

Encode:
for Index = 0 to 7
if ByteIn.0[Index] = 0 then
Manch.0[Index*2] = 0
Manch.0[Index*2+1] = 1
else
Manch.0[Index*2] = 1
Manch.0[Index*2+1] = 0
endif
next Index
For Index = 0 to 7
Manch.0[(Index*2)] = ~ByteIn.0[Index]
Manch.0[(Index*2)+1] = ByteIn.0[Index]
'Next Index
'Return

smeet
- 28th April 2006, 02:56
I have shown Next Index and Return as commented.. They are not commented though...