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 20: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 21: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
I did write uS when I meant mS, but no worries.
The synching issue isn't a problem, because the PIC on the PC sends a command out to the other PIC and it acts on that command. The other PIC is in receive mode straight after the command is sent waiting 250ms for something to come in.
On the code bit....
I expected 3638, I got 146. I expected 3640 or something close, and I get 224. The annoying thing is, I had this part working a few weeks ago, and I messed around with it, and now I can't remember how I done it. thats how I ended up messing around with the formats, and of course, sending a byte and getting a string....not a good way to make things work
ALTHOUGH, I have now found the error. It's not so much in the TX or RX, but in the definition of temp. I'm working on that now, so I will get back with a real update in the next hour or two
Last edited by gringobomba14; - 18th July 2008 at 22:09. Reason: Found the problem
I sent to the LCD display whats being sent by the radio, and I'm not getting what I'm sending. I'm sending 637 (that 6 came from nowhere by the way) and I'm receiving 236 or 224 or 3 or some other almost random number. Maybe time for bed and see what tomorrow brings. or half a stick of dynamite and a box of PIC's
Bookmarks