Electronics > Beginners
DIY Function Generator
ziplock9000:
--- Quote from: Brutte on January 14, 2017, 02:19:46 pm ---
--- Quote from: pandy on January 14, 2017, 01:31:51 pm ---(..)however nowadays with fast uC available i would rather replace discrete NCO by software and move RAM LUT to separate IC's (there is plenty asynchronous fast SRAM chips - bigger - better), add to this fast DAC and you may have arbitrary waveform generator.
--- End quote ---
That was the route I took.
I use STM32 microcontroller (STM32L-Discovery) as an arbitrary signal generator.
The uC comes with two 12-bit DACs that can go up to ~2Msps each (with external op-amp for gain and offset) so this is a double-channel generator. It is capable of generating 20-point sin(x) at 100kHz on each channel. Can be started externally or it can trigger a scope (good for sweeping frequency).
The nice thing is that such signal generator does not use CPU at all so it does not really matter how fast a uC is clocked (32MHz is ok). I just initialize timers and DMA and let it run in background.
--- End quote ---
Any chance you can share your design mate? Did you use external RAM to buffer the waveform or just generate it real-time?
I might do something similar with an arduino although with that I'd need an external DAC.
MarkF:
--- Quote from: Brutte on January 15, 2017, 11:36:59 am ---
--- Quote from: MarkF on January 14, 2017, 08:36:01 pm ---I built a DDS with an AD9834, a PIC18F2550 and a small OLED display.
--- End quote ---
I wanted to tie STM32L to USB and make some GUI for uploading ROM table and tweaking frequency on-the-fly but due to lack of time I prepare that data offline and just flash a uC.
--- End quote ---
I started trying to build an arbitrary generator but quickly found that the frequencies that I could generate was very limited by the update rate I could achieve for the DAC. 100KHz in your case . My range is limited to 1Hz to 1Mhz because I only used a 32MHz clock for the AD9834. A DAC with a SPI interface would be even more limiting.
Vtile:
I kind of return to my previous post... It would be actually interesting to build a function gen from operational amplifiers. I IIRC have seen many old OPA741 based ones floating around.. How good one of those design would be with more modern high stability, high linearity and high speed chips. Hmm... Anyone tried out or can daveCAD the idea as nonsense. The math behind the OPAs should be pretty much the same as in 1968 when 741 did pop out.
Brutte:
--- Quote from: MarkF on January 16, 2017, 12:23:51 am ---I started trying to build an arbitrary generator but quickly found that the frequencies that I could generate was very limited by the update rate I could achieve for the DAC. 100KHz in your case . My range is limited to 1Hz to 1Mhz because I only used a 32MHz clock for the AD9834. A DAC with a SPI interface would be even more limiting.
--- End quote ---
You cannot generate an arbitrary function with AD9834 at 32Msps as that would require 32MHz*8bit = 256Mbaud SPI! This chip can go that fast only by using internal memory (sine, square and triangle IIRC, + kind of sweep) so no arbitrary.
Arbitrary function generator has to be able to generate absolutely any programmable shape one can imagine. With that AD you are limited to the SPI speed (<3 MB/s for a PIC18F2550 at ~100% cpu load) so in theory you could reach 3Msps and 8-bit resolution max (IMHO).
--- Quote ---Any chance you can share your design mate? Did you use external RAM to buffer the waveform or just generate it real-time? I might do something similar with an arduino although with that I'd need an external DAC.
--- End quote ---
Sure. I'll try to include whole Eclipse project into a zip and attach here later (end of the week).
I am not sure how you are going to port that to arduino as it relies solely on the hardware available. I just fill registers (DAC, two TIMs, DMA and GPIO) with config data and press "start", CPU load is exactly 0%. This uC has similar peripherals to popular STM32F103RC if you necessarily need to port that to something else.
I did not have to use any external memory because STM32L152RB has 128kiB of internal flash. Even sampling 2Msps there is enough storage for 128k points (1 x 8bit) or 32k points (2 x 12bit) if you need that much. And there is still 16kiB room in SRAM for an application, if one ever needed such.
ziplock9000:
Thanks.
I might have a look around to see if there's a DAC + RAM module for the Arduino rather than going with a different uC architecture for the moment. I'd have the Arduino algorithmically populate the RAM and then output it via the DAC.
Complete noob question here.
Does using a uC->RAM->DAC avoid most (or all) of the filtering issues compared to using a real-time DDS+Crystal?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version