Forum Rule: Always post complete source code & details to reproduce any issue!
Page 3 of 4 FirstFirst 1 2 3 4 LastLast
Results 51 to 75 of 76

Thread: ESP32 as I2S input-device

  1. #51
    Member SomeoneFromGermany's Avatar
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    48
    Its exactly the same here.

    Example 4 and 6:
    No reaction at the plotter.
    Click image for larger version. 

Name:	Screenshot 2021-09-17 135658.jpg 
Views:	13 
Size:	16.2 KB 
ID:	25879

    Example 5:
    only a few right looking samples.
    Click image for larger version. 

Name:	example5.jpg 
Views:	11 
Size:	59.1 KB 
ID:	25880

  2. #52
    I forgot to adapt the bit clock divider for example5. But I just fixed that and chances are good that it works now.
    Example 4: If the plotter shows something, then at least the isr of SAI2 is called, which is good. It is strange if the plotter shows something even if the clock lines are disconnected.
    Example 5: The Teensy is again master with its internal clock. If this example is working, then we know that the hardware is connected correctly.
    Example 6: The final goal. SAI2 is in slave mode. Any audio block that is clocked by the internal PLL like SAI1 in master mode or the spdif output could be added. In the example I added the spdif output, but you can replace it with SAI1. But let's first focus on example 4. It should be easier to debug and if it is working, example 6 should also work.

  3. #53
    Member SomeoneFromGermany's Avatar
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    48
    Example 4:

    Still nothing on the Plotter...
    Click image for larger version. 

Name:	Bild_2021-09-17_151616.jpg 
Views:	12 
Size:	23.7 KB 
ID:	25881

    I also dont have an oszilloscope on hand right now.
    Do you think it would be good to look at the signals?
    if so i will organize one for monday.

  4. #54
    I should have explained my commit more clearly: It only changed the behavior of example 5, where the Teensy is master. I hope that it works now.
    I would like to first get example 5 running (smallest risk of failing), then example 4 and then example 6 (most complex).

    Regarding the oszilloscope: I probably messed up the SAI2 configuration, but it would help if you can check the clock lines, so that we can be sure that it is a problem of the configuration and not of the hardware.

  5. #55
    Senior Member
    Join Date
    Jun 2018
    Location
    USA
    Posts
    196
    I just downloaded your latest updates and ran it. Example 5 still runs but the waveform is broken still. Disconnecting the clocks causes the plotter to stop.

    I went back and retested 4 and 6... I thought the plotter was counting with the clocks but I may have been wrong. I'm not getting anything out of it now.

    Quick question: How many variations of the ESP32 code are there really? Is it just master or slave? I don't see any other differences at first glance.

  6. #56
    Member SomeoneFromGermany's Avatar
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    48
    Example 5 still has the same broken waveform on my setup too.

    In the current version (examples1-6) all configurations should be the same, except the MODE_Master/SLAVE.

    Quote Originally Posted by alex6679 View Post
    Regarding the oszilloscope
    I will make few screenshots of the Interface lines, with all examples1-6 or other/newer on monday.

  7. #57
    Ok I might found something: At SAI2 the receiver needs to run in sync with the transmitter (at SAI1 its the other way around). I configured the receiver bit clock for 16bit, but it uses the bit clock of the transmitter anyway and my change had no effect. Now I also adapted the transmitter for 16bit samples in master and in slave mode. Can somebody of you please test if the examples work now?

  8. #58
    Member SomeoneFromGermany's Avatar
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    48
    I tried example 5 and it still didnt got any data on the plotter.
    Also i had to copy everything to the same folder, because it woldn't compile. I think this has something to do with the Arduino ide.

  9. #59
    Senior Member
    Join Date
    Jun 2018
    Location
    USA
    Posts
    196
    I downloaded your latest files and applied them to example 5. I get a broken waveform but it seems like maybe a bit larger of a broken waveform. Disconnecting the clock lines; the clock continues to count. Teensy is in Master, so I guess this makes sense.

    I wonder if we should/could have two plotters. One for SAI1 and one for SAI2.

    Click image for larger version. 

Name:	Screenshot 2021-09-17 213107.png 
Views:	11 
Size:	21.6 KB 
ID:	25886

    When debugging my ADC3140 module I remember that there was a "shift" that had to take place. I believe I had to put 16 bits in the front of the signal, plus 16 bits of audio at the end. Please don't quote me, I looked at the code and I have it shifting 1 "slot" which I believe was 16 bits. I wonder if this waveform shows that there is silence where it expects audio...

  10. #60
    I don't know what you planned to test, but you can connect up to 8 channels to the plotter.
    Regarding the shifting the bits: The input works for at SAI1 and I just used the same configuration at SAI2. So I don't think that it has something to do with shifting bits.

    The strange thing is: I have a working example at which SAI2 runs in slave mode (with TDM8 instead of i2S and 32bit) and we have a working example with SAI1 in slave mode (I2S and 16bit). But the combination SAI2 + I2S +16bit (master or slave) ist that difficult to get working?

    I had an idea how I could use my Teensy/ESP32 to test my examples without spending too much effort on changing my hardware. Maybe I'll find some time tomorrow to test that.

  11. #61
    I just saw that yesterday I reset the bit clock divider back to the value for 32bit samples. I fixed that (again).
    Can you please give it a last try. Tomorrow I'll be back home and if my fix is not working, I'll do the next test runs on my hardware without bothering you.

  12. #62
    Member SomeoneFromGermany's Avatar
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    48
    Example 5 works now.
    There are still inserted zeros, but this should be no problem if the ESP is master.
    Click image for larger version. 

