the wondrous tales of a software guy in hardwareland

The Making Of monotrino, Part 3

Part 3 is the saddest part :-( Yesterday was a small step backwards for a man, one giant leap backwards for DIY electronics…

I sat down dutifully with my soldering iron, wires, resistors, tin and whatnot. Goal was to connect the remaining 8 buttons of my sequencer. Things went pretty smooth, took me 2 hours to finish the job. Approximately 60% faster than the cumulative ~5 hours I spent for the 12 piano-key buttons, which is good :-)

Done with the hard work, I finally hooked up the Arduino and uploaded my sketch to test the buttons and calibrate the reading values. Aaaand… it didn’t work :-(

Instead of the expected readings, all I could get out of the analog pin (A6) were wildly fluctuating values between ~700 and ~1000 if no button was pressed. And a steady 0 whenever I pressed a button, no matter which one. Except for the second button in the row, which didn’t affect the reading at all when pressed, eg. was still floating. AAARGH.

Oh boy. As much as it is rewarding when your creation works, it is frustrating when it doesn’t. I double checked all the solder points to spot errors, badly connected wires, overlapping contacts etc. But I couldn’t find anything obvious, everything seems OK from what I can see.

The uncomfortable truth is: hardware is several orders of magnitude more difficult than software to debug. Unless you are a trained electrical engineer, I assume. Sadly, I’m not. And I have not even the smallest clue about what to fix, and how :-(

Well, some clue maybe, but so small it almost falls below the epsilon of usefulness. The fact that analogread() fluctuates with no button pressed, even if I have activated the internal pull-up resistor, could suggest that the pull-up is fried. That would be bad, but probably the lesser evil. I can use another analog pin and leave A6 for a knob. All the alternatives (a defective button, a fried 1k resistor, or my Arduino completely broken) would be more or less a disaster for my project, involving at least hours and hours of desoldering, with a medium to high chance of irrimediably ruining my perfboard.

The “debug” will require testing the Arduino pins on a breadboard, probing with the multimeter, and probably one or more human sacrifice to the electric Gods. But I was really out of energy and motivation yesterday for this to happen. I will investigate the problem at my best, hoping to find a solution sooner than later. But this incident definitely slows down my build process. Not to mention the vast damage to my self-esteem :-(

So, no picture for today, no good news either. Wish me better luck next time!


UPDATE: Wohoo! Yepee! The world smiles again :-)

I had a suspect, and it turns out that what I suspected is true! In sumary: nothing is broken, I did no mistake in the circuitry, and – most importantly – my honour is safe :-)

What I observed is absolutely normal. The fact is that the two extra analog pins on the Nano (A6 and A7) are slightly different from other pins. They are pure analog pins, which means they don’t share the same “port” as digital pins, and cannot be used as such. As a consequence, they have no internal pull-up resistor!

For my project, this means I will have to use another pin (A4, for example) and leave A6/A7 for strictly analogic stuff, like knobs for example. Not a big deal, just one single wire end to desolder and resolder.

I think this is definitely a flaw in the Arduino documentation. They mention anywhere generically that “all pins have internal pull-ups” and “all analog pins can be used as digital pins”. This is just plain wrong if you are working with an Arduino Nano and its two extra analog pins. It took me a visit to the ATmega datasheet (which is mostly waaay over my head) and a post in the Arduino forum, for good measure, to have the issue clarified. A small note somewhere on the Arduino website would have been very courteous: -)

Actually, now that i think about it, I didn’t really test that my buttons work using another pin… but I’m totally confident they will.

And now that my inner peace is regained, the usual work in progress pictures:

On the front panel you can see the knobs I “snapped in” in their final positions and a few more resistors in the upper right part.

The back side is becoming a real cable monster :-) And I still have to add some…

I plan to continue with the knobs and wiring the audio jack for the < ode>tone(), so that I can (finally!) start working on the code for monotrino.



Comments are currently closed.