Maximum frequency output from a PIC


Closed Thread
Results 1 to 40 of 69

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Posts
    83


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Thank you Henrik for your suggestions.
    I will try the tonight and report the findings.
    If I must I will stay with 12F series which might give me the corect output.
    The goal is to get 1MHz with output with a 15 mS ON and 5 mS OFF from one single chip.

    Regards,

    Nick

  2. #2
    Join Date
    Oct 2012
    Posts
    83


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    One other choice will be to have the PIC12f output (the 1MHz) controlled ON and OFF by one of its input pins kind like Dave did in his application. This will give me more flexibility with the rest of the concept which is not completely defined yet.
    Once I have a clearer picture I will present it to the forum.

    Nick

  3. #3
    Join Date
    Oct 2012
    Posts
    83


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    If anyone is interested here are the results of the speed test using the two methods suggested by Henrik:
    • Writing directly to the output pin at 8MHz internal clock I got a little over 500 kHz but the duty cycle is 25% or 75% depending on the order you write to the pin 0 or 1.
    • Using x consecutive writes to the pin (but with a gap at the end of the sequence) increases the burst frequency to about 1 MHz with a duty cycle of 50%. BTW I used 10 cycles.

    So far I learned a lot in the process.

    Henrik, based on your prior experience with CCP module I have few questions that you might be able to answer:
    1. What will be the maximum frequency out that can be achieved from a given master clock?
    2. Can the output be turned ON and OFF at some predetermined intervals (let's say 15 mS ON, 5 mS OFF)?
    3. What other requirements are there for the PIC (other the CCP module) to be able to get that?
    4. Will PIC12F683 do the job?

    I will start searching the forum for this kind of applications and I’m sure I might be able to find something to get me started.

    Thank you to all the members of this forum that are making PIC programming accessible to more and more hobbyists.

    Who said you can’t teach old dogs new tricks?:

    Regards,

    Nick

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Hi Nick,
    Henrik, based on your prior experience with CCP module I have few questions that you might be able to answer:
    1. What will be the maximum frequency out that can be achieved from a given master clock?
    As per the datasheet, PWMPeriod = (PR2+1) * 4 * Tosc so with an 8MHz oscillator and PR2=0 the maximum PWM frequency would be 2MHz (1/(1*4*0.000000125)
    2. Can the output be turned ON and OFF at some predetermined intervals (let's say 15 mS ON, 5 mS OFF)?
    Yes, that's what the PWM module does, however the number of available dutycycle ratios depends on the selected output frequency. At the maximum output frequency you have 2bits of resoultion, ie the dutycycle can be 0%, 33%, 66% or 100%.

    You keep saying that you want 1MHz output frequency with 15ms on-time and 5ms off-time. That's a period of 20ms which equals a frequency of 50Hz - not 1MHz. If you mean 15us on-time and 5us off-time it'll be 50kHz, still not 1MHz.
    3. What other requirements are there for the PIC (other the CCP module) to be able to get that?
    No, not really.
    4. Will PIC12F683 do the job?
    I think it might, I'll have to look into it a bit further though.

    /Henrik.

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Henrick, I think what NickMu means is, you have a carrier frequency of 1 Mhz. being generated by an oscillator and you modulate it with a gated signal of 15 Ms. on and 5Ms. off. What looks like OOK modulation. NickMu, am I right? Is this what you are looking for?
    Dave Purola,
    N8NTA
    EN82fn

  6. #6
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    NickMu, If this is what you are looking for then maybe you should look at using an 12F1840. It has a DATA SIGNAL MODULATOR module that is quite usefull for generating waveform like this.
    Dave Purola,
    N8NTA
    EN82fn

  7. #7
    Join Date
    Oct 2012
    Posts
    83


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Hi Henrik,

    Thank you for your help and my apologies for not making myself clear.
    I am in need of a modulated high frequency source. The main frequency (carrier) should be between 250 kHz and 4 MHz pending some results of testing in progress. I will start with 1 MHz and move up or down on carrier frequency.
    I need to be able to turn this carrier ON and OFF in bursts of 15 mS ON and 5 mS OFF.

    My project is still in its infant stages, so right now I’m at the point of poking around to see what can be done with a minimum amount of components.

    The larger project this is part of is a non-contact power and data transfer. This week and next week I will be doing a lot of testing on the power transfer part to find an optimal frequency that will make it easier to do both with as little loss as possible.

    My first power transfer test is encouraging (I can transfer about 1.5 W which is more than I need) with about 66% efficiency. For this I’m using a Mosfet driven by a variable gated oscillator. It serves the purpose for testing but in the final design I would like to have something much simpler especially at the slave unit side where I have a lot of limitations space being one of them.

    My research also shows that for power transfer lower frequencies (100 – 400 kHz) are better. For data transfer I would prefer to use higher frequencies since I already tested a wired 4 MHz power and data transfer. Also I understand that higher carrier frequency will allow higher data transfer rate. I must have 9600 but 19200 will be better.

    This week I will do some research on employing the CCP module to do most of this part.
    I will also study Dave’s example which seems to be doing almost what I need only at lower frequencies.

    Dave, you are right and thanks for the suggestion, I will look into it. I am familiar with PIC12F683 but if I must learn new tricks I will.

    So many things, so little time.

    Thanks again for your help.

    Regards,

    Nick

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Hi Nick,
    No problem, I didn't have a 12F683 at home but I did have a 12F1840. Now, the 1840 has an ECCP module while the 683 has a standard CCP module so the following code MAY need to be changed slightly (the CCP1CON register) in order to work properly on the 683 (I'm not using the data modulator here). It sets the CCP module up to output a 1MHz, 50% dutycycle PWM on PortA.2. The main program then simply toggles the timebase (TMR2) for the CCP module on and off to modulate the output.
    Code:
    ' ***************************************************************
    ' Pin Connections
    ' ***************************************************************
    
    ' RA0                       -> Not used
    ' RA1                       -> Not used
    ' RA2                       -> CCP1 output
    ' RA3                       -> Not used
    ' RA4                       -> Not used
    ' RA5                       -> Not used
    
    ' ***************************************************************
    ' Device Fuses
    ' ***************************************************************
    
    #CONFIG
       __config _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF
       __config _CONFIG2, _PLLEN_OFF & _STVREN_ON & _BORV_LO & _LVP_OFF
    #ENDCONFIG
    
    ' ***************************************************************
    ' Compiler directives
    ' ***************************************************************
    DEFINE OSC 8               ; We're running at 16Mhz
    
    ' ***************************************************************
    ' Initialization
    ' ***************************************************************
    
    OSCCON   = %01110000        ' 8MHz internal osc
    ANSELA   = 0                ' Digital only for all PortA pins
    TRISA    = %00000000        ' Make PORTA outputs
    
    CCP1CON = %00001100     ' Normal PWM 
    PR2 = 1                 ' 1MHz output @8MHz system clock
    CCPR1L = 0              ' 50% Dutycycle
    CCP1CON.5 = 1
    CCP1CON.4 = 1
    
    ' ***************************************************************
    ' Actual program
    ' ***************************************************************
    Main:
        T2CON.2 = 1             ' Timebase ON
        PAUSE 15
        T2CON.2 = 0             ' Timebase OFF
        PAUSE 5
    Goto Main
    I have a scope screen grab of the output but for some reason the file upload manager on the forum refuses to work, the upload just hangs...aarghh....

    Now, if you intend to do other things with the PIC as well then this simple aproach obviously won't work. But you could use a timer interrupt in order to turn on and off the carrier at the correct intervals. I haven't personally used the data signal modulator module in the 12F1840 but it sure sounds like the "correct" way forward. The 12F1840 also allows you to run at 32MHz using the internal oscillator and 4x PLL which would allow you to get higher output frequency using the CCP module than on the 12F683 which tops out at 8MHz.

    /Henrik.
    Last edited by HenrikOlsson; - 23rd August 2013 at 19:22.

Similar Threads

  1. internal TMR for frequency output
    By Samoele in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th January 2009, 10:38
  2. How to calculate PIC sampling frequency
    By minmin in forum General
    Replies: 1
    Last Post: - 26th September 2006, 19:02
  3. Replies: 2
    Last Post: - 20th January 2006, 22:09
  4. Maximum frequency count on 16F628/4MHz
    By solara in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 23rd May 2005, 11:38
  5. Low frequency output
    By barkerben in forum General
    Replies: 5
    Last Post: - 16th November 2004, 16:25

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts