PDA

View Full Version : serout and serin problem



nicolelawsc
- 10th April 2006, 20:10
hi all,
i am dealing with a rf transmitter and receiver project. there are 3 transmitter and 1 receiver used in this project. transmitter used pic16f84a and the receiver used 16f877a.
below is the code


transmitter:
include "modedefs.bas"
define osc 4
input porta.0
output portb.0
output portb.1
output portb.2
output portb.3

led_on:
high portB.1
if porta.0=1 then transmit

transmit:
low portb.1
high PORTB.2
serout PORTB.0,N9600,["A",1]--(tansmitter1),
--serout PORTB.0,N9600,["A",2]--(transmitter2)
--serout PORTB.0,N9600,["A",3]--(transmitter3)


low PORTB.2
low portb.1
goto led_on


end




receiver:


serin PORTB.2,N9600,["A"],rx


SELECT CASE rx
CASE 1
goto station1

CASE 2
goto station2

CASE 3
goto station3

END SELECT


station1:

lcdout $FE,1, "station one"

portb.6=0
portb.3=1

pause 2000
portb.3=0
goto loop


station2:

lcdout $FE,1, "station two "
portb.6=0
portb.5=1
pause 2000
portb.5=0

station3:
lcdout $FE,1, "station three "
portb.3=1
portb.5=1
pause 1000
portb.3=0
portb.5=0
goto loop
end



my problem now is at the receiver i use lcd to test the result and i found out the serin command at the receiver and the select case below it also did not perform at all.It just direct go through content in station 1 only. station 2 and 3 totally did not perform.


another problem is i want to define the value of X1, X2,X3, Y1,Y2,and Y3.
but the value of X1,Y1,and X2 are negative value so how can i deal with it?all in word.
X1 = ? (X1=-2)
Y1 = ? (Y1=-2)
X2 = ? '(X2=-2)
Y2 = 6000 '(Y2=6)
X3 = 6000 '(X3=6)
Y3 = 6000 '(Y3=6)


hope to hear u soon.thank you for ur consideration. :)

picster
- 11th April 2006, 14:30
Sorry, I just realized that your serouts are exclusive to each associated transmitter device.... kind of hard to know what's going to happen without knowing what lines are being used as busy/handshaking lines...

nicolelawsc
- 11th April 2006, 18:41
do u hv any suggetion to solve this problem?actually i hv 3 pair of transmitter and only one receiver.each of the transmitter with a identify code for receiver to determine the code sent from which transmitter.as i post the code above. Below shows the concept of my code,can u please give me some comment whether my code have any problem.i try many ways already but still do not know why my receiver can not receive data. :(
serout PORTB.0,N9600,["A",1]--transmitter 1 with the identify code "1"
serout PORTB.0,N9600,["A",2] --transmitter 2 with the identify code "2"
serout PORTB.0,N9600,["A",3]--transmitter 3 with the identify code "3"
and at the receiver the command is--serin PORTB.2,N9600,["A"],rx
what i mean here is each of the transmitter hv the password "A" and the number at the back of "A " represent the identify code.then at the receiver if the rx it receive is "1", mean receive from transmitter 1.
rx is "2" mean receive from transmitter 2 and rx "3"mean receive from transmitter 3.
is it my code got error?any correction for me?

actually at the receiver pin 3 is detect pin.at the datasheet it stated may used to derive a carrier detect to enable external circuit when a signal is being received.if unused connect a 10k ohm resistor to Vcc.
so i jz connect it directly with 10Kohm resistor to Vcc.Do u think this pin can help me in this situation?if yes,can u please gv me some guide line?


another problem is i am dealing with a math problem. the equation as below:
---theta s= actan (Y2/X2)- theta 2-----
Y2, X2 and theta 2 are known,i need to find the theta s but by using pic basic pro, i do not know how to deal with "actan"

Dwayne
- 11th April 2006, 19:44
Hello,

I don't fully understand what you are trying to do, or what your schematic is looking like but I would try the following:

1. You said it only works on Transmitter 1.. That is case statement 1.

For this, I would drop the case statement and us "IF" "Then" statements... see if that makes a difference.

2. You have extremley long pauses after each recieve... the first 2 have 2 second pauses, the last one has 1 second pause.... Is this too long of a pause??? Is it necessary?

3. Baudrate... 9000 Try something like 300 first.


Dwayne