Interfacing with a modular synth

Status
Not open for further replies.
the lm4040 doesn't exist in 3.3v, just 2.0, 2.5, 3.0, 4.096 and some larger values. mouser for example has the 3v version in the TO92 package, but i wouldn't worry too much if you can't find one/don't want to put in a large order with them. note that on the teensy there's a 470R resistor already connecting the AREF pin to 3v3, which would correspond to "Rs" in the lm4040 data sheet (or the 3k3 one in the Tides datasheet.)

The 3k3 one between the 3.3v input and the 2.5 output?

So I can just omit the 3k3?
 
So really I would be better off using a 3.3 reference voltage of some kind as my input voltage is 12v and I have to get it down to 3.3 for the teensy anyway.

No idea why the input is 12v on that one — the spec says 0 to 8v

it's probably better to keep VREF slightly below VDD, so 3.0v would be good. don't get bogged down too much over those values, you can always go back and change things once you have things basically running.

ah, that makes more sense, i thought you were going to reference to 12v.

the v/oct input is a summing mixer, CV + offset (via the 10k pot + 2k49). so you kind of move around those 2.16v (27/100 * 8v). looks as if you offset by 2.7v (10v) if the pot is fully closed, and 0.54v (2v) if fully open, and you provide some headroom (roughly 0.6 volts on either side).
 
The 3k3 one between the 3.3v input and the 2.5 output?

So I can just omit the 3k3?

if attaching directly to AREF, yes. there's the 470R already.

LM4040.jpg

this is from the lm4040 datasheet - we're talking about 'Rs'. i don't know how much current is needed at VREF, but presumably not much. for the 3.0v version, the datasheet gives a minimum current of ~ 60 µA, so the 0.63mA should be plenty (Vs = 3.3v, Vr = 3.0v. so (Vs-Vr)/470R = 0.63mA)).
 
Having the adjustment on an octave input is fairly standard so you can adjust the pitch.

Ok - so my workings for a 3v reference:

8*(27/100) = 0.27 = 2.16 volts

2.16/2.5 = 0.864

3 * 0.864 = 2.6 volts

8v / 2.6v = 3 = 8*(33/100) = 2.64 volts

This is all so easy when you know how.
 
Last edited:
This is probably @mxxx as he pointed this out.

So I am looking at the power circuit.

Screen Shot 2014-10-07 at 20.58.33.png

I have some LM1117-5 to power the Teensy — and an LM4040-3 to power the AREF.

So my plan was (with the same caps around the power and ground)

Code:
+12v-----22u-----LM1117-5-----22u-----100n-----[+5 to Teensy]-----LM4040-3-----470u-----[3v to Teensy AREF]

(all caps to ground)
 
So my plan was (with the same caps around the power and ground)

Code:
+12v-----22u-----LM1117-5-----22u-----100n-----[+5 to Teensy]-----LM4040-3-----470u-----[3v to Teensy AREF]

(all caps to ground)

you don't need to connect the LM4040 to 5v in this case, as noted AREF already is connected to 3v3; also there's a typo - the rightmost cap is 470n. you also want to copy over the diode (D1). otherwise, i'd say this should do.

like so (here D1 is a 1N5817):

schem.jpg

[edit:] ie D1 from the Tides schematic; i've not drawn the 470n cap, but i guess it can't hurt.
 
Last edited:
Perfect - thanks mxxx.

I'm going to scale the octave output to 0-3 or 0-5v as I think 0-8 is a stretch with noise etc

I now have a borrowed modular synth - my friends "spare" kit - so full steam ahead.
 
I have just realised something — the output from the DAC isn't related to the analog reference voltage? I have 3v powered to the AREF pin but my output is still 3.3v

I have set up analogReference(EXTERNAL) etc
 
how did you end up your setting up your external reference?

personally i haven't used the onboard DAC much, but i'd figure you have to set it - somehow - à la :


Code:
void AudioOutputAnalog::analogReference(int ref)
{
	// TODO: this should ramp gradually to the new DC level
	if (ref == INTERNAL) {
		DAC0_C0 &= ~DAC_C0_DACRFS; // 1.2V
	} else {
		DAC0_C0 |= DAC_C0_DACRFS;  // 3.3V
	}
}
 
analogReference(External) is to set the ADC, i think:

Code:
if (analog_reference_internal) {
		ADC0_SC2 = ADC_SC2_REFSEL(1); // 1.2V ref
		#if defined(__MK20DX256__)
		ADC1_SC2 = ADC_SC2_REFSEL(1); // 1.2V ref
		#endif
	} else {
		ADC0_SC2 = ADC_SC2_REFSEL(0); // vcc/ext ref
		#if defined(__MK20DX256__)
		ADC1_SC2 = ADC_SC2_REFSEL(0); // vcc/ext ref
		#endif
	}

edit: well, no. it's the same thing, analogWrite seems to take care of the |= DAC_C0_DACRFS, so i don't know. are you measuring 3v at AREF?
 
