Maximum frequency output from a PIC


Closed Thread
Results 1 to 40 of 69

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Posts
    82


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Hi Henrik,

    I will try your code tonight. I only have 12F683 PICs and to change to 12F1840 will take some time for me (I’m still using an older version of PBP) which, more than sure, does not support this chip.
    If I can get modulated 1 MHz from one chip for now it will save me a lot of time with the testing and a lot of space on the board.
    I will post my findings as soon as I have results.

    As always thank you for your help.

    Regards,

    Nick

  2. #2
    Join Date
    Oct 2012
    Posts
    82


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    I had to make few minor changes to Henrik’s code to adapt it to a 12F683 and make the code compatible with my old PBP 2.47.

    Here is the working code that generates bursts of 15 mS ON and 5 mS OFF with a carrier frequency of 1MHz (Sorry Henrik for mutilating your nicely commentated code but REMing some of the lines makes it easier on my eyes).
    Code:
    @ device  pic12F683, intrc_osc_noclkout, wdt_on, mclr_off, protect_off
    DEFINE OSC 8            ' We're running at 8 Mhz
    OSCCON=%01110111        ' 8MHz internal osc
    ANSEL   = 0             ' Digital only for all PortA pins
    TRISIO=%00100000        ' Make PORTA outputs
    CCP1CON = %00001100     ' Normal PWM 
    PR2 = 1                 ' 1MHz output @8MHz system clock
    CCPR1L = 0              ' 50% Dutycycle
    CCP1CON.5 = 1
    CCP1CON.4 =1
    Main:
        T2CON.2 = 1         ' Timebase ON
        PAUSE 15
        T2CON.2 = 0         ' Timebase OFF
        PAUSE 5
    Goto Main
    This will make my testing a lot easier and fine tune the power transfer part. In the real life I will replace the fixed timing of the T2CON.2 control with some other mechanism (something like Dave did). Right now my first priority is to decide on the final frequency and tune my LC circuits for maximum efficiency on power transfer and maximum reliable speed on data transfer.
    Unfortunately I do not have too much time to experiment with the new 12F1840 which is by far the best way to go. It involves so many more variables for me including complete upgrade of my hardware and software and I’m not ready for it yet.

    One question for Dave:
    You used a data speed of 3000 bps. Did you try to push your system to see what will be the maximum data speed that you could get?
    And two questions for everyone:
    Is there a 10F, 12F or low pin count 16F PIC, supported by my older 2.47 PBP that will have a 16 MHz internal clock?
    What kind of minimal hardware / software upgrade to be able use PIC12F1840?

    Thank you in advance.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Hi Nick,
    Great, I'm glad you've got it working on the '683!

    You'd need to check microchip.com and use the product selector tool they have to find which PICs have the oscillator options you want and then cross reference that with the supported devices list for the compiler version you have.
    If you find yourself in a position where you need to consider upgrading to PBP3 I wouldn't hesitate a second. The big difference is how the CONFIG bits are handled - and it's a big step forward IMO. Then you have the conditional compilation features and (since you're even on pre 2.50) you'll get support for 32bit variables when using PIC18 series devices and a couple of new commands.

    PBP doesn't really know much about the hardware but obviously your device programmer needs to support the chip you're programming for - you need to check the list for your particular device programmer. I have a PICKit3, it's cheap and it works.

    /Henrik.

  4. #4
    Join Date
    Oct 2012
    Posts
    82


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Thanks Henrik for your support and encouraging.
    Switching to the latest software and hardware is one of my next priorities.
    I was going to order a PICKit3 just to get familiar with it until I will cross the bridge. Your sample code will be my first try.

    MeLabs use to have a really helpful PIC selection system. What happened to it? I wasn’t aware that Microchip has the product selection tool. I will use it from now on.

    I’m sure that other members of the forum will be interested in some of the aspects of my project and I pledge to keep everyone posted with my progress. It’s time to order some parts and start testing.

    Regards,

    Nick

  5. #5
    Join Date
    Oct 2012
    Posts
    82


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Despite the loss of few last posts this tread still has enough information to support my next hypothetical question:
    As posted before I’m employing a PIC12F683 to generate a modulated 500KHz carrier.
    The output is 15 mS carrier ON followed by 5 mS carrier OFF and it drives a LC resonant circuit to transfer power to a remote sensor. In my efforts to keep the part count and manual adjustments to a minimum I was wondering if a second PIC12F683 on the receiving side will be able to perform as a missing pulse detector and flip a pin high when the carrier is present and drive it low when the carrier is OFF?
    I am aware that some jitter will be present but for my intended purposes even 100 uS will be fine.
    How will one go about getting something like that to work?
    I’m thinking that if an input is set for IOC and the interrupt is cleared as soon as possible. This indicates that the carrier is ON.
    If no more interrupts that means carrier is OFF.
    I never used interrupts so any input if this is a good approach will be appreciated. Some possible links to something like this will be more than helpful.

    Regards,

    Nick

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Hi,
    It can probably be done with a PIC, not sure it's the best way though....

    What does the signal actually look like at the receiving end? I imagine it's not a nice squarewave at logic levels so, depending on how you do this, you probably need to do some signal conditioning before feeding it further. Because of this I'm not sure a PIC or other logic device is the best tool for the job. Can't you just use a lowpass filter with a suitable time constant followed by a simple transistor buffer?

    Or, if the signal IS conditioned to logic levels, perhaps use a retriggerable flip-flop with something like 2.5us time constant. The 500kHz carrier will then keep triggering the flip-flop, as soon as the carrier goes away the flip-flop output will fall withing 2.5us. If the signal isn't conditioned to logic levels perhaps using a 555 timer as the flip-flop could do it but again, it all depends.....

    If you insist on using a PIC for the job I'm sure we can figure something out though.

    /Henrik.

  7. #7
    Join Date
    Oct 2012
    Posts
    82


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Hi Henrik,

    It is funny but I used both your suggestions in my younger days. I also used a frequency to voltage convertor (LM2917 if my memory serves me right). Each has its limitations and advantages.
    Since I started using PICs I pledge to myself that I will replace any of the analog or logical components that can be replaced especially when it comes to timing circuits. In this case it is so easy to change one line in the code to generate a different frequency or duty cycle with much better accuracy than analog circuits. I also pledge to myself to learn as many special functions of the PICs as I possibly can. Like I said before I’m a slow learner but nobody bits me when it comes to forgetting things (LOL).
    I am aware that some signal conditioning will be necessary but that is my last of the worries. I recently discovered those single gate chips in small packages and I’m sure that a couple resistor and capacitors combined with a trigger smith will do fine.
    At least knowing now that it can be done using a regular PIC I will research this avenue and keep you posted.

    Thank you again for the valuable input.

    Regards,

    Nick

Similar Threads

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