Wednesday, June 7, 2017

Taken by a Strange Mood - Is any project really "finished"?

I'm back.  I can't stay away.  I can't leave well enough alone.

First things first, I need to catch you guys up.  There was one more major modification that I needed to make to the Pi/fan interface to make everything actually work.  You see, when I purchased the fan that is now permanently glued inside the pi case which is also permanently glued inside the TV chassis, I didn't take enough care to note that it pulled something like 250 mA when operating.  So my nice brilliant fan control script worked, but because I had the fan wired up to the 5V GPIO pin, it would draw its 250 mA from the Pi computer itself.  What this resulted in is emulator and playback slowdown whenever the fan came on, because the Pi would automatically throttle back its clock speeds when it detected an undervoltage due to too much current being drawn.  Long story short, my fan was pulling too much current from the rest of the pi, and I had to wire in a separate 5V power source to power the fan alone.

I used a voltage regulator connected to my extra 12V pins that come off of the TV power supply. (If you'll recall, I have 4 pins on that connector, 2X 12V and 2X ground).  I had a lot of problems with intermittent fan function after doing this, and extra loud fan, and it all came back to a wiring problem with these 4 pins.  So I had to remake the connector with better crimped terminals so I could get consistent connection.

So, fan being powered technically by a separate source, my power issue when fan on problem went away... mostly.  I'm not sure exactly what is going on (because I can't take voltage measurements while the thing is in "real world" use), but every few seconds I'd still get my undervoltage signal as well as emulator slowdown/stutter.  It was never consistent, and completely intermittent.  My power supply is rated at 5V, 3.5 amps, so it should be adequate, but I have no way of testing it to verify that it can actually supply this.  Ultimately, I decided to ignore the warnings and disable the throttle back at undervoltage.  I added these lines to my /boot/config.txt file.

avoid_warnings=2
smsc95xx.turbo_mode=Y

These lines disable the on screen undervoltage warning icon, and ensures that turbo mode stays on, as well as increasing some network performance to ensure we get good streaming playback from my media server.

So, that gets you caught up to where I am today.  The TV has been in use and deployed in the kids play room for months, with hardly a hiccup.  I've been doing everything I can to optimize the software experience.  The Pi boots into Kodi 17.3 (as of writing), with PlexKodiConnect addon installed.  This allows me to use my Plex smartphone app to queue up and play movies on this TV, just like a chromecast.  We also use the Kodi remote app Kore, which allows us to also share youtube videos to this TV from a smartphone without having to navigate the on screen display.  I'm patiently waiting for the official Plex for Kodi addon to mature enough to the point that I can use it exclusively (still needs the plex companion, and support for Plex addons before I can do this).

I've also been messing around with the RetroPie half of this device.  Specifically, I'm trying to find a frontend for all the roms on the server that's quicker than EmulationStation.  ES is fine for small libraries, but it takes a long time to startup if you have large ones.  I tried out Mehstation, but found that scraping artwork and game info to be too much of a chore.  Now I've settled on Attract-Mode, and have almost finished getting things set up.  Its functional, but not pretty.  I have a lot of missing artwork that doesn't make any sense to me.  EmulationStation scraped artwork beautifully, and it also filled in intellegent human readable names for all my MAME games, and it properly scraped artwork. Neither Attract-Mode or Mehstation matched it, and I'm not sure what's going on.

Anyway, while working on this software problem I ran into the last limitation caused by my hardware setup.  I had the wife accidentally turn off the TV while I was working on it remotely, and then I had to wait 5 minutes or so for the supercapacitors to drain down before I could power it back on. A minor annoyance, but one that I've determined to fix.

I read an article about hooking up a proper on-off switch to the pi, and how one guy accomplished an auto power-off after pi shutdown using a secondary microcontroller.  Before I knew it I had one on order.  It comes tomorrow.  The plan is to sense a pin on the pi that will go from high to low at shutdown, and then use a transistor to cut the power from the capacitors.  This will effectively "unplug" the Pi after it has finished its shutdown process.  I'll then sense another pin on the microcontroller connected to the power supply that will turn the transistor "on" at power on, allowing the pi to boot.

I wish I had known about this solution before, because with this setup I actually could have used an off the shelf phone battery backup instead of my supercapacitors, but we're here now.  I'll post another blog with pictures once I'm done.  Until next time...