Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 12 of 12

Thread: dac in on propshield with teensy 3.2

  1. #1
    Junior Member
    Join Date
    Oct 2016
    Posts
    18

    dac in on propshield with teensy 3.2

    Does anyone have a working example of the mono audio through sketch, using propshield and 3.2?

    I can get audio out, but there is something I'm missing, most likely in the code. I can't get any sign of life from the dac in port as shown here:

    https://www.pjrc.com/store/propshield_pinout.png
    https://www.pjrc.com/store/prop_shield.html

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,252

    Cool Prop shield sound tests

    Here are some tests that I have used in the past.

    Here are some sound samples that I converted to RAW format. The sounds originally came from Adafruit for one of their Halloween builds. You will need these for PropSound2:


    Here are my current config and library files (you will need Meissner_Config for PropSound2):


    Here are 3 tests:


    The tests are:
    • PropSound: This test originally came from Paul, and I modified it to take input from the USB serial console to raise/lower the sine wave;
    • PropSound2: This test just plays a bunch of pre-recorded sounds from memory (it needs the libraries in the first 2 zip files);
    • Talkie_Clock: This is a test originally from Peter Knight to have a voice say a time. I think this was posted when the prop shield beta was being performed.
    ]

    I tend to use this speaker for connecting to the Prop shield:
    Attached Files Attached Files

  3. #3
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,192
    you need to connect the T3.2 DAC/A14 to AudioIn on the propshield. Yes?

  4. #4
    Junior Member
    Join Date
    Oct 2016
    Posts
    18
    Quote Originally Posted by MichaelMeissner View Post
    Here are some tests that I have used in the past.

    Here are some sound samples that I converted to RAW format. The sounds originally came from Adafruit for one of their Halloween builds. You will need these for PropSound2:


    Here are my current config and library files (you will need Meissner_Config for PropSound2):


    Here are 3 tests:


    The tests are:
    • PropSound: This test originally came from Paul, and I modified it to take input from the USB serial console to raise/lower the sine wave;
    • PropSound2: This test just plays a bunch of pre-recorded sounds from memory (it needs the libraries in the first 2 zip files);
    • Talkie_Clock: This is a test originally from Peter Knight to have a voice say a time. I think this was posted when the prop shield beta was being performed.
    ]

    I tend to use this speaker for connecting to the Prop shield:
    Unless I misunderstand you, they are all dac out tests. i have that working, I need dac in.

  5. #5
    Junior Member
    Join Date
    Oct 2016
    Posts
    18
    Quote Originally Posted by manitou View Post
    you need to connect the T3.2 DAC/A14 to AudioIn on the propshield. Yes?
    Kinda, but they are seperate inputs are they not? I'm focussing on using the dac in on the propshield.

  6. #6
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,192
    Quote Originally Posted by Peter2708 View Post
    Kinda, but they are seperate inputs are they not? I'm focussing on using the dac in on the propshield.
    DAC is an output not an input. There is no DAC on the propshield. Connect T3.2 DAC/A14 to AudioIn on propshield to have T3.2 generate sounds/sinewave out DAC to AudioIn ... to speaker on propshield. See schematic https://www.pjrc.com/store/prop_shield.html

    if you have propshield mounted on top of T3.2, the DAC and AudioIn pin/holes are right above each other.

    Here is simple sketch to generate sine wave on T3.2 DAC, hook DAC to propshield AudioIn and listen to tone on propshield speaker.

    Code:
    float phase = 0.0;
    float twopi = 3.14159 * 2;
    elapsedMicros usec = 0;
    
    void setup() {
      analogWriteResolution(12);
    }
    
    void loop() {
      float val = sinf(phase) * 2048.0 + 2048.0;
      analogWrite(A14, (int)val);
      phase = phase + 0.02;
      if (phase >= twopi) phase = 0;
      while (usec < 500) ; // wait
      usec = usec - 500;
    }
    Don't forget digitalWrite(5,HIGH); to enable amp on propshield.

    or use the Audio library to drive DAC
    Code:
    // prop shield need pin 5
    // start monitor to hear sound,  hit key to increase freq
    #include <Audio.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioSynthWaveformSine   sine1;          //xy=180,469
    AudioOutputAnalog        dac1;           //xy=380,468
    AudioConnection          patchCord1(sine1, dac1);
    // GUItool: end automatically generated code
    
    int freq = 1100;
    
    void setup() {
    	Serial.begin(9600);
    	while (!Serial);
    	Serial.println("Setting up");
      //dac1.analogReference(EXTERNAL);   // louder, default is 1.2v INTERNAL
    	pinMode(5, OUTPUT);
    	digitalWrite(5, 1);//Enable Amplifier.
    	AudioMemory(12);
    	sine1.amplitude(1.0);
    	sine1.frequency(1000);
    	Serial.println("Send Serial Char to increase freq");
    }
    
    void loop()
    {
    	if (Serial.available()) {
    		Serial.read();
    		sine1.frequency(freq);
    		Serial.println(freq);
    		freq += 100;
    	}
    }
    Last edited by manitou; 02-18-2018 at 11:07 PM.

  7. #7
    Junior Member
    Join Date
    Oct 2016
    Posts
    18
    Quote Originally Posted by manitou View Post
    DAC is an output not an input. There is no DAC on the propshield. Connect T3.2 DAC/A14 to AudioIn on propshield to have T3.2 generate sounds/sinewave out DAC to AudioIn ... to speaker on propshield. See schematic https://www.pjrc.com/store/prop_shield.html

    if you have propshield mounted on top of T3.2, the DAC and AudioIn pin/holes are right above each other.

    Here is simple sketch to generate sine wave on T3.2 DAC, hook DAC to propshield AudioIn and listen to tone on propshield speaker.

    Code:
    float phase = 0.0;
    float twopi = 3.14159 * 2;
    elapsedMicros usec = 0;
    
    void setup() {
      analogWriteResolution(12);
    }
    
    void loop() {
      float val = sinf(phase) * 2048.0 + 2048.0;
      analogWrite(A14, (int)val);
      phase = phase + 0.02;
      if (phase >= twopi) phase = 0;
      while (usec < 500) ; // wait
      usec = usec - 500;
    }
    Don't forget digitalWrite(5,HIGH); to enable amp on propshield.

    or use the Audio library to drive DAC
    Code:
    // prop shield need pin 5
    // start monitor to hear sound,  hit key to increase freq
    #include <Audio.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioSynthWaveformSine   sine1;          //xy=180,469
    AudioOutputAnalog        dac1;           //xy=380,468
    AudioConnection          patchCord1(sine1, dac1);
    // GUItool: end automatically generated code
    
    int freq = 1100;
    
    void setup() {
    	Serial.begin(9600);
    	while (!Serial);
    	Serial.println("Setting up");
      //dac1.analogReference(EXTERNAL);   // louder, default is 1.2v INTERNAL
    	pinMode(5, OUTPUT);
    	digitalWrite(5, 1);//Enable Amplifier.
    	AudioMemory(12);
    	sine1.amplitude(1.0);
    	sine1.frequency(1000);
    	Serial.println("Send Serial Char to increase freq");
    }
    
    void loop()
    {
    	if (Serial.available()) {
    		Serial.read();
    		sine1.frequency(freq);
    		Serial.println(freq);
    		freq += 100;
    	}
    }
    Thanks, I have no problem getting audio out, with or without the audio shield.

    There is a pin confusingly marked dac in on the prop shield, are you telling me that this is just badly labelled. Is there no way to get audio IN to teensy?

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,556
    Quote Originally Posted by Peter2708 View Post
    Is there no way to get audio IN to teensy?
    Yes, there are ways, but the prop shield is designed to only do audio output.

    For audio input, you'd need the audio shield, or something like this microphone board, or build the circuit documented here (right-side panel under "Hardware"), or one of the many I2S MEMS mics, or something similar to any of these.

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,556
    Might also be worth mentioning DAC stands for "Digital to Analog Converter", which necessarily means analog output.

    For analog input, you want ADC for "Analog to Digital Converter".

    And yeah, we should probably look at revising the labeling on the prop shield for future batches. Any feedback about what would have been clearer?

  10. #10
    Junior Member
    Join Date
    Oct 2016
    Posts
    18
    Quote Originally Posted by PaulStoffregen View Post
    Might also be worth mentioning DAC stands for "Digital to Analog Converter", which necessarily means analog output.

    For analog input, you want ADC for "Analog to Digital Converter".

    And yeah, we should probably look at revising the labeling on the prop shield for future batches. Any feedback about what would have been clearer?
    That is indeed why I found the label confusing.

    After looking at your schematic, perhaps just Amp In might be easier to understand.

  11. #11
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,530
    Looking at the schematic of the prop shield where the so called DAC pin signal goes to the input of an audio amplifier IC, and seen that the pin is physically located to connect almost automatically to the DAC output of the Teensy 3.2, I can‘t see any ambiguity or confusion...

  12. #12
    Junior Member
    Join Date
    Oct 2016
    Posts
    18
    Quote Originally Posted by Theremingenieur View Post
    Looking at the schematic of the prop shield where the so called DAC pin signal goes to the input of an audio amplifier IC, and seen that the pin is physically located to connect almost automatically to the DAC output of the Teensy 3.2, I can‘t see any ambiguity or confusion...
    The schematic is not ambiguous. The label DAC IN confused me, and still does I'm sorry to say.

Tags for this Thread

Posting Permissions

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