Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 6 FirstFirst 1 2 3 4 ... LastLast
Results 26 to 50 of 132

Thread: Dual channel 16bit dac PT8211

  1. #26
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    Hm, looks exactly like the picture in the Datasheet now:
    Click image for larger version. 

Name:	screenshot.jpg 
Views:	128 
Size:	27.5 KB 
ID:	7534
    (i've set the right channel to output zeros. top: BitClock, mid: LR-Clock, last: Data)

    Click image for larger version. 

Name:	Image1.jpg 
Views:	912 
Size:	35.0 KB 
ID:	7535

    I'll make a new "output_pt8211" in my github and a pullrequest as soon i have verified that it works. Should have the chips in a few days - have some sop-adapters that i can use for testing..
    Last edited by Frank B; 07-04-2016 at 07:46 PM.

  2. #27
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    This format is called "right justified", IIRC. Maybe this more generic name is better suited for the object?

  3. #28
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    let's hear what Paul says..

    https://github.com/FrankBoesing/output_pt8211

    I'm very curoius wether it works or not..

    edit: there are some more changes:
    - i've disabled MCLK (not needed)
    - i've deleted the i2s input
    Last edited by Frank B; 07-04-2016 at 08:45 PM.

  4. #29
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    Quote Originally Posted by Frank B View Post
    let's hear what Paul says..

    https://github.com/FrankBoesing/output_pt8211

    I'm very curoius wether it works or not..

    edit: there are some more changes:
    - i've disabled MCLK (not needed)
    - i've deleted the i2s input
    First, @BEN, thank you for the chips!

    I soldered one to an SOP-Adpterboard, output is connected directly to a chinese amplifier-board for a few $ - andit WORKS.
    Ok, at least it sounds ok - i have a small speaker connected and can't say wether the qualtiy is good or not.

    Maybe, someone with an oscilloskope can check the waveforms ?

    @Paul, want a pullrequest ? The waveform-check is the only thing missing, and maybe it could go into the next beta ?


    Click image for larger version. 

Name:	DSC_0318[1].jpg 
Views:	144 
Size:	36.8 KB 
ID:	7577

    Last edited by Frank B; 07-07-2016 at 05:43 PM. Reason: add pic

  5. #30
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Oh that's great news! I can help with the scope waveform, but not before next week. Do you power the DAC from 5 or 3V3?

  6. #31
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    Quote Originally Posted by Ben View Post
    Oh that's great news! I can help with the scope waveform, but not before next week. Do you power the DAC from 5 or 3V3?
    Both works. I measured 5.1 Volt.
    Don't hurry.. :-)

    Maybe next week, we can speak about filters and a Vreg (if required...)
    I want to make a board (I'm still undecided: With amplifer or not, headphone?..)

    I need a good output for another, very big (well, amount of work..) project. (mono)
    Last edited by Frank B; 07-07-2016 at 10:28 PM.

  7. #32
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    Correction: Some problems with 5V: after some minutes of playing it stops.
    3.3 Volt works better.

  8. #33
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Quote Originally Posted by Frank B View Post
    Correction: Some problems with 5V: after some minutes of playing it stops.
    3.3 Volt works better.
    Eww that's nasty. Can you try adding some capacity to the 5V rail? I think 10F is safe for the USB port, and another 100nF across the DAC?
    I managed to get some SO8 adapters from the friendly guys at our physics department, so I'll be able to hook up the scope sometime next week, and I found a schematic and layout for a 3rd order low pass, sadly the layout is a bit big by todays standards, SO8 OP and 1206 R and C, single sided layout; that would need an update. But let me look at the scope first before we rush to conclusions

  9. #34
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    There are already 470F on the Amplifier-board But i can try it tomorrow.

    The datasheet shows a simple RC-Filter (15k+470pf) - is that ok ?
    I want to add a amplifier to my project-board, maybe mono, and if possible with optional headphone connector. Which chip can i use ? >1mm pitch would be best. ~ 1 watt.
    Last edited by Frank B; 07-09-2016 at 02:14 PM.

  10. #35
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Quote Originally Posted by Frank B View Post
    There are already 470F on the Amplifier-board But i can try it tomorrow.
    Oh ok. That's strange, 5.1V is totally within spec. Maybe the 100n will help...
    Quote Originally Posted by Frank B View Post
    The datasheet shows a simple RC-Filter (15k+470pf) - is that ok ?
    Thats -3dB at about 22.5kHz, surely won't hurt, but maybe won't help either. I'll have to look at the FFT when the scope is hooked up.
    Quote Originally Posted by Frank B View Post
    I want to add a amplifier to my project-board, maybe mono, and if possible with optional headphone connector. Which chip can i use ? >1mm pitch would be best. ~ 1 watt.
    Hard to say, maybe the Ti LM4861 (http://www.ti.com/lit/ds/symlink/lm4861.pdf)? Available at reichelt in SO8 (http://www.reichelt.de/ICs-LM-2000-L...69&OFFSET=500&).
    But adding virtually any IC to this project destroys the idea of a cheap 25ct DAC, so there really is no "correct" choice IMHO. On the other hand, a hobby doesn't need to make sense, and who am I to judge

  11. #36
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    Quote Originally Posted by Ben View Post
    Oh ok. That's strange, 5.1V is totally within spec. Maybe the 100n will help...
    Thats -3dB at about 22.5kHz, surely won't hurt, but maybe won't help either. I'll have to look at the FFT when the scope is hooked up.
    Hard to say, maybe the Ti LM4861 (http://www.ti.com/lit/ds/symlink/lm4861.pdf)? Available at reichelt in SO8 (http://www.reichelt.de/ICs-LM-2000-L...69&OFFSET=500&).
    But adding virtually any IC to this project destroys the idea of a cheap 25ct DAC, so there really is no "correct" choice IMHO. On the other hand, a hobby doesn't need to make sense, and who am I to judge
    I added 10uF, 100nF and the resistor. Works good now.
    But, possibly, it could have been a bad connection on my breadboard.

    LOL, yes..sense...yes there is none. From this point of view, my whole project does not make sense. And i could use the teensy-dac.
    I want to add the DAC+amplifier+a small speaker to my ili-9341 display-board.
    Last edited by Frank B; 07-10-2016 at 11:34 AM.

  12. #37
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Frank, do you have a working sketch using your PT8211 object you can share? My Teensy stalls before a single loop() is completed (checked with Serial), so a known-good example would be great.

    I installed a fresh Arduino 1.6.9 + Teensyduino 1.29 Beta #4 (minutes before Paul announced the official release ) and copied the files from your git. I checked the Audio.h manually and the only difference is the #include "output_pt8211.h", so this should be ok. Maybe my Teensy is faulty, it's one of the first T3.2 and sat in a drawer for quite some time...

  13. #38
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    Hi Ben,
    every sketch should work. You can use the audio-lib examples. But i can post a tested one this evening after work.
    If there is a SGTL5000 control in your sketch, remove it. It tries to talk to the chip via i2c, maybe this is the problem (does it block?)

    Frank.

  14. #39
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Quote Originally Posted by Frank B View Post
    Hi Ben,
    every sketch should work. You can use the audio-lib examples. But i can post a tested one this evening after work.
    I'd appreciate it. I didn't start with the examples but from blank, maybe it was just to late in the evening to generate proper code

    Quote Originally Posted by Frank B View Post
    If there is a SGTL5000 control in your sketch, remove it. It tries to talk to the chip via i2c, maybe this is the problem (does it block?)

    Frank.
    No, just two sine blocks and the PT8211 (and patch cords). I will try again tomorrow, I'm sorry I won't have time today though.
    Ben

  15. #40
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    Ok,

    here are detailed instructions

    Paul wants to merge both outputs into one, so let's try to use output_i2s instead of my stripped down variant.

    1. Edit output_i2s.cpp
    in Line 320/321, remove the Frame-Sync-Early-Bit :
    Code:
     I2S0_TCR4 = I2S_TCR4_FRSZ(1) | I2S_TCR4_SYWD(15) | I2S_TCR4_MF
            | /* I2S_TCR4_FSE | */ I2S_TCR4_FSP | I2S_TCR4_FSD;
    That's all needed to bring the PT8211 to work. And, hey, it STILL works with the SGTL-Chip after that change.


    2. Use this Sketch:

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioSynthWaveformSine   sine2;          //xy=147,346
    AudioSynthWaveformSine   sine1;          //xy=181,270
    AudioOutputI2S           i2s1;           //xy=353,308
    AudioConnection          patchCord1(sine2, 0, i2s1, 1);
    AudioConnection          patchCord2(sine1, 0, i2s1, 0);
    // GUItool: end automatically generated code
    
    
    void setup() {
     AudioMemory(10);
     sine1.frequency(1000);
     sine1.phase(00);
     sine1.amplitude(0.9); 
    
     sine2.frequency(1000);
     sine2.phase(90);
     sine2.amplitude(0.9);  
    }
    void loop() {}
    Thats all.

    have fun,
    Frank.

    p.s. no need to hurry..
    I have big problems to get I2S on the overclocked K66 to work... but for my project i need heavy overclocking - so ... might be easier to use the DAC.
    Last edited by Frank B; 07-11-2016 at 05:18 PM.

  16. #41
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Frank, thank you so much. I edited the *.cpp and I'm running your test sketch. It worked right of the bat. I don't know what I did wrong on Saturday, must have been a coding error, I use the same hardware as before.

    Have a look:

    Click image for larger version. 

Name:	ref_fft2.png 
Views:	81 
Size:	22.8 KB 
ID:	7626
    This is the output waveform without any external circuitry apart from 47nF across the rail, powered from Vusb. Note that the scope applies averaging and due to trigger jitter the waveform is a bit distorted. In reality the waveform is even more "stepped" and slews between individual voltage levels in about 400ns, holding the voltage very stable for the rest of the sample time. So in conclusion, there is no output filtering at all in the DAC.

    Also interesting: with the sketch you provided (amplitude=0.9) I get a signal of about 920mV peak-peak, which means barely over 1V full-scale. From the datasheet I expected more than double the amplitude. Any idea?



    This is an FFT (done with the scope, so no high precision measurement, but the DAC is bad enough to have it's flaws exposed even with that...)

    Click image for larger version. 

Name:	ref_fft.png 
Views:	58 
Size:	16.7 KB 
ID:	7624


    Click image for larger version. 

Name:	ref_fft1.png 
Views:	69 
Size:	20.4 KB 
ID:	7625

    The leftmost peak is what we want, at 1 kHz. Scaling is 10dB per division, so the lower harmonics are about 50db below the signal. Bad, very bad, but what do we expect for 25 cent... Notice the horrendous amount of nyquist errors mirroring around the sample frequency to the right of the spectrum, 1kHz before and after 44.1kHz. I placed the scopes cursor on one of those peaks in the third picture. I also did a FFT up to several MHz and I can see signals up to about 2MHz.

    Conclusion: We definitely need a reconstruction filter, and I'd say we go with butterworth instead of the more "audiophile" bessel to get those nyquist images as low as possible and because any attempt to treat this signal with care is a waste of time and effort.

    I'll do some tests regarding the DACs sensitivity to power quality and 5V vs. 3V3 operation later this week, and I'll cobble together some filtering on the output to see what passive filtering can do.

  17. #42
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    Quote Originally Posted by Ben View Post
    From the datasheet I expected more than double the amplitude. Any idea?
    Is it ignoring the first bit ? We could try to invert the bitclock and see if that helps.. In the datasheet-diagrams is a pause before the first bit.

    Quote Originally Posted by Ben View Post
    I'll do some tests regarding the DACs sensitivity to power quality and 5V vs. 3V3 operation later this week, and I'll cobble together some filtering on the output to see what passive filtering can do.
    I could try to use 4 x oversampling, if that makes things easier (less external parts?) - is it worth to try it ?
    Last edited by Frank B; 07-15-2016 at 07:30 AM.

  18. #43
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Quote Originally Posted by Frank B View Post
    Is it ignoring the first bit ? We could try to invert the bitclock and see if that helps.. In the datasheet-diagrams is a pause before the first bit.
    Not ignoring, I think it treats the MSB as the second-most SB and defaults the MSB to 0. But yeah, certainly a problem with the digital interface.
    Quote Originally Posted by Frank B View Post
    I could try to use 4 x oversampling, if that makes things easier (less external parts?) - is it worth to try it ?
    If you can run the output object with higher sample rate than the rest of the audio lib, sure, would be great. You'd need to decide on the interpolation method though, a high order low pass would eat up a lot CPU time. All in all, if you just want to drive a small speaker integrated in a display, this is too much effort. But I can totally see two of these DACs used with the Quad-Output object for sensor-actor-applications (think PID control loops), and in those applications oversampling might be worth the effort. I suppose we should ask Paul if he's ok with us developing a low-cost alternative to the audio shield for analog output. Maybe a single board with two PT8211 for cheap quad out?

  19. #44
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    I can not imagine many use-cases for four channel audio on the teensy...

    I look if I can do anything re: the digital interface. But I don't own an oscilloscope .
    Your screenshot shows less than 32 steps... ?!
    Im not audiophile and my ears are not the best- for me , the sound is ok.. even with a larger speaker (?)
    On the other hand, sometime ago i read of china-chips (i2s) that had 8 bit R2R instead16...

    Edit: The max. value for amplitude is 1.0, not 0.9
    Last edited by Frank B; 07-15-2016 at 03:42 PM.

  20. #45
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Oh no my fault regarding the amplitude. The output scales with the supply voltage. I think I got that previous measurement when I had it running off of the 3V3 rail. At 5V the output swings 2.3 Vpp, thats in spec according to the datasheet. The interface is ok as it is!
    So Frank, I guess it's ok to use the chip as it is for your display application. If you want, add a low pass with 8.2kOhm and 1nF to the output.

    I will include resistors and caps for a 3rd order Sallen-Key LP filter in my next order, just for the fun of it. And I ran out of rail2rail OPs in DIP, so I can't continue with the filter right now.

    Regarding the few steps: At 1kHz the slew rate is more than 1 LSB per sample time (1/fs), that's why it looks so coarse. Look at the minima and maxima of the sine, the steps are much smaller there. It may still be that the DAC has less than 16 bit resolution, but I'd need a precision multimeter to measure this. I have some at work, but we are currently moving into another building and everything is packed away in boxes, so I won't be able to do that measurement for at least another month.

  21. #46
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    Quote Originally Posted by Ben View Post
    Also interesting: with the sketch you provided (amplitude=0.9) I get a signal of about 920mV peak-peak, which means barely over 1V full-scale. From the datasheet I expected more than double the amplitude. Any idea?
    I have 2.42 Volt. Measured with output of constant values 32767 vs(minus) -32768 - hacked the I2S output-code for it.. :-)
    For 16383 / -16384 , it is the half - so...

    - peak-peak is ok
    - MSB is ok

    Do you have an audioshield ? Could you pls. check and do your measuring with the osc. with it ? Just to make sure that it's no software-bug somewhere in the audio-lib.

  22. #47
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    it's all good, it was my fault, see my post #45.

  23. #48
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    Quote Originally Posted by Ben View Post
    it's all good, it was my fault, see my post #45.
    No Problem...

    Maybe, if I can find some time, I try to add upsampling to the output-objects. It will make the external filtering a bit easier, I hope. (4x 44= 176KHz )
    Let's see...

    Is linear interpolation sufficiant, or do we we need a more advanced interpolation-filter ? CIC ? FIR? (but at the moment I don't know how to calculate them ;-)
    I don't want to waste more CPU-cycles than necessary !
    Last edited by Frank B; 07-15-2016 at 06:45 PM.

  24. #49
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    Hi,

    i added 4x linear upsampling - no digital low-pass.
    It is unoptimized, just for testing..

    I hear no difference, but the measurements would be interesting... (with simple RC-lowpass, perhaps?)

    https://github.com/FrankBoesing/outp...put_pt8211.cpp
    Last edited by Frank B; 07-15-2016 at 10:26 PM.

  25. #50
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Ok just a quick feedback, I really need to go to bed. This looks EXCELLENT. The linear interpolation can be seen clearly on the scope, works as expected. I measured 2.22% max CPU time with the sketch attached below. Very promising. Good work Frank.


    Code:
    #include <Audio.h>
    //#include <Wire.h>
    //#include <SPI.h>
    //#include <SD.h>
    //#include <SerialFlash.h>
    
    
    AudioSynthWaveformSine			sine1;
    AudioOutputPT8211				PT8211_1;
    //AudioConnection				patchCord1(sine1, 0, PT8211_1, 1);
    AudioConnection					patchCord2(sine1, 0, PT8211_1, 0);
    
    
    void setup() {
    	Serial.begin(9600);
    	
    	AudioMemory(10);
    	sine1.frequency(10000);
    	sine1.phase(0);
    	sine1.amplitude(0.9); 
    }
    
    void loop() {
    	Serial.print(AudioProcessorUsage());
    	Serial.print("   ");
    	Serial.println(AudioProcessorUsageMax());
    	delay(100);
    }
    I'll do some FFT's for comparison tomorrow, with and without RC filter. If you have any sketches you want me to view on the scope please go ahead and post them, I'll be happy to share scope screenshots, raw data, whatever you need.

    Ben

    PS: Unfortunately I'm no expert with digital filters either. I know CIC is super easy and fast on FPGAs, but has it advantages over "normal" FIR/IIR when implemented on a micro? For FIR/IIR calculation I know some tools, but not for CIC, and I don't know how to efficiently implement CIC filters in C++.

Posting Permissions

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