Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 31

Thread: SGTL5000 for DC control voltage output

  1. #1

    SGTL5000 for DC control voltage output

    Can the SGTL5000 be used like a regular DAC with regards to just staying at a certain voltage if desired? I would like to use it for modular synth control voltage (CV). Just want to make sure it's not necessary for it to constantly receive a stream of data. I'm not familiar with I2S.

    I'm going to revisit my Teensy 3.x synth project, but this time around I'm going with an SSI2144 VCF and an analog VCA. So I'll need a bunch of control voltages in addition to the DCO from the Teensy.

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    7,002
    I2S is a continous stream of data. And i'd say the SGTL5000 is not a good choice.. i'm sure there are better (non-i2s) chips to do this. But if you really want to use an I2S-Audio-DAC, maybe try the cheap Pt8211??

    ..but..really, if I were you, i'd try to find an other, non-I2S chip.

    https://de.rs-online.com/web/c/halbl...ort-order=desc

  3. #3
    I'm trying to keep the analog output under control of the Audio Library. I guess I'll have to hook the SGTL5000 up to a DC source in the designer and see what it does. Certain things like resonance CV can probably just use a heavily filtered PWM. 3db point there could be 1 KHz.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,986
    To use the SGTL5000 chip for DC coupled control voltage (CV) you'll need to access the pins directly. The audio shield has 2.2uF capacitors in series with the signals.

    Click image for larger version. 

