That problem has gone. For future reference, I am using version 2.47. The problem I'm having now is this. I have perfect radio communications between 2 16F877A's, at both short and long range, but I'm not having much success transmitting and then receiving variables.
My TX line is :
SEROUT2 PORTc.2,16780,[((id<<6)+(rhtc/100<<3)+(temp/100))]
which seems not to be a problem
my RX line is
SERIN2 PORTc.4,16780,250,programstart,[str myvar\6]
but I don't get what I send. I'm sure there is a glaring error somewhere, but when I hserout myvar I get numbers, but not what I sent
You're only sending one byte, but expecting to receive 6? How does that work?
And your SEROUT doesn't make a lot of sense...
You're shifting id up 6 bits, adding in a number that may or may not fit into those next 3 bits, and doing the same thing with the last number. What's up with that?
Maybe it would be best if you showed your code rather than your broken snippets.
Last edited by skimask; - 18th July 2008 at 21:42.
I got the SEROUT line from your posting(yesterday, 19:49), but all I really want to do is send an id (25 or 35) and a 4 digit temp or humidity reading, then receive same using the serout2/serin2 commands. When I send the command to the remote module it receives it perfectly as it is a constant number and sends what it is asked to....
receive: ' receive
portc.1 = 1 ' switch on port
pause 25 ' give radio 25 ms to slew
SERIN2 PORTC.0,16780,250,main,[command]
if command = 25 then goto tempsend
if command = 35 then goto humsend
goto main
When I send 25 it goes to tempsend, when I send 35 it goes to humsend.
My latest attempt to send what I want is as follows:
tempsend:
portc.1=0 ' Back to main
lcdout $fe,1,"tx t" ' send to lcd
portc.3=1 ' switch on tx
for c =0 to 4 ' start 4 pass loop
pause 150
SEROUT2 PORTc.2,16780,[temp]
PAUSE 100 ' Pause 100uS
next c ' next pass
portc.3=0 ' switch off tx
goto main ' Back to main
temp is a 4 digit number and comes from the SHT71 sensor and is displayed correctly on the LCD
The above is received with:
SERIN2 PORTc.4,16780,250,programstart,[str myvar\4]
HSEROUT ["A= ",dec myvar," B= ",#myvar," C= ",myvar," ",32,13,10] ' Display result
CLEAR ' Clear array
so I can have an idea what is being received and work out how to make it what I want
Last edited by gringobomba14; - 18th July 2008 at 22:17. Reason: quick few bits to make it easier to understand
So, if you're sending it like this:
SEROUT2 PORTc.2,16780,[temp]
Why are you trying to receive it like this?
SERIN2 PORTc.4,16780,250,programstart,[str myvar\4]
Doesn't it make sense that the format for sending and receiving would probably be the same? It really wouldn't make a lot of sense to have 2 commands that perform the same function (albiet the opposite function) send and receive the same data in 2 completely different ways, does it?
How about trying some of this...Just try it and see what happens:
Code:tempsend: portc.1=0 : lcdout $fe,1,"tx t" : portc.3=1 for c =0 to 4 pause 150 How long does this pause? SEROUT2 PORTc.2,16780,[temp] PAUSE 100 ' Pause 100uS This doesn't pause for 100us... next c ' next pass portc.3=0 : goto mainAnd another thing...you might have sync'ing issues. You've got a 250ms timeout on the SERIN2 in the RX code, and various pauses and such in the TX code. How often are the two actually going to be ready for each other?Code:SERIN2 PORTc.4 , 16780 , 250 , programstart , [ temp ] HSEROUT ["A= ",dec temp," B= ",#temp," C= ",temp," ",32,13,10] ' Display result 'A = should be a formatted integer, B=should be a formatted integer, C=will probably be garbage CLEAR ' Clear array
Bookmarks