NCO to generate square wave - Page 1
Forum section: electronics / general

author: Evan.Cornell
author_rank: Regular Contributor
timestamp: December 08, 2021, 01:56:46 am
content: I need to produce N (probably less than 16) number of square waves, fixed 50% duty cycle with frequency of 1MHz, but each independently variable in frequency with steps of no more than 100Hz, within ~50kHz on either side of 1MHz.Are N channels of numerically controlled oscillator (NCO) blocks within FPGA a plausible method to do this?I found a VHDL snippet herehttps://gist.github.com/RickKimball/45d0753a900f92d5fdd836746062588cthat seems to be rather compact.

author: langwadt
author_rank: Super Contributor
timestamp: December 08, 2021, 02:25:37 am
content: all you need is an adder per output, the MSB is you squarewavebut you will have jitter of +/- a clockcycle

author: oPossum
author_rank: Super Contributor
timestamp: December 08, 2021, 02:32:31 am
content: Skyworks (formerly Silicon Labs) has several clock generator chips with multiple outputs. Many with 8, a few with 12.https://www.skyworksinc.com/en/Products/Timing-Clock-Generators

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 08, 2021, 03:08:08 am
content: A resolution of 100 Hz? Wow. The difference between the period of a 1 MHz signal and 1 MHz + 100 Hz is just about 100 ps.You can get an average frequency with that resolution using the technique mentioned above without requiring an actual resolution of 100 ps (which would require a base clock of 10 Ghz!!), but then you'll get inevitable jitter. What is the acceptable jitter here?

author: BrianHG
author_rank: Super Contributor
timestamp: December 08, 2021, 03:47:34 am
content: If you want jitterless, then you will end up having to use long-division low frequency phase comparator (like 100hz) PLLs designed for this purpose. Though, you would need 16 of them and an MCU to control all or for the strict phase comparator with VCO, you would need an FPGA to generate all 16 reference 100hz output signals + the high frequency 1MHz signals.Using a DDR trick with CycloneIV/MAX10, I have generated 1ns step accurate (equivalent to a 1GHz base clock) outputs running the core clock at 500MHz. Since you need 100ps, as SiliconWizard said, you would need an FPGA with a 10gbps transmitter to pull this off with 0 added jitter where as my trick would generate an additive corrective 1ns jitter once every 1-9 output toggles unless you tune the output right on any integer 1000hz offset of 1MHz.

author: NorthGuy
author_rank: Super Contributor
timestamp: December 08, 2021, 06:16:44 am
content: With delay elements and/or phase shift, it should be possible to achieve 100 ps resolution, may be even better.

author: Someone
author_rank: Super Contributor
timestamp: December 08, 2021, 08:15:49 am
content: Quote from: Evan.Cornell on December 08, 2021, 01:56:46 amAs above, the answer is yes if you either:don't care about jitterordo some in depth/complex use of the hard resources

author: Evan.Cornell
author_rank: Regular Contributor
timestamp: December 08, 2021, 02:12:14 pm
content: Thanks all for the replies. I don't think jitter is a huge concern for the application.. the purpose of the tunable square wave frequencies is to be able excite a transducer right at its resonant point, which will vary based on individual transducer characteristics. I think as long as the average frequency is tunable, cycle-to-cycle jitter shouldn't be too detrimental to the application.I have definitely seen the SiLabs / Skyworks line of clock generators, but availability is awful right now, so was exploring the FPGA/NCO option, hopefully with one of the various sub-$10 parts from Lattice that seem to be relatively easily available these days.

author: ejeffrey
author_rank: Super Contributor
timestamp: December 08, 2021, 04:40:40 pm
content: Is it important to not unintentionally excite a different transducer? A simple clocked square wave generator will have quite some spurs. If that is a problem you will probably need to do something better.Do you want to do this with just the FPGA or can you use external components?The bog standard way to do this is a fractional N PLL. You can get 1 Hz resolution without using an excessively low phase comparison frequency.Another approach is to use a NCO + DAC to generate a sine wave, low pass filter it and then use a high speed comparator to make the square wave. Even a low resolution DIY resistive ladder DAC will help.Depending on your transducer characteristics you could forgo the fpga entirely and make oscillator circuits using the transducer itself as the frequency selecting element.Each take substantial extra components for 16 channels but will produce more spectrally clean output if that is important.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 08, 2021, 05:31:52 pm
content: Quote from: Evan.Cornell on December 08, 2021, 02:12:14 pmThen definitely try the approach with a phase accumulator. The higher the base clock, the lower the jitter you'll get. A 100 MHz base clock sounds reasonable here for what you want to achieve and should be no problem even on a modest FPGA. It's a couple hours work, so I'd definitely prototype this first and see if it fits your requirements.

