Sawppy Will Be At DTLA Mini Maker Faire

The Downtown Los Angeles (DTLA) Mini Maker Faire, hosted at the Los Angeles Public Library central location, is coming up this weekend and my rover Sawppy will be among the many maker projects at the event.

DTLA Mini Maker Faire Website

Sawppy will be one of several rovers present. JPL’s Open Source Rover team should be there with their original build, SGVHAK will be there with the beta build rover I contributed to, which inspired my Sawppy and they’ll all be hanging out together.

The JPL team will also be giving a brief presentation in the KLOS Children’s Theater upstairs about their rover project, followed by an even briefer presentation by me on building Sawppy. Both of these talks are listed on the workshop schedule though (as far as I know) there is no hands-on workshop activity planned. Sawppy will be present and running for people to see up close, but no assembly (and certainly no disassembly!) is planned. I may bring an extra corner steering unit for people to play with, and they’ll be welcome to take that apart and put it back together, but not much beyond that.

(Cross-posted to Hackaday.io)

Highland Park Railroad Open House

HPRR01 - WelcomeHighland Park Society of Model Railroad Engineers is my local railroad club. I appreciate the detailed work that goes into a model railroad layout but I haven’t decided to spend the time and money required to do a good job at it myself. Still, when they hold an open house, I go and admire the work they’ve put in. This is a train layout that has been worked on by club members for most of the last seven decades!

The club house appears to be literally a house – a former residential building that has now been completely taken over by the club. Roughly half of the available square footage inside are train tracks, with the remainder used for support equipment, workshops, and general club space.

HPRR02 - Layout Partial

“Does your train of thought have a caboose?” Generally speaking… mine do not.

HPRR03 - Safety and Caboose

The general theme is 1940s-1950s America, conveniently covering the final transition period from steam locomotives to modern diesel electric and all electric trains. Since this club is in the Los Angeles area, there are trains inspired by local history, like some Red Cars.

HPRR04 - Red car

A scratch built reproduction of Angel’s Flight climbs the side of a mountain rather being in the middle of a city like the real thing.

HPRR07 - Angel's Flight

A steam locomotive was set up as if it’s on museum display.

HPRR08 - Highland Pacific locomotive display

And behind the museum piece, an impressive train station.

HPRR09 - Union Station

One of several train yards in the layout, anchored by a big turntable.

HPRR11 - Turntable

Another train yard featured a group of train enthusiasts taking pictures. I wonder if the figurines are modeled after specific members of the club who would go on such trips.

HPRR15 - Train phtographers

Many little towns dot the layout.

HPRR16 - Town

Some of the town buildings have storefronts inside.

HPRR17 - Town detail

This bridge painting crew is having a bad day.

HPRR12 - Bridge painters

Locomotives running on the layout are under command of train engineers at these stations, coordinated by a dispatcher.

HPRR10 - Train engineers

Behind the scenes, a massive panel of relays manage the layout.

HPRR05 - Relay panel

Wire-wrapping was already a technology on its way out when I started learning electronics, but given the age of the club, it’s not surprising that some wire wrapping is still present.

HPRR06 - Wire wrapping

The power conversion and distribution panel.

HPRR14 - Power supply

Venturing underneath the train tracks is not for the faint of heart or the easily confused, but it’s far more spacious and less cluttered than I had expected.

HPRR13 - Underneath

One of the many objectives of the open house is to recruit new members to the club. While I’m very appreciate the work, I think I’ll stick with software and robots rather than get into model trains.

Still, I’ll probably stop by on the next open house.

Sony KP-53S35 Teardown

SonyTD 01 - Final serviceThis Sony KP-53S35 rear projection television is over 21 years old and we’re going to pull it apart. The aim is to get parts for future projects that are difficult (or unreasonably expensive) to buy on their own. Plus a few auxiliary items because it’s easy to get them at the same time. The “shopping list” sorted by size are:

  • A large Fresnel lens that’s a core part of the main screen.
  • The large front-surface mirror reflecting picture onto screen.
  • Lens assemblies on picture tubes.
  • Speakers.
  • Caster wheels.

SonyTD 02 - Tag.jpg

Since this might get messy, the doomed TV was moved out to the driveway for dissection. The rear service panel is the obvious place to start. [mle_makes] has taken apart many RPTVs and was recruited as expert guide to the process. [amybaldwindev] has not taken many things apart before and is here to learn.

SonyTD 03 - Back panel

With the service panel removed, we can see the heart of the TV: picture tube and electronics driving them. The rest of a RPTV is basically empty space.

SonyTD 04 - Back panel removed

