微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 微波和射频技术 > 天线设计和射频技术 > How to communicate two pic controller with rf module?

How to communicate two pic controller with rf module?

时间:04-05 整理:3721RD 点击:
Sir i am confused with rf tranmitting and receiving.can any one help me how to communicate two pic controller with rf module...........
Thank you in advance.i am using hitech c compiler.

Here I have used Pic ccs c to program the 16f877a it is working
***receiver program ***
#include <16F877A.h>
#fuses XT,noWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NO DEBUG,NOCPD
#use delay(clock=4000000)
#use rs232 (baud=2400, xmit=pin_C6, rcv=pin_C7,bits=9,stop=1,enable=pin_c0, parity=N,errors)
#use fast_io(b)

int16 test =0,al=0;

#int_rda // RX ucuna veri gelince meydane gelen kesme
void serihaberlesme_kesmesi ()
{
disable_interrupts(int_rda); // int_rda kesmesini pasif yap
al=getch();
}
void main()
{
setup_adc_ports(NO_ANALOGS); //ANALOG giriş yok
setup_adc(ADC_OFF); //ADC yok
setup_psp(PSP_DISABLED); //PSP birimi devre dışı
setup_timer_1(T1_DISABLED); //T1 zamanlayıcı devre dışı
setup_timer_2(T2_DISABLED,0,1); //PWM frekansı ayarlanması
setup_ccp1(CCP_OFF); //CCP1 birimi PWM ?ıkışı i?in ayarla
setup_ccp2(CCP_OFF); //CCP2 birimi PWM ?ıkışı i?in ayarla
set_tris_b(0x00);
output_b(0x00);
output_b(0xFF);
delay_ms(100);
output_b(0x00);
enable_interrupts(GLOBAL);
enable_interrupts(int_rda);
// Aktif edilen tüm kesmelere izin ver

while(true)
{

switch(al)
{
case 'A':
{
test =1;
output_b(test);
/* output_high(pin_c0);
delay_ms(50);
output_low(pin_c0); */
}
break;
case 'B':
{
test =2;
output_b(test);
output_high(pin_c0);
delay_ms(10);
output_low(pin_c0);
}
break;
case 'C':
{
test =3;
output_b(test);
output_high(pin_c0);
delay_ms(10);
output_low(pin_c0);
}
break;
case 'D':
{
test =4;
output_b(test);
output_high(pin_c0);
delay_ms(10);
output_low(pin_c0);
}
break;
case 'E':
{
test =5;
output_b(test);
output_high(pin_c0);
delay_ms(10);
output_low(pin_c0);
}
break;
case 'F':
{
test =6;
output_b(test);
output_high(pin_c0);
delay_ms(10);
output_low(pin_c0);
}
break;
case 'G':
{
test =7;
output_b(test);
output_high(pin_c0);
delay_ms(10);
output_low(pin_c0);
}
break;
case 'H':
{
test =8;
output_b(test);
output_high(pin_c0);
delay_ms(10);
output_low(pin_c0);
}
case 'I':
{
test =9;
output_b(test);
output_high(pin_c0);
delay_ms(10);
output_low(pin_c0);
}
break;

}
enable_interrupts(int_rda); // int_rda kesmesi aktif
}
}


And
***transmitter program ***
#include <16F877A.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD //No EE protection

#use delay(clock=4000000)
#use rs232 (baud=2400, xmit=pin_C6, rcv=pin_C7,enable=pin_c0,bits=9, parity=N,stop=1)
#use fast_io(a)
#use fast_io(e)

int16 ver,test=0;
void gonder() // alıcı uyandırma kodları
{
putc(0x55);
putc(0x55);
putc(0x55);
putc(0x55);
putc(0x55);
putc(0x00);
putc(0x00);
putc(0x00);
putc(0x00);
putc(0x00);
putc(0xFF);
putc(0xFF);
putc(0xFF);
putc(0xFF);
putc(0xFF);
putc(ver); //alıcıya ver değişkeni i?indeki bilgi g?nderiliyor
}
void main()
{
setup_psp(PSP_DISABLED);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_vref(FALSE);
setup_adc_ports(NO_ANALOGS); //ANALOG giriş yok
setup_adc(ADC_OFF); // ANALOG giriş yok
setup_psp(PSP_DISABLED); //PSP birimi devre dışı
setup_ccp1(CCP_OFF); //CCP1 birimi PWM ?ıkışı i?in ayarla
setup_ccp2(CCP_OFF); //CCP1 birimi PWM ?ıkışı i?in ayarla
set_tris_a(0xFF);
set_tris_e(0b111);
output_a(0xFF);
output_e(0b111);
output_b(0xFF);
delay_ms(500);
output_b(0x00);
while(true)
{
//
if(!input(pin_a0))
{
test=1;
delay_ms(10);
while(!input(pin_a0));
ver='A';
gonder();
}
//
if(!input(pin_a1))
{
test=1;
delay_ms(10);
while(!input(pin_a1));
ver='B';
gonder();
/* output_high(pin_c0);
delay_ms(500);
output_low(pin_c0);*/
}
//
if(!input(pin_a2))
{
test=1;
delay_ms(10);
while(!input(pin_a2));
ver='C';
gonder();

}
//
if(!input(pin_a3))
{
test=1;
delay_ms(10);
while(!input(pin_a3));
ver='D';
gonder();
}
//
if(!input(pin_a4))
{
test=1;
delay_ms(10);
while(!input(pin_a4));
ver='E';
gonder();
}
//
if(!input(pin_a5))
{
test=1;
delay_ms(10);
while(!input(pin_a5));
ver='F';
gonder();
}
//
if(!input(pin_e0))
{
test=1;
delay_ms(10);
while(!input(pin_e0));
ver='G';
gonder();
}
//
if(!input(pin_e1))
{
test=1;
delay_ms(10);
while(!input(pin_e1));
ver='H';
gonder();
}
//
if(!input(pin_e2))
{
test=1;
delay_ms(10);
while(!input(pin_e2));
ver='I';
gonder();
}
}
}

Please, Can you post this circuit for code? Thank for your share!
email: quangdien0301@gmail.com

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top