Teensy 3.2 DAC output Low Amplitude

Status
Not open for further replies.

Teenfor3

Well-known member
Are all Teensy 3.2 the same default configuration. I have been using quite a lot of Teensy3.2 lately and I send the same program sketch to them all using the same version IDE. It basically sends an audio tone out on DAC pin which is connected to an amplified speaker. In general all works fine and each has the same loudness of output, except for 2 teensy3.2 where the output is about one third of normal loudness. The teensy otherwise works fine it is only the loudness level is lower. Is there any way of checking if they are from a different batch with maybe different firmware etc. I use analogueReference(internal). or are there any parameters that should be set to ensure things are not changed during programming. When programming I open the IDE, Plug in the teensy and upload to first, then close the small dialogue box after it says rebook OK, then unplug first teensy, then plugin next teensy, click upload and so on. The long compiling is done at first upload, for all other teensy upload, it just does quick upload. Is that the proper procedure??. It is hard to replicate because it has only happened in 2 of about 30 teensys. Recompiling and uploading or uploading a different sketch does not fix the problem, the DAC output is still low.
 
Did some more checking.
I have 15 of teensy3.2 and I checked each with only a lineout jack connected between DAC and analogue Ground. Plugged this into computer linein and recorded each teensy output using Audacity. I had each teensy running a simple waveform sending out to DAC. All 15 gave me +/- 5db to 6db on Audacity for my setting which is normal, so I assume they are OK to use in my project. Doing same with the 2 teensy I think faulty gave me output +/- 2db to 3db. I did notice if I run the faulty ones for several minutes the output changes from time to tine for about 1 second and nothing touching the wiring or computer. ????
 
I had each teensy running a simple waveform sending out to DAC.
Could you share this code? Then I can upload this to a number of T3.2's and check the DAC output here as well.

Paul
 
Just wondering, should you use the digital GND connection for DAC output instead of the analog GND pin?
I believe (but I could be wrong) the AGND pin is to be used for ADC input only.

Vssa.PNG

Is this easy for you to try out on the 2 faulty T3.2's? There is a digital GND pin next to the program button.

Paul
 
Are these boards connected to anything else while you're testing? The DAC output does not have a really strong drive. So if you're got these mounted to another PCB or anything else, even if you're convinced it wouldn't have any effect, now is the time to consider that it might be dragging down the voltage by unexpectedly putting a load on the DAC pin.

You're talking about Teensy being faulty. While almost anything is theoretically possible, having a pin work partially is a pretty unlikely failure mode. The common ways for a Teensy to be wrong are a pin not connected, or shorted to something else.

The only explanation that makes sense is if the DAC pin is shorted to another pin which is in output mode, or something else that is acting as a load, trying to drive the signal low while the DAC tries to drive the pin high. Just recently we had a thread about a problem on Teensy LC where the pin was configured in output mode (which can't happen on Teensy 3.2 since the DAC pin doesn't have digital output capability). But a short to another pin which is configured in output mode would give this behavior.

So my question is how is the Teensy 3.2 you're testing really connected. Is it truly sitting on a non-conductive surface, not soldered or connected to any other stuff, with no possibility anything else might be connected to that misbehaving DAC pin?
 
Thanks for reply, I have always used AGND but have tried both now and dont see any difference, problem still there.
I didnt post any test code earlier most teensys dont show the problem and I maybe never noticed the problem on a single teensy. It was only when I was testing a number of them one after the other I noticed one had a lower audio volume than the rest, and now it has occurred again. It is basically any audio output sketch that I tried showed up the problem on the 2 faulty ones and If I replace the faulty teensy in the existing wired project the new teensy works OK and no changes to the wiring, so problem must be with the teensy. So all I was doing to test was run any audio sketch into a good teensy3.2 and also the faulty teensy3.2 and compare the DAC out either on amp speaker or in audacity. I have now attached a sketch that runs a simple sine waveform and plays it out on DAC. I noticed that changing analogue Ref from internal to external makes a difference. On EXTERNAL both good and faulty teensy give the same amplitude, I set my audacity to be 1db for for the sketch highest part of the wave. Then changed sketch to INTERNAL and good teensy gave about 0.4db and faulty teensy gave me about 0.1db for the same sketch (INTERNAL) highest part of the wave.
I have also tried analogewrite (128) and (256) and get 1.65 and 3.3 volts with DMM on good and faulty both.

Code:
#include <Audio.h>

