hangs with teensy lc

Status
Not open for further replies.

flok

Active member
Hi,

I designed some hardware: 2 analogue inputs (-5...5V), 4 digital input (one for which I forgot to add a voltage divider). It also has a din midi plug.

https://vps001.vanheusden.com/~folkert/hwteensylc.pdf

To test it, I wrote a simple arduino script which shows the readings of the digital inputs and the analog readings.

The proble now is that it is very unreliably; sometimes it runs for ages but often it crashes after 1 or 2 lines of output.

Code:
void setup() {
	Serial.begin(115200);

	pinMode(2, INPUT);
	pinMode(5, INPUT);
	pinMode(11, INPUT);
	pinMode(12, INPUT);

	Serial.println(F("Go!"));
}

void loop() {
	Serial.print(analogRead(A0));
	Serial.print('\t');
	Serial.print(analogRead(A1));
	Serial.print('\t');
	Serial.print(digitalRead(2));
	Serial.print('\t');
	Serial.print(digitalRead(5));
	Serial.print('\t');
	Serial.print(digitalRead(11));
	Serial.print('\t');
	Serial.print(digitalRead(12));
	Serial.println(F(""));

	usbMIDI.sendNoteOn(0x40, 0x7f, 1); 
	delay(10);
        usbMIDI.sendNoteOn(0x40, 0x00, 1); 
}

Apart from the missing voltage divider in the digital input, are there any other hardware problems?
 
Before focusing on the hardware, look at a simple software issue that might be causing trouble.

MIDI controllers which don't read (and ignore if not needed) incoming MIDI messages tend to stall if your PC sends anything. The incoming MIDI messages fill up all the available USB buffer memory, preventing all other USB communication from working.

In Arduino, click File > Examples > Teensy > USB_MIDI > Buttons, and then look at the code at the end up loop(). Try copying that code into your loop() function. Maybe that will help?
 
Also, you might consider adding another delay after you send the note off message. As written, this will immediately turn the note right back on again.

You probably should delay longer. 10 ms is only ~3 cycles of the 329 Hz note you're turning on. That will make only a tiny chirp, or no sound at all if the synth software has a slow attack time.
 
Before focusing on the hardware, look at a simple software issue that might be causing trouble.

MIDI controllers which don't read (and ignore if not needed) incoming MIDI messages tend to stall if your PC sends anything. The incoming MIDI messages fill up all the available USB buffer memory, preventing all other USB communication from working.

Ah that I did not know. That indeed helps a bit.

The problem did not disappear yet.
I ordered another LC that I'll use solely with software-tests, e.g. not with new hardware. So that I know that I did not damage it.
 
Hang on; I saw this earlier with an arduino uno I only realised! (talking serial through usb to a host system) I thought it had to do with an uart filling up but an usb-buffer makes more sense.
 
Status
Not open for further replies.
Back
Top