Forum Rule: Always post complete source code & details to reproduce any issue!
Page 3 of 4 FirstFirst 1 2 3 4 LastLast
Results 51 to 75 of 82

Thread: Interfacing with a modular synth

  1. #51
    Senior Member
    Join Date
    Aug 2014
    Posts
    165
    Quote Originally Posted by mxxx View Post
    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?

  2. #52
    Senior Member
    Join Date
    Feb 2013
    Posts
    563
    Quote Originally Posted by jcarruthers View Post
    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).

  3. #53
    Senior Member
    Join Date
    Feb 2013
    Posts
    563
    Quote Originally Posted by jcarruthers View Post
    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.

    Click image for larger version. 

Name:	LM4040.jpg 
Views:	296 
Size:	19.1 KB 
ID:	2740

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

  4. #54
    Senior Member
    Join Date
    Aug 2014
    Posts
    165
    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 by jcarruthers; 10-01-2014 at 10:27 AM.

  5. #55
    Senior Member
    Join Date
    Aug 2014
    Posts
    165
    This is probably @mxxx as he pointed this out.

    So I am looking at the power circuit.

    Click image for larger version. 

Name:	Screen Shot 2014-10-07 at 20.58.33.png 
Views:	1237 
Size:	68.3 KB 
ID:	2761

    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)

  6. #56
    Senior Member
    Join Date
    Feb 2013
    Posts
    563
    Quote Originally Posted by jcarruthers View Post

    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):

    Click image for larger version. 

Name:	schem.jpg 
Views:	221 
Size:	57.0 KB 
ID:	2762

    [edit:] ie D1 from the Tides schematic; i've not drawn the 470n cap, but i guess it can't hurt.
    Last edited by mxxx; 10-08-2014 at 06:44 AM.

  7. #57
    Senior Member
    Join Date
    Aug 2014
    Posts
    165
    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.

  8. #58
    Senior Member
    Join Date
    Aug 2014
    Posts
    165
    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

  9. #59
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,111
    Quote Originally Posted by jcarruthers View Post
    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
    This may be related to:
    Quote Originally Posted by jcarruthers View Post
    Jim (Orgone Accumulator) has also indicated the need for the OPA2277/TLE2062 to play nicely with the Teensy.

  10. #60
    Senior Member
    Join Date
    Aug 2014
    Posts
    165
    Luckily I have one of those to try out then.

  11. #61
    Senior Member
    Join Date
    Feb 2013
    Posts
    563
    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
    	}
    }

  12. #62
    Senior Member
    Join Date
    Aug 2014
    Posts
    165
    Hmmm— I just set it to external— but that doesn't look like it's doing much different

  13. #63
    Senior Member
    Join Date
    Feb 2013
    Posts
    563
    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 by mxxx; 10-11-2014 at 09:28 AM.

  14. #64
    Senior Member
    Join Date
    Aug 2014
    Posts
    165
    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.

  15. #65
    Senior Member
    Join Date
    Feb 2013
    Posts
    563
    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 by mxxx; 10-11-2014 at 10:31 AM.

  16. #66
    Senior Member
    Join Date
    Aug 2014
    Posts
    165
    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.

  17. #67
    Senior Member
    Join Date
    Aug 2014
    Posts
    165
    Am hoping Paul can answer this?

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

  18. #68
    Senior Member
    Join Date
    Aug 2014
    Posts
    165
    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 by jcarruthers; 10-13-2014 at 10:35 AM.

  19. #69
    Senior Member
    Join Date
    Feb 2013
    Posts
    563
    Quote Originally Posted by jcarruthers View Post
    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

  20. #70
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,812
    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.

  21. #71
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,812
    Quote Originally Posted by jcarruthers View Post
    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/Au...ut_dac.cpp#L81

  22. #72
    Senior Member
    Join Date
    Feb 2013
    Posts
    563
    Quote Originally Posted by PaulStoffregen View Post
    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
    so https://www.pjrc.com/teensy/K20P64M72SF1.pdf is misleading? as pointed out above, it specifically mentions VDDA, not VREFH as the reference for the DAC:

    "The DAC reference can be selected to be VDDA or the voltage output of the VREF module (VREF_OUT)"

  23. #73
    Senior Member
    Join Date
    Aug 2014
    Posts
    165
    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.

  24. #74
    Senior Member
    Join Date
    Aug 2014
    Posts
    165
    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.

  25. #75
    Senior Member
    Join Date
    Feb 2013
    Posts
    563
    Quote Originally Posted by jcarruthers View Post
    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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •