Teensy 3.1 not working with different IDE and Teensyduino versions

Status
Not open for further replies.

dsparks

Well-known member
I have tested a Teensy 3.1 with an audio board attached with the following included sketch.

/* Mono Peak Meter

Scrolling peak audio level meter in the Arduino Serial Monitor

Audio input needs to connect to pin 16 (A2). The signal range is 0 to 1.2V.
See the documentation in the Audio System Design Tool for the recommended
circuit to connect an analog signal.

This example code is in the public domain
*/

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

// GUItool: begin automatically generated code
AudioInputAnalog adc1;
AudioOutputI2S i2s1;
AudioAnalyzePeak peak1;
AudioConnection patchCord1(adc1, peak1);
AudioConnection patchCord2(adc1, 0, i2s1, 0);
AudioConnection patchCord3(adc1, 0, i2s1, 1);
// GUItool: end automatically generated code


void setup() {
AudioMemory(4);
Serial.begin(9600);
}

// for best effect make your terminal/monitor a minimum of 31 chars wide and as high as you can.

elapsedMillis fps;

void loop() {
if (fps > 24) {
if (peak1.available()) {
fps = 0;
int monoPeak = peak1.read() * 30.0;
Serial.print("|");
for (int cnt=0; cnt<monoPeak; cnt++) {
Serial.print(">");
}
Serial.println();
}
}
}

It works perfectly when using the Arduino 1.0.6 IDE with the teensyduino version prior to 1.24

But when I try run the sketch in Arduino 1.6.5 IDE with teensyduino 1.24. I get no serial output and no audio output.

Even though the program compiles fine with no errors in both.


Can you not use an older physical Teensy 3.1 with the new IDE and teensyduino?
 
Try compiling and loading a sketch like shown here: https://forum.pjrc.com/threads/31518-Can-t-communicate-with-Teensy-3-2-through-Teensyduino?p=88073&viewfull=1#post88073

The Teensy 3.1 is still current and fully supported. The IDE has changed greatly and perhaps the audio library as well.

That linked code shows waiting for the Serial to come on line - so your output may just be lost before the serial monitor shows up. It will also blink the LED if it is free to do so.

Code is better displayed when marked like this: code.PNG
 
The code you shared, does work on my system.

Im not sure what you mean by.. "That linked code shows waiting for the Serial to come on line - so your output may just be lost before the serial monitor shows up."

I appreciate your help.
 
Just what you did I think - follow the LINK to the CODE. Look in setup and there is a
while (!Serial && (millis() <= 4000))
qBlink();
that waits 4 seconds after power up for the serial monitor to connect.

Select, Cut it and paste it to a new sketch.

Make sure "Tools / Board" has Teensy 3.1 selected.

Compile and then upload it automatically or with a button press.

I just repeated that and it works fine for me.

If you are seeing anything else your Arduino install is busted - or the connection to your device isn't right. You'd need to provide more details than : "does work on my system"
 
I did copy and paste the code you shared previously into a new sketch. And it DID work.

However, what does that do for the code I am trying to run that I posted?

I ran your code example exactly as shown in the thread you shared. Running on Arduino IDE 1.6.5 and teensyduino 1.24 . It works.

The code I am trying to run that I shared initially, does NOT.
 
The goal of the working example was to see working hardware - DONE! Also provide a template for things you might change or adjust in an updated sample - use the WHILE( !serial ... ) in the setup() code so you get usable USB output. Put in a blinking light to help see how far it gets and where it stops.

Your hardware must be good if it worked before - so as noted it may be a change in the audio lib ... can you take a current TeensyDuino 1.26 installed example and see any signs of life - or stepwise recreate the code using the current audio tool?

If you can make any headway or add more info and post updated code with more info - somebody might see something else to work with.
 
Thank you for the detail.

I have updated to the latest teensyduino 1.26 and Arduino 1.6.6.

Using the latest audio lib included with the software upgrade. And using the example sketches.

Producing sound with it, such as a sine wave and out works fine. But once I try to bring sound in from the

analog audio input route, I get nothing. Unless I go back to the older versions of < 1.24 and 1.0.5 arduino IDE.

So I know the hardware works fine.
 
I'm running your program on a Teensy 3.1 right now. I had to add #include <SerialFlash.h>, but otherwise it seems to work perfectly.

I've only tested with A3 open circuit (massive static) and shorted to GND (silent). I could test with real signals if needed, but it certainly looks like it's working.

Here's the exact code I tried.

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputAnalog adc1;
AudioOutputI2S i2s1;
AudioAnalyzePeak peak1;
AudioConnection patchCord1(adc1, peak1);
AudioConnection patchCord2(adc1, 0, i2s1, 0);
AudioConnection patchCord3(adc1, 0, i2s1, 1);
// GUItool: end automatically generated code


void setup() {
  AudioMemory(4);
  Serial.begin(9600);
}

// for best effect make your terminal/monitor a minimum of 31 chars wide and as high as you can.

elapsedMillis fps;

void loop() {
  if (fps > 24) {
    if (peak1.available()) {
      fps = 0;
      int monoPeak = peak1.read() * 30.0;
      Serial.print("|");
      for (int cnt = 0; cnt < monoPeak; cnt++) {
        Serial.print(">");
      }
      Serial.println();
    }
  }
}
 
My only guess is perhaps you've got Tools > CPU Speed set different in Arduino 1.0.6 vs 1.6.x. The pre-1.5 versions use a different settings file, so it's possible to have 2 different settings.

There's a known bug where the ADC input object fails at 72 MHz. It works fine at 96 MHz.

Maybe you've got the newer Arduino set to 72 MHz and the old one set to 96 MHz?
 
That worked!

Why would the #include <SerialFlash.h> have to be in there though for a straight pass through?
 
Before Arduino 1.6.6, if you use a library which in turn uses other libs, you have to have a #include for every lib in your sketch, even if you don't directly use those other libs, and even if you don't use any of the features which would need those libraries.

Recent versions of the Audio library added support for playing from serial flash chips (the chip you can add to the bottom side of the audio shield), so including SerialFlash.h is needed if you use Arduino 1.6.5 or earlier, as you also need SD.h, SPI.h and Wire.h, even if you don't use those libraries directly in your sketch. Various parts of the Audio library do use all of those libs.

Arduino 1.6.6 has a new build system which automatically discovers all the required libraries. You only need #include <Audio.h> with Arduino 1.6.6.
 
Status
Not open for further replies.
Back
Top