| Author |
Message |
bod
Joined: Apr 28, 2009 Posts: 148 Location: Glasgow
|
Posted: Thu Jul 22, 2010 11:50 am Post subject:
DCO square wave to triangle/sawtooth wave Subject description: is it possible? |
 |
|
hello,
its been a wee while since i've been on here, work, a few job interviews and life keep getting in the way of my synth building hobby/addiction!
anyway, a friend and i were discussing building a cheap simple synth for him the other day, preferably analogue, but happy with lunettas and any other style of modulation/wave form generation etc thrown in.
he thought about using an arduino to generate square waves across 3 octaves as it would be easy to control via midi, and then convert the square wave to triangle or/and sawtooth waves with analogue circuits, into a filter stage (analogue LP VCF) and then a VCA. a poor mans 303 he called it!
my initial reaction was "aye, that'll work no bother with an op amp integrator" but then it dawned on me it wouldnt. so we wired it up anyway as he didnt quite understand my reasons, using a bipolar PSU, a tl072 opamp with a resistor and capacitor in the usual integrator fashion.
but sure enough, as the square wave frequency increases, the triangle waves amplitude decreases, and quite drastically so. the arduino code we used puts out a 0-5v square at a 50/50 pulse width, but over one octave the amplitude of the triangle wave drops 1.5 volts from +/-3v to +/-2.25v, and its quite noticable to the ears.
we initially thought that a standard comparator/integrator lfo works in much the same way, there fore why wouldnt this, but the rate pot on an lfo obviously reduces the square waves amplitude at low frequencies but increases the amplitude at higher frequencies and keeps everything at a steady amplitude all round. i think.... (well, amongst other things anyway like resistor values)
so, now i am determined, that even though it may not be the best route to take, I want to make the bugger work as i refuse to be beaten by an AVR chip!! (he on the the other hand couldnt care less and is happy to move on...)
so the options now are to rewrite the code to output a falling pwm output, run through a low pass filter to convert the falling PWM signal into a reasonable sawtooth at set frequencies across 3 octave, which can then be used as a waveform itself, and also convert it to a square wave with variable PWM through a comparator circuit.
or:
(and it took me a long time to get here but thanks for reading....) does anyone have any suggestions on how to wave shape a square wave to a triangle or sawtooth without loosing amplitude by means of an analogue circuit? |
|
|
Back to top
|
|
 |
Boogdish
Joined: Sep 21, 2009 Posts: 122 Location: Bloomington, IN
|
|
|
Back to top
|
|
 |
bod
Joined: Apr 28, 2009 Posts: 148 Location: Glasgow
|
Posted: Fri Jul 23, 2010 12:51 am Post subject:
|
 |
|
| sweet, i'll give that a try and let you know how it goes! |
|
|
Back to top
|
|
 |
Tim Servo

Joined: Jul 16, 2006 Posts: 924 Location: Silicon Valley
Audio files: 11
|
Posted: Fri Jul 23, 2010 1:09 am Post subject:
DCO square wave to triangle/sawtooth wave |
 |
|
Hey Bod,
That's actually not a simple task (as you've found out). What you really need to do is change the RC time constant of the integrator as the square wave frequency changes. Since you're using a micro to generate the square waves, I can think of two possible methods to do this:
1) Have the processor generate an analog control voltage proportional to the square wave frequency. Use that control voltage and an OTA chip like the 13700 or SSM2164 as a voltage controlled resistor to change the time constant. The control voltage wouldn't need too much accuracy, and could be generated with a simple PWM output.
2) Have the processor switch different resistor values in and out with analog switches. You might be able to get away with one different resistor for each octave, depending on how much gain change you can live with. The processor would switch in different resistor values depending on what octave the square wave was playing in.
Anyway, both of these solutions do a similar thing, but solution 1 is continuously variable, and would give better results (but it would be more complex). Solution 2 might be simpler, but it might not work as well.
Tim (continuously variable) Servo |
|
|
Back to top
|
|
 |