const int16_t tone1[256] = {
0,
628,
1256,
1883,
2509,
3133,
3756,
4376,
4994,
5608,
6220,
6827,
7431,
8030,
8624,
9213,
9796,
10374,
10945,
11510,
12067,
12618,
13160,
13696,
14222,
14740,
15249,
15750,
16240,
16721,
17192,
17652,
18102,
18540,
18968,
19384,
19789,
20181,
20562,
20930,
21285,
21628,
21957,
22274,
22577,
22866,
23142,
23403,
23651,
23884,
24103,
24307,
24497,
24672,
24832,
24977,
25108,
25223,
25322,
25407,
25476,
25530,
25569,
25592,
25600,
25592,
25569,
25530,
25476,
25407,
25322,
25223,
25108,
24977,
24832,
24672,
24497,
24307,
24103,
23884,
23651,
23403,
23142,
22866,
22577,
22274,
21957,
21628,
21285,
20930,
20562,
20181,
19789,
19384,
18968,
18540,
18102,
17652,
17192,
16721,
16240,
15750,
15249,
14740,
14222,
13696,
13160,
12618,
12067,
11510,
10945,
10374,
9796,
9213,
8624,
8030,
7431,
6827,
6220,
5608,
4994,
4376,
3756,
3133,
2509,
1883,
1256,
628,
0,
-629,
-1256,
-1884,
-2510,
-3134,
-3757,
-4377,
-4995,
-5609,
-6221,
-6828,
-7432,
-8031,
-8625,
-9214,
-9797,
-10375,
-10946,
-11511,
-12068,
-12619,
-13161,
-13696,
-14223,
-14741,
-15250,
-15751,
-16241,
-16722,
-17192,
-17653,
-18103,
-18541,
-18969,
-19385,
-19790,
-20182,
-20563,
-20931,
-21286,
-21629,
-21958,
-22275,
-22578,
-22867,
-23143,
-23404,
-23652,
-23885,
-24104,
-24308,
-24498,
-24673,
-24833,
-24978,
-25109,
-25224,
-25323,
-25408,
-25477,
-25531,
-25570,
-25593,
-25600,
-25593,
-25570,
-25531,
-25477,
-25408,
-25323,
-25224,
-25109,
-24978,
-24833,
-24673,
-24498,
-24308,
-24104,
-23885,
-23652,
-23404,
-23143,
-22867,
-22578,
-22275,
-21958,
-21629,
-21286,
-20931,
-20563,
-20182,
-19790,
-19385,
-18969,
-18541,
-18103,
-17653,
-17192,
-16722,
-16241,
-15751,
-15250,
-14741,
-14223,
-13696,
-13161,
-12619,
-12068,
-11511,
-10946,
-10375,
-9797,
-9214,
-8625,
-8031,
-7432,
-6828,
-6221,
-5609,
-4995,
-4377,
-3757,
-3134,
-2510,
-1884,
-1256,
-629
};


// GUItool: begin automatically generated code
AudioSynthWaveform       waveform1;      //xy=285,868
AudioOutputAnalog        dac1;           //xy=739,914
AudioConnection          patchCord1(waveform1, 0, dac1, 0);

// GUItool: end automatically generated code

int freq = 800;

float wavamp = 0.9;


void setup() {
  // put your setup code here, to run once:

 AudioMemory(150); //set memory allocation
        
  // by default the Teensy 3.1 DAC uses 3.3Vp-p output
  // if your 3.3V power has noise, switching to the
  // internal 1.2V reference can give you a clean signal
   dac1.analogReference(INTERNAL);
   // dac1.analogReference(EXTERNAL);
   
    delay(40);
    
   // GHB 482 default ........................ HA
     waveform1.begin(0.5, 1, WAVEFORM_ARBITRARY);  
     waveform1.arbitraryWaveform(tone1, 1200);   
   }

void loop() {
  // put your main code here, to run repeatedly:
  
   waveform1.amplitude(wavamp);
 
delay(200);

for( int i = 1000; i > 0;i-=100)
{
 waveform1.frequency(i);

 delay(200);
}
 //waveform1.amplitude(0.0);
 waveform1.amplitude(0.8);
 //waveform1.frequency(0.0);
// waveform1.amplitude(0.0);
 delay(200);
 wavamp = wavamp + 0.1;
 if (wavamp >= 1.05) wavamp = 0.00;

}
 
Thanks PaulStoffregen for your reply. Sorry I was typing my last post when you were posting. Yes the "faulty" board is only connected to the USB port of my computer sitting in isolation on my wooden plastic desktop and as far as I can see the nothing is connected to any pins. It had been soldered in my project when fault discovered and all I did was unsolder it and solder in a new on and the project worked perfect with new board. I now have the faulty board with nothing connected except USB programming and a audio jack wires clipped to DAC pin and AGND and also tried GND.
 