Last edited:
You can do it for sure— quoted from another thread—

Quote Originally Posted by neutron7 View Post
quick question, can i use external reference for the DAC? i am using 3v external ref for the ADC inputs already.
Yes, the on-chip DAC can use the AREF voltage. In the audio library, use dac1.analogReference(EXTERNAL), where "dac1" would be the name of the AudioOutputAnalog object for the DAC.


I'll double check the 3v — pretty sure I check that.
 
in the audio library, the default is 1.2v / internal. i think the above (answer to quick question) refers to that.

normally, it should default to VDDA. though i'm not quite awake yet ... VREFH doesn't seems affect the DAC, so i'm not sure it can be done.*

* edit: i'm somewhat confused myself now. when they posted it, i too had taken paul's reply to neutron7 saying that the DAC can be set to AREF, ie whatever voltage is applied there, much like the ADC. https://www.pjrc.com/teensy/K20P64M72SF1.pdf doesn't even mention VREFH in connection with the DAC though (on p.46) : "The DAC reference can be selected to be VDDA or the voltage output of the VREF module".

i'm even more mystified by the orgon accumulator, then. it's just doing

Code:
analogReference(EXTERNAL);
analogWriteResolution(13);

no idea where the 13 comes from, but i'm guessing it can't be outputting 3v.
 
Last edited:
I'm very confused :)

I successfully got the DAC interfacing with a VCO last night — the 3v nicely correlates with 3 octaves. Wondered why the numbers weren't adding up and then realised it wasn't outputting 3v.

In the end I just did *(3/3.3) to scale the value. It's reasonably spot on - only being a Hz or so out.
 
Am hoping Paul can answer this?

Overview: is the DAC output voltage controlled by the AREF? If not - can it be controlled?
 
From the datasheet:

1. The DAC reference can be selected to be VDDA or the voltage output of the VREF module (VREF_OUT)
2. A small load capacitance (47 pF) can improve the bandwidth performance of the DAC

From the schematic VREF_OUT is connected to 3.3v
 
Last edited:
From the schematic VREF_OUT is connected to 3.3v

no, there's a 100n cap to ground, VREF_OUT is not connected to anything. but yep, paul should chime in; i'm guessing it might be possible in theory --"If the user wishes to drive VREF_OUT with a voltage other than the output of the VREF module, the VREF module must be disabled." (p.41) -- but that feature isn't available on the teensy, if i see it right. so it'll be either VDDA = 3.3v or VREF_OUT = 1.2v

anyways, if you need better DAC performance, better to use some external IC
 
There are 2 reference pins on the chip.

VREFH is the default, at 3.3V. The VREFH pin is an input to the chip.

VREF_OUT is the internal 1.2V reference. The VREF_OUT pin is an output from the chip, driven by the 1.2V internal reference, which requires an external 0.1 uF capacitor for stability.
 
is the DAC output voltage controlled by the AREF? If not - can it be controlled?

The DAC can use either external AREF (VREFH) which defaults to 3.3V from a 470 ohm resistor, or the internal (VREF_OUT) at 1.2V. By default, if you use analogWrite(A14, val), it will be the 3.3V reference. If you use analogReference(), the reference for both ADC and DAC is changed.

You can also directly write to the DAC's hardware register, to configure which reference it uses. The audio library does this, to cause the DAC to default to 1.2V, regardless of the ADC setting. The audio lib also has dac.analogReference() to control which reference voltage the DAC uses. Here's the code, which might help you if you want to reconfigure just the DAC.

https://github.com/PaulStoffregen/Audio/blob/master/output_dac.cpp#L81
 
So as long as I use analogReference(EXTERNAL) it should be 3v - as I have 3v on the AREF pin.

I'll double check everything when I get home.
 
So I double checked that I have 3v on the AREF pin - and that I have analogReference(EXTERNAL) set - all ok.

So am at a loss as to why I am getting 3.3v on A14.
 
So I double checked that I have 3v on the AREF pin - and that I have analogReference(EXTERNAL) set - all ok.

So am at a loss as to why I am getting 3.3v on A14.

i'd say: if the datasheet is to be trusted, that's the expected behaviour. teensy has VDDA = 3v3.

btw, re your question over at muffwiggler: the stuff you posted above - Tides and Yarns - perfectly conforms to what *is* considered good practice (i think is fair to say). specifically, note that nothing is referenced to the rails, there's voltage references used throughout; the output stages differ subtly, because these modules are supposed to do different things (DC precision matters: yarns; DC precision doesn't really matter: tides). some design choices are debatable of course. for example, some people will say better to use a comparator not transistor switches before the digital inputs, because the latter aren't guaranteed to neatly saturate for just any input signal (ie turn "on"); spurious triggers might result. in practice though that doesn't seem to bother a lot of people (judging from the absence of complaints in the direction).
 
Status
Not open for further replies.
Back
Top