Electronics > Projects, Designs, and Technical Stuff
variable frequency square wave
ogden:
--- Quote from: IDEngineer on May 24, 2019, 04:49:30 pm ---If by "accuracy" you mean "lack of jitter", yes - the PIC's will do it because it's all in hardware. I've seen it on the scope. This isn't rocket science... it's not difficult for digital logic to stay within 1KHz on a 1MHz fundamental (which is 0.1%).
--- End quote ---
Fine. Let's take timer that is running at (precise) 72 MHz. Now please show how to generate 993 KHz, with 0.1% accuracy. By accuracy I mean frequency accuracy, output obviously w/o significant jitter.
NorthGuy:
--- Quote from: ogden on May 24, 2019, 04:10:34 pm ---Are you absolutely sure that PIC or STM32 can generate any arbitrary frequency up-to 1MHz with 0.1% accuracy? Before you answer - take some time and do some math
--- End quote ---
There are some PICs designed for high frequency PWM. They can do much better actually. For example, dsPIC33CK256MP508 family can produce 250 ps PWM resolution.
Of course, rare MCU can produce sub-ns rise/fall times, so the wave you generate will not be very square if you look at it with 1 ns resolution. Thus, the 0.1% accuracy of 1MHz wave is a moot point. It all depends on the purpose of the generated square wave.
ogden:
--- Quote from: NorthGuy on May 24, 2019, 05:18:33 pm ---There are some PICs designed for high frequency PWM.
--- End quote ---
Yes, There are few STM32 chips as well, yet HR timers as you already mention are made for PWM, not frequency division/generation. Proper way of generating arbitrary frequency clock is DDS. Second best way is programmable clock IC like mentioned Si5351.
--- Quote from: NorthGuy on May 24, 2019, 05:18:33 pm ---Thus, the 0.1% accuracy of 1MHz wave is a moot point. It all depends on the purpose of the generated square wave.
--- End quote ---
Requirements are clearly stated in the OP: "0.1% accuracy of the frequency control".
IDEngineer:
--- Quote from: ogden on May 24, 2019, 05:05:43 pm ---Fine. Let's take timer that is running at (precise) 72 MHz. Now please show how to generate 993 KHz, with 0.1% accuracy. By accuracy I mean frequency accuracy, output obviously w/o significant jitter.
--- End quote ---
Oh, I see what you're asking. You want infinitely small increments of frequency. Sounds like you're headed for a pure analog solution!
NorthGuy has already pointed out that PWM's often have much finer increment control. And looking back at the section of the STM32's spec sheet that I quoted, you'll note it specifically mentions "PWM" as another mode it supports. I just glanced at that spec sheet again, and PWM is offered not only on those timers, but others that are included in the STM32 family as well.
"By accuracy I mean frequency accuracy" (your words to me) is different from "arbitrarily small frequency increments". I stand by my earlier comment that a hardware timer-based approach can, indeed, deliver 0.1% frequency accuracy for those quantum frequencies it can select. However, if your definition of "frequency accuracy" is now changing to "arbitrarily small frequency increments" then you're going to need analog because no digital approach - not even a dedicated DDS chip - has infinitely small quanta.
EDIT: Perhaps we can all get off the pedantic train here and wait for the OP to more clearly define his needs.
ogden:
--- Quote from: IDEngineer on May 24, 2019, 05:50:01 pm ---EDIT: Perhaps we can all get off the pedantic train here and wait for the OP to more clearly define his needs.
--- End quote ---
He did define his needs clearly enough, in first few sentences of his post:
--- Quote from: dpenev on May 20, 2019, 07:32:10 am ---One of the requirement is to generate square wave with arbitrary frequency in the range 1KHz - 1MHz.
I need something like 0.1% accuracy of the frequency control.
--- End quote ---
[edit] What you say about DDS is so wrong:
--- Quote ---However, if your definition of "frequency accuracy" is now changing to "arbitrarily small frequency increments" then you're going to need analog because no digital approach - not even a dedicated DDS chip - has infinitely small quanta.
--- End quote ---
Tuning granularity even for cheapest, most basic DDS IC AD9837 is (excerpt from DS): The frequency registers are 28 bits wide: with a 16 MHz clock rate, resolution of 0.06 Hz can be achieved.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version