When I change the line dac1.analogreference to INTERNAL in the test sketch from my earlier post the output of the "faulty" teensy is about one quarter amplitude it should be. Comparing to same test on good teensy. When I set it to EXTERNAL the output from both teensy is higher due to EXTERNAL ref but both DAC give same amplitude. which leads me to believe it cannot be a short on the pins etc ???. It must be something to do with INTERNAL ref or how I am using it. the only thing I do is change the line of code, I dont connect any ref voltages etc. ???
When I run the sketch below in this post both good and faulty boards DAC outputs give same output. This sketch does not refer to INTERNAL or EXTERNAL refs so which is it using.??

Code:
// Simple DAC sine wave test on Teensy 3.1

float phase = 0.0;
float twopi = 3.14159 * 2;
elapsedMicros usec = 0;

void setup() {
  analogWriteResolution(12);
}

void loop() {
  float val = sin(phase) * 1000.0 + 2050.0;
  analogWrite(A14, (int)val);
  phase = phase + 0.02;
  if (phase >= twopi) phase = 0;
  while (usec < 5) ; // wait
  usec = usec - 5;
}
 
I have looked all around the board and cannot see anything bridging or shorting any of the pins or the pins on the chip. The only other thing I found is the DC voltage at the DAC pin on a good Teensy is 0.6 volts on my DMM whereas the DC voltage at the DAC pin on the " 2 faulty ones" is 0.16 volts....??? This is the voltage measured with only USB port on teensy plugged in and teensy loaded with the arbitrary wave sketch posted earlier post. With the analogWrite sketch both the good teensy and the bad teensy give 1.61 volts at the DAC pin measured with my DMM.
 
Last edited:
I still haven't got to the bottom of this problem. I have connected up maybe 60 Teensy3.2 over the past years and never had this problem until recently. I have connected another 10 this week and found 2 to have this problem. They were given the same connections athe others and the same sketch yet these 2 have lower volume DAC output. I measured the DC voltage at the DAC pin and found the following.....depending on where I had dac.analogReference EXTERNAL or INTERNAL.......
Good teensy INTERNAL 0.6 volt, Good Teensy EXTERNAL 1.64 volts.
Bad teensy INTERNAL 0.116 volt, Bad Teensy EXTERNAL 1.64 volts.
Dodgy teensy INTERNAL 0.45 volt, Dodgy teensy EXTERNAL 1.65 volts.
All of the teensy were working just low volume on the bad one. The dodgy teensy had just slightly lower volume and was slight crackling sound at times.
All the teensy good bad and dodgy worked well on EXTERNAL and no crackling but much more volume so I had to change other setting in my project to compensate. I can work with EXTERNAL setting OK but still wondering why this is happening. It looks like on some teensy the DAC does not default to EXTERNAL. Is the 3.3 volt looked at as EXTERNAL..???

// by default the Teensy 3.1 DAC uses 3.3Vp-p output
// if your 3.3V power has noise, switching to the
// internal 1.2V reference can give you a clean signal
// dac.analogReference(INTERNAL);
dac.analogReference(EXTERNAL);

What else should I be setting when using these commands. ?? Should I actually have a voltage reference of some sort wired in...??

Is there something intermittent or at random happening because I have something not setup.??
 
The 1.2V reference on Teensy 3.2 depends on capacitor C2 and its connection to pin 17 on U1.

parts_placement_teensy32_top_vref.png

Maybe this capacitor was somehow damaged? If you visually inspect the boards, that is the place to look for trouble.

You could also try measuring the voltage on the side of C2 facing the main chip (U1), if you have a multimeter probe small enough to touch that tiny C2 capacitor. It should measure 1.2V.
 
Last edited:
Thanks for reply. I have checked around this capacitor C2 and cannot see any damage. The closest pins to it had not been soldered. The only pins that had been soldered are 15-19, 22, 23, 25, 32,33,0, and 1.
The voltage at C2 is same as 17 on U1. On the faulty teensy for INTERNAL Ref, DAC is 0.19V, Cap C2 is 0.36V and for EXTERNAL Ref DAC is 1.65V, Cap C2 is 0.36V
 
I am having a similar issue and would like to know if a solution was found. I have only recently started getting these problems as well. My problem occurs after the program has been running for a while.

I was going to do a post, but will hold off to see if the solution is presented here. I am also thinking of just doing an opamp to mitigate potential load effects on the DAC pin which can handle a max of 1mA.

Question: When you use the external reference, does it work as expected?
 
No the problem has not been solved. I got the "faulty" Teensy3.2s replaced and they worked OK, Internal Ref and External Ref settings.
In my case the voltage on C2 was low. But dont know for what reason except as stated in earlier posts. Would an overload on DAC blow the Internal Ref or simply blow the DAC pin output. The DAC pin output continued to work OK on External Ref even if C2 volts were low....so suggests to me DAC pin was not blown by an overload in this case. I ever only had it connected to a Line Input on an amplified speaker. Also the output was low from first switched on, it didn't work OK for a while and then go low.

What are your symptoms ??. Have you taken any measurements ??.

When I use external Ref it works as expected. I have used about 25 teensy since noticing the problem and have programmed them all to use external Ref and all working OK. I checked some of them for voltage on C2 and all that were checked measured OK.

When I say I use external Ref all I do is add the line ... dac.analogReference(EXTERNAL); in the sketch ...... I have no additional Int or Ext reference voltage connected.

I had been hoping that some more interrogation could have been done to see what actually happened regards settings, register bits set etc to see if all was setup correctly. ??
But I would need some help or pointers in that regard.
 
What are your symptoms ??. Have you taken any measurements ??.

When I use external Ref it works as expected. I have used about 25 teensy since noticing the problem and have programmed them all to use external Ref and all working OK. I checked some of them for voltage on C2 and all that were checked measured OK.

When I say I use external Ref all I do is add the line ... dac.analogReference(EXTERNAL); in the sketch ...... I have no additional Int or Ext reference voltage connected.

I had been hoping that some more interrogation could have been done to see what actually happened regards settings, register bits set etc to see if all was setup correctly. ??
But I would need some help or pointers in that regard.

I did some measurements yesterday of one of 3 that were "broken." The C2 reference for the broken one was still 1.2V as Paul had mentioned it should be.

I tried switching between External and Internal References with no change in the DAC pin. I used the following to try and enable between the internal/external reference:

Code:
DAC0_C0 = DAC_C0_DACEN | DAC_C0_DACRFS;    //Uses 3.3V reference, DACREF_2.    For Internal Reference 1.2V DAC0_C0 = DAC_C0_DACEN;

This may be wrong, but I read this in another section and I believe I tried to verify with the datasheet.

Symptoms I am having:

We have a PWM input on pin 5, in which the code will parse and send a PWM output to a servo through pin 9, and then the DAC will convert the ADC value to 4095 resolution for an analog output to another board.

Code:
TPSadc = map(ServoOUT,ThrottleClosed,ThrottleOpen,0,4095);         // map throttle servo values to DAC output range
    tps_part = map(ServoOUT,ThrottleClosed,ThrottleOpen,0,100);        // this is throttle variable going out to Particle mother board
    //analogWriteResolution(12);                                         // zero to 4095 resolution setting
    analogWrite(A14, TPSadc);                                          // send new DAC value

However, after a period of running, the DAC pin appears to break and not exceed a "random" voltage which I am thinking is related to the last analog value sent. (i.e. I have had the DAC pin max at ~1V and another max at ~2.4V). I have yet to figure out if this is a software issue or simply the DAC pin being overloaded. I am inclined to think the DAC pin is being overloaded because there is potential for transient current load (short through a few capacitors) upon startup. This can especially occur if the ADC value upon turn on/output is above 1V in which is very possible for our system due to the PWM signal.

I am currently in the process of doing an OpAmp unity follower to mitigate the risk of transient current load and general load on the DAC pin.
 
I don't think your problem is same as mine.......
The C2 reference for the broken one was still 1.2V
In may case the 1.2V on C2 was low for "broken".
I tried switching between External and Internal References with no change in the DAC pin.
What change were you expecting, what were you measuring??.

Are you using the Audio Library, use the commands/statements from it to do the changes.

You would need a simple test sketch to test each bit and try and isolate is it a PWM or ADC or DAC problem??

after a period of running, the DAC pin appears to break and not exceed a "random" voltage

Does teensy break, broken and not work at all on any DAC sketch or can it be rebooted and work again then break again when running your sketch.??

The OPAmp may provide a buffer but may mask the real problem. ??
 
What change were you expecting, what were you measuring??.

I was hoping that switching the references would yield a change in the output of the DAC pin.

Are you using the Audio Library, use the commands/statements from it to do the changes.

You would need a simple test sketch to test each bit and try and isolate is it a PWM or ADC or DAC problem??

