I'm stumped. I've tried everything I can think of to get rid of the 6.35 hz peak and the garbage up to the 2K peak from the sine wave sample. I lowered the teensy clock to 24 MHz in case that was the cause I also changed the cable which only has a single 100uf cap in the signal path. Previously it was a low pass filter at about 16khz. No change, I still show the large peak at 6.36hz and it tapers off in a linear fashion down to the peaks I'd expect from the sine code. I'm recording up to 0db hoping the signal would be higher than the noise. Still showing the same basic wave form. The FFT is from Adobe Audition and the sound card is built into my Lenovo M900. Does anyone have an idea where I could be getting the almost 0db peak at 6.35hz? I'm out of things to try other than a new sound card or another teensy. Thanks.
Attached is the frequency analysis screen from audition.
Attached is the frequency analysis screen from audition.
Code:
#include "math.h"
//Teensy 3.2 & 3.1 have a proper analog output. You can always filter PWM, but true analog output responds rapidly. The output is created by the stable reference voltage, so it's doesn't vary if your power supply voltage changes slightly.
// Simple DAC sine wave test on Teensy 3.1
float phase = 0.0;
float twopi = 3.14159 * 2;
elapsedMicros usec = 0;
void setup() {
Serial.begin(57600);
analogWriteResolution(12);
}
void loop() {
float val = sin(phase) * 2000.0 + 2500.0;
// float val = sin(phase) * 2000.0;
analogWrite(A14, val);
// Serial.println(val);
phase = phase + 0.02;
if (phase >= twopi) phase = 0;
while (usec < 500) ; // wait
usec = usec - 500;
}