Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP : RF communication with RS232 / PIC16F877

Status
Not open for further replies.

blend

Electrical
Jan 27, 2004
3

Hi,
My problem is that I can't threat my RS232's datas.
Here's my program in the first PIC16F877, then it will be send to a RF module:

er=0;
er2=0;
en1=0x20;
en2=0;
en3=0;
en4=0;
ena=0x02;
enb=0;
e=er+er2+en1+en2+en3+en4+ena+enb;
printf("%c",e);
//////////////////////////////////////////////////
and then xmit to
( module linx RF HP-2 )
//////////////////////////////////////////////////
then received to
( module linx RF HP-2 )
//////////////////////////////////////////////////
then the information is threated by PIC16F877
that's the program :
#include "16F877.h"
#include "stdlib.h"
#use delay (clock=20000000)
#include "gg_div.c"
#include "gg_lcd.c"
#include "gg_str.c" //librairie maison
#use Rs232 (baud=9600,xmit=pin_c6,rcv=pin_c7)
#include "stdio.h"
void main (void)
{
char e;
set_tris_c(0x80);
set_tris_d(0x00);
e=getch();
/////////////////////////////////////
But then, I can't use the code that I received .. I can see it on the oscilloscope .. but when I do e=getch() then printf("%c",e) It doesn't show up on the hyperterminal.

Maybe I have to modify the second program.
help me.
thanks.
-lp
 
Replies continue below

Recommended for you

1) What RF module are you using?

2) What is getch()? How does it specifically work?

3) Have you verified that you are meeting all of the interface protocol requirements between the PIC and RF module?

.
.
.
 
Hi-

Well, first of all you might consider that you need an
inverter to get the output of the pic into the correct
logic level. I typically use a 2N2222 transistor for
a simple inverter, and yes, I do drive it with only +5
volts. It works most of the time. If you feel
uncomfortable with that, you might consisder using one
of the Max 232X type chips which drive + and - voltage
levels from a single +5V supply. Then you might also
want to go with the old 1488/1489 chips which require
+ and - 12 volts.

So, just to be on the safe side, when you transmit your
characters, you see a low level at the com port of
the hyperchannel when the pic is not transmitting and
when it transmits, there is a high logic level at the
start bit of the character.

Try tying the TX data of the hyperterminal to the RX
pin and see if you indeed are echoing characters. I
assume that you are with the scope output, but it is
a comforting feeling to know that the hyperterminal is
working correctly.

Also, is the baud rate correct? That can cause jibberish
or nothing at all to be received. Are the number
of data bits and stop bits correctly set at the pic and
the hyperterminal? Those can cause "framing errors" and
could also cause jibberish or nothing. Same is true
of the parity settings.

Hint: try a SLOW baud rate 300 or 1200 baud and work you
way up. Depending on the RF modules you are using,
you can add significant distortion in the digital signal.

Hint. Try it hardwired without the RF modules in the loop.

I am using the 2N2222 as mentioned above with a PIC16F77
running them at 19.2 K baud hard wired to a laptop
running minicom (the linux equivalent of hyperterminal).
They pass data correctly and with great reliability.

Hope these thoughts help.

Cheers,

Rich S.
 
wow thanks Rich. I'll give you a feedback soon !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor