PT8211 and Teensy 4

Status
Not open for further replies.

kets

Active member
Hi
Thanks for an amazing product.
I have made a small midi bass synth using T4 and 25L12835F flash and PT8211 as audio output.

My problems two:
1. Using PT8211 create a lot of computer noise on the output.
when I instead use TDA1311A (compatible) the noise is gone.
I have followed all the rules of design for my PC board.
Has anybody had the same experience with PT8211.

2. My synth is mono so I only need one channel of the DAC so I use L, but I'm forced to connect the same source for both channels as input.
If I don't my code hangs. This was not the case when I used T3.2 instead.

include <Audio.h>
#include <Wire.h>
#include <SerialFlash.h>
#include <SPI.h>
#include <Bounce2.h>
#include <MIDI.h>

MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);


// Create the Audio components. These should be created in the
// order data flows, inputs/sources -> processing -> outputs
//
// basstämma
AudioPlaySerialflashRaw bas[2];
AudioEffectEnvelope env[2];

// ackordskomp 3-4 stämmor samtidigt
AudioPlaySerialflashRaw acc[4];
AudioMixer4 mix0;

AudioMixer4 mix1;
AudioMixer4 mix2;
AudioOutputPT8211 ptout;

// basen
AudioConnection c0(bas[0], 0, env[0], 0);
AudioConnection c1(bas[1], 0, env[1], 0);

// kompet in i mixer 0
AudioConnection c2(acc[0], 0, mix0, 0);
AudioConnection c3(acc[1], 0, mix0, 1);
AudioConnection c4(acc[2], 0, mix0, 2);
AudioConnection c5(acc[3], 0, mix0, 3);

// mixa ihop bas och komp
AudioConnection c10(env[0], 0, mix1, 0);
AudioConnection c11(env[1], 0, mix1, 1);
AudioConnection c12(mix0, 0, mix1, 2);

// output to PT8211 dac (both L och R)
AudioConnection c20(mix1, 0, ptout, 0);
AudioConnection c21(mix1, 0, ptout, 1);


I'm using Arduino 1.8.12 and Teensy Loader 1.53 on Ubuntu

/Tomas
 
I had similar problem
if you connect the PT8211 VCC to the teensy 3v3 instead of the direct 5VUSB the noise is alot better
but not completely gone if you turn the volume up.
 
Do you know that you can connect the PT8211 to the second I2S port
(using AudioOutputPT8211_2 this is available in the design tool as pt8211_2)

which is PIN-PIN compatible without any overlapping routing
also this makes the lines very short except the VDD but there should be a
decoupling capacitor between VDD and GND so that should not be any problem

teensy4andPT8211.jpg
 
I have used the recomended layout:

BCK: 21
WS: 20
DIN: 9

20201110_111643.jpg
 

Attachments

  • TDA1311.jpg
    TDA1311.jpg
    24 KB · Views: 142
I'd treat the Vdd on the PT8211 as an analog supply, use a separate supply for it from the digital ones (perhaps a 3.3V LDO regulator
from the 5V?). At the very least it needs the filtering circuit from the datasheet, 10 ohms / 47µF+100nF, and an inductor wouldn't be
a bad idea in both the supply and ground to separate out analog from digital at RF.

USB 5V from a computer or laptop is usually pretty noisy from DC to daylight - a separate USB hub supply might be cleaner, especially
in the audio band. Ground noise may be an issue too, which is one reason most high performance ADC/DACs have separate analog
supply and ground.
 
I have already tested using a Powerbank for 5V but no difference.
The noise is more like a distortion of the sound.
I suspect that it comes from the software lib. As I said the TDA1311 chip works perfectly with no distortion.
Also my problem with connection to the pt8211 output indicates software problems.
 
I have already tested using a Powerbank for 5V but no difference.
The noise is more like a distortion of the sound.
I suspect that it comes from the software lib. As I said the TDA1311 chip works perfectly with no distortion.
Also my problem with connection to the pt8211 output indicates software problems.

If its distortion rather than noise, its not noise and we've been chasing our tails a bit!

Have you seen this thread? https://forum.pjrc.com/threads/29284-Dual-channel-16bit-dac-PT8211/page3
 
TDA1311A:
I missed that when I used them. Strangely enough they works perfectly at 3.3V.
I don't know if it just the ones I have.
 
Last edited:
Sound input and output from my midi bass box

