Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 22 of 22

Thread: Rev C cards with a Teensy 4.1

  1. #1
    Junior Member
    Join Date
    May 2019
    Posts
    17

    Rev C cards with a Teensy 4.1

    So I want to create 6 to 8 individual 16 bit audio outputs from a Teensy 4.1, my idea is to create a 6 voice oscillator board similar to the TSynth but with the dual VCO section only created with the Teensy.

    Problem is that I only have 4x Rev C cards left over from other projects and as I will not be fitting the cards directly onto the Teensy 4.1, can I simply connect 3 or 4 cards onto a board with the Teensy and hard work them to it. The cards look identical in the schematics with just different pin outs.

    Would this work as I'm in the Ukraine and rev D cards are impossible to purchase?

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,975
    Yes - as you mentioned it is simply the pinouts changed. You just need to be careful when you wire it up. One of Paul's T4 Beta test boards had socket on it for the Rev C (this was before there was a Rev D)

  3. #3
    Junior Member
    Join Date
    May 2019
    Posts
    17
    Thanks Kurt, I think I saw something posted by Paul showing a demo of multiple outputs for at least 2 cards. I will build a little test board with sockets for everything so I can mod and change as I need.

  4. #4
    Senior Member
    Join Date
    Jul 2014
    Posts
    3,459
    should work with custom software:
    T4.x has up to 4 I2S data out ports, which could generate 16 out channels
    for 4 Audioboards you would need to use two different I2C controls ports.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,814
    Yes, Rev C audio boards work fine with Teensy 4.1 if you use reasonably short wires to route the signals the correct pins. MCLK and GND are the wires where length matters. But don't overthink the "reasonably short", as an extra inch or few centimeters doesn't make much difference.

    Rev B and older can also work, if you add a resistor in to the MCLK signal. Rev C has the resistor built in.

  6. #6
    Junior Member
    Join Date
    May 2019
    Posts
    17
    I will try to locate the boards as close to the Teensy as possible.

  7. #7
    Senior Member
    Join Date
    Apr 2021
    Location
    Cambridgeshire, UK
    Posts
    445
    Quote Originally Posted by WMXZ View Post
    should work with custom software:
    T4.x has up to 4 I2S data out ports, which could generate 16 out channels
    for 4 Audioboards you would need to use two different I2C controls ports.
    I think there's something slightly screwy with your maths here - each IS out gives two channels, so you can have 4x2 on I2S1 and another 1x2 on I2S2 for an easy-ish maximum of 10 output channels.

    For the "custom software" <blows own trumpet> you could look at this modification which is intended to simplify using other IC control ports and addresses on SGTL5000-based boards. They can only use 2 different control addresses, so you'll have to modify 1 board to the other address to control 6 outputs, or 2 boards to control the full 8 outputs, using 2 different IC ports (Wire and Wire1). Alternatively, without modifying your audio adaptors, you could control one each on Wire, Wire1 and Wire2 for a total of 6 outputs.

  8. #8
    Junior Member
    Join Date
    May 2019
    Posts
    17
    Thanks for the information, having a hard time with Putin and his missiles at the moment, but I will try and knock up a board tomorrow.

  9. #9
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    120
    @craigyb If there is anything i can just ship to you, let me know.

  10. #10
    Junior Member
    Join Date
    May 2019
    Posts
    17
    Quote Originally Posted by fdaniels View Post
    @craigyb If there is anything i can just ship to you, let me know.
    Thanks for the offer, very much appreciated. I think I have enough to be getting on with just to keep me busy here.

  11. #11
    Senior Member
    Join Date
    Jul 2014
    Posts
    3,459
    Quote Originally Posted by h4yn0nnym0u5e View Post
    I think there's something slightly screwy with your maths here - each IS out gives two channels, so you can have 4x2 on I2S1 and another 1x2 on I2S2 for an easy-ish maximum of 10 output channels.
    I guess you are right on the number. For the rest, that was my idea also.

  12. #12
    Senior Member
    Join Date
    Apr 2021
    Location
    Cambridgeshire, UK
    Posts
    445
    Quote Originally Posted by WMXZ View Post
    I guess you are right on the number. For the rest, that was my idea also.
    Yes, sorry, was lazy with my editing the quoted message!

  13. #13
    Junior Member
    Join Date
    May 2019
    Posts
    17
    I've got 3 boards wired up on each I2c output using the modified audio library that can address wire, wire1 etc and although everything compiled when I'm using the test code created by Paul recently no waveforms are generated. I guess I should just try and get sound out of one card first.

  14. #14
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,814
    Here's a thread where I tested 2 of the Rev D boards with Teensy 4.1.... with photos and the code used.

    https://forum.pjrc.com/threads/61123...l=1#post242054

    Not sure how much that really helps, since you're using 3 boards.

    If you show us photos of the wiring and the code you're running, maybe we'll be able to help more?

  15. #15
    Junior Member
    Join Date
    May 2019
    Posts
    17
    Hi Paul

    Yes, that's the code I'm using with changes to the setaddress line to setwire, but even without the changes I would have expected card 1 to work.

    Also I tried an I2c scanner sketch and it couldn't find any cards which I thought was a bit strange. I will make a schematic and post it up shortly.

  16. #16
    Junior Member
    Join Date
    May 2019
    Posts
    17
    Click image for larger version. 

