Signal modulation projet Using PIC16F877a

Discussion in 'Embedded Systems and Microcontrollers' started by Mo2teye, Dec 5, 2012.

  1. Mo2teye

    Thread Starter New Member

    Jan 7, 2012
    2
    0
    Hello everyone,

    Basically it's a small project, 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

    [​IMG]

    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.

    [​IMG]

    code for the pic :

    Code ( (Unknown Language)):
    1. void main() {
    2.  
    3. TRISA=1;
    4.  
    5. TRISB=0;
    6.  
    7. while ( 1 ) {
    8.  
    9. if ( PORTA.F0==1){
    10.  
    11.     PORTB.F0=1 ;
    12.     delay_us (12.5) ;
    13.     PORTB.F0=0 ;
    14.     delay_us (12.5) ;
    15.  
    16.     }
    17.  
    18. }
    19.  
    20. }
    21.  
    22.  
    ( 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

    [​IMG]

    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. Or maybe convert that analogue signal to DC voltage and input it as digital input if its easier, what do you guys suggest ?

    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
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Repost with images that actually fit on a screen. Those are just HUGE!!!

    Try the "Go Advanced" button in the reply window. It has a "Preview" button.
     
  3. Mo2teye

    Thread Starter New Member

    Jan 7, 2012
    2
    0
    Yeah I am sorry about that, i DID notice how big they were after I submitted the thread but couldn't edit it, the there was no edit button ( there still isnt any btw ), why is that ?

    Anyway back to the project I discovered that I cannot generate a signal that has a frequency bigger than 1 MHz, so ill stick to that I guess.

    Period should be 2 microseconds. But the PIC still isnt outputting anything, It is giving me this waveform when I try to simulate it using multisim :

    [​IMG]

    And it should have been a Square wave signal no ? What is wrong ?
    Anyway i tried to generate it with the following code :

    Code ( (Unknown Language)):
    1.  
    2. void main() {
    3.  
    4. TRISA=1;
    5. TRISB=0;
    6.  
    7. while (PORTA.F0=1){
    8.  
    9.         PORTB.F0=1;
    10.         delay_us(2);
    11.         PORTB.F0=0;
    12.         delay_us(2);
    13.  
    14.     }
    15.  
    16. }
    17.  
    18.  
    Can anyone help in this ?
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    (I believe you'll get an edit button when you hit 10 posts.)

    Open up the Microchip spec on this device and look at all the alternate analog functions on Port A that are on by default and thus override your digital settings. Typically the A2D and the comparators use that port. A port pin doing analog will read
    as a zero, thus your while loop is never true to fire.

    Also check there is nothing conflicting on Port B, but that is usually free of these conflicts (it's mostly used for digital things like interrupt or interrupt on change).

    Inside MPLAB is a wonderful simulator to check out code like this.

    Welcome to the forums!
     
Loading...