Help with Teensy hanging SOMETIMES with a MCP23017 connected

Status
Not open for further replies.
Hi Guys

I would really appreciate some advice/guidance/help with a problem.

I am using a teensy 3.6 with 2 encoders without switches, 4 encoders with switches and 14 momentary push buttons plus a i2c MCP23017 with 6 encoders without switches and 1 encoder with a switch all interfacing with x-plane, and generally working very nicely. Also, I’m reading x-plane’s status and turning on the pin 13 LED.

It’s all set up on a couple of breadboards, I had a lot of wiring issues with the MCP23017 but it seems OK now after swapping out the breadboard and IC, except for the problem.

My problem is, SOMETIMES the Teensy hangs when rotating an encoder a couple of full turns OR after 10 or 20 minutes have passed.

Both issues are very intermittent and can be resolved by unplugging and replugging the usb cable.

Not sure how to go about debugging this, I don’t find it easy to debug Arduino sketches and short of debugging it don’t really know what I can test to try and track the issue down. I don’t have access to or the ability to use fancy test equipment.

I can post a fritzing and code if its any help.

Malcolm
 
Do you have 2 pull-up resistors somewhere on the I2C bus? The raw MCP23017 does not have pull-up resistors.

You might want to checkout https://github.com/TeensyUser/doc/wiki/I2C for more information.

Yes I’ve got 4.7k resistors to +3.1 volts on both lines. Did have 2.2k resistors but the bus seemed more unstable with these.

I’ve read the wiki but it didn’t help me much. It’s a very intermittent error, for example had a 1.5 hr flight this afternoon with one hang (which happened when I was turning an encoder) cleared by a hard reset.
 
Hi Guys

I would really appreciate some advice/guidance/help with a problem.

I am using a teensy 3.6 with 2 encoders without switches, 4 encoders with switches and 14 momentary push buttons plus a i2c MCP23017 with 6 encoders without switches and 1 encoder with a switch all interfacing with x-plane, and generally working very nicely. Also, I’m reading x-plane’s status and turning on the pin 13 LED.

It’s all set up on a couple of breadboards, I had a lot of wiring issues with the MCP23017 but it seems OK now after swapping out the breadboard and IC, except for the problem.

My problem is, SOMETIMES the Teensy hangs when rotating an encoder a couple of full turns OR after 10 or 20 minutes have passed.

Both issues are very intermittent and can be resolved by unplugging and replugging the usb cable.

Not sure how to go about debugging this, I don’t find it easy to debug Arduino sketches and short of debugging it don’t really know what I can test to try and track the issue down. I don’t have access to or the ability to use fancy test equipment.

I can post a fritzing and code if its any help.

Malcolm

Just a quick thought, as I've scratched my head over a similar thing in the past, when using multiple LED button switches - from the data sheet of the MCP23017, max current per pin is 25mA, but the total can't exceed 150mA out, or 125mA in. If a lot of pins on the MCP are used at the same time, you might be getting a sudden, and inconsistent, surge or sag that takes it over its limit, after which the MCP23017 will need to be reset. I found that using multiple MCP chips, to spread out the load a little, helped.

Paul.
 
Thanks for the suggestion. I am using 15 of the MCP pins but only operate one encoder at a time.
Redoing the wiring has been a big help and I’m in the process for moving it off the solderless to soldered breadboard and it’s been a lot more stable lately. Having said that I had to do a reset (USB in/out) last night. Might set up a reset button.

Malcolm
 
Thanks for the suggestion. I am using 15 of the MCP pins but only operate one encoder at a time.
Redoing the wiring has been a big help and I’m in the process for moving it off the solderless to soldered breadboard and it’s been a lot more stable lately. Having said that I had to do a reset (USB in/out) last night. Might set up a reset button.

Malcolm

Does it hang? Or do you have the problem, the MCP is not always recognized correctly on startup.
I had this problem and was able to solve it with ".endTransmission" -statement right after "Wire.begin()".

On the other hand, I have pullup-resistors on the SDA and SCL line with 4.7k each
 
I've found in the past, that sometimes I need to put in a delay of a second or two before the Teensy connects to the device helps a lot (i.e. particularly the Teensy 4.0 runs so much faster that the I2C device hasn't finished initializing yet).
 
Does it hang? Or do you have the problem, the MCP is not always recognized correctly on startup.
I had this problem and was able to solve it with ".endTransmission" -statement right after "Wire.begin()".

On the other hand, I have pullup-resistors on the SDA and SCL line with 4.7k each

Usually it just hangs after a while 2 min to 60 min, completely random. But actually come to think of it it’s usually associated with the same encoder. Could it just be a duff encoder? I also have 4.7 k pull-ups.

Today, 04:08 PMMichaelMeissner
I've found in the past, that sometimes I need to put in a delay of a second or two before the Teensy connects to the device helps a lot (i.e. particularly the Teensy 4.0 runs so much faster that the I2C device hasn't finished initializing yet).

It doesn’t seem to be an initialising problem. I had a 3000 millisecond delay but that seemed to stop initialisation all together. The main issue is the Teensy hanging after a period of time, I don’t know what it’s doing. I found the scanner sketch extremely useful in checking the basic comms.

Malcolm
 
Status
Not open for further replies.
Back
Top