Author Topic: Sawtooth/ramp waves with fixed amplitude from sine or square clock source?  (Read 1514 times)

0 Members and 1 Guest are viewing this topic.

Offline osvaldo

  • Contributor
  • Posts: 6
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: http://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

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 1769
  • Country: au
  • Question Everything... Except This Statement
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 amp

as 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,
« Last Edit: August 01, 2013, 10:28:01 PM by Rerouter »

Offline fcb

  • Frequent Contributor
  • **
  • Posts: 719
  • Country: gb
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.


Offline osvaldo

  • Contributor
  • Posts: 6
...
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.

I 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: fcb
...
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).

Indeed 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

Offline Odysseus

  • Regular Contributor
  • *
  • Posts: 92
  • Country: us
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.pdf  I 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.
« Last Edit: August 03, 2013, 04:56:08 PM by Odysseus »

Offline daveatol

  • Regular Contributor
  • *
  • Posts: 59
  • Country: zw
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.

Offline fcb

  • Frequent Contributor
  • **
  • Posts: 719
  • Country: gb
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.

PLL 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 amplitude
accurate - use the peak-detector to automatically adjust the current to hit the correct amplitude
you 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).

Offline w2aew

  • Super Contributor
  • ***
  • Posts: 1024
  • Country: us
  • I usTa cuDnt speL enjinere, noW I aR wuN
    • My YouTube Channel
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.
======================================
YouTube channel: http://www.youtube.com/w2aew

Offline TinkeringSteve

  • Regular Contributor
  • *
  • Posts: 73
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 amp

as 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,

Have 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.

Offline fcb

  • Frequent Contributor
  • **
  • Posts: 719
  • Country: gb
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 amp

as 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,

Have 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.

Yup. 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.

Offline TinkeringSteve

  • Regular Contributor
  • *
  • Posts: 73
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 amp

as 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,

Have 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.

Yup. 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.

Well, 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.

Offline fcb

  • Frequent Contributor
  • **
  • Posts: 719
  • Country: gb
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.

Offline w2aew

  • Super Contributor
  • ***
  • Posts: 1024
  • Country: us
  • I usTa cuDnt speL enjinere, noW I aR wuN
    • My YouTube Channel
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...

Circuit tutorial - sawtooth generator w/ current sources, diode switches and hysteresis comparator
======================================
YouTube channel: http://www.youtube.com/w2aew

Offline beatle

  • Contributor
  • Posts: 23
  • Country: lv
This is marvelous, w2aew! Thank you!


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf