Teensy 3.5 + Exemple 'AnalogControlChange' Problems

Status
Not open for further replies.

sprkrn

Member
Hello,

I've ordered 2 x teensy 3.5 and uploaded the exemple code 'AnalogControlChange'. I've selected 'Midi' in Usb Type.
When I launch Ableton (with no fader on the teensy) and that I map one of the 4 CC, I have that :


I don't know what is the problem ! That glitch is quite big.

Thanks a lot

Code:
/* USB MIDI AnalogControlChange Example

   You must select MIDI from the "Tools > USB Type" menu
   http://www.pjrc.com/teensy/td_midi.html

   This example code is in the public domain.
*/

#include <Bounce.h>

// the MIDI channel number to send messages
const int channel = 1;

// the MIDI continuous controller for each analog input
const int controllerA0 = 10; // 10 = pan position
const int controllerA1 = 11; // 11 = volume/expression
const int controllerA2 = 91; // 91 = reverb level
const int controllerA3 = 93; // 93 = chorus level

void setup() {
}

// store previously sent values, to detect changes
int previousA0 = -1;
int previousA1 = -1;
int previousA2 = -1;
int previousA3 = -1;

elapsedMillis msec = 0;

void loop() {
  // only check the analog inputs 50 times per second,
  // to prevent a flood of MIDI messages
  if (msec >= 20) {
    msec = 0;
    int n0 = analogRead(A0) / 8;
    int n1 = analogRead(A1) / 8;
    int n2 = analogRead(A2) / 8;
    int n3 = analogRead(A3) / 8;
    // only transmit MIDI messages if analog input changed
    if (n0 != previousA0) {
      usbMIDI.sendControlChange(controllerA0, n0, channel);
      previousA0 = n0;
    }
    if (n1 != previousA1) {
      usbMIDI.sendControlChange(controllerA1, n1, channel);
      previousA1 = n1;
    }
    if (n2 != previousA2) {
      usbMIDI.sendControlChange(controllerA2, n2, channel);
      previousA2 = n2;
    }
    if (n3 != previousA3) {
      usbMIDI.sendControlChange(controllerA3, n3, channel);
      previousA3 = n3;
    }
  }

  // MIDI Controllers should discard incoming MIDI messages.
  // http://forum.pjrc.com/threads/24179-Teensy-3-Ableton-Analog-CC-causes-midi-crash
  while (usbMIDI.read()) {
    // ignore incoming messages
  }
}
 
Hello,

I've ordered 2 x teensy 3.5 and uploaded the exemple code 'AnalogControlChange'. I've selected 'Midi' in Usb Type.
When I launch Ableton (with no fader on the teensy) and that I map one of the 4 CC, I have that :


I don't know what is the problem ! That glitch is quite big.

Thanks a lot
If you have no fader attached then the pin will 'float' and give glitchy readings.
 
Hello,

Thanks for the answer. That's the same when I plug a pot or a fader to the teensy.

Thanks,
Flo
 
Well given the code is a working example I would say you have a hardware problem.

Does the pot track with random movement around its approximate position or does the pot have no effect?
 
First (hardware side): Are your potentiometers / faders correctly connected ? LEFT/BOTTOM=>AGND, WIPER=>A0, RIGHT/TOP=>3.3V?
If yes, look with an oscilloscope at pin A0 if the signal is still stable there or if the Teensy transmits correctly the readings from a "dirty" input signal.
Unfortunately, you didn't post any schematics/pictures of your setup, nor more specifications... As soon as the potentiometer's resistance will exceed 10k, the varying source impedance of all Teensies' delta-sigma ADCs during the read cycle will come into play and you'll have to connect a 10nF capacitor between the analog input pin and AGND to get stable readings (see the Kinetis application note).

Second (software side): If you made really sure that there is no hardware problem and the problem still persists, modify temporarily your code to slow down the reading cycle to 200-500ms and print the potentiometer readings to the serial monitor instead of sending them as midi control change messages. Post the result here.
 
Well given the code is a working example I would say you have a hardware problem.

Does the pot track with random movement around its approximate position or does the pot have no effect?

It could be, but I've ordered 2 of them, and that's the same on both..
 
I don't mean there's something wrong with PJRC's hardware... that's highly unlikely even on one new Teensy. I mean your hardware configuration or its connections.

A bad solder connection on an otherwise correct setup could give this result if you soldered your own pins. (Some new users assume a friction connection to the Teensy is sufficient and you did use the word 'plug' in reference to the Teensy and not a breadboard... )

Or you may have made a wiring error. But without details we can only guess.
 
Hello,

Thanks for the answer. I have a macbook pro and I bought the Teensy with pins, so I did not solder anything. I think I'll buy an other Teensy to see if it works, I don't have any other idea.
 
Good to know it's not the solder thing but buying more Teensys, while great for pjrc, will not help you as the chances you got two defective Teensys is vanishingly small.

Post a photo of your breadboard and maybe someone can spot the problem.

Knowing the pot is having no effect suggests the Teensy is not getting any current from the voltage divider your potentiometer should be set up to provide. Your voltage divider may not be powered or grounded correctly.

https://www.pjrc.com/teensy/tutorial4.html
 
...oh... make sure you use 3.3 volt power source for you voltage divider or you will get a dead zone on the top portion on your pot. On a 3.6 you can damage the board but the 3.5 will tolerate the higher voltage.
 
Hello,

It's just plugged in my computer, with a standard usb cable. It is not right?
Here are some photos of the Teensy :

IMG_20171208_205236.jpg
IMG_20171208_205252 (1).jpg
 
A photo of how you connected your potentiometer...

The first connection on the potentiometer should be grounded to AGND (but will work on any regular ground connection too but with the potential of more noise).
The other side should be to the 3.3 volt pin from your Teensy
The middle connection on the potentiometer (called the wiper) needs to be connected to the data pin.

For your code to work it should be one of A0 to A3.

If you leave the other three pins being read but left floating then you will be generating a lot of MIDI messages that are just noise.
It's best to comment out the lines of code that read the floating pins

Code:
    int n0 = analogRead(A0) / 8;
    //int n1 = analogRead(A1) / 8;
    //int n2 = analogRead(A2) / 8;
    //int n3 = analogRead(A3) / 8;
 
What people will need to help you, are full schematics of your circuit plus a picture of you actual realization of that circuit, so that one can check if you made the correct connections, if your wiring is adapted, if the needed decoupling capacitors are in place, etc.

Three days ago already, I posted above (post #5) a series of questions and suggestions including checking the analog readings with an oscilloscope. Until now, you haven’t given any feedback to that. How do you expect to get help if you are so uncooperative and refuse to proceed to the simplest systematic circuit debugging procedures?

Look, I’ve been doing analog and mixed analog-digital circuit design for more than 30 years now. And I’m pretty sure that your problem can be identified and fixed within very short time without wasting the time of many forum members guessing wildly around if only you are polite, that means being reactive and answer questions and provide needed information within short time, too. Nobody is interested in filling several forum pages with guess posts and other meaningless stuff, before you write back with things which weren’t requested.
 
Last edited:
Status
Not open for further replies.
Back
Top