No idea where to place this so just put it here in the lobby

Basically it's a very small project nothing more, I want to emit a 5 MHz frequency signal after i press a button, and light the LED connected to the other PIC as shown in the diagram below



this is just part of the project obviously but need this running before i proceed,
I will need to design the emitter and the receiver myself.

I dont really know how to implement all these since all i know is theoratical but this is what i plan to do :

Emitter :
basically i will output from the pic a waveform signal, whose frequency is let's say 5 MHz and through a highpass filter and should get a sinewave, at least thats the plan.



code for the pic :
void main() {

TRISA=1;

TRISB=0;

while ( 1 ) {

if ( PORTA.F0==1){

	PORTB.F0=1 ;
	delay_us (12.5) ;
	PORTB.F0=0 ;
	delay_us (12.5) ;

	}

}

}

( 12.5 microseconds is the period for a 5MHz signal )

I need help in choosing the values of R1 and C1, and before anyone saying " that is highschool level .. " , yes i know, exactly.. i forgot all these thats why im asking


Receiver :

RLC circuit whose natural raisonnance frequency is 5MHz



Thats it basically, I will input the sine wave i receive into the analogue pins of the PIC and when voltage is detected output to the other pin of the PIC.

Will this work or am i missing something or I am doing something really stupid ?
I have indeed been far from all these so excuse my mistakes if any

Thanks in advance for any help
@Khaled well i think you've missed that 25 micro second = to 40000 Hz= 40 Khz for a 5Mhz signal you need 200 nano second which is non achievable using the 16F877a microcontroller .
IF you use assembly language to write your program the way your planing (pin toggle ) you get max 1Mhz because using 20MHz crystal each instruction need 200 nano second to complete and you need at least 3 instructions.
solo220 wrote@Khaled well i think you've missed that 25 micro second = to 40000 Hz= 40 Khz for a 5Mhz signal you need 200 nano second which is non achievable using the 16F877a microcontroller .
IF you use assembly language to write your program the way your planing (pin toggle ) you get max 1Mhz because using 20MHz crystal each instruction need 200 nano second to complete and you need at least 3 instructions.
yeah man thank you for the reply, i figured as much shortly after posting. The 200ns error was a noob error i am ashamed of.. so much for engineers of the future :P

What i might end up doing is use the output of the PIC16F877a controller and a transistor to pass a 5MHz signal into the filter. Should work with a Field effect transistor no ?
@Khaled can you give us more details about the project , like the distance between the transmitter and receiver .

because maybe it's easy to generate the 5MHz signal and modulate it but what about the other elements of the signal path , I mean antennas and receiving end did you thought about that?
without some signal pre-amplification the max distance you can get is some centimeters.
maybe you should reconsider to use a higher frequency using other means to generate the rf signal like some rf module because beside the problem of the receiver end at 5Mhz you need an antenna length of 60 meters .
solo220 wrote@Khaled can you give us more details about the project , like the distance between the transmitter and receiver .

because maybe it's easy to generate the 5MHz signal and modulate it but what about the other elements of the signal path , I mean antennas and receiving end did you thought about that?
without some signal pre-amplification the max distance you can get is some centimeters.
maybe you should reconsider to use a higher frequency using other means to generate the rf signal like some rf module because beside the problem of the receiver end at 5Mhz you need an antenna length of 60 meters .
Thanks for your answer, yes i realise that, but the project is very simple, i only want to use the signal to trigger a signal across a chasm, the PIC playing the role of a signaling station and a small 5 cm gap playing the role of the chasm. Basically the 2 antennas will be around 5 to 10 cm apart so I dont think it will really matter, or will it ?

And i will just end up generating a signal with a 1 microsecond period ( meaning a frequency of 1 MHz ) and just connect it to the antenna.
The receiver side will consist of an RLC circuit and an antenna. This should work right ?
solo220 wroteyes it should work at this distance but add to the receiving end an envelope detector like this one
http://en.wikipedia.org/wiki/Envelope_detector .
I am facing a problem, I wrote the following code :
void main() {

TRISA=1;
TRISB=0;

while ( 1 ) {

while (PORTA.F0=1){

        PORTB.F0=1;
        delay_us(2);
        PORTB.F0=0;
        delay_us(2);
        }

     PORTB.F0=0;}

}
and I get the following output no matter what the value of A0 is. ( I connected a switch to the A0 port of the PIC controller and switching from ON to OFF should stop any output.
Instead I get this :




Any ideas ?
Try this:
#include "16f877a.h" // didn't see it, so I'm not sure if you included it or not

void main() {

CMCON = 0x07; // switch off comparators to use A0 for input
TRISA=1;
TRISB=0;
PORTB = 0; // initiate B0 before using

while ( 1 ) {

while (PORTA.F0=1){

        PORTB.F0=1;
        delay_us(0.2); // a frequency of 5MHz is a delay of 0.2us (f = 1/T so if f = 5MHz => T = 1/5M = 0.2u)
        PORTB.F0=0;
        delay_us(0.2);
        }

     PORTB.F0=0;}

}
I would also recommend that you write a code for debouncing the switch, otherwise your single press on the switch will appear as multiple presses for the PIC.

I have a question though: why are you using PICs as the basis for the transmitter and receiver circuits? Is it a requirement to do so for the project? If not, why not simplify your work and simply use 555 timers instead? They are cheaper, are easy to use, and don't require any programming.
Use the pwm, 50% cycle. You can achieve higher freq
Thanks a lot mesa it worked.

And yes I included the library but forgot to include the headers in the post.

and yes I am forced to use the PIC line of micro-controllers, basically the purpose of the project was the programming of the PIC controller.

Thanks again mesa

and yes padre i had't thought of that and it worked as well thanks a lot