Maximum frequency output from a PIC


Closed Thread
Results 1 to 40 of 69

Hybrid View

  1. #1
    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,
    Yes, as long as the loop takes longer to exectute than the period time of the PWM signal (2us in this case) it'll work without additional delay in there. When running at 8MHz each ASM instruction takes 500ns so there's really only time 4 instructions in this case. The Goto Main takes 2 and the jump caused by the IF-THEN takes 2 so that's 4, then we have the rest so it's pretty safe to run it without any delay.

    Here are the screenshots I mentioned:
    Name:  DS4_QuickPrint1.jpg
Views: 4512
Size:  93.4 KB

    Name:  DS4_QuickPrint2.jpg
Views: 4464
Size:  96.1 KB

    /Henrik.

  2. #2
    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 just can’t wait to try the code again (that will be in a couple of hours after I get off work).
    The signals look really good. Only about 12 uS delay on the falling edge which is better than I need. Is it the same at the rising edge?

    Thanks,

    Nick

  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,
    Yes and no....
    Yes because it's going to be in the same ballpark.
    No, because it's not going to be an absolute number (on the rising OR falling edge) because the carrier signal might "come on" (or off) at any time. If it happens to do that just before we check it the delay will be very short, if it happens to do it just after we just checked the delay will be a little longer.

    I measured a couple of pulses here.
    Delay on rising edge: 10, 7.5, 9.5, 10, 7.5, 6.5 us
    Delay on falling edge: 9.5, 11.5, 12, 8, 8, 11 us

    So I think you can consider 12us to be around the worst case for this particular code. Would you prefer constant delay at the cost of it being longer? (Not promising anything, just asking).

    And, don't forget it's Programmers Day today - the 256th day of the year! :-)

    /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

    Hi Henrik,

    I only asked to confirm my theory about how it will look at the other edge which is exactly your explanation.
    It does not make any difference to me for this application and as I stated before I could live with it even if it was longer. It is important though to know it so I can compensate for it.
    Happy Programmer’s day!

    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

    As much as I hate to say it I managed to release a portion of the built in smoke from one of my PICs just before the load and test of the new codes.
    I did not have the smoke pump to push some back in nor did I have a replacement PIC handy so it will have to wait until tomorrow.

    Regards,

    Nick

  6. #6
    Join Date
    Oct 2012
    Posts
    82


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    After fixing the missing smoke problem and modifying the code for PIC12F683 (see my prior posts for configs) the code works without any glitches. I only added on the Tx side one other pin toggle so it made it easier on my scope to compare the Tx and Rx sync. I could see the small amount of jitter at each edge and by changing the time base of the scope I could read (as predicted) delays from about 6 uS to 12 uS. Sorry but I cannot post screen shots from my old analog scope but they are like Henrik’s samples.

    I cannot explain what happened the first time and why it did not work. It might have been my scope that was confused by the complex signals (at that time I did not have the extra pin toggling) and did not latch properly on the trigger.

    BTW Henrik what are you using as your scope? It looks pretty handy. I’m still using at least 10 years old technology and even though I’m getting close to retirement I’m planning on upgrading all my tools once again because this is going to be my favorite way of spending my free time. Hopefully good wife servicing this weekend will provide the necessary budget (LOL).

    I can’t thank enough to Henrik for his help and patience. I learned at least two new things that I was afraid to play with before: PWM side of the CCP1 module and the using TMR0 as fast counter. I always need to start with a simple working sample code to get me started and this exercise gave me the opportunity to build a good foundation for future projects. I envision at least 25 PICs working 24/7 in my house for the next 5 years driving various gadgets. I know some might say that you can buy one gadget that will do the work of all little once but nothing gives me more satisfaction when I see things that I built long ago still working with no failures. And on top of that “I got the hammer” (LOL again).

    Next step: interrupts.

    Regards,

    Nick

  7. #7
    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,
    No worries, I'm glad I could help and I'm glad you got it working.

    My scope is a RIGOL DS4014, it's a 4-channel 100MHz bandwidth scope.
    I've had it for a bit over a year now and I really do enjoy it. There's been a lot of development on the scope market in the last couple of years and there are manufacturers in the far east now churning out some pretty impressive machines (and some quite horrible ones as usual) at prices well below similar specs units from the name brands.

    /Henrik.

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