11.5.20

Principium 3.0: under the hood 3

aah. wiring.
the keyboard obviously has thirteen wires: one common (+3.3v) and then one for each key contact, all running to Bela's digital I/O pins.
add in twelve pulldown resistors to make it all behave: done.


next , i threw in the only thing i bought extra. an M-Audio Midisport 1x1. cheap, reliable, small footprint when uncased: no need to reinvent the wheel there. in the end i ran wires from the input port to a panel mounted 5 pin jack, keeping the integrity of the M-Audio. because you never know.
i cut a USB cable in half, plugged it into the Midisport, and soldered the other end to the bottom of the BBB's usb host port. a plug would have been in the way too much there. so now Bela recognises it at startup and acts as a host - works flawlessly. if i ever want to use the host port for something else, i can just unplug the Midisport.

then - a little show and tell for jack wiring.


i used switching jacks, and came up with the above.
a single mono cable in the left output jack sees a mono mix of the L and R channels through the two 1k resistors.
obviously we can put another mono cable in the right output jack - that breaks the mixdown connection and now we have dual mono, split stereo, whatever you want to call it: L channel on L jack, R channel on R jack. the standard, quoi.
what you don't see too often is option 3: nothing in the left jack, but stereo on a TRS cable in the right jack. nice for using a Y-cable. and if you should accidentally plug a mono cable in there with the L jack empty, you'd just pull the L channel to ground through the 1k resistor, so no problem. no stereo, no mixdown, but no problem.


 then, horror of horrors - the display.
i picked a double digit 7 segment display out of the scrap box. must've pulled it out of something, but can't remember what. tested it, got every segment lighting up on the breadboard - great.
ordered me some 40110 CMOS counters, since you can clock those to count up and down - perfect for bank selection - and they can act as a 7 segment driver! sounded Purrfect.
however.
in my enthousiasm, i failed to realise there's two types of 7 segment displays: there's common cathode, which the 40110 likes very much, and then there's common anode, which the 40110 doesn't quite get along with. guess which one i had.
now i could have ordered me some new IC's, but that meant waiting.
i could have inverted all the 40110's outputs, but that meant inverting 14 signals and it seemed like too much hassle - and real estate.
i could have ordered me a new display, but it had cost me so much effort to make a hole in the front panel to fit this one, that i didn't want to go through that again. (and believe me, i checked - couldn't find any new ones with the exact same dimensions.)


in the end, i dug up an ancient Arduino Duemilanove which wasn't seeing much action - C++ and all, you know.. not my bag - and i guess it's about to go unsupported soon anyway. hah.
the benefits were that it could receive 3.3v signals and see them as HIGH (which the 40110 wouldn't have running at +5v), i could invert however much i damn well pleased, there were 7 segment libraries to be found and, within reason, i could interface with the display directly without having to come up with extra circuitry.
i tried to multiplex the two digits with the SevSeg library. meaning: the arduino lights up one digit at a time, but so fast you see both of them light up. which spares you some pins, since you only need 7 segment pins and not 14 for two digits. now, this only worked with resistors on the segments for me (the other option being resistors on the digit pins), and results in terms of luminosity were disappointing to say the least.
after much trial and error and measurements, i actually initiated two SevSeg objects (one for each digit), i'm driving every single led LOW on it's own pin on the Arduino, and i'm using every single pin on the Duemilanove except one (0= rx).
the display power source is the raw +5v output on Bela (straight from the wall wart, basically), the Arduino itself is powered from the regulated +5v USB out on Bela to the +5v pin on the Arduino. i know this is not recommended practice, but that's only because you then bypass the arduino's own regulator. since this is already regulated it won't damage anything.

i don't know the specifics of the display itself, but the current limiting resistors i used were surprisingly low: i have 100 ohms on each pin, and current draw is about 170mA when displaying the number 88 (all segments lit.) that's not too close to the 200mA limit of the Arduino, and i don't see myself using 88 soundbanks any time soon. every other number is below that: on average i would say i'm drawing something like 100 to 120mA, which seems fine.
the only thing that is a tiny bit stupid is that, at startup, the segment connected to pin#13 lights up by itself. probably to do with the internal resistor+led. if i feel very brave, brave enough to brave the hot glue barrier i created myself, i might swap that pin for the DP on the display - the decimal point, aka the little dot in the corner. wouldn't mind that so much.



close-up of the opened back panel. to the left is Bela, usb cable for the midisport visible underneath. the microSD card is right next to the miniHDMI, so easy enough to pull. next to Bela is display driver buddy Duemilanove. which has a little reminder to unplug the +5v line should i ever want to reprogram it.