PIC16F877A with RF modules 433Mhz (FS1000A Tx and MX-RM-5V Rx)

Status
Not open for further replies.

imranahmed

Advanced Member level 3
Joined
Dec 4, 2011
Messages
817
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Karachi,Pakistan
Activity points
6,493
Please let me know I programmed a two PIC16F877A one is Tx and other is Rx but not doing good transferring of data to receiver. I checked both PIC16F877A with sample LED blinking code they both are working. PIC16F877A does not have internal oscillator I used 8Mhz Crystal with 15pF Capacitors. I am using Mikro C Pro for PIC compiler and using UART module. I check both Tx and Rx RF module both working good on Arduino but I want to make them work with PIC16F877A.
PicKit 3 Programmer used.

Receiver Code:
Code:
 #define _XTAL_FREQ 8000000 //Crystal Frequency, used in delay
unsigned char uart_rd;
void main() {
    UART1_Init(9600);               // Initialize UART module at 9600 bps
    TRISD2_bit = 0;
    PORTD.RD2 = 0;

    while(1){
    if (UART1_Data_Ready()) {     // If data is received,
    uart_rd = UART1_Read();     // read the received data,

   if(uart_rd == 0x1E){
    PORTD.RD2 = 1;
   }
    if(uart_rd == 0x1A){
    PORTD.RD2 = 0;
    }
    }
    }
}

Transmitter Code:
Code:
#define _XTAL_FREQ 8000000 //Crystal Frequency, used in delay
unsigned char uart_rd;
void main() {
  UART1_Init(9600);               // Initialize UART module at 9600 bps
  TRISD2_bit = 1;
  while(1){

    if (Button(&PORTD, 2, 1, 1)) {               // Detect logical one

       UART1_Write(0x1A);

    }else if(Button(&PORTD, 2, 1, 0)) {

       UART1_Write(0x1E);

    }
  }
}
 

Attachments

  • RxTx.jpg
    8.4 KB · Views: 161

These simple ASK receivers aren't suited to transmit UART data with arbitrary bit sequences. Arduino projects with ASK modules are using a special library to recode the data to a balanced bit sequence. Search for RadioHead ASK library.
 
These simple ASK receivers aren't suited to transmit UART data with arbitrary bit sequences. Arduino projects with ASK modules are using a special library to recode the data to a balanced bit sequence. Search for RadioHead ASK library.

Yes I used RadioHead library it is for Arduino but I used for PIC16F877A, is there any library for PIC16F877A?
 

It should be possible to port the library to xc8 or MikroC. The problem of unequal bit sequences can be tackled by applying a kind of Manchester encoding and send an UART symbol for 4 data bits. But receiver synchronisation is less effective because it still depends on single start bit detection.

The method has been discussed in various Edaboard threads Problems on RF communication between PIC | Forum for Electronics (edaboard.com)
 

hello
you are sending(0X1A,0X1E) two byte individually . why you don't transmit
the two bytes individually via com port RS232 to your PC HyperTerminal program to ensure that uart built in func. works well
 
hello
you are sending(0X1A,0X1E) two byte individually . why you don't transmit
the two bytes individually via com port RS232 to your PC HyperTerminal program to ensure that uart built in func. works well
Yes but it is not working above comments says that UART not works individually, Manchester coding needed I am trying Manchester and will let know to forum.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…