Sunday, September 17, 2017

Running Energia on Mac OS X

Energia is a programming environment for the Texas Instruments LaunchPads, based on the Wiring and Arduino frameworks. It took a bit of effort to get it working on my Mac. I'm running OS X 10.11.6, El Capitan; hopefully these instructions will work for the more recent OS X 10.12, Sierra.

1) The most obvious thing is to go to energia.nu/guide/guide_macosx instead of the windows page.

2) After starting Energia, go to the Tools -> Board -> Board Manager menu item and choose your target board. You should see a list of boards. For instance, you can choose

Energia MSP432 boards by Energia
Boards included in this package:
MSP_EXP432P401R

Clink Install for the entry corresponding to your target board. (I believe the entry listed above is for the black MSP432 Launchpad. If you have a red board, you should probably install the "MSP432 EMT Red boards" instead -- just a guess.)

3) Now quit Energia, since we'll need to implement an annoying workaround. When I first tried compiling a program, I got a dialog box with this error:

To use the "java" command-line tool you need to install a JDK.

Some discussion about this error may be found here. After doing a lot of google searching and hitting my head against the table a lot, I came up with a somewhat annoying but not utterly dreadful workaround.

If you open up a Terminal and type which java, it will tell you: /usr/bin/java

If you type java -version, it will tell you: No Java runtime present, requesting install.

Based on this webpage, I discovered /usr/bin/java is a link to

/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

Instead, it should be a link to

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java

You can't readily change the /usr/bin/java link without disabling something called System Integrity Protection (SIP), which isn't really something I wanted to do.

So, here's my hack:

3A) In the Terminal, type

sudo ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java” /usr/local/bin/java

That puts a link in /usr/local/bin, which SIP doesn't complain about.

3B) We need to get into the "package" of Energia.app. (I'm assuming you put it in your main Applications folder.) In the Terminal, type

cd /Applications/Energia.app/Contents/MacOS

In that folder, you'll find a file called Energia, which starts up the program. Let's rename it something else that we can call from our own Energia script. Type:

mv Energia Energia_main

3C) Then create a text file called Energia that contains these three lines:

#!/bin/bash
export PATH=/usr/local/bin:$PATH
./Applications/Energia.app/Contents/MacOS/Energia_main

Now, when you double-click on the Energia icon, it will change your path to put /usr/local/bin before /usr/bin so Energia will find the correct java command line program. This path change is restricted to this running of Energia, so hopefully this won't mess up any other program that for whatever reason really should have /usr/bin before /usr/local/bin in the path.

Usual caveats apply; your mileage may vary. Use the above information at your own risk (although I don't think I'm suggesting that you do anything particularly risky.)

Saturday, September 16, 2017

Teardown of SNES and Genesis USB Gamepads

I picked up these incredibly cheap USB gamepads on eBay: Two SNES-style for $8.90 total, and two Genesis style for $15.24 total. They work reasonably well.
Let's take them apart, starting with the SNES-style controller. Removing the screws from the back reveals the boring side of the PCB, showing the crystal and the four standard USB wires.

Flipping over the board reveals a glop top and ten nice pads and two through-hole connections for the shoulder buttons that you could solder to, giving you twelve inputs if you wanted to use the PCB as general button-like-thing-to-USB converter.

Here's what the SNES-style controller looks like with the buttons and D-pad removed.
Now let's take look at the Genesis-style controller. Removing the screws from the back once again reveals a crystal and the four standard USB wires. Also note that the shoulder buttons are tactile switches.

Flipping over the board reveals a glop top, eleven nice pads and two through-hole connections for the shoulder buttons that you could solder to, giving you thirteen inputs if you wanted to use the PCB as general button-like-thing-to-USB converter.
Here's what it looks like with the rubber membranes removed.
For completeness, here's what the individual buttons look like, along with the inside of the back of the controller: 


Tuesday, September 12, 2017

Let's put those electrons to work!

I'm Aaron Lanterman, a Professor of Electrical and Computer Engineering at Georgia Tech.* This is my blog on DIY electronics**, with an aesthetic bent towards the retrofuristic: steampunk, dieselpunk, and games such as Bioshock and Fallout. Over the next few months, we'll design and construct a custom bass guitar pedal and a R2-D2 hat that bleeps and blinks. We'll hack together some custom game controllers and portable gaming consoles. We'll play around with analog circuits for music synthesis. We'll fix some old tube radios. We'll fix a car's air conditioning using three zip ties and install a new car stereo.

Along the way, we'll do some reverse engineering, and experiment with "single-board computers" like the Raspberry Pi and "microcontroller boards" like Arduinos and the Texas Instruments Launchpads.

I have another blog, focused on education: Edupocalypse Now: Education and Innovation in the End Times.

Like everyone else in 2006, I had a Livejournal where I posted political rants and personal life observations. (I technically still have it, although I don't post much there nowadays.)

*Opinions expressed here are my own, and not those of my employer. I may at times provide commentary on equipment that was donated to me or  Georgia Tech; I will disclose such situations in the interest of fairness (although I believe I can offer unbiased advise).

**Any electronic project may present a risk of injury or death, particularly when dealing with mains voltages. It is important to follow appropriate safety practices. The author of these pages, Aaron Lanterman, disclaims any liability for injury, death, or other damage caused in using any of the information contained on these webpages.