Categories
Fun Projects Raspberry Pi

64×64 LED Matrix + Doom

From the weekend hacks department: I now have DOOM running on my 64×64 matrix!

GitHub repo: https://github.com/twstokes/doom-matrix

Categories
Arduino Fun Projects Raspberry Pi

Domo Arigato

If the objective was to make the robot less creepy, I’ve failed miserably.

Categories
Projects Raspberry Pi

Snake Eyes + Servos

Categories
Raspberry Pi

Booting the Raspberry Pi from an SSD

It’s been possible to boot a Raspberry Pi from an SSD for a while now, but the process didn’t seem to have the full blessing from the Raspberry Pi Foundation. This changed recently when they announced their beta firmware to officially support it.

It was pretty painless to get it working, so here’s how I did it. Some notes up front:

  1. Based on research of past success stories, I went with this adapter – the ELUTENG SATA to USB 3.
    ⚠️ Beware! I’m seeing in Amazon reviews that this adapter may have moved to a non-compatible chip! Here’s a great resource for compatible adapters.
  2. I used a Raspberry Pi 4 4GB
  3. The SSD I used was a spare Samsung EVO 250GB I had from a retired machine
  4. I connected the SSD directly to the USB 3 port
  5. I went with the headless version of Raspberry Pi OS (formerly known as Raspbian), but this should work with any of them
  6. Since my RPi was already running off an SD card I wanted to be able to plug in the USB drive and do this all from my couch. I only had to get up once, and that was to take out the SD card on the final reboot!

Steps

Most of these instructions all came from here.

Don’t blindly follow these instructions unless this post is only a few days old! Things are bound to change – this is beta software. Do it at your own risk. If a step has something in [brackets], you need to figure out your particular value.

  1. sudo apt update
  2. sudo apt full-upgrade
  3. sudo vim /etc/default/rpi-eeprom-update
    1. Change to: FIRMWARE_RELEASE_STATUS="beta"
  4. sudo rpi-eeprom-update -d -f /lib/firmware/raspberrypi/bootloader/beta/pieeprom-2020-05-15.bin
  5. On the RPi, download the Raspberry Pi OS image and copy it to the SSD. Make sure the SSD isn’t mounted!
    1. wget https://downloads.raspberrypi.org/raspios_lite_armhf_latest
    2. shasum -a 256 raspios_lite_armhf_latest (verify the SHA)
    3. unzip raspios_lite_armhf_latest
    4. sudo dd bs=4M if=2020-05-27-raspios-buster-lite-armhf.img of=/dev/[SSD DEV NAME] conv=fsync
  6. sudo rpi-update
  7. Reboot, and hopefully the SSD will automount. The RPi isn’t expected to boot from it yet, but should treat it like an external drive.
  8. sudo cp /boot/*.elf /media/[SSD mount]/boot
  9. sudo cp /boot/*.dat /media/[SSD mount]/boot
  10. Because I went with the headless install, I wanted to be able to SSH into it
    1. sudo touch /media/[SSD mount]/boot/ssh
  11. Power off the RPi
  12. Remove the SD card
  13. Power up
  14. Hopefully you’re booting off the SSD!

Performance

SD Reads: 42MB/sec
SD Writes: 22 MB/sec

SSD Reads: 314 MB/sec (7.4x)
SSD Writes: 212 MB/sec (9.6x)

Categories
Commodore 64 Projects Raspberry Pi

Pi 1541 – it works!

After some initial struggles, we’re good to go!

Categories
Commodore 64 Projects Raspberry Pi

Pi1541

The Commodore 64 in all its glory!

After the fun and nostalgic experience of pulling our C64s out of storage, I wondered how someone could add new software in this day and age. It didn’t take me long to find Pi1541, which is:

a real-time, cycle exact, Commodore 1541 disk drive emulator that can run on a Raspberry Pi 3B, 3B+ or 3A+

https://cbm-pi1541.firebaseapp.com/

All I needed to do was provide an RPi 3, load some stuff to an SD card, make a cable, and I would magically have an emulated 1541!

Making a cable

I bought a high quality DIN 6 pin cable, some Dupont headers, and a crimping tool from Amazon to get it built. This guide (also linked from the Pi1541 page) set me on the right track.

Crimped and ready to go. This was only my THIRD time cutting them all off and starting over.
Header attached. I chose to order the cables by pin order – 1 through 6.
Assembled, wired up, and ready to go… so I thought.

The process to construct the cable was straightforward after teaching myself how in the world one crimps these tiny Dupont connectors. The trick is to line up and fasten the wire with some needle-nose pliers first, then carefully insert the connector in your crimp tool so you don’t destroy the “box end” where the male connector is received.

Connecting things up

I followed the “Option A” on the Pi1541 site for wiring since I wouldn’t be including any other peripherals. An important piece of this schematic is the bi-directional logic level converter. The RPi speaks 3.3V logic while the C64 speaks 5V.

I loaded up the SD card, connected everything, fired up the C64, and plugged in the RPi. Everything worked perfectly, right? Nope.

Trouble

At first the RPi didn’t boot at all – I had just a solid red light, so it was time to troubleshoot:

  • Did I fry something on the Pi?
  • Was the SD card bad?
  • Did I load the software incorrectly to the card?

Good news: The Pi wasn’t dead. I confirmed this by booting from a spare SD card that had Raspbian loaded to it. Whew.

I then found the Pi would boot with the Pi1541 firmware, but only if the cables on the header pins were disconnected.

The culprit: The cheapo “bi-directional logic converter” I had lying around didn’t work at all like I assumed it did. Instead of supplying 3.3V and 5V to it (like it properly should), it only wants 5V. Turns out I was sending 3.3V to an output. Ouch.

Now we had a booting Pi with everything connected up, but still no disk drive:

The emulated device can’t be found by the C64.

Now we wait

After much troubleshooting I’ve come to the conclusion that I’ll just need to use a proper logic level shifter before proceeding. I’ve ordered some of these and will have to wait patiently as their expected arrival is the end of the month…

Categories
Arduino Coding Golang Raspberry Pi

A Tree Divided

See the GitHub Repo!

The tree reacting to Clemson scoring

Idea

Every year Clemson plays USC for their state rivalry game. I pull for Clemson and my wife pulls for USC, so we’re what you call a “House Divided”. Since this game takes place on or after Thanksgiving, it’s a great time to incorporate the LED Christmas tree and troll my spouse!

The tree works like this:

  • When a team scores, it plays their fight song and lights up with their primary and secondary colors.
  • The lights on the tree are distributed by the ratio of points. When it’s tied, they each get 50% of the lights. If Team A has 2/3 more points, they get 2/3 more lights in their color.
  • The ring under the star at the top of the tree is the color of winning team. If they’re tied, it’s split.
  • When the game is finished, the tree is the color of the team that won.

Software

I used Golang for the software since I primarily write code in another language and want to get better at it. It makes use of various interfaces to aid in testing and abstration:

  • The Fetcher interface gets the latest game state from a data source
  • The Player interface plays audio at the given path
  • The Illuminator interface controls a light source (in this case the LED tree)

The source code for a local data fetcher is included in this repo only. The remote fetcher I built may or may not have used an API meant for this sort of consumption. It simply fetched from a remote data source, unmarshalled a JSON data structure, and supplied what the Fetcher interface needed.

The code runs on a Raspberry Pi and communicates with the MCU via serial. An iHome IBT63 speaker is used to play audio from the Raspberry Pi. I didn’t use the Bluetooth connection and instead used the shared power and audio connector, plugging one end into the RPi’s stereo jack and the other into the USB port.

I cross-compiled from my Mac using the rpi.sh script in the executable’s directory.

Firmware

  • Uploaded using PlatformIO
  • Runs on a NodeMCU ESP8266
Categories
Raspberry Pi

A good Raspberry Pi 4 case

My excitement for the new Raspberry Pi 4 turned into disappointment upon learning it couldn’t handle sustained loads without some sort of extra cooling solution. After installing it in this case, I’m happy to say things are looking stable.

The case comes with a fan and three heat sinks
Results of the load test
Categories
Projects Raspberry Pi

The Rover has dual steering!

Categories
Arduino Projects Raspberry Pi Swift

Controlling the Rover’s camera with an iPad gyroscope

The Rover got its own iOS app and I implemented a neat way to control the camera servos.

https://twitter.com/TannerStokes/status/1130288403491241984