Name:	Schematic_revc_2022-07-12.png 
Views:	15 
Size:	109.0 KB 
ID:	28911

    I hope this is viewable, although I have 3 cards attached, I've only shown 3

  17. #17
    Junior Member
    Join Date
    May 2019
    Posts
    17
    Code:
    #include <Audio.h>
    
    
    // GUItool: begin automatically generated code
    AudioInputI2SHex         i2s_hex2;       //xy=190,343
    AudioOutputI2SHex        i2s_hex1;       //xy=431,344
    AudioConnection          patchCord1(i2s_hex2, 0, i2s_hex1, 0);
    AudioConnection          patchCord2(i2s_hex2, 1, i2s_hex1, 1);
    AudioConnection          patchCord3(i2s_hex2, 2, i2s_hex1, 2);
    AudioConnection          patchCord4(i2s_hex2, 3, i2s_hex1, 3);
    AudioConnection          patchCord5(i2s_hex2, 4, i2s_hex1, 4);
    AudioConnection          patchCord6(i2s_hex2, 5, i2s_hex1, 5);
    AudioControlSGTL5000     sgtl5000_1;     //xy=633,280
    AudioControlSGTL5000     sgtl5000_2;     //xy=633,368
    AudioControlSGTL5000     sgtl5000_3;     //xy=635,457
    // GUItool: end automatically generated code
    
    void setup() {
      // create 4 test waveforms and distinct frequencies
      analogWriteFrequency(28, 440);
      analogWriteFrequency(33, 530);
      analogWriteFrequency(36, 610);
      analogWriteFrequency(37, 610);
      analogWrite(28, 128);
      analogWrite(33, 128);
      analogWrite(36, 64);
      analogWrite(37, 190);
    
      AudioMemory(12);
    
      // Enable the first audio shield, select input, and enable output
      sgtl5000_1.setWire(Wire, LOW);
      sgtl5000_1.enable();
      sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
      sgtl5000_1.volume(0.5);
    
    //  // Enable the second audio shield, select input, and enable output
      sgtl5000_2.setWire(Wire1, LOW);
      sgtl5000_2.enable();
      sgtl5000_2.inputSelect(AUDIO_INPUT_LINEIN);
      sgtl5000_2.volume(0.5);
    }
    
    void loop() {
    }

  18. #18
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,814
    Quote Originally Posted by craigyb View Post
    Also I tried an I2c scanner sketch and it couldn't find any cards which I thought was a bit strange.
    SGTL5000 chips will not respond to I2C unless you have MCLK active.

    For testing, you can add analogWriteFrequency() and analogWrite() in the scanner example setup() function, to cause a waveform on pin 23. Just a couple MHz is plenty. The exact frequency doesn't matter and you don't need BCLK or LRCLK if you're only trying to use I2C. Or add the audio library and 1 instance of any I2S object to cause MCLK, BCLK, LRCLK to turn on. Even if you don't have an oscilloscope or frequency counter, just a quick DC voltmeter check on pin 23 can confirm if a clock is present. The duty cycle is 50% so you should measure about 1.65 volts if MCLK has a clock signal present.

  19. #19
    Junior Member
    Join Date
    May 2019
    Posts
    17
    I can see a clock on the MCLK line, more of a sinewave but symmetrical in appearance.

    I have loaded another test sketch which plays a sinewave with alternating frequencies and this works on sound card 1, so I'm confident in my wiring.

    Click image for larger version. 

Name:	20220712_204906.jpg 
Views:	11 
Size:	143.8 KB 
ID:	28912

    Click image for larger version. 

Name:	20220712_204923.jpg 
Views:	12 
Size:	197.2 KB 
ID:	28913
    Last edited by craigyb; 07-12-2022 at 05:52 PM.

  20. #20
    Senior Member
    Join Date
    Apr 2021
    Location
    Cambridgeshire, UK
    Posts
    445
    I can't 100% see your wiring, but it looks as if you only have one IS input wired; if I'm reading the library code right, your second audio adaptor needs its DOUT / pin 13 wired to the T4.1 pin 6, which can function as either OUT1D or (presumably) IN1B.

    Secondly, I2S1 has 5 data pins, each supporting 2-channel audio, but you have to have at least one configured as output and one as input. Hence you can't use an AudioInputI2SHex and an AudioOutputI2SHex together - one has to be Quad. They'll clash (I think) over the use of T4.1 pin 9, and probably do neither function! The audio system design tool puts a warning triangle on the two I2SHex objects when I import your design from post #17, for that very reason...
    Last edited by h4yn0nnym0u5e; 07-12-2022 at 09:15 PM. Reason: Added note about the warning triangles

  21. #21
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,814
    Spent a few minutes looking over the wiring. MCLK, BCLK, LRCLK looks good. I2C looks probably ok too. Looks like the DIN connections are good too, going to pin 7 (OUT1A), pin 32 (OUT1B) and pin 8 (OUT1C).

  22. #22
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,814
    Quote Originally Posted by h4yn0nnym0u5e View Post
    Hence you can't use an AudioInputI2SHex and an AudioOutputI2SHex together - one has to be Quad.
    Yes, I believe that is probably the cause of the problem.

    I imported the audio instances from msg #17 back in the design tool, and sure enough it shows the warning that they can't work together.

    Click image for larger version. 

Name:	screenshot.png 
Views:	11 
Size:	53.3 KB 
ID:	28917

Posting Permissions

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