Very Very good point. I will have to try that next. This will help me identify the root cause between software/hardware. I am not using an Audio Library. I took this project over from a previous engineer's work. It does not appear that audio library or any other library is being used to directly initialize the DAC pin. The code I pasted earlier is the only reference to the DAC and is an analogWrite function with mapping resolution.



Does teensy break, broken and not work at all on any DAC sketch or can it be rebooted and work again then break again when running your sketch.??

The remaining pins and functions of the Teensy work perfectly fine. Only A14 Pin appears "broken." I use "broken" in quotations because I do not know for certain the pin is broken. I can only say with certainty that with the other board not attached and direct measuring (nothing else attached) on A14 with my sketch and PWM input, the output does stops at the "random" voltage. (aka 1.2V on one board and ~2volts on another board). I did read the analog write value and the value is correct but the output voltage of the pin is incorrect.
 
How do you know A14 is broken. How are you measuring it. If using a multimeter you will read only the dc value 0.6V or 1.64V if the ac signal is high freq. If using a scope you should see both the ac signal superimposed on the dc value. Try simple sketch in post #8 above
 
How do you know A14 is broken. How are you measuring it. If using a multimeter you will read only the dc value 0.6V or 1.64V if the ac signal is high freq. If using a scope you should see both the ac signal superimposed on the dc value. Try simple sketch in post #8 above

I will definitely try that out! Thank you for your help so far. I believe you are correct that my problem is not your problem as well. I went and reread this post again.

From my understanding about your problem:

- Sinusoidal Amplitude from DAC is a lower amplitude than other "good" teensy3.2s.
- When you change reference from INTERNAL to EXTERNAL the amplitude is corrected?
- When you performed an Analog write 128/256, the output voltage was correct of 1.65/3.3V.

My problem:

- The analogWrite(12 bit resolution) of 4095 is not outputting a max 3.3V but rather lower voltages.
- I.e. One teensy now has a max of 1V (1240) output. Any analog write higher than 1240 remains at a 1V max regardless of ADC value.
- I can analogWrite lower values such as 900 and the voltage will change to the correct voltage.


I am trying to correspond values from 0-4095 with 0-3.3V, and that is how I came to the assumption that the A14 pin broke. I measured the voltage of A14 both with a multimeter and oscope, and both max out at 1V for the one board regardless of a 4095 analogWrite.

Thank you once again Teenfor3. You have been a great help so far and I will definitely upload sketch from post #8 to see if A14 works properly with that sketch.
 
This is a simpler sketch and lets you see 0.0. to 3.3 in 0.1V steps on DMM using analog write only an 12 bit resolution

Code:
// Simple DAC  test on Teensy 3.2
// maps 3.3 volts to 4096 in 0.1V intervals
// 4096 divided by 33 is 124 counts per 0.1V approx.

int val=0;

void setup() {
  analogWriteResolution(12);
}

void loop() {
  
  analogWrite(A14, val);

val = val + 124;

if (val >= 4096) val = 0;
delay(3000);
  
}
 
This is a variation of my last post. I allows switching between EXTERNAL and INTERNAL Refs for the DAC and hence for 12 bit resolution maps either 1.2 V to 4096 OR 3.3V to 4096
Default for good teensy uses 3.3V and doesn't need the line ..... comment out either line to try both options

Code:
// Simple DAC  test on Teensy 3.2
// maps 3.3 volts to 4096 in 0.1V intervals
// 4096 divided by 33 is 124 counts per 0.1V approx.
//  above works as default or if this Ref is added to sketch ... analogReference(EXTERNAL);
//  If this Ref .... analogReference(INTERNAL); ... is added to sketch them DAC increments 0.0 to 1.2V for 0 to 4096 counts.
//   change sketch to 4096 divided by 12 = 341 for 0.1V increments on DAC pin.

int val=0;

void setup() {
  
 //  analogReference(INTERNAL);
     analogReference(EXTERNAL);
  
  analogWriteResolution(12);
}

void loop() {
  
  analogWrite(A14, val);

      val = val + 124;     // for default or EXT and 0.1V inc to 3.3V
 //   val = val + 341;  // for INT and 0.1V inc to 1.2V

if (val >= 4096) val = 0;
delay(3000);
  
}

I tried your line of code below and it didnt work for this simple sketch, but teensy still worked again when I removed it with the sketch above.
DAC0_C0 = DAC_C0_DACEN | DAC_C0_DACRFS; //Uses 3.3V reference, DACREF_2. For Internal Reference 1.2V DAC0_C0 = DAC_C0_DACEN;
 
Last edited:
Status
Not open for further replies.
Back
Top