Next to be removed was the large rear mirror. I was a little disappointed to find this was an ordinary rear-surface mirror, not a front-surface mirror as I had hoped for. Still, it has many future project possibilities.

SonyTD 05 - Mirror removed

The largest two circuit boards were mounted on a tray that could slide out for servicing, giving us a better look at the heart of the machine. Aside from some beefy-looking heat sinks, there is little desire for whatever’s on these non-HDTV circuit boards. They’ll be stashed away and likely disposed in electronics waste disposal in the future.

SonyTD 06 - Tubes and electronics

Old age made the circuit boards uninteresting, but old age made the picture tubes novel. They were removed next, and their focusing lens assemblies removed.

SonyTD 07 - Tube lens removal

With the lens assemblies removed, we can see the picture tube behind a liquid cooling assembly. We knew to expect three tubes: one each for red, green, and blue. And it wasn’t too surprising to see color imparted by colored lenses. What’s puzzling is the fact the red and green tubes got colored lenses…. but the blue one did not. Do these tubes emit blue by default?

SonyTD 08 - Tube no lens front

The three tubes are different in other ways: The red and green tubes had an extra circuit board on their control yokes, but the two boards are clearly different. In contrast, the blue tube had no circuit board on its control yoke at all.

SonyTD 09 - Tube no lens rear

Here’s how the three tubes (and their control yokes) were mounted in the case, which may be useful if they are to ever light up again.

RPTV Picture tube and coil orientation

The coolant (most likely ethylene glycol) in the chamber in front of all three tubes were drained into a glass jar for safe disposal. (Or potential reuse.) Once drained, the cooling assembly was removed to expose the picture tube face. Visible on each face is a burned-in rectangle representing 21 years of TV watching. Due to the geometry of the optical path, the tubes on either side had a trapezoidal pattern (visible here) and the center tube has a rectangular pattern.

SonyTD 10 - Tube burn in

These large powerful high-voltage tubes are not going to be used for their designed purpose in the future, but the glass work is beautiful and I hope to find an aesthetic way to display them. All the components were stripped off the glass vessel.

SonyTD 11 - Bare tube

It’s a bit of a shame, as the wiring in the control yoke has aesthetics of their own.

SonyTD 12 - Control yoke

With all the components packed away, it was time to break down the cabinet. It is mostly built from injection-molded polystrene and should be recyclable.

SonyTD 13 - Plastic frame

This is where a reciprocating saw (the Harbor Freight knockoff of a Sawzall) became very handy.

SonyTD 14 - Breaking down

At the end of the day, a big bulky RPTV has disappeared. Its desirable components were packed for reuse, hazardous components were packed for safe disposal, and the remaining cabinet pieces broken up for household waste/recycling.

Yet to come: giving these salvaged parts new life.

Entering the Wide World Of ESP32

Espressif Logo

As a thanks for participating in the ESP32 mesh network project by Morgan and Ben, people whose badges became nodes on the network were generously gifted the ESP32 module mounted to each of our badges. Unfortunately, I managed to damage mine before the big stage demo so sadly I didn’t put in the honest work to earn that ESP32. Still, I now have a damaged ESP32 that I can try to fix.

Before I start trying to fix it, though, I should have a better idea on how to tell if a ESP32 is up and running. The only mechanism I had before was to run the badge mesh network app and see if there’s any response, but I want to know more about how a ESP32 works in order to better tell what’s broken from what’s working. Also – since I’ve desoldered my ESP32 from the carrier board, it is not nearly as easy to test it against the badge.

I’ve read about a lot of projects built using the ESP32 on Hackaday, so I know it’s popular for and it would be cool to add it to my own project toolbox. Given its popularity, I thought it wouldn’t be a problem to find resource on the internet to get started.

I was right, and wrong. There is no shortage of information on the internet, the problem is that there’s too much information. A beginner like myself gets easily disoriented with the fire hose of data presented by ESP32.net.

Do I start with Espressif’s own “ESP-IDF” development framework?

Do I start with an Arduino-based approach to ESP32 development?

Do I start with Amazon’s tutorial for how to use an ESP32 with AWS?

How about other individual tinkerer’s adventures on their own blogs? Here’s one person’s initial report poking around an ESP32, including using an oscilloscope to see how quickly it can change output based on input. And here’s another Hello World, and there are many more blogs covering ESP32. (Soon including this one, I suspect.)

It’s going to take a while for me to get oriented, but it should be fun.

Adafruit Feather System

I received a Adafruit Hallowing in the Supercon sponsor gift bag given to attendees. While reading up about it, I came across this line that made no sense to me at the time.

OK so technically it’s more like a really tricked-out Feather than a Wing but we simply could not resist the Hallowing pun.

