Sawtooth/ramp waves with fixed amplitude from sine or square clock source? - Page 1
Forum section: electronics / projects

author: osvaldo
author_rank: Newbie
timestamp: August 01, 2013, 12:08:32 pm
content: Hi all,this is my first post in the forum, but I've been a EEVBlog fan for a long time. I hope someone can help me out!A bit of background info:I have created a DDS based signal generator (Using PIC MCU to drive a AD9833 for DDS output). The generator is capable to produce sine, triangle and square waves up to 12.5Mhz. However the output at higher (more than 2 Mhz) frequencies is far from perfect (nowhere near the desired wave forms). Anyway, currently I don't need more than 2MHz.I have added a 7-th order elliptic filter to smooth the sine output from the DDS. After th? filter I use a Schmitt trigger in order to obtain a rectangular wave forms (I can adjust the duty circle as well). The problem is I don't know how I can create sawtooth/ramp or a triangular wave forms based on the DDS signal as a reference clock source (either rectangular or the filtered sine). My most important requirement is for a sawtooth waveform, with adjustable frequency and a constant amplitude in the frequency range from 1Hz to 2MHz.My query is:Is there a cheap, easy for implementation solution, which could generate sawtooth/ramp waveforms (triangle as an extra is welcome too) with linear slope, adjustable frequency and fixed amplitude in wide frequency range?In one of the forum topics I read a post:https://www.eevblog.com/forum/blog/eevblog-483-microcontroller-voltage-inverter-tutorial/msg247080/#msg247080,which suggests usage of 4046 PLL chip, that generates a higher frequency square wave, which tracks the input and a 4024 binary counter, which is then fed into a cheapo r2r DAC consisting only of a resistor ladder. Incorporating that, possibly I could generate arbitrary frequency sawtooth with fixed amplitude. However the frequency range that I could get from 4046 PLL will not cover requirements (this is my opinion based on the formulas given in 4046 datasheet, that specify the frequency range). It will be best if I could cover the range from 1Hz to 2MHz.Can anyone recommend something, which could do this?Sorry for the long first post, I hope that I managed to explain the problem (excuse me for my English, as it's not my native language).Thanks,Osvaldo

author: Rerouter
author_rank: Super Contributor
timestamp: August 01, 2013, 12:19:06 pm
content: If you want linear sawtooth waveforms over a wide frequency range your only real option would be with a controlled current source, feeding a capacitor and a nice quick npn or mosfet to slam it down,you would then buffer that output with an op ampas for keeping amplitude constant that comes down to what you can get away with, and matching the frequency steps of your chip to your ladder dac, which sadly is 28 bits which means you ideally want at least 22 bits for reasonable amplitude control,

author: fcb
author_rank: Super Contributor
timestamp: August 01, 2013, 04:51:22 pm
content: No. Not a simple/cheap answer.If you don't care to much about fStab, then find a MAX038. If you care about long-term stability then PLL to a reference (which could be generated by your DDS). MAX038 is NRTD/obsolete.You can build a discreet ramp generator (or probably better a triangle core) and drive it from your DDS (some sort of servo on the constant-current source required of you need a level level).You need to provide more detail really.

author: osvaldo
author_rank: Newbie
timestamp: August 02, 2013, 02:43:09 pm
content: Quote from: fcb on August 01, 2013, 04:51:22 pmI previously came across MAX038 based project, but I could not find the chip available for sell, also its analog setup of the frequency dropped me from using it.I wanted to create signal generator for common wave forms like wave/square/triangle/saw and ability to set the frequency in discreet steps - 1Hz. The DDS approach allowed me to do my second requirement - to set the frequency in 1Hz steps and to have somewhat stable and easily adjustable frequency (if it the freq drifts I could easily with small steps make it correct again).Quote from: fcbIndeed I like th? idea for a discreet ramp generator (or triangle core with adjustable symmetry) drived from the DDS signal, unfortunately I don't know how to do it. I think this will probably involve some gain adjustment of the signal in order to have equal amplitude across wide freq range... for this I definitely need help

author: Odysseus
author_rank: Regular Contributor
timestamp: August 03, 2013, 06:52:23 am
content: Integrating a square wave and compensating the amplitude of the resulting triangle wave sounds tricky at best, so I would follow the suggestion put forth by the others and use a PLL.Take a look at the more modern 74HCT9046:www.nxp.com/documents/data_sheet/74HCT9046A.pdfI think you'd like to see the waveforms shown in figure 7 of that datasheet. Technically, the 9046 generates a pure triangle wave on it's timing capacitor, but it's not referenced to ground. It can be extracted using a differential amplifier on the C1A and C1B pins.The other problem is the tuning range. Normally, a VCO has a linear relationship between input voltage and output frequency. Instead, you can instead use a BJT, which has an exponential voltage to current transfer function, to replace the resistor which normally determines the PLL tuning range (R1 in the datasheet). You can also read about more a more sophisticated exponential current source here:http://www.uni-bonn.de/~uzs159/expo_tutorial/So, instead of connecting the filtered output of the phase detector to VCO_IN like normal, connect it to the base of a BJT through an opamp follower. The collector of the BJT is then used in place of R1. The emitter is tied to ground.Unfortunately, this simple solution will not allow duty cycle variations in the triangle wave.