author: Evan.Cornell
author_rank: Regular Contributor
timestamp: December 08, 2021, 08:51:11 pm
content: Quote from: ejeffrey on December 08, 2021, 04:40:40 pmI don't think this is an issue for my application.Quote from: ejeffrey on December 08, 2021, 04:40:40 pmAny implementation examples here? The idea is to adjust the frequency to hit each transducer's specific resonant point, but if there's an analog way to do this without manual adjustment, that would be most desirable.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 08, 2021, 09:11:56 pm
content: Are those ultrasound piezo transducers?

author: Evan.Cornell
author_rank: Regular Contributor
timestamp: December 08, 2021, 09:12:30 pm
content: Quote from: SiliconWizard on December 08, 2021, 09:11:56 pmYes.

author: hamster_nz
author_rank: Super Contributor
timestamp: December 08, 2021, 10:14:08 pm
content: On Xilinx 6 or 7 series the SelectIO SERDES is good to about 1Gb/s.500 bits on, 500 bits off gives 1.000MHz499 bits on, 500 bits off gives 1.001MHz (not perfectly square duty cycle, but near enough)499 bits on, 499 bits off gives 1.002MHzThat is with minimal jitter.499 bits on, 500 bits off, followed with nine blocks of 500 bits on, 500 bits off = 10 pulses over 9,999 cycles = 1.000100 MHz with some jitterIf that meets your needs, then it is perfectly achievable with a little bit of actual design work.

author: Evan.Cornell
author_rank: Regular Contributor
timestamp: December 08, 2021, 10:58:48 pm
content: Do any of the regular pins on spartan 7 work in that 1Gbps mode?

author: hamster_nz
author_rank: Super Contributor
timestamp: December 08, 2021, 11:48:01 pm
content: > Do any of the regular pins on spartan 7 work in that 1Gbps mode?Yes. Different grades have different speeds.See table 15 (on page 15) ofhttps://www.xilinx.com/support/documentation/data_sheets/ds181_Artix_7_Data_Sheet.pdffor specs.

author: BrianHG
author_rank: Super Contributor
timestamp: December 08, 2021, 11:55:52 pm
content: Dont know about spartan, but with altera, I do know that you can get the DDR DQ pins to do the 1GHz unbalanced, IE 2.5v or 3.3v outputs. Meaning a 1ns jitter with with a NCO. (Note that I have 2 projects online here at EEVblog which do run CycloneIV and Max10 at this 1GHz with read/write data, so I know it can be done. I got the bottom end slowest CycloneIV to transmit HDMI at 1.08GHz through regular DDR-DQ pins.)It is probably the same with Spartan unless you use LVDS dedicated transmitters which are balanced low voltage outputs. LVDS usually means 1.8 or 1.5v output, but 2 of them per channel which will need a differential receiver to amplify each channel. Spartan 7 is a faster FPGA than CycloneIV/MAX10. I would only choose MAX10 if you want low power and no bootprom as 16 NCOs running at 100MHz driving a 10:1 serdes transmitter would only draw something like 50-100ma VCC on a Cyclone/Max10. Though, the MAX10 will require a compiler workaround to run it's outputs at 1GHz.

author: langwadt
author_rank: Super Contributor
timestamp: December 08, 2021, 11:57:59 pm
content: Quote from: Evan.Cornell on December 08, 2021, 10:58:48 pmafair SERDES and DDR is available on all pins (~1Gbps need LVDS so pair of pins)

author: hamster_nz
author_rank: Super Contributor
timestamp: December 09, 2021, 07:56:41 am
content: Quote from: langwadt on December 08, 2021, 11:57:59 pmBut when you are generating a square wave at about 1MHz +/-50kHz then a single-ended output buffer will be just fine.