feather-logo

I can tell the words “Feather” and “Wing” has some meaning in this context that is different from their plain English meaning, but I didn’t know what they were talking about.

But since this is Adafruit, I knew somewhere on their site is an explanation that breaks down whats going on in detail. I just had to follow the right links to get there. My expectations were fully met – and then some – when I found this link.

So now I understand this is a counterpart to the other electronics hobbyist programming boards and their standardized expansion board form factor. Raspberry Pi foundation defines their HAT, Arduino defines their Shield, and now Adafruit gets into the game with feathers (a board with brains) and wings (accessories to add on a feather.)

Except unlike Raspberry Pi or Arduino, a feather isn’t fixed to a particular architecture, or a particular chip. As long as they operate on 3.3 volts and can communicate with the usual protocols (I2C, SPI), they can be made into a feather. Adafruit make feathers out of all the popular microcontrollers. Not just the SAM D21 at the heart of Hallowing, but also other chips of the ATmega line as well as recent darling ESP32.

Similarly, anyone is welcome to create a wing that could be attached to a feather. As long as they follow guidelines on footprint and pin assignment, it can fit right into the wings ecosystem. Something for me to keep in mind if I ever get into another KiCad project in the future – I can build it as a wing!

 

V-USB For Super Basic USB On AVR Chips

One of the gifts to Supercon attendees was a Sparkfun Roshamglo badge. While reading documentation on writing software for it, one detail that stood out about this Arduino-compatible board was the lack of a USB-to-serial bridge. Such a component is common on Arduino boards. The only exceptions I’m aware of are the Arduino Leonardo line using the ATmega32u4 chip which has an integrated USB module.

The ATtiny84 on the Roshamglo is far too humble of a chip to have an integrated USB functionality, so that deviation from standard Arduino caught my interest. In fact, not only does the board lack a serial-to-USB bridge, the ATtiny84 itself doesn’t even have a UART peripheral for serial communication with a serial-to-USB bridge. Now we’re missing not one but two things commonly found in Arduino-compatible boards.

What’s the magic?

vusb-teaserThe answer is something called V-USB, a software-only implementation of basic USB fundamentals. It is not a complete implementation, most notably it does not handle all the error conditions a full implementation must gracefully handle. But it does enough USB to support the Micronucleus boot loader. Which creates a very basic way to upload Arduino sketches to an ATtiny84 without an USB serial interface engine (SIE), or even a UART, on the ATtiny84 chip.

Yes, it requires its own custom device driver and upload tool, but there are instructions on how to make all that happen. The point is minimizing hardware requirements – no modification on the host computer, and minimal supporting components for the ATtiny84.

It looks like a huge hack, and even though SparkFun cautions that it is not terribly reliable and won’t work on every computer, it is still impressive what the V-USB people have done under such limits.

Sawppy Sees Brief Internet Fame

A few days ago I noticed a sudden spike in internet traffic to Sawppy – page views on my personal blog, Sawppy’s Hackaday.io project page, the Github repo, and YouTube video all rose dramatically. It took a little digging around various statistics reporting pages to figure out where the interest was coming from. Answer: someone had submitted Sawppy to Hacker News giving Sawppy a brief taste of internet fame.

Given the general attention span of the internet at large, the traffic disappeared just as quickly as it came. But in that brief moment in time, a few thousand people spared a few seconds (or more) of their lives to look over Sawppy and that’s more than what I had before.

Sawppy SpikeAnd this bit of exposure might lead to other interesting projects down the line. It seems to have caught the eye of someone with interest in the Pi Wars robot competition. Sawppy’s current configuration is indeed controlled by a Raspberry Pi, but according to contest rules Sawppy is too big to fit as-is. I’m not sure a six-wheeled rocker-bogie suspension would be useful for any contest objectives (challenges) in Pi Wars. But it would absolutely make my day if I see one of the competitors downscale Sawppy to fit in the size envelope, thereby creating a “Sawppy Jr.”

(Cross-posted to Hackaday.io)

Eyes At Supercon: Adafruit HalloWing

HalloWing CloseupAnother key attraction in the Supercon swag bag was a HalloWing from Adafruit. Not just the module, a complete package: in order to make sure Supercon attendees can immediately start playing with it, a battery is included. Plus a lanyard to make sure we can wear it for others to see and start conversations about this Adafruit product. It’s exactly the kind of thing we’d expect as a sponsorship item in the swag bag. Adafruit has produced a lot of products that appeal to this exact audience, along with a ton of tutorials and useful reference information that have helped me in my own explorations.

The Supercon edition of HalloWing came with a custom firmware running through a simple slide show. It cycles through a few bitmap images of event sponsor logos: Adafruit logo, Hackaday logo, Digi-Key, etc. But that barely scratches the capability of this module.