Name:	InkedScreenshot 2021-09-18 122217_LI.jpg 
Views:	10 
Size:	76.6 KB 
ID:	25890

    I haven't tested the other examples jet.
    I' happy to be bothered, to find a solution so feel free to bother me
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Bild_2021-09-18_122453.jpg 
Views:	7 
Size:	78.3 KB 
ID:	25889  

  13. #63
    Senior Member
    Join Date
    Jun 2018
    Location
    USA
    Posts
    196
    Example 5 works for me too!

    I'm also happy to be bothered for a solution.

    Click image for larger version. 

Name:	Screenshot 2021-09-18 063249.jpg 
Views:	15 
Size:	68.6 KB 
ID:	25891

  14. #64
    Nice, we expected of course some distortion. Have you also tried examples 4 and 6 yet? Maybe they already work.

  15. #65
    Member SomeoneFromGermany's Avatar
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    48
    Example 5:

    I wrote a python-script (available here https://github.com/NoMedia-py/TeensySerialSamplesToCSV) that records samples of the output of your examples and saves it to a csv file which can be opened and plotted with Microsoft Excel or other programms.

    I tested a example with an 500Hz sine wave and noticed that sometimes the waveform is cut off:
    Click image for larger version. 

Name:	SpikeOutput1.png 
Views:	8 
Size:	44.1 KB 
ID:	25893
    Click image for larger version. 

Name:	SpikeOutput4.png 
Views:	5 
Size:	19.9 KB 
ID:	25894
    Click image for larger version. 

Name:	SpikeOutput3.png 
Views:	7 
Size:	34.3 KB 
ID:	25895

    Could it be that an buffer overflow occurs somewhere?

  16. #66
    Member SomeoneFromGermany's Avatar
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    48
    Quote Originally Posted by alex6679 View Post
    Have you also tried examples 4 and 6 yet?
    Example 4 and 6 are working!
    I have jet to analyze the waveform, but so far it looked promising.

    EDIT:
    Example 6 only works with the left channel. Right channel has no data.

    Both example still have inserted zeros and are clipping. I can not guarantee that the my python code causes the clipping, but I can say that it dont inserts the zeros.
    Click image for larger version. 

Name:	Example6.png 
Views:	7 
Size:	21.6 KB 
ID:	25896
    Click image for larger version. 

Name:	Example63.png 
Views:	5 
Size:	15.6 KB 
ID:	25897
    Last edited by SomeoneFromGermany; 09-18-2021 at 06:56 PM.

  17. #67
    At example 6 only one channel of the input is connected to the plotter. That's the reason for the missing data.

    I'll try to reproduce the other problem.

  18. #68
    I just tested example 4 and 6. They both worked here. Here is the result of example 6:
    Click image for larger version. 

Name:	signal6.jpg 
Views:	9 
Size:	55.3 KB 
ID:	25912
    At example 6 you can ignore the 'glitches' within the first few seconds. They occure since the incoming sample rate is not exactly known at the beginning, but they are not audible. At least I never noticed them when I listen over my speakers.

  19. #69
    Member SomeoneFromGermany's Avatar
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    48
    That does indeed makes sense. Now i get Right and left channel data.

    But how do we get this data to the audio shield now?
    I didnt had much hope that it would be that easy to just set outputI2S and connect the audioshield, but i tried it anyways. It didnt work.

  20. #70
    I have no experience with the audioshield, but you could search or make an example at which a sine wave is generated on the Teensy and send to the audioshield. If that works, you can replace the sine wave generator with the SAI2 input at which the ESP32 is connected.
    You probably already know that, but from example 6 code, you only need 5 lines:
    Code:
    #include "input_i2s2_16bit.h"
    #include "async_input.h"
    
    ...
    
    AsyncAudioInput<AsyncAudioInputI2S2_16bitslave> i2sSlaveInput;
    AudioConnection          patchCord1(i2sSlaveInput, 0, XXX, 0);
    AudioConnection          patchCord2(i2sSlaveInput, 1, XXX, 1);
    You don't need the spdif-output of the example.

  21. #71
    Member SomeoneFromGermany's Avatar
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    48
    The connection between the teensy and the audioshield is no problem thanks to the audiolibrary. I tried exacly that using the OutputI2S instead of the spdif output. The only hope is that i connected the audioshield wrong. If thats not the case, i think both modes are not working correctly together.?

  22. #72
    I don't see a reason why SAI1 in master mode and SAI2 in slave mode wouldn't work together. I use them together the other way around: SAI2 in master mode and SAI1 in slave mode and it works.

  23. #73
    Senior Member
    Join Date
    Jun 2018
    Location
    USA
    Posts
    196
    Thanks alex6679. I should have time to test this later today.

    If the initial test goes well, I'll also be attempting to run SAI1 in TDM mode and SAI2 in standard stereo I2S mode. Do you think that's going to work? Or will SAI2 have to run TDM as well? I heard you may have an example for ESP32 in TDM mode too?

  24. #74
    Member SomeoneFromGermany's Avatar
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    48
    Update:
    I took a look with the oszilloscope.
    SAI1 outputs what you would expect: 2,8 MHz BCLCK, 11MHz MCLK, data in 32 falling BLCK edges in one cycle of LRCLK and the last 16 bit always zeros.

    Turns out I somehow killed my audioshield.
    Last edited by SomeoneFromGermany; 09-20-2021 at 01:47 PM.

  25. #75
    Member SomeoneFromGermany's Avatar
    Join Date
    Apr 2020
    Location
    Germany
    Posts
    48
    Everything works!
    An other audioshield did the trick...

    Thank you for your great help!!!

Posting Permissions

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