author: daveatol
author_rank: Regular Contributor
timestamp: August 03, 2013, 07:30:33 am
content: For the PLL, how would you filter the phase signal over the range of 1Hz to 2MHz effectively? You'd need a huge time constant to handle the 1Hz signal which would mean you'd probably be waiting maybe 10 seconds for a lock.Do you need all waveforms at once? It's obviously easier just to get the sine and sawtooth waveforms from the DDS (sine can still pass through your elliptic filter), and derive the squarewave from the sine or sawtooth waveforms.

author: fcb
author_rank: Super Contributor
timestamp: August 03, 2013, 06:19:36 pm
content: Quote from: daveatol on August 03, 2013, 07:30:33 amPLL pretty much won't work for 1Hz to 2MHz, without some huge compromises.If you want that sort of range, then I would probably stick with the DDS (especially if you have it working) and figure out the ramp generator. Split the problem/range into manageable chunks, and as you have a micro, probably do something like this:Make 4+ sections, that cover the ranges (for example!): 1Hz to 100Hz, 100Hz to 10KHz, 10KHz - 200KHz, 200KHz - 2MHz. For each section, build:1. Build a ramp generator (basically a *constant-current source driving a capacitor), drive the ramp/reset from your DDS.2. Build a peak detector, feed the output of this into your micro.3. *Build a digitally variable constant current source - pretty simple to do with a 16bit DAC, opamp, transistor.You can probably reuse the DAC across the ranges, also the peak-detector - but you'll want to optimize each of the ramp generators. Try and keep the peak currents to 100-200uA, perhaps more on the fast sections.Then you could use several control strategies:fast sweep - use a table of current settings to maintain the correct amplitudeaccurate - use the peak-detector to automatically adjust the current to hit the correct amplitudeyou could also create a hybrid of the above.Making and adjustable duty-cycle version is more complex, but quite possible. Get a simple one running first though! You might also want to have overlapping ranges, and perhaps one range that covers audio-friendly sweeps (20Hz to 20KHz).As for DAC's - use some low-cost 24bit stereo parts, or perhaps you have a spare DDS that you can set for DC (unlikely to be more than 12bit though).

author: w2aew
author_rank: Super Contributor
timestamp: August 04, 2013, 12:38:47 am
content: I've got a circuit on my bench that I was planning to do a video on when I return from vacation. It is a simple constant amplitude sawtooth circuit that uses a pair of current sources (actually a current sink and a current source) being fed into a diode switch configured as a SPDT into a capacitor, whose voltage is monitored by a comparator with hysteresis. The output of the comparator controls the state of the diode switch. The hysteresis sets up the switching thresholds, so the amplitude of the sawtooth is constant. The value of the cap and the two current sources determines the frequency and symmetry of the sawtooth.It's a nice little circuit to discuss current sources, diode based switching and comparator hysteresis, so that's why I thought I'd put a little tutorial video around it. Hopefully in a week or two when I return from vacation.

author: TinkeringSteve
author_rank: Frequent Contributor
timestamp: August 04, 2013, 12:23:11 pm
content: Quote from: Rerouter on August 01, 2013, 12:19:06 pmHave you done this successfully, and could share a working schematic?I myself am interested in audio range application for this only. This is how the last "sorta analog" synths of the 80's supposedly worked (and from the ramp creating other waveforms), and I have this in the back of my head for some time, wanted to play with that. I've seen only a block schematic of this, alas.

author: fcb
author_rank: Super Contributor
timestamp: August 04, 2013, 05:00:15 pm
content: Quote from: TinkeringSteve on August 04, 2013, 12:23:11 pmYup. Lots of synth's did this back in the day. Look up Rolands Juno 6 / 60, there are probably schematics published. However what I would say is (unless you need a very stable frequency) or really want to build a VCO - you'd be better off with an ICL8038 or XR2206/2209.

author: TinkeringSteve
author_rank: Frequent Contributor
timestamp: August 04, 2013, 10:28:17 pm
content: Quote from: fcb on August 04, 2013, 05:00:15 pmWell, I kind of like this DCO concept and some day wanted to try it out. Otherwise I have my software oscillators.But those chips, thanks, I'll keep them in the back of my head, they have nice ranges for some other applications as well.

author: fcb
author_rank: Super Contributor
timestamp: August 05, 2013, 12:46:24 pm
content: Software based oscillators are great for SINE, and some band-limited versions of other waveforms. But nothing software-based beats analog-based sawtooths and square waves to have on the bench.

author: w2aew
author_rank: Super Contributor
timestamp: August 12, 2013, 03:49:12 am
content: Apologies for resurrecting an older thread - but I thought that some of the concepts in this video (which I just posted for a friend) might be of interest to followers of this thread.This video is a circuit tutorial on a constant amplitude sawtooth generator using current sources, diode switches and a hysteresis comparator...

author: beatle
author_rank: Contributor
timestamp: August 12, 2013, 02:27:11 pm
content: This is marvelous, w2aew! Thank you!