I have recorded output from the box to compare with input file.

2_36 is the input
2_36_D is the distorted output

/Tomas
 

Attachments

  • midibass.zip
    43 KB · Views: 91
Hi Tomas,
I listened to your sound samples and there is indeed some distortion added to the original sample. Perhaps caused by the envelope function? Or a clipping mixer?
You may want to post your complete code because importing the code from message #1 into the Audio Design Tool did not show all connections and we need to know how the parameters are set for the different audio blocks.

Paul
 
It's not the Envelope function. I suspected that and removed it but no difference.
here is a testcode that gives the same result. (It loops my bass notes)

#include <Audio.h>
#include <SPI.h>

// Create the Audio components. These should be created in the
// order data flows, inputs/sources -> processing -> outputs
//
AudioPlaySerialflashRaw bas0;
AudioEffectEnvelope env0;

AudioMixer4 mix1;
AudioOutputPT8211 ptout;

// Create Audio connections between the components
//
//AudioConnection c1(bas0, 0, env0, 0);
AudioConnection c2(bas0, 0, mix1, 0);
AudioConnection c5(mix1, 0, ptout, 0);
AudioConnection c6(mix1, 0, ptout, 1);

// SPI flash
#define MOSI 11 // kets
#define MISO 12
#define SCK 13
#define CSPIN 10 // kets


#define LED 6

void setup() {

Serial.begin(9600);

// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(30);

//Set up SPI flashminne
SPI.setMOSI(MOSI);
SPI.setMISO(MISO);
SPI.setSCK(SCK);
if (!SerialFlash.begin(CSPIN)) {
while (1) {
Serial.println("Unable to access SPI Flash chip");
delay(1000);
}
}

//mixer
mix1.gain(0, 0.5); //bas0


}

void loop() {

char abas[20];
for(int i = 28; i <= 47; i++) {
String txtljud = "2_" + String(i) + ".RAW";
txtljud.toCharArray(abas,20);

bas0.play(abas);
env0.noteOn();
while(bas0.isPlaying()) {
digitalWrite(LED, HIGH);
delay(100);
}
env0.noteOff();
digitalWrite(LED, LOW);
delay(1000);
}
}
 
The input and output sound files you sent are in MP3 format.
Since the AudioPlaySerialflashRaw block requires the data to be RAW 16 bit signed integers in LSB-first format, could there be a problem with converting the MP3 input file to RAW 16 bit format?
[on the other hand, you said the TDA1311A played well...]
What happens if you remove the mixer as well?

Paul
 
No I convert from wav-format using sox. Here is the file.
 

Attachments

  • 2_36.RAW.zip
    166.4 KB · Views: 74
I have tested to remove mixer also. The same result.
However if I use the mixer and reduce volume to say 0.05 and play the noise/distortion is almost as loud as my sample.
This indicates that the pt8211 output is the problem.
I also need to have bas0 routed to both channels of ptout. If not I get no sound at all.

/Tomas
 
Strange... Perhaps your PT8211 part is just broken?
I used the PT8211 board from PJRC several times and never had an issue with it. Did you buy the board or just the chip?

Paul
 
They are chips I did buy from Ebay. I have mounted 2 of them on different boards with the same result.
In that case all of my chips are broken. Or are they very sensitive to solder?

Tomas
 
There are different versions of PT8211.
Mine is called PT8211-H. It's not branded Ptc (original)

There is also PT8211-S and plain PT8211 around.

Question is if that matters?
Which is on your card from PJRC?

/Tomas
 

Attachments

  • 20201111_185728.jpg
    20201111_185728.jpg
    115.3 KB · Views: 82
I certainly would never trust any chip bought from eBay these days in the slightest unless I knew
the reputation of the seller.

I looked at the spectrum of the signals and the "distorted" one had a higher level of harmonics, extending beyond the clean
signal well above 1.4kHz, suggesting fairly heavy harmonic and intermodulation distortion (basically like a fuzz-box does).

If you want a better test signal try something like a 800Hz / 1kHz two tone, and look at the spectral artifacts.
 
Emailed Princeton in Taiwan about the PT8211-H. Their reply:
Dear Sir:

Thank you for your interests toward our product. Please be informed that we don’t have PT8211-H. If you have any further question, please feel free to contact us.

Best regards

Well, that's confirmed then.
Paul
 
Status
Not open for further replies.
Back
Top