Hello again. After a short break I am revisiting this problem.
I decided that messing around with solderless breadboard and AC power adapters of unknown provenance was too much of a headache. So, in an effort to discount any connection/interference/power problems, I have done two things: a) procured some stripboard and soldered up my circuit in a more permanent fashion; b) found a spare PC ATX power supply and used that to power everything.
So, all good now, right? No! I was extremely exasperated to find I apparently still had the
same damn problem with the MCP23017 resetting itself!
But, I think I have found the cause in this instance, which is kind of similar in nature to what was happening before, but not quite.
I checked with the scope again for any kind of sagging on the reset pin of the 23017, but didn't see anything at all - it was rock-steady. Confused that I wasn't having precisely the same issue as last time, I decided to apply Dave's rule #1: "Thou shalt measure voltages". I found that my ATX PSU is actually a little off-spec with the voltage levels at such low loads; +5V is actually 5.3V, and +12V is actually 11.5V, although at least both are solid and interference/ripple-free. The reset line voltage on the Arduino, however, is for some reason only 4.85V in the high state. That's nearly 0.5V lower than the MCP23017's +5V supply voltage. Aha!
So, what I guess is happening is that the 23017 is seeing this voltage difference and interpreting that as a reset. To check this, I tied the 23017's reset pin with a 10K pull-up resistor to the 'full' +5V, and the problem goes away.
As to why it reset only when I tried to
do anything with the 23017, I can only theorise that perhaps the whole chip is running according to the I2C clock, and it only checks the reset pin state once per cycle (or some similar mechanism). Can anyone comment on that? Also, the datasheet says the reset pin's low threshold is supposed to be 20% of VDD - 1.06V in my case. That's quite a way below what it appears to be doing in practice.
But, back to the nub of the problem: my Arduino's reset line 'high' voltage is too low. Why? The 5V pin is at 4.99V, so pretty much spot-on, so it's not as if the Arduino's 5V regulator is dodgy.
However, I suppose I have to address the more general problem that my Arduino's '5V' is not at the same level as '5V' of the rest of my circuit. I need to make them equal. I can think of several possible ways to go, but each seems to have a drawback:
- Supply the PSU's +12V to the Vin pin - doesn't help, as the on-board regulator's 5V output will still be lower.
- Supply the PSU's +5V to the Vin pin - can't, as the on-board regulator has a dropout of about 1.1V, so needs > 6V.
- Supply the PSU's +5V to the 5V pin, bypassing the on-board regulator - have read that this is not recommended, as it also bypasses the automatic Vin/USB power source selection, leaving the 5V being fed both externally and from USB. Not only that, but I also read that 'backfeeding' a higher voltage (5.3 vs. 5V) to a linear regulator's output is not good for the regulator.
In summary, I am now stuck in a catch-22 situation. Could tie the 23017's reset pin to VCC, but then I lose the facility to have it reset itself whenever the Arduino does. Could 'force-feed' the Arduino with external 5V, but then I cannot simultaneously use the USB connection, and it might be bad for the on-board regulator chip.
I don't know how to solve this situation. Anybody got any ideas?