Name:	schematic_audio2.jpg 
Views:	157 
Size:	69.6 KB 
ID:	13485

    You might also find the pin 10 (VAG) on the SGTL5000 useful. It's the DC offset voltage the chip uses for its signals. This pin is sensitive, so you probably want to use a JFET or CMOS input opamp to buffer it. Then you could use another opamp as a subtractor circuit to try to remove the DC offset, and then of course add gain to get the signal up to a +/- 5V range (or whatever you're using for CV).

    Both the offset and gain will probably need trimming. For a low volume product, this might be easiest to do with analog circuitry, if the PCB space and extra time for a calibration step to adjust them is acceptable. Of course the more modern approach would involve characterizing the hardware, which still requires a calibration step but perhaps with a fancy PC-interfaced multimeter. Then you could store the DC offset and gain adjustment in your code and apply them with DC synth & mixer objects. A few times I've considered making a 4-channel DC coupled version of the audio shield for modular synth folks, where we'd do this here at PJRC and store the 8 calibration values in an EEPROM chip. Maybe someday....

    Hopefully this helps?

  5. #5
    Thanks Paul. I plan on using a buffer-amp circuit found here in the forums (it's from a Mutable Instruments module) to get the CV to the +/- 10V range needed by the rest of the analog circuitry. Offset isn't that big of an issue as the VCF has an adjustment for that. I suppose in a real product you'd use an extra DAC/ADC pair to measure the offset and then tweak vRef through an op-amp summer until it zeros. I'm just buildinhg "modules" out of perma-proto boards for synth tinkering.

  6. #6
    I swapped the 2.2 uF caps with 1k resistors (they were the only 0603 parts I had). Here's the results:

    The 'dc' object is really just meant to provide evelope control inside the audio library. Yes it did change the DAC output, but it's inverted, and it swings around a rather small output range when fed with values between -1 and 1. Same deal on very low frequency square waves. High is about 1V and low is about 1.6V

    So, no, you can not use the audio library to produce external DC control voltages. But that's OK, it is not really hard to make linear slope envelopes driving external DAC with a state machine. You could keep the library to use as an audio waveform generator. I think making good waveforms without aliasing is the hard part.

  7. #7
    Junior Member
    Join Date
    Jan 2019
    Posts
    7
    Hello Paul,
    I really love the Audio Shield and am planning to use it, however what I first prototyped on the EuroShield does not translate well to the breadboard.
    I need DC current for one of my audio outputs (I use each channel of the stereo output as a mono output), as it is planned to be used as a gate signal.
    While the DC output works perfectly when using the EuroShield, when using the Audio Shield alone for a new project, the signal is attenuated over time (gate signal becomes like low-frequency saw) and not unipolar anymore (my strictly positive signal becomes negatively offset). What is the easiest way to fix this?
    Should I try to locate the 2.2F capacitor of this channel, unsolder it and replace it with solder?
    Should I leave it in place and solder a wire to the jack output before the capacitor?
    Regarding the offset, is it not possible, without using pin 10, to ask the SGTL5000 not to add any offset to its output?
    If not, can you quickly sketch the circuit that needs to be used?
    Thank in advance for your answer!
    Edouard

    Quote Originally Posted by PaulStoffregen View Post
    To use the SGTL5000 chip for DC coupled control voltage (CV) you'll need to access the pins directly. The audio shield has 2.2uF capacitors in series with the signals.

    Click image for larger version. 

Name:	schematic_audio2.jpg 
Views:	157 
Size:	69.6 KB 
ID:	13485

    You might also find the pin 10 (VAG) on the SGTL5000 useful. It's the DC offset voltage the chip uses for its signals. This pin is sensitive, so you probably want to use a JFET or CMOS input opamp to buffer it. Then you could use another opamp as a subtractor circuit to try to remove the DC offset, and then of course add gain to get the signal up to a +/- 5V range (or whatever you're using for CV).

  8. #8
    Why dont you just use the teensy's dac for dc? Codecs are designed for ac...you can use both at the same time in the audio library.
    Or if all you need is a gate why not use a digital pin instead?

  9. #9
    Junior Member
    Join Date
    Jan 2019
    Posts
    7
    Thank you so much for your suggestion. You're right these were options, to use the Teensy's DAC and a digital pin for the gate. I guess that even for my first project, I wanted to have a 16-bit output for the audio output, and have a slew option on the gate signal that allows it to be transformed into an envelope, which I don't think a digital pin can do, I think it only does HIGH or LOW. Maybe in analog mode it would work though, I'd have to test if it works and what is the resolution. But in any case, I don't think I can avoid to add op amps after my outputs, in order to be at Eurorack levels.

  10. #10
    Oh, so you want an envelope.
    I think you misunderstood me, you can use the audioshield for audio AND the teensy's DAC(s) for envelopes, lfos, dc voltages, etc... at the same time.
    The DAC is 12 bit i believe, more than adequate for what you want.
    And yes, you will need amplification for euro levels for sure

  11. #11
    Junior Member
    Join Date
    Jan 2019
    Posts
    7
    Yes you're right I could try to use the Teensy's 12-bit DAC at the same time. I'll investigate that. Thanks a lot!

  12. #12
    Junior Member
    Join Date
    Jan 2019
    Posts
    7
    Quote Originally Posted by fabuloso_mocoso View Post
    you can use the audioshield for audio AND the teensy's DAC(s) for envelopes, lfos, dc voltages, etc... at the same time.
    Thank you so much fabuloso_mocoso, it works fabulously and much better than a PWM digital output with a capacitor that slows the signal transients.

  13. #13
    No prob. Glad i could be of help

  14. #14
    Member
    Join Date
    Sep 2020
    Location
    Massachusetts
    Posts
    58
    I am very curious about this. I would like to use the "DC" signal in the Teensy Audio Library, modulated by the envelope et cetera, as a "real" DC signal for some analog circuits. I don't see how this is possible without hacking the library. I would need either a new output module that translates the audio stream to DC, or a way of getting the "value" of the envelope as a float and then just writing it out to dac/pwm myself.

    Am I missing something?

    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>

    // GUItool: begin automatically generated code
    AudioSynthWaveformDc dc1; //xy=154,244
    AudioEffectEnvelope envelope2; //xy=314,244
    // GUItool: end automatically generated code



    void setup(){
    }

    void loop(){
    // ------------> How do I get a numeric value out of my envelope?
    }

  15. #15
    Member
    Join Date
    Sep 2020
    Location
    Massachusetts
    Posts
    58
    Basically, it would be good to have a float envelope2.getValue(); method, but if I could only poll that in loop() it wouldn't be great.
    What I really want is a different class of output device handling non-audio signals.

    Let me put it another way: Just like a modular analog synthesizer, I want to be able to extract and manipulate control signals without needing them to go through the audio signal path. The Teensy Audio Library attempts to normalize all signals in such a way as to treat all Connections as audio signals. A real analog synthesizer has normalization making it "electronically possible" plug any source into any destination, but in practice, we tend to keep control signals and audio signals in strictly different categories unless we're doing AM or FM modulation.

    If I could easily pick apart the control signals and route them as control signals either internally or externally, it would be an enabler. I see the source code for larger Teensy synthesizer projects and developers struggle with this. The DC object helps, but it needs _something_ to make it more versatile.

  16. #16
    Member
    Join Date
    Sep 2020
    Location
    Massachusetts
    Posts
    58
    I am not suggesting all control signals should go through the Teensy audio path.I am suggesting they should not go through the audio path. There is zero percent chance I will ever take a 10Hz sine wave I am using for vibrato and process it as an audio signal with my flanger. There is a chance I would use that LFO to control the clock of my flanger. That distinction needs to exist at a foundational level.

  17. #17
    Member
    Join Date
    Sep 2020
    Location
    Massachusetts
    Posts
    58
    The reason I am chewing on this issue is because I would like to do just that: I would like to be able to control an analog voltage controlled filter with the same envelope code I use to control my virtual sounds. I'll try some thing and post some code here soon. But, my approach probably involves C++ inheritance.

  18. #18
    Senior Member
    Join Date
    Apr 2020
    Location
    Tucson
    Posts
    135
    blakeAlbion, the audio library is very powerful about patchability. It's really just up to what you want to do and connect it with code. My widget has control over 256 sound parameters, all mapped to midi control channels, and it models a modular synth as closely as possible. Just as with a modular, values (voltages) and frequencies are arbitrary. For example, my synth has 8 note polyphony on one voice and 3 lfos per voice capable of modulating 3 vcos. Those "lfos" could just as easily run a frequency sweep across the VCO freq input and give lovely DX7 FM effects by not being lfos at all.

    For what you mention, just pass a DC signal into an envelope gen, and connect the output of the generator to one of the SGTL5000 ports. But remember the SGTL5000 has some special features activated by control bits that may affect its ability to pass a DC signal. Make sure the SGTL5000 doesn't have an internal offset filter that needs to be disabled.

  19. #19
    Member
    Join Date
    Sep 2020
    Location
    Massachusetts
    Posts
    58
    boxxofrobotos, thanks!

    I'm not sure how that would work, but I'll have a helping of that. Does this imply that if I picked some library-compatible DAC I could route the DC to that output?
    Okay, I will read the library code. Any other code I should be looking at?

  20. #20
    Senior Member
    Join Date
    Apr 2020
    Location
    Tucson
    Posts
    135
    Yes, in fact I am working on a widget for eurorack (isn't everyone?) that is easy-peasy ootb library stuff using that nice fat 6 input 8 output codec chip. That's 8 outputs that can carry any signal you decide. Just remember you can't "patch" in the conventional sense. My approach is to use banks of mixers...

  21. #21
    Senior Member
    Join Date
    Apr 2020
    Location
    Tucson
    Posts
    135
    BTW blakeA, if I am understanding you correcttly in your point about not doing things "in the audio path" here's something to consider: When you change a CV at a high rate of delta (as you do digitally with ease) you introduce audible steps. This is why my synth does absolutely everything as an analog model in the "signal path" as much as possible: because every "CV" change needs to happen at sample rate, with proper rate limiting. There's more than 30 filters in my machine that just make sure "control voltages" don't change too fast, or even that square waves from lfos behave more "analog."
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Screenshot from 2020-10-06 10-25-41.jpg 
Views:	16 
Size:	159.2 KB 
ID:	22147  

  22. #22
    Member
    Join Date
    Sep 2020
    Location
    Massachusetts
    Posts
    58
    oh my poor, dated, tiny brain...

  23. #23
    Member
    Join Date
    Sep 2020
    Location
    Massachusetts
    Posts
    58
    I will do a proof-of-concept for this with a modified version of the AudioEffectEnvelope class. I will have a callback update a PWM output, with the attenuation value of the envelope scaled for a 12 bit DAC.

    Code:
    .... end of update method in Envelope
      transmit(block);
      release(block);
      if (functionPointer > 0x00) {
        functionPointer((mult_hires >> 14) / 16);
      }
    }
    
     .... envelope1.setCallback(&handleEnvelopeUpdate);
    
    
    void handleEnvelopeUpdate(int newValue){
      // Serial.println(newValue); // Update that PWM
      analogWrite(22, newValue);
    }
    Let's see how this works with N number of callbacks for N number of envelopes in my application. Probably need to limit the rate of the callback a bit.
    Last edited by blakeAlbion; 10-20-2020 at 02:31 AM.

  24. #24
    Member
    Join Date
    Sep 2020
    Location
    Massachusetts
    Posts
    58
    If nothing else this will let me drive leds with the envelope value; nice eye candy

  25. #25
    Member
    Join Date
    Sep 2020
    Location
    Massachusetts
    Posts
    58
    Yup, my proof-of-concept works end-to-end. I am driving an AS3360 VCA (who loves a zero-to-two volt control range) with a Teensy Audio Library Envelope over a PWM pin on a Teensy 4.0. For my purposes this may be sufficient, or I may want to use an SPI DAC board. And the pulsing green LED is a nice touch.

    I really ought to _extend_ the AudioEffectEnvelope class rather than simply replace it.

Posting Permissions

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