bod
Joined: Apr 28, 2009 Posts: 148 Location: Glasgow
|
Posted: Fri Jul 23, 2010 2:21 am Post subject:
|
 |
|
cheers tim, i had thought about an OTA option also, which i recon would be easy enough to implement through pwm as you say, and by running it through a low pass filter and a voltage follower into the the OTA to lower the amplitude.
working out the levels would be easy enough with an o-scope for the gain.
i'm at work just now but thinking about the previous suggestion i think i'll hit the same problems as before witht he integrator.
lots to try this weekend!  |
|
|
Back to top
|
|
 |
richardc64

Joined: Jun 01, 2006 Posts: 679 Location: NYC
Audio files: 26
|
Posted: Fri Jul 23, 2010 9:14 am Post subject:
|
 |
|
Getting a sawtooth from a square can be quite simple. Start with a square twice the frequency you want, divide by 2 and sum the 2 squares in the right proportion and you get a 4-step "sawtooth." Start with a square 4 times the desired frequency and add another divide-by-2 and you get an 8-step saw. A small cap can smooth the steps, but this effect will also be frequency dependent.
The dividers can be external or I imagine the Arduino itself could do the division(s). _________________ Revenge is a dish best served with a fork... to the eye |
|
|
Back to top
|
|
 |
slabman
Joined: Sep 01, 2005 Posts: 102 Location: UK
|
Posted: Fri Jul 23, 2010 1:44 pm Post subject:
|
 |
|
This might work. The approach is a little indirect, but it gets there in the end. First, look at René Schmitz's 3 phase LFO -
http://www.uni-bonn.de/~uzs159/triphase.html
This is | Quote: | | a phase shift oscillator built arround three gates of a 4069. The resistors which determine the frequency have been replaced by switched capacitors. The arrangement of the switch and the cap simulates a resistance, when a clocking frequency is applied to the switch |
You'd feed the square wave from the DCO in, in place of the simple vco in the diagram. The timing capacitor would have to change to bring the oscillator up to the audio range.
You'd now have 3 sinewave outputs. Unfortunately we now enter the realms of even more speculative speculation. This reference suggests that sine to triangle conversion is possible -
http://www.ingentaconnect.com/content/klu/34/2006/00000025/00000006/00001209
Maybe the phrase 'hyperbolic tangent behavior' will prompt some genius to tell us how this can be done!
Alternatively, since Mr Schmitz's circuit shows that strapping a switch across a capacitor makes a variable capacitor, perhaps this method can be applied to a classic comparator/integrator oscillator. It 'should' be immune to the frequency-dependent amplitude problem.
Alternatively, read Tom Wiltshire's great explanation of how the Juno DCO works here - http://www.electricdruid.net/forums.html?page=info.junodcos |
|
|
Back to top
|
|
 |
bod
Joined: Apr 28, 2009 Posts: 148 Location: Glasgow
|
Posted: Sat Jul 24, 2010 2:33 am Post subject:
|
 |
|
wow, some great ideas, cheers boys!
i'm liking the method used by the juno DCO, its similar to the idea tim had with the OTA to use a proportional CV to control the amplitude, but the juno version is going to require a few experiments with the charging capacitor value. i'm guessing the higher the cv, the shorter the amount of time the capacitor takes to charge and keeps the amplitude level.
the dividing of the the square wave one could be done with a 4017 or a flip-flop or two, with appropiate resistors on the outputs and summed with an opamp i presume richard? coding is not my strong point to be honest, so while it is likely the arduino can do this, i'll stick to hardware. i know how to deal with that side of things!
the sinewave idea looks nice too! oh decisions decisions! |
|
|
Back to top
|
|
 |
slacker
Joined: Nov 18, 2007 Posts: 301 Location: England
Audio files: 11
G2 patch files: 1
|
Posted: Sat Jul 24, 2010 3:23 am Post subject:
|
 |
|
Have a look at the schematic for the picsynth that use the divider with mixer resistors idea.
You could also try feeding the the square wave into a CD4046 set up like the glide circuit from the Wasp http://www.elby-designs.com/wasp/glide.pdf you can then tap off a saw tooth or triangle from pins 6 and 7 like in the Wooglebug or Thomas Henry's new X4046 VCO. |
|
|
Back to top
|
|
 |
bod
Joined: Apr 28, 2009 Posts: 148 Location: Glasgow
|
Posted: Sat Jul 24, 2010 10:00 am Post subject:
|
 |
|
the pic synth is pretty cool, ive never seen that one before! its kinda what we were aiming at in a lot of ways. maybe i should give up now...
anyway, i dont have any counters to hand, but i have tried out the 4046 with some success (that thing just confuses me sometimes...) and the juno method, which seems to work a treat so far!
at present i only have a pot adjusting the voltage that the capacitor charges from and it needs to be manually adjusted for each note. but i can get nearly identical amplitudes for each note over 3 octaves, and the square/pulse outputs work as well, from roughly 5% to 90% pulse width via a pot. i still need to muck around with the limiting resistors for the pwm pot.
i still need to try out the pwm/cv for adjusting the capacitor voltage, which may prove to be the only down fall...
cheers, bod. |
|
|
Back to top
|
|
 |
richardc64

Joined: Jun 01, 2006 Posts: 679 Location: NYC
Audio files: 26
|
Posted: Sat Jul 24, 2010 10:52 am Post subject:
|
 |
|
| bod wrote: | | the dividing of the the square wave one could be done with a 4017 or a flip-flop or two, with appropiate resistors on the outputs and summed with an opamp i presume richard? |
I was thinking of flip-flops, 4013s or such. The resistor weighing is binary: each division gets a series resistor half the value of the previous one. For more than 4 dividers an R2R net becomes more practical.
But with a 4017 you'd have 10 equal spaced steps. With a pot on each output (cough: Baby10) you could dial up any arbitrary wave shape. The disadvantage is you'd have to start with a squarewave 10X the frequency you want.
Here's a stepped triangle idea http://www.geofex.com/article_folders/lfos/psuedorandom.htm#Regular%20Stair%20Step%20LFO _________________ Revenge is a dish best served with a fork... to the eye |
|
|
Back to top
|
|
 |
bod
Joined: Apr 28, 2009 Posts: 148 Location: Glasgow
|
Posted: Thu Aug 05, 2010 12:47 am Post subject:
|
 |
|
Morning,
I've been playing around with different methods for this, and so far the OTA method for limiting the amplitude of the lower notes and the Juno method seem to be my preferred options.
The stepped triangle wave worked a treat with a 4015 counter in the way as the RG Keen examples, but when it came to creating a pulse wave via a comparator, the pwm was also stepped to the same number as the triangle, which wasn’t to my liking unfortunately. the more steps the better i guess, but 8 just wasnt enough, although the triangle wave sound it produced was pretty good.
The other suggestion for a triangle convertor suffered the same fate as the integrator method I used initially and requires the OTA to level off the lower notes to the same as the higher notes.
I think after much playing around and tinkering I'm going to persevere with the Juno DCO trick. I'll post a schematic for what I've got working tonight. The PWM output from the arduino gets filtered through a low pass filter and buffered and feed into the capacitor, so I can get 5 good octaves with one resistor instead of the 3 different resistors for the range that the Juno uses. There is probably a very good reason for the use of 3 different values, but for the sake of keeping things simple just now I'll stick with the one, which leaves me with C1 to B5 in the note range which isn’t too shabby!
Now I'll have to tinker about with implementing an LFO, which wasn’t in the initial plan, but I'm hooked on this now! and thats a whole other subject in itself!! maybe this should be moved to the micro processor forum?
Cheers for all the help and suggestions so far! |
|
|
Back to top
|
|
 |
|