Reading Adafruit’s product information page, it looks like one signature attraction of the HalloWing is that it’s one of the boards with support for CircuitPython. A recent addition to Adafruit’s grand plan to make electronics more approachable to more people, it is hoped that Python would be even easier for beginners to pick up than Arduino.

As my first experiment, I tried to modify the slide show. I translated each animation frame of Nyan Cat into 128×128 bitmap files and loaded them onto my HalloWing. By editing slide show parameters like removing transition effects and shortening time between slides, I had hoped that I can turn the slide show into a crude animation of Nyan Cat in action. Sadly I took a wrong turn somewhere, and my HalloWing no longer boots up. I suspect I skipped a critical step for updating slide show program’s CircuitPython source code and managed to corrupt storage.

Fortunately it was easy to reset the HalloWing with a fresh copy of its firmware. Standard (non-Supercon) HalloWing purchased from Adafruit comes with “spooky eyes” firmware that displays an eyeball that randomly looks around. I followed instructions and my HalloWing is back up and running with an eyeball. Side bonus, it looked cooler than a slide show.

This is just a start. I look forward to digging more into this board’s possibilities in the near future. CircuitPython, Arduino, and at the center of it all? A SAM D21 chip, part of the line I just learned about at Supercon.

I foresee a lot of fun with this new toy.

Mystery At Supercon: Supplyframe Cube

What’s big, orange, and a mystery? The Supplyframe cube given to Supercon attendees. It is a pretty neat physical manifestation of the Supplyframe logo. It is made of injection-molded plastic that’s been given some sort of surface finish treatment. The result is a vaguely satin feel more upscale than commodity plastic. It also comes in a nice cardboard box whose description of its contents were not sufficiently technical for the hardware hackers looking it over. Likely intentionally to give it an air of mystery.

Supplyframe Cube with Box

We see a micro USB port on the side, and a clear plastic rectangle mounted on the bottom. Also visible on the bottom are four screws, and removing them to see the insides revealed an expected circuit board behind the micro USB port. What was less expected was the wire soldered to the board, and a sheet of copper foil at the other end of the wire. What is this thing?

Supplyframe Cube interior

This being Supercon, people quickly figured out there’s a FTDI USB to serial chip behind the port, so computers see the cube as a serial port. When plugged in, the plastic rectangle at the bottom reveals its function to diffuse light from the twelve LEDs shining downwards. It’s all very pretty, but what does it do?

People were making headway figuring it out, and they got to check their answers during Voja’s scheduled talk about the 2018 Hackaday Supercon badge. Voja did say a few words about the badge, but he was clearly more interested in talking about the cube which he also designed. He switched gears to the cube around the 6:40 mark of the recorded talk.

The default firmware implements a random number generator that could store up to 2 megabytes of random bytes. The copper foil works as one half of a capacitor for transmitting data between two cubes sitting next to each other, so one cube can get an identical copy of the random bytes in another cube. Once copied, each cube could be used as one-time ciphers to encrypt up to two megabytes of data that only a person with the other cube can decrypt.

But of course, that’s just the default firmware. Voja went over what’s on the board and what else it can do. The LEDs are random (except when they all light up to signal a cube is waiting for transmit or receive) and there’s currently an accelerometer sitting unused. After the conference Voja created a Hackaday.io project for the cube and now we wait to see if people do fun things with it.

Gifts At Supercon: Sponsorship Swag Bag

When I checked in to Supercon Saturday morning, I was given the items given to every Supercon attendee. A T-shirt, of course. A magazine (pamphlet? flyer?) titled Supplyframe RealTalk Electronics. A small water bottle, and a reusable tote bag filled with stuff.

Supercon2018 Goodie Bag

In the background of this picture is the tote bag. All the stickers in the bag were laid out to the lower left: two Tindie stickers and many more Hackaday stickers of all types. On the top is a Hackaday postcard. All fun stuff, but what excites Supercon attendees are the electronics.

The orange item in the upper left is the enigmatic Supplyframe cube. A 3D realization of their company logo, it has electronics inside for a purpose mysterious to Supercon attendees (at least at first.)

Next to the cube, sitting on top of its antistatic bag and nearly invisible due to its size, is a Tomu. A complete ARM powered computer on a circuit board the size of a USB plug, it is remarkable here because it was still in development at last year’s Supercon. At the time its creator had solved most hardware issues and was recruiting people to help write the supporting software. I heard the recruiting pitch but sadly my programming skills were not aligned with the project’s needs. It’s great to see that others have pitched in and made Tomu a reality.

Next to Tomu is a LED circuit board in the shape of Hackaday’s Jolly Wrencher logo alongside a Tindie LED badge of similar function. Many attendees soldered these up through the weekend for a little bright wear.

Below the Tindie badge is a Sparkfun Roshamglo board. I read the product description saying it was an electronic way to play rock-paper-scissors over infrared signals, but I knew that couldn’t be the whole story because there’s obviously a USB connector at the end and you don’t need that for a silly little game. And further reading confirmed the rock-paper-scissors was only the default firmware – users can use the Arduino IDE to program the onboard ATTiny84 chip to do something else. This might be a fun exploration.

And last but not least, in the lower right peering back at the camera is an Adafruit Hallowing. It is shown assembled here because I couldn’t wait to take a picture before putting it together. More on this nifty little board shortly.

Shine At Supercon: Pixelblaze Cube

When I was working on my time-lapse camera badge hack for last year’s 2017 Superconference badge, I had the luck to meet Ben a.k.a Electromage, creator of Pixelblaze. He was sitting across the table from me and had to stare at the backside of my Luggable PC Mark II for most of the weekend. Our paths crossed again earlier in 2018 at the Bay Area Maker Faire, where I was working for Tindie‘s booth and he stopped by to drop off a sample Pixelblaze unit as he sells on Tindie. After my booth shift was over, I stopped by his booth set up to promote Pixelblaze and was impressed by what I saw.

I don’t recall anything demonstrating Pixelblaze at Supercon 2017, but Ben brought a nice attention-pulling demo for Supercon 2018: a sound-reactive LED cube controlled by Pixelblaze with optional sensor expansion board. It was sitting in front of him on the badge hacking bench as he worked most of the weekend on that ESP32 mesh network. Here’s a view of the cube looking down the length of the bench at all the other badge hackers.

Pixelblaze Cube

The cube’s five visible sides each had an 8×8 = 64 LED array, and they react to changes in sound volume. The microphone is part of the sensor expansion board and is paired with its own processor to dynamically adjust to local ambient noise level to pick out sharp changes. All that audio processing was required, Ben explained, because electronic microphones don’t react to sound the same way human hearing does. His algorithms make the sensor board act similarly to how a human being perceive sound. All this is necessary so a Pixelblaze program reacting to sound would “look right” to a human observer.

After seeing Pixelblaze in action at Bay Area Maker Faire, I added “play with Pixelblaze” to my electronic to-do list. Seeing this sound-reactive demo cube in action at Supercon 2018 promoted it higher on my list. And now, thanks to an unexpected series of events and Ben’s generosity, I now have one on hand I could play with.

My first challenge: I don’t have an individually-addressable LED strip/array to use with this Pixelblaze. Reading Pixelblaze documentation I learn the APA-102 series of LED modules are the best match for Pixelblaze capabilities, so I’ve ordered a meter long strip to start. I’m looking forward to seeing what I can do with it.

Miss At Supercon: ESP32 Mesh Network Demo

In the pre-Superconference badge hacking call to action, wireless badge communication was raised as a specific challenge laid out for attendees to tackle. One particularly ambitious effort was to build a mesh network for wireless communication using ESP32 modules mounted to the badge expansion header. The ESP32 mounting system is straightforward, it was the software that would prove to be tricky.

At the end of the weekend, Morgan and Ben got the network up and running with just over an hour to spare. They started recruiting people to join their IRC-style chat network for the final demo, and I signed up. In the test session I was able to see messages sent over the network, and send a few myself. But when it came time for the actual demo on stage, my badge was unable to connect! Fortunately they had enough other participants so my participation was not critical, but I was sad to have missed out. After the presentation (and winning a prize) the team told everyone on the network we could keep the ESP32 as a token of thanks.

After the conference I examined my ESP32 mount and found a few cracked solder joints. It looks like I had accidentally smashed my ESP32 module sometime between the test session and the presentation. Looking on the Hackaday.io project page, I found the simple schematic and tested connections using my multimeter. Several connections were indeed severed between the badge header and the mounting circuit board. I tried the easy thing first by reheating all the solder to see if they could bridge the gaps. This helped, but two lines remain faulty and were patched with wires.

After this patch, I tested with [mle_makes] ESP32-equipped badge and we could not communicate, indicating further problems with my ESP32. The next step is to desolder it from the board to see if I could use the ESP32 as a standalone module. Once the module was removed from the carrier board, I saw a problem: three of the pads had separated from the module, one of them being the EN(able) pin critical to a healthy ESP32. The other two damaged pads (IO34 and IO35) I hope I could live without.

Is this the end of the road for my gifted ESP32? I thought it was, but [mle_makes] disagrees. The next experiment is to try soldering to the trace leading to EN pad, or the via further inboard. This will be a significant challenge – that via is smaller than the tip of my soldering iron! 

Heard At Supercon: SAM D MCU from Atmel (Now Microchip)

One of the best parts of attending Hackaday Supercon is the opportunity to chat with other like-minded people and see what they find interesting. Because odds are good that I’ll find it interesting, too. A prime example this year was hearing about the SAM D series of microcontrollers developed by Atmel. It is now branded a Microchip product due to acquisition.

Since I was spending most of my time in the badge hacking area, “talking shop” usually meant talking about microcontrollers in one context or another. The heart of the Hackaday Superconference 2018 badge is a PIC32 processor, which doesn’t seem to be particularly well-regarded among the people I talked to. I personally pledge no particular allegiance to one chip over another – my philosophy is that they’re all tools with their own advantages and disadvantages. But that’s not the same opinion held by everyone, and it’s interesting to hear other opinions.

The PIC32 is a completely different architecture from the 8-bit PICs I’ve played with earlier.. PIC32 aim for a higher tier of products with higher functionality but also higher price. I had been aware of Atmel’s AVR line of chips, though I have yet to play with them firsthand. As head-to-head competitor with Microchip PIC for many years, they too have a low-end 8-bit offering and a high-end AVR32 line. I was also aware that ARM-based chips like those used in the Raspberry Pi and my cell phone occupies an even higher tier, though they could reach as low as PIC32/AVR32 tier.

I was wrong: They can actually be downsized even further than that! I did not know ARM can be so flexible until conversations at Supercon. Chips with a Cortex-M0 core can be price and feature competitive with 8-bit PICs and AVRs. One such example being the SAM D series of controllers. The lowest end SAM D10 is available from Digi-Key for roughly a dollar each. They’re not available in a breadboard-friendly DIP form factor for experimentation, but that can be mitigated by relatively inexpensive development breakout boards like the SAM D10 Xplained pictured below.

And the best part of learning this as part of a friendly Supercon crowd: When I honestly said I didn’t know about the SAM D series, I didn’t get an elitist “Oh you don’t know? You are so out of touch” response, I got an excited welcoming “Oh you don’t know? Well now you have something new and fun to explore!” This attitude makes a huge difference in community building.

ATSAMD10-XMINI
SAM D10 Xplained Mini evaluation board, available from Digi-Key

 

Hackaday Badge Nyan Cat Wrap Up

With just two minor bugs in Nyan Cat both centered around power management, I’m content to leave them for later (if ever.) And it’s not like I have any way to patch all the badges out there… we don’t exactly have a badge counterpart to Windows Update. I’m going to finish documenting this project and move on to the next.

The first item is to create a page on Hackaday.io about this project. I’ve had several projects where I documented in parallel on Hackaday.io and here, but Nyan Cat was a rush job and I couldn’t spare the time. That project page will focus on the Nyan Cat specifically, so for example it won’t have the blog entries about exploring hardware features of the Belgrade badge.

Nyan Cat on .io

The second item is to dip my toes in YouTube video content creation. I’m setting low expectations on my first effort. A short script was written beforehand but I still stumble over a few words and the delivery is a bit wooden. The camera is fixed and looking straight down at the badge. The biggest problem turned out to be lighting, I have not yet figured out the camera settings required to have it do a faithful translation of colors on screen. (I had the exact same problem a year ago.)

It’s not great, but the best way to get better is to learn by doing!

Hackaday Badge Nyan Cat Bugs

I had a great time at 2018 Hackaday Superconference and I think Nyan Cat was a success as part of the conference badge. I’m happy with it, even though I found two minor problems with my Nyan Cat app during the weekend.

The first problem was that it does not tell the badge it is running, which is required to prevent automatic power-down. The auto-sleep feature was added after my code was merged into master, shortly before the badges started getting flashed en masse. I knew this power saving feature was going in but I was busy with badge production. So I didn’t have the chance to add code to keep the badge from going to sleep while Nyan Cat is running. My life was filled with rows and rows of badges.

Acrylic back installation

What this means is that Nyan Cat couldn’t just keep running on a badge forever. The badge will go to sleep and need to be awakened for animation to resume.

Somewhat related to the above, there’s a problem with timer synchronization upon wake. It appears that when the badge is asleep, the main timer still advances at some rate. I believe this is a side effect of loop_badge() in badge.c. Called by timer #5 every 15 milliseconds to check the status of the power button. During this check, the main system timer (running on timer #1) clicks upwards even though the rest of the badge is asleep.

What this means is that, if the badge is running Nyan Cat when it goes into low power mode, the timer will advance even though the animation & music does not. As a result, when the badge wakes up, the loops in charge of animation and timing will frantically try to catch up. It only takes a second or two to get back in sync, but in that brief moment we get a comically distorted kitty running and singing at warp speed.

This second problem can be reproduced by:

  1. Launch Nyan Cat with ‘nya’ to see and hear dancing singing pop tart cat.
  2. Push the power button to put the badge in low power mode.
  3. Wait about 30 seconds.
  4. Push the button again to wake up the badge.
  5. See and hear cat in hyperdrive for a few seconds before slowing down to normal speed.

I might go back and fix these bugs in the future, but they’re not horrendous embarrassments (and Nyan Cat in hyperdrive is pretty hilarious) so I’m content to leave them as-is for now.

(Cross-posted to Hackaday.io)

Hackaday Badge Nyan Cat At Supercon

NyanCat Badge 1024w

In my pull request for Nyan Cat to go in the Hackaday Superconference 2018 badge, I included a way to launch it by typing ‘nya’ at the main menu. It existed mainly because I felt silly to create a pull request for a feature that was impossible to launch. This was originally intended to be a placeholder and be replaced by something else, but due to time crunch that “something else” never happened. So the final badge firmware flashed to every unit distributed to Supercon attendees had Nyan Cat launched via ‘nya’. It’s not the original intention, but also not the end of the world.

What this meant was that Nyan Cat badge app is now also an unplanned social experiment. By default only people who comb through badge firmware source code will find it. I didn’t think that would be enough, so on Friday I walked around telling people about it while the animation was playing on the badge around my neck. I think I told roughly one dozen people (some of them in groups) by the time Friday evening’s official kickoff party was done. Saturday morning at the official opening ceremony, I saw a person I didn’t recognize with Nyan Cat running on their badge. At that point I felt the knowledge seeding stage was complete, and it was time to let the word-of-mouth propagation take over.

One thing I thought was interesting: I had programmed a mute button to the app so it’s possible to play the animation without the music. Every time I told someone about Nyan Cat, I also mentioned ‘0’ would mute and ‘9’ would resume playback. However, as the weekend went on, I realized not everyone who knew about ‘nya’ knew about the mute button! It’s possible these people found out about ‘nya’ by reading the badge main menu source code (which launched the app) but not the app’s own source code (where the mute code lives.) It was also possible it got lost in the word-of-mouth propagation.

I knew there was a risk that people (including myself) would be annoyed at the music by the end of the weekend. But the sheer number of people packed in a small venue created a noisy enough environment that the music is actually a little difficult to hear over ambient noise. I didn’t encounter any complaints about it being a nuisance. Whew!

 

 

 

 

 

 

(Cross-posted to Hackaday.io)

Hackaday Badge: The Cat And The Hack

After all the work, my Nyan Cat is now running on an actual Supercon badge, running the default firmware which will be part of every 2018 Supercon badge. Woohoo!

NyanCat Badge 1024w

This specific unit of hardware actually has a minor assembly error: one of the battery trays is installed backwards. Here’s a picture of the back – both springs should be on the bottom, so both batteries have their positive end pointing up. The battery tray on the left is reversed from the way it should be.

Defective Badge Rear

The correct fix is to desolder the battery tray and solder it back on in the correct orientation. The simple hack is to jam a battery in there in the correct electrical orientation but against the tray orientation. Since this is a common mistake, the tray actually has a guard against reverse insertion. There’s a small plastic nub to prevent electrical contact if a battery is installed backwards. This nub allows the protruding positive end of AA battery to make contact, but keeps the flat negative end from making contact.

Nub Intact

Side note: When equipped with protective battery tray like this one, putting a battery in backwards is a valid way to stop battery power consumption, because it opens the circuit and no current will flow. However some people have gotten in the habit of reversing batteries to deactivate electronics with or without this nub. Without this nub, they risk cell voltage reversal and damaging the battery. It makes me wince to see it.

But back to the badge: since the correct battery orientation in this case is reverse of tray orientation, the expedient hack is to snip the nub away with some tools and insert the battery “backwards”.

It’s a hack and it works.

Nub Snipped

Hackaday Badge Nyan Cat Claws Back Final Bytes Before Wrapping Up

poptartcat320240There are just a few more touches before the finish line for getting my Nyan Cat project ready for consideration for the Hackaday Superconference 2018 badge. The final space savings came from realizing I only used two out of three voices in music playback, but my song structure carried three values so the unused voice takes up space holding zeroes. Maybe it’s only a few hundred bytes, but that’s still waste I could trim.

Once trimmed, I reviewed my code and realized I was still reading key-presses by reading the raw IO lines instead of using the existing stdio_get() API. This was a mistake made early on, when I thought it would block my animation/music until a key is pressed. Functionally speaking, neglecting to use the API not a terribly huge deal, but if I want the program to serve as example code it should do the right thing.

And finally, code comments. I want this to be something people can read through and understand how to write code for the badge in C using some techniques that are absent from other examples on the badge. This is an important part of the pitch for putting Nyan Cat on the badge – it should be educational in its construction in addition to being entertaining to launch.

After I committed the final code updates and comments, I realized I forgot to update the memory footprint listed by the flag to turn Nyan Cat on/off in a build. Final tally: 84 bytes of data memory, 8468 bytes of program memory. This is over the 8 kilobyte goal I was shooting for, but certainly a tremendous reduction from the original 30+ kilobytes.

I packaged my Nyan Cat into a pull request against the upstream depot, and it was accepted. Now my sample project will be a part of the default firmware on every Supercon badge.

(Cross-posted to Hackaday.io)

Hackaday Badge Nyan Cat Sheds A Few More Bytes

poptartcat320240I built my Nyan Cat project on the Hackaday Belgrade 2018 badge. Now there’s a slim opening for it to be part of the Hackaday Superconference 2018 badge. The key is to get Nyan Cat skinny enough to fit through that door. Most of the 512 kilobytes of program storage on the badge’s PIC32MX370F512H chip have already been spoken for, leaving only about 16 kilobytes available. I set out to take up less than half of that space. I’m now just over 10 kilobytes, I need to trim another 2+ kilobytes.

The first task is to port the code from a fork of the Belgrade repo over to a fork of the Supercon repo. During this move, Nyan Cat code also migrated from being a customized user_program.c to its own nyancat.c source file in order to leave the default user program alone for badge hackers to play with. First I verified it still worked in the new repo – overweight and all – then I got to work trimming more data.

The key insight for more savings is realizing that we now store a quarter-scale image of 80×60 pixels and scale up at rendering time. Since they are encoded (and decoded) one scanline at a time, this means no single run length of pixels can be longer than 80. Previously, 12 bits were used to store length because a 320×240 image may have a run of 320 – longer than the maximum 8-bit value of 256. Now I only need 8 bits for run length. (The color palette always had only 14 colors, so it still needed only 4 bits.)

This trims every run in the image, color index + run length, from 16 bits down to 12. This did indeed trim data down to a little over 8.5 kilobytes. But code readability took a hit as a result: the smallest convenient unit in C is in multiple of 8 bits, so working with 12 bit values involve a lot of bit manipulation to pack and unpack that data.

(Cross-posted to Hackaday.io)

Hackaday Badge Nyan Cat Needs A Diet

Now I’ve got Nyan Cat animation running while playing a simplified adaptation of the Nyan Cat music on my Hackaday Belgrade 2018 badge. I started writing run-length encoding on Friday, had a crash course in reading sheet music on Saturday, and by end of Sunday I had music and animation loop running together. This is roughly the same timespan that will be available to people putting their own projects on Hackaday Superconference 2018 badge, I just had the opportunity to do it a week ahead of time.

The original intent was twofold: One, to give myself some hands-on familiarity with the badge code base and two, have Nyan Cat project code available for other badge hackers as reference. I originally planned to have Nyan Cat up on Github for people to look at, but with this success my ambition grew: can this musical pop tart cat be part of the default badge firmware?

The greatest constraint on badge firmware is available space. Before I started this exploration, I hacked and slashed a bunch of features to make things lightweight, but if Nyan Cat is to be on the basic badge, it must coexist with all those features I had cut. And there isn’t enough free space for >30 kilobytes of Nyan Cat.

The majority of that space were consumed by run-length encoded animation frames, so that’s an obvious place to start. Code – both on encoding and decoding – most easily accommodates even power-of-two reductions. Nyan Cat is a blocky little kitty and should preserve well in downscaling from full resolution (320×240) to half (160×120), quarter (80×60), and eighth (40×30.) Here they are displayed in their pixel dimensions.

PoptartcatPixel

And here they are with pixels scaled up to fill a 320×240 screen, as it would on the badge.

PoptartcatScaled

There is visible degradation from full to half resolution, but not terrible. Nyan Cat starts getting pretty blocky at quarter resolution, but still recognizable. Eighth resolution is not usable.

So it looks like quarter scale is the sweet spot to target. This reduces the animation data from over 32 kilobytes to a little over 8 kilobytes. The music data and the program to bring it all together adds roughly another 2 kilobytes. It’s a good start but there is still room for improvement.

(Cross-posted to Hackaday.io)