NCO Calculator


Closed Thread
Results 1 to 25 of 25

Thread: NCO Calculator

Hybrid View

  1. #1
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: NCO Calculator

    The basic formula reduces down to:

    NCO Value = (Frequency * 2,097,150) / Fosc

    Building the NCO Calc in Visual Basic, the behind-the-scenes math was:

    NcoDec = (Freq * 2.09715) / Fosc
    NcoDecR = Math.Round(NcoDec, 3)
    FreqDn = Math.Round(((NcoInt * Fosc) / 2.09715), 4)
    FreqUp = Math.Round(((NcoInt1 * Fosc) / 2.09715), 4)

    There's a bit of other code in there, but that's the math.

  2. #2
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default Re: NCO Calculator

    I think I found the problem... 2^21 equals 2097152, not 2097150. When I plug the 2097152 value into your formulas the phase increment and output frequency results match my calculations.

    Thank you so much for helping me verify my calculations are correct.

    Cheerful regards, Mike, K8LH

    Fosc = 32000000
    Freq = 1843200

    NCO Decimal = 120795.9552
    NCO HEX = 1D7DC
    Result Rounded Up = 1843200.68359375
    Result Rounded Down = 1843185.4248046875
    Resolution = 15.2587890625-Hz
    Last edited by Mike, K8LH; - 9th May 2018 at 04:15.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default Re: NCO Calculator

    I never used the NCO up to this moment. What is the purpose of this module?

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default Re: NCO Calculator

    Well Ioannis, Here is an excerpt form the data sheet:

    The Numerically Controlled Oscillator (NCO1) module
    is a timer that uses the overflow from the addition of an
    increment value to divide the input frequency. The
    advantage of the addition method over simple
    counter-driven timer is that the output frequency
    resolution does not vary with the divider value. The
    NCO1 is most useful for applications that require
    frequency accuracy and fine resolution at a fixed duty
    cycle.

    I have recently built and coded a closed loop PID control for a stepper motor with the NCO.
    Dave Purola,
    N8NTA
    EN82fn

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default Re: NCO Calculator

    Thanks Dave for the info.

    Ioannis

  6. #6
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: NCO Calculator

    With NCO you can target frequencies with spectacular accuracy as opposed to PWM or other methods. Many of the newer PICs with NCO also have the option of using LFINTOSC and MFINTOSC with NCO for a slower-than-Fosc(/4) clock. My current project targets frequencies as slow as 2 Hz, with accuracy to 0.02 Hz, and as high as 3.1 MHz. NCO lets me get that accurate.

  7. #7
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default Re: NCO Calculator

    Hi mpgmike:

    At the risk of seeming like a troll, may I make a couple suggestions, just in case you ever revisit your NCO Calc program, please?

    (1) Allow entry of NCO Frequencies such as 8388608-Hz without rounding.
    (2) Correct the NCO bit width constant (2097152) in your calculations.
    (3) Display the NCO frequency resolution.
    (4) Display the output frequency error.

    I whipped up a quick spreadsheet to highlight the calculation problems I'm experiencing. Your NCO Calc app' introduces errors by rounding the NCO frequency and by using the incorrect NCO bit width constant in your calculations.

    Have fun. Best wishes. Cheerful regards, Mike, K8LH

    Name:  K8LH NCO Calc.png
Views: 5688
Size:  37.5 KB
    Last edited by Mike, K8LH; - 11th May 2018 at 01:03.

Similar Threads

  1. help with calculator
    By minssss in forum General
    Replies: 3
    Last Post: - 10th November 2009, 00:12
  2. Calculator LCD
    By menze in forum General
    Replies: 0
    Last Post: - 26th June 2006, 21:31
  3. help with my calculator project
    By loayaouad in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th May 2005, 07:42
  4. Calculatorīs LCD
    By srspinho in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 4th May 2005, 10:27
  5. Calculator
    By neiron21 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st February 2005, 00:53

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