I'm done testing the DCO that I got from JLCPCB. It worked flawlessly - after fixing a few firmware bugs that is.
I had to change the function of Data Ready to SPI Chip Select, that fixed some startup problems when the DCO had started before the main MCU powered up. Amplitude tuning works incredibly well and sync hard-syncs like it should.
I did however realise a few things:
The current setup with a 56k charge-voltage-to-current converter resistor and a 1nF integrator cap means we cannot reach 20kHz with an amplitude 0-10V. Also, the MCU draws a lot of current, around 150mA it seems. The current firmware allows 8Hz to 8kHz approx.
In addition, the circuit has both an MCU and a DAC, so if we could tap the DAC directly we could make a wavetable oscillator of sorts.
For version 1.4 I did a lot of improvements:
- Exposing the DAC output and changing the buffer resistors from 47k to 22k. The DAC can only drive 60k load, so by reducing the load for the internal buffer we can hopefully connect a second, external buffer that can be used as a digital audio output.
- I've also exposed the buffered dac output. The cap is already exposed in both ends. This makes it possible to connect a resistor in parallell with the charge resistor, to increase the current to the cap.
- All DAC SPI pins have been exposed
- Three utility pins on the MCU has been exposed, to make debugging easier (connecting leds etc)
- To reduce current consumption, it should also be possible to run the device at 3.3v, and reducing the crystal frequency from 32MHz to 16MHz. This requires a rewrite of the DCO firmware, but nothing too complicated.
I've ordered 40 of these from JLCPCB, fingers crossed :-D
Showing posts with label saw wave. Show all posts
Showing posts with label saw wave. Show all posts
Tuesday, June 9, 2020
Monday, September 25, 2017
Xonik Waveshaper - breadboarded version
I finished breadboarding the waveshaper last night. Here is the schematics (not bug checked though) and a few photos of the output waveforms from the sub oscillator. The saw wave looks like crap but that is because I used a function generator without saw output as the source of the original wave (using a triangle wave with a very unbalanced center in place of the saw). It will look a great deal better with a real saw wave input.
![]() |
| Full waveshaper circuit. Note that the sub saw output has the same polarity as the input. It is also possible to get an inverted output. |
![]() |
| Square wave (top) and square wave sub oscillator |
![]() |
| Pulse wave and square wave sub oscillator |
![]() |
| 1 oct down and 2 oct down saw waves. |
Sunday, September 24, 2017
Coming soon: the Xonik Waveshaper
On my breadboard today: The Xonik Waveshaper - insert a non-centered 0-10V saw wave from the Xonik DCO and you'll get the following (centered) waves:
- Saw
- Inverted saw
- Triangle
- Sine
- Pulse/square with VC-PWM and VC amplitude (no VCA needed)
- Sub oscillator with square -1oct, square -2 oct, saw -1 oct and saw -2 oct.
The current triangle/sine circuit is based on the Jupiter 8 and Yusynth modular, the sub oscillator is a simplified version of the Xonik Sub oscillator. The pulse circuit amplitude control idea (but not circuit) is lifted from the Juno.
Wednesday, August 2, 2017
DCO: Switching to JFET to try to improve low frequency amplitude
To try to fix the issue I'm having where the saw wave amplitude is too low at low frequencies, I decided to redesign the core using a JFET in place of the BJT that resets the integrator.
I found no p-channel JFET in my parts box, but I had plenty of the J112 n-channel JFETs, so to make things easier I decided to go with the yusynth design.
The Yusynth design however, has a 0-5V saw wave, whereas mine is 0 to -10V. To make sure things would still work, I changed the core ever so slightly to get a 0-10V:
instead of tapping the charge voltage directly from the DAC using a positive opamp buffer, I switched to a unity gain negative amplifier. This would sink current instead of sourcing it, changing the charging direction. To make this works one also have to replace the 2n3906 PNP transistor with a 2n3904 NPN (One should also switch the polarity of the timer output, but as both a positive and negative going spike are generated, just slightly offset in time, this was not required for testing).
But testing this, I got a big surprise - the low frequency amplitude was no longer too low - it was too high! Previously I had to increase the DAC value from 60 to 80-something, now I had to reduce it from 60 to 48 (steps times 5V/65536).
This made me less certain that switching to a JFET would improve anything, but I still decided to try it.
I added an LM311 comparator, and set its negative input to 0.118V using a 120k and a 4k7 resistor. This would assure that when the positive input was just slightly higher than 0V, the output would spike up to 15V, and when the input was 0V the output would be -15V - similarly to the yusynth circuit, where the comparator outputs a negative voltage to turn off the JFET. The circuit worked instantly (!), but as suspected, nothing changed.
So, now I guess I've ruled out the reset transistor as the cause of the offset. Also, the fact that the amplitude error changes when I swap the charging polarity, makes me believe that the cap is not at fault either (though I will still check this).
That leaves either the DAC (which is unlikely for the same reason as the CAP) or the opamp buffer.
It could also be that a small difference in the power lines (measured to +15.01 and -15.00 volts) could cause this, I don't know. I will try recalibrating and also try different opamps to see if that changes anything.
For reference: Here is the original breadboarded circuit with the 0 to -10V output. I have since added the missing 2R2 resistor, however, that changed nothing. The DAC is connected where the 20k pot is in this drawing
I found no p-channel JFET in my parts box, but I had plenty of the J112 n-channel JFETs, so to make things easier I decided to go with the yusynth design.
The Yusynth design however, has a 0-5V saw wave, whereas mine is 0 to -10V. To make sure things would still work, I changed the core ever so slightly to get a 0-10V:
instead of tapping the charge voltage directly from the DAC using a positive opamp buffer, I switched to a unity gain negative amplifier. This would sink current instead of sourcing it, changing the charging direction. To make this works one also have to replace the 2n3906 PNP transistor with a 2n3904 NPN (One should also switch the polarity of the timer output, but as both a positive and negative going spike are generated, just slightly offset in time, this was not required for testing).
But testing this, I got a big surprise - the low frequency amplitude was no longer too low - it was too high! Previously I had to increase the DAC value from 60 to 80-something, now I had to reduce it from 60 to 48 (steps times 5V/65536).
This made me less certain that switching to a JFET would improve anything, but I still decided to try it.
I added an LM311 comparator, and set its negative input to 0.118V using a 120k and a 4k7 resistor. This would assure that when the positive input was just slightly higher than 0V, the output would spike up to 15V, and when the input was 0V the output would be -15V - similarly to the yusynth circuit, where the comparator outputs a negative voltage to turn off the JFET. The circuit worked instantly (!), but as suspected, nothing changed.
So, now I guess I've ruled out the reset transistor as the cause of the offset. Also, the fact that the amplitude error changes when I swap the charging polarity, makes me believe that the cap is not at fault either (though I will still check this).
That leaves either the DAC (which is unlikely for the same reason as the CAP) or the opamp buffer.
It could also be that a small difference in the power lines (measured to +15.01 and -15.00 volts) could cause this, I don't know. I will try recalibrating and also try different opamps to see if that changes anything.
For reference: Here is the original breadboarded circuit with the 0 to -10V output. I have since added the missing 2R2 resistor, however, that changed nothing. The DAC is connected where the 20k pot is in this drawing
Monday, July 31, 2017
Wave centering - bias circuit
The DCO generates a wave running from 0 to -10V. To center this, I tried using two resistors and a 1uF capacitor, followed by a buffer. This works fine for higher frequencies, but at the bottom of the frequency range we get severe distortion, turning the straight lined saw wave into a slope.
Also, this arrangement won't work for Pulse signals as the pulse width has more energy at either top or bottom.
The square and pulse waves are a bit interesting as the amplitude CV does not have to run through a VCA. Instead, the amplitude is equal to the CV. This means that subtracting half the CV from the output wave will center it.
I've come up with the following, untested (and incomplete) circuit that shows my idea:
Also, this arrangement won't work for Pulse signals as the pulse width has more energy at either top or bottom.
The square and pulse waves are a bit interesting as the amplitude CV does not have to run through a VCA. Instead, the amplitude is equal to the CV. This means that subtracting half the CV from the output wave will center it.
I've come up with the following, untested (and incomplete) circuit that shows my idea:
Wednesday, June 21, 2017
DCO - aribtrary reset point
I've been a bit worried about the fact that the DCO frequency may only be changed when the period reset timer runs. At low frequencies this may mean a noticeable loss of timing presision - worst case for a 20Hz signal would be 1/20 s off. At 120BMP, the duration of a 1/16th note is 1/32 second, so it will miss by a lot. If my calculations are correct, playing "flight of the bumblebee" at near-unhearably low frequencies will be impossible ;-) I am not sure how much of a problem the inaccuracy is in practice, but it is something to investigate further.
This constraint is there for a good reason, as we need a perfect match between charging voltage and reset time for the saw wave to get the correct amplitude. If we choose to change the charge voltage at any given time, without changing the reset timer, the amplitude of the first cycle after the change will be either too high or too low.
Idea 1:
Ideally, we should change the remaining time of the reset timer too. This would be a case of subtracting the current remainder from the new period timer value, correcting for the time the calculation takes, and then updating the timer - IF the time the calculation took was less than the remaining time.
This is slightly more complicated than what it sounds like. As the current timer and the new timer may not have the same prescaler, we need to take this into account when calculating the correct reset values. We also need to make sure we don't mess up the reset pulse timer.
Idea 2:
A different approach would be to do the first reset in hardware. If we connect the saw output to a comparator, and check if the level is just slightly larger than the normal, correct amplitude, we could trigger a reset using the sync input, preventing a large amplitude error. The amplitude error that is inevitable because the reset point must be larger than the correct amplitude is hopefully small enough to be inaudible. This lets us change the charging voltage at any time and still not get a large amplitude error.
This will fix the case where the amplitude is too large, but the case where it is too small (e.g. the new charge voltage is lower) will not be fixed. To fix this, we must also reset the period timer at the same time. Doing so guarantees that the charging time is at least long enough for the new charging voltage to fully charge the cap. In most cases the charing time will be too long as it adds to the time already elapsed since the last reset, but then the previous comparator fix will reset the period at approximately the right time.
The disadvantages to this method may be:
Idea 3:
A third method would be to always reset the cap at the instant a frequency change occurs. The timing will then be as accurate as possible. The main disadvantages are
I will give the choice between 1 and 2 a more thorough thought and try to build 2 to see how it feels like. All options may be retrofitted to the current DCO even if the PCB has been created, as the comparator circuitry can be housed outside of the DCO itself..
This constraint is there for a good reason, as we need a perfect match between charging voltage and reset time for the saw wave to get the correct amplitude. If we choose to change the charge voltage at any given time, without changing the reset timer, the amplitude of the first cycle after the change will be either too high or too low.
Idea 1:
Ideally, we should change the remaining time of the reset timer too. This would be a case of subtracting the current remainder from the new period timer value, correcting for the time the calculation takes, and then updating the timer - IF the time the calculation took was less than the remaining time.
This is slightly more complicated than what it sounds like. As the current timer and the new timer may not have the same prescaler, we need to take this into account when calculating the correct reset values. We also need to make sure we don't mess up the reset pulse timer.
Idea 2:
A different approach would be to do the first reset in hardware. If we connect the saw output to a comparator, and check if the level is just slightly larger than the normal, correct amplitude, we could trigger a reset using the sync input, preventing a large amplitude error. The amplitude error that is inevitable because the reset point must be larger than the correct amplitude is hopefully small enough to be inaudible. This lets us change the charging voltage at any time and still not get a large amplitude error.
This will fix the case where the amplitude is too large, but the case where it is too small (e.g. the new charge voltage is lower) will not be fixed. To fix this, we must also reset the period timer at the same time. Doing so guarantees that the charging time is at least long enough for the new charging voltage to fully charge the cap. In most cases the charing time will be too long as it adds to the time already elapsed since the last reset, but then the previous comparator fix will reset the period at approximately the right time.
The disadvantages to this method may be:
- Charging time may change slightly when the ambient temperature changes. Resistor values barely change so I have to check the effects on the charge capacitor.
- The amplitude of the first period will always be slightly wrong after a frequency change. Not sure if that will be audible. It may possibly only be a problem for fast changing pitch.
Idea 3:
A third method would be to always reset the cap at the instant a frequency change occurs. The timing will then be as accurate as possible. The main disadvantages are
- The saw wave will always start at the same position. Two DCOs running in parallel will then be in almost perfect sync.
- A fast changing pitch will reset the timer multiple times per second, possibly hundreds or thousands of times. At low frequencies this means no saw wave runs to completion, giving us a way too low amplitude (though shifted to the maximum).
I will give the choice between 1 and 2 a more thorough thought and try to build 2 to see how it feels like. All options may be retrofitted to the current DCO even if the PCB has been created, as the comparator circuitry can be housed outside of the DCO itself..
Wednesday, June 7, 2017
DCO core up and running
After spending a long time converting and optimising the DCO code for the PIC16F18325, I finally connected a DAC and tested the thing last night.
All frequency tests seemed ok, and the charge current tracked the frequency almost perfectly, charging the saw core capacitor to 5V even if frequencies changed. Only for the lowest frequency I tried (16.35Hz) did the cap not fully charge. I successfully tried frequencies up to 7000Hz. At 14000Hz the charge current was once again too low, but this was expected as the DAC output cannot reach a high enough level with the current combination of cap and charge current converter resistor (100kOhm). I tried swapping the resistor for a 56k one and the saw voltage swing doubled as expected, so a little experimenting with various resistor values will probably fix this issue.
I have had some issues with the saw core op amp oscillating. Not sure what causes it (well, I suspect it is due to the capacitor in the feedback loop), but some brands seem more susceptible to this than others.
I've tried the TL072CP and TL062CP from Texas Instruments and they both oscillate. TL072BD and 4556D from JRC work fine. Maybe the B/C difference could explain it.
The DCO uses modern, easily available components, the reset transistor is a 2N3906. The DAC currently used is a MAX541, with an SPI speed of 8MHz. The 'production version' will probably use a MAX5216 as this is way cheaper.
I was not aware that I could get such a high speed, now I consider moving the DAC update into the interrupt routine. It will probably double the time spent in the routine, but even this would only reduce the max transfer speed from the master controller to the DCO to around 950kbps, meaning we could still update the DCO 50.000 times per second (or rather, transfer new pitch values, the DCO will only update at period reset positions).
Next up is adding and testing SPI control, then recalculating the lookup tables to be centred around Cs (a C should be at 32768 = virtual 0V). Then finally breadboarding the wave shaper circuitry and deciding on voltage control and how to center the waves around 0V.
I must also decide the p-p voltage output. 12V seems to be the Juno way, this is the highest "safe" voltage possible since the saw is generated between gnd and the negative power rail (-15V). I assume that keeping the voltage as high as possible up to the point where several waves are summed is a good idea, to keep noise to a minimum.
All frequency tests seemed ok, and the charge current tracked the frequency almost perfectly, charging the saw core capacitor to 5V even if frequencies changed. Only for the lowest frequency I tried (16.35Hz) did the cap not fully charge. I successfully tried frequencies up to 7000Hz. At 14000Hz the charge current was once again too low, but this was expected as the DAC output cannot reach a high enough level with the current combination of cap and charge current converter resistor (100kOhm). I tried swapping the resistor for a 56k one and the saw voltage swing doubled as expected, so a little experimenting with various resistor values will probably fix this issue.
I have had some issues with the saw core op amp oscillating. Not sure what causes it (well, I suspect it is due to the capacitor in the feedback loop), but some brands seem more susceptible to this than others.
I've tried the TL072CP and TL062CP from Texas Instruments and they both oscillate. TL072BD and 4556D from JRC work fine. Maybe the B/C difference could explain it.
The DCO uses modern, easily available components, the reset transistor is a 2N3906. The DAC currently used is a MAX541, with an SPI speed of 8MHz. The 'production version' will probably use a MAX5216 as this is way cheaper.
I was not aware that I could get such a high speed, now I consider moving the DAC update into the interrupt routine. It will probably double the time spent in the routine, but even this would only reduce the max transfer speed from the master controller to the DCO to around 950kbps, meaning we could still update the DCO 50.000 times per second (or rather, transfer new pitch values, the DCO will only update at period reset positions).
Next up is adding and testing SPI control, then recalculating the lookup tables to be centred around Cs (a C should be at 32768 = virtual 0V). Then finally breadboarding the wave shaper circuitry and deciding on voltage control and how to center the waves around 0V.
I must also decide the p-p voltage output. 12V seems to be the Juno way, this is the highest "safe" voltage possible since the saw is generated between gnd and the negative power rail (-15V). I assume that keeping the voltage as high as possible up to the point where several waves are summed is a good idea, to keep noise to a minimum.
![]() |
| The charge current is a bit too low at the lowest frequency |
![]() |
| The dots above the peak of the saw wave is the reset pulse |
![]() |
| The reset pulse gets more and more visible as the frequency increases and we zoom in |
![]() |
| The charge current is too low above a certain frequency. This will be fixed. |
Monday, May 29, 2017
Juno saw sub oscillator
Someone mentioned that there is such a thing as a juno sub osc mod that gives you a saw sub oscillator.
Now, I know nothing about this mod but I can immediately think of two ways of doing this:
1) Use my saw sub osc design that combines the saw with the square to shift and attenuate the saw wave and making a wave one octave down
2) Replicate the saw core - let the sub osc output control the reset transistor, and tap (a buffered version of) the charge voltage from the DAC output and attenuate it 50%
Should be an easy fix :)
Now, I know nothing about this mod but I can immediately think of two ways of doing this:
1) Use my saw sub osc design that combines the saw with the square to shift and attenuate the saw wave and making a wave one octave down
2) Replicate the saw core - let the sub osc output control the reset transistor, and tap (a buffered version of) the charge voltage from the DAC output and attenuate it 50%
Should be an easy fix :)
Wednesday, April 5, 2017
Juno 106 vs 6/60 DCOs
There are some differences between the DCOs in the Juno 106 and the Juno 6/60 - except for the fact that the DCOs on the 106 are integrated into a single chip.
First of all, according to the datasheet, the 106 uses an NPN instead of a PNP transistor to reset the integrator (saw wave converter).
More interestingly, the way they sum the saw wave and the pulse waves are very different.
The Juno 60 has a separate control line for the pulse wave, connected to TR2. It looks just like the one for the saw wave (TR3) so one can assume that it turns on and off the pulse output. Also, the output of the pulse is sent through D2 which will block any positive halves of the pulse (? which sort of makes sense as the saw wave is also negative only).
The 106 on the other hand, has no such control line, which means that the pulse output is always on. The pulse output has a diode to ground which I assume means that it will never be negative (?).
So how can the 106 output a saw wave and no square wave? One theory may be that if the user selects saw wave only, the pwm is set to 50%. Summing the sqare and saw waves will chop up the saw wave just as it reaches its half period, and move the remainder upwards. If the amplitude of the saw and square waves are equal, the saw wave will magically realign with its phase shifted half a period, this time centered around 0V.
DISCLAIMER: This is only my initial theory after studying the datasheets, no measurements have been made.
But how about when both the saw and pulse waves are on? Wouldn't this mess up how the wave turns out? Since the saw wave is positive and the pulse is negative, couldn't the total amplitude end up being double?
Well, the high part of the pulse will always come at the second half of the period, thus it will never "lift" the saw wave from higher that minus half the total voltage p-p. Also, The parts that are lifted will only be lifted by 1 x the voltage p-p.
In practice, this means that if we could set the duty cycle to 0%, the output would be a saw wave that starts at 0 and drops to minus the total voltage p-p. If the duty cycle is 50%, we get a saw wave with the same amplitude centered around 0V.
This is interesting and may reveal a flaw in my assumptions. As the wave is centered around 0V by a capacitor later, summing a pulse and saw wave this way will only shift the saw wave phase! I need to check if the polarity and phase assumptions for the square wave actually holds. What happens if instead the polarity is reversed or the phase shifted by half a period?
TODO: Write about SUB OSC and level control (done by using the output from the DAC) and how the passing through a diode affects the signal (reversed in one)- one uses NPN and the other uses PNP, 60 has a resistor to GND at the transistor base. The 106 has no on-off switch for the SUB OSC, only a volume control.
Both the 106 and the 60 DCOs have their outputs mixed with noise (with adjustable volume) right before a 10uF non-polarized cap and injected into the IR3109/800170 filter chips. The mixing point has no opamp connected to it so I assume this job is done by the chips. I guess the cap is there to filter out any DC component and center the waves around 0V. I have not looked closely at this - what happens here when the frequency changes for example, will still stay centered during the transition because the amplitude is still the same?
BTW: NP in the juno datasheet means Non-polarized (capacitor). MF means metal film (resistor). G (capacitor) may mean 2% (needed for accuracy in the integrator).
First of all, according to the datasheet, the 106 uses an NPN instead of a PNP transistor to reset the integrator (saw wave converter).
More interestingly, the way they sum the saw wave and the pulse waves are very different.
The Juno 60 has a separate control line for the pulse wave, connected to TR2. It looks just like the one for the saw wave (TR3) so one can assume that it turns on and off the pulse output. Also, the output of the pulse is sent through D2 which will block any positive halves of the pulse (? which sort of makes sense as the saw wave is also negative only).
The 106 on the other hand, has no such control line, which means that the pulse output is always on. The pulse output has a diode to ground which I assume means that it will never be negative (?).
So how can the 106 output a saw wave and no square wave? One theory may be that if the user selects saw wave only, the pwm is set to 50%. Summing the sqare and saw waves will chop up the saw wave just as it reaches its half period, and move the remainder upwards. If the amplitude of the saw and square waves are equal, the saw wave will magically realign with its phase shifted half a period, this time centered around 0V.
DISCLAIMER: This is only my initial theory after studying the datasheets, no measurements have been made.
But how about when both the saw and pulse waves are on? Wouldn't this mess up how the wave turns out? Since the saw wave is positive and the pulse is negative, couldn't the total amplitude end up being double?
Well, the high part of the pulse will always come at the second half of the period, thus it will never "lift" the saw wave from higher that minus half the total voltage p-p. Also, The parts that are lifted will only be lifted by 1 x the voltage p-p.
In practice, this means that if we could set the duty cycle to 0%, the output would be a saw wave that starts at 0 and drops to minus the total voltage p-p. If the duty cycle is 50%, we get a saw wave with the same amplitude centered around 0V.
This is interesting and may reveal a flaw in my assumptions. As the wave is centered around 0V by a capacitor later, summing a pulse and saw wave this way will only shift the saw wave phase! I need to check if the polarity and phase assumptions for the square wave actually holds. What happens if instead the polarity is reversed or the phase shifted by half a period?
TODO: Write about SUB OSC and level control (done by using the output from the DAC) and how the passing through a diode affects the signal (reversed in one)- one uses NPN and the other uses PNP, 60 has a resistor to GND at the transistor base. The 106 has no on-off switch for the SUB OSC, only a volume control.
Both the 106 and the 60 DCOs have their outputs mixed with noise (with adjustable volume) right before a 10uF non-polarized cap and injected into the IR3109/800170 filter chips. The mixing point has no opamp connected to it so I assume this job is done by the chips. I guess the cap is there to filter out any DC component and center the waves around 0V. I have not looked closely at this - what happens here when the frequency changes for example, will still stay centered during the transition because the amplitude is still the same?
BTW: NP in the juno datasheet means Non-polarized (capacitor). MF means metal film (resistor). G (capacitor) may mean 2% (needed for accuracy in the integrator).
Labels:
DCO,
juno,
juno 106,
Juno 60,
pulse wave,
saw integrator,
saw wave
Subscribe to:
Posts (Atom)






















