Baldengineer’s Projects Overview

open_vapors_125px

Open Vapors: OSH Toaster Oven Controller

quadcopter_125px

Quadrotor: Quadcopter from Scratch

mso_demoboard_scope_125px

MSO Demo Board: For DS1052D

binboo_1_125px

BinBoo: Binary Clock

IMG_3165

Accurate RTC Shield: Based on DS3231

msgeq7_250px

MSGEQ7: Simple Audio Spectrum Analyzer

8x6_matrix_250px

8×6 LED Matrix Shield

Raspberry Pi Startup Script Tutorial

Part 3: Pi Soft Power Controller, what to put on the Pi

raspberry pi startup script

The last couple of weeks I have been making progress and posts on my RetroPie build. I’m putting a Raspberry Pi inside of an actual SNES (well Super Famicom). Part 1 covered the schematic for a Soft Power Controller. In Part 2 I broke down the RPSPC state machine. This 3rd and final post of the series is a Raspberry Pi startup script tutorial. It covers how to make scripts run at startup and shutdown.

When I started researching how to make Raspbian run a script at startup and shutdown, I found a ton of links and questions asking for help. None of them helpful. Why? Because they were wrong. At least, they are now.

/etc/rc.d doesn’t matter!

It turns out, Raspbian Jessie does not use SysV for init (anymore). So it does not matter what you scripts you put in /etc/rc.d. Pretty simple but missed by many!

Here is a correct Raspberry Pi Startup Script Tutorial.

The Key is systemd

Once I started researching how to make systemd do what I wanted, new problems emerged. The syntax for systemd is not as straightforward as I first thought. Thanks to readers, I was pointed towards the RedHat systemd manual. After reviewing it, I was able to create a service that runs at startup and shutdown.

In the end, I was unable to prevent this process from running during reboot. There seem to be some more layers to make sure systemd knows the difference. In the end, I decided it was not necessary to avoid the reboot.

Continue Reading »

Soft Power Controller State Machine

Here's the logic behind the Pi Soft Power Controller

RPSPC State Machine

Previously I looked at the hardware needed to build a Raspberry Pi soft power supply. This week I’m looking the state machine for the microcontroller. Why is such a complicated circuit necessary? I am replacing a Super Famicom (SNES) motherboard with the Pi. The trick is, I want to use the original power switch to turn the Pi on and off.

This requirement presents a problem. When the switch goes into the “OFF” position, power needs to stay on long enough for the Pi to properly shutdown. So the switch itself can’t provide power to the Pi directly. With minor changes, the code in this state machine could be made to work with push buttons as well. If I add that feature in the future, I’ll update the code on the RPSPC GitHub project.

Before continuing with the state machine, first I need to thank all the mailing list members. You guys really rock. When I asked for state machine diagraming tool suggestions, you guys sent me enough options for an entire (future) post to compare them. 

Continue Reading »

Raspberry Pi Soft Power Controller – The Circuit

Part 1 Control Rasp Pi power with an Arduino-based controller

The RetroPie project enables retro-gaming with a Raspberry Pi. All of the Pi models have enough computing power to emulate the major 8-bit and 16-bit computers of the 80s and 90s. With the Pi 3 I have even been able to play PS1 games with no problem. My current project is to put my Raspberry Pi running RetroPie into an old Super Famicom (SFC), or SNES, case. The catch? I want the original SPST power switch to work. And by work, I mean allow the Raspberry Pi to shutdown properly when the switch goes into the off position.  To accomplish this task, I am building a Raspberry Pi soft power controller.

Raspberry Pi Soft Power Block Diagram

Here’s a block diagram of the power controller. The basic blocks in a Raspberry Pi soft power controller include the LDO, a switching supply for the Pi, an AVR-based microcontroller, and the Raspberry Pi. This post will describe each of these hardware blocks.

One design objective was to draw as little current as possible when off. For my RetroPie, I will not be running on battery. However, I do not like the idea of wasting energy when something is turned “OFF.”

This overview is a multi-post write-up. This first part is on the hardware. In the next post, I will explain the AVR’s firmware. Later, I will come back to the Raspberry Pi side of the project.

Last week’s post was on Project Sharing Sites. I’m using two for this project. Hackaday.io will host the build log while GitHub has all of the design files. And by all of the file I mean the schematics, firmware, laser cutter files (soon), and Raspberry Pi code.

Hackaday.io Project Page  GitHub Repo

Continue Reading »

3 Way Camera Shoe

Thingiverse.com
17-JUL-2016

DSLR Shoe AdapterWhen recording videos for either baldengineer.com or, more often, AddOhms, I need at least two things attached to my camera. I used a Canon T5i. The two devices I need to have connected are a shotgun microphone and a wireless receiver. In the past, I just let the remote’s wireless receiver dangle. That really bothered me.

I’m still surprised this DSLR shoe adapter didn’t already exist on Thingiverse. Anyway, I created one. Head over to Thingiverse to download it.

Proper Larson Scanner with Software PWM (Repost)

Add some persistence and use more Arduino pins

proper larson scanner

Last week I had a detailed Arduino tutorial on software pulse width modulation using millis() and micros(). Why? Because I wanted to create a Proper Larson Scanner, with persistence and at least 8 LEDs.

KITT larson scanner example

From Amazon

Even though it is a popular project for the Arduino Uno, most Larson scanner tutorials, like my first one, have a few flaws. First, there is no persistence, or tail, to the LED as it moves back and forth. Persistence could be solved by using pulse-width-modulation. The Uno and other 328p-based micros only have 6 Pulse Width Modulation (PWM) pins. And let’s be honest, every project is made better by adding more LEDs. 🙂

If you look at this cover shot of KITT from Knight Rider you will see there isn’t just a single light source. It appears multiple lights are turned on, as well as fading effect. This fading effect creates a tail. Of course, the reason is probably that standard light bulbs were being used back in the 80s. Traditional light bulbs don’t turn on or off nearly as fast as LEDs.

Presenting the Proper Larson Scanner

Knowing that a popular Halloween hack is to add Cylon (or KITT) lights to your pumpkins, I thought it was time for a Proper Larson Scanner. This code example does a couple of important things.

  1. It implements my “software pulse width modulation.”
  2. Can be used on all 20 I/O pins of an Uno (or other 328p Arduino)
  3. Does not use any delay()s!

So if you want to make your pumpkin even more Cylon-like this Halloween, check out this full tutorial on a proper Larson scanner.

Continue Reading »

Arduino Software PWM with millis()

Use pulse width modulation on any Arduino pin

software PWM code example line by line

The Arduino Uno has six pins dedicated to Pulse Width Modulation (PWM). PWM is great for analog-like control for the speed of motors or LED fading. But what if you want to control more than 6 devices? Or what if you’re using the PWM pins to control servo motors, but still want to fade an LED on a 7th pin?

One option is to change boards and processors. For example, you could move up to the Arduino Mega 2560. That means a bigger board and more cost.

Using millis() and micros(), it is possible to do PWM entirely in software. The best part is; if you can set the pin to OUTPUT, you can use this technique.

This tutorial will explain how you can use micros() and millis() to get more PWM pins on an Arduino Uno, Nano, or Pro Mini. It will probably work on other boards and processor types, but I haven’t tested them yet.

There’s a reason I needed this software PWM code. Subscribe to the mailing list, RSS feed, or follow me on social media to see why next week…

Apologies to the email subscribers if the code isn’t formatted correctly. Click here to read the full post.

Continue Reading »

Corner Case: 90-deg turns for WS2812

josh.com
NeoCorner from josh.com

NeoCorner from josh.com

If you’re working with the WS2812B and need to turn corners, you’ll want to check out this NeoPixel Corner adapter PCB from josh.com. It’s a pretty simple board. I came across it as a solution for an upcoming lighting project.

In josh’s example, he used a CNC to mill the PCBs. If you’re using one-sided FR4, that might work well. You’ll want to double-check thicknesses if you want to use OSHPark or similar.

You can check out the full write-up here or the NeoPixel Corner Board project GitHub.

On a related link, this document explains differences between WS2812 and WS2812B.

PCB Checklist – What to check before you submit

PCB Checklist Banner

Recently I’ve been expanding my retro game collection to include game cartridges imported from Japan. The problem is that I don’t have Japanese game systems (yet). So I’m creating an open source adapter to convert Famicom carts to the NES. Before I submit the PCB to OSH Park, I’m going to run through this PCB Checklist to make sure I don’t forget something silly.

This PCB checklist is something I’ve built over my years of creating boards. If you’ve got tips from your own list, don’t forget to leave a comment letting us know.

PCB Production Checklist

The concepts on this list will apply to almost any PCB software. The tips I give relate to EAGLE, since that is what I use most often. Feel free to comment to add tips for other design software like upverter.com or KiCad.

Keep reading to see the list.

Make sure you also check out the comments, some really great suggestions there too!

Continue Reading »

Never trust an autorouter

I am not a fan of relying on the Autorouter in EAGLE — or any PCB CAD software for that matter. When laying out a board, I’ll use the autorouter to get an idea if the part placement is going to work or not. In this case, I was reminded how much autorouters suck! Even after running for while, the autorouter could only route up 50% of the nets (signals).

Never Trust The Autorouter

As Chris Gammell‘s T-Shirt Says, Never Trust The Autorouter.

It only took me about 20 minutes to start over and finish the manual layout. I still want to clean it up a little, but over all, I beat the Autorouter.

What is the board anyway?

In January I visited Tokyo on my annual work trip. While there, I ran over to Akihabara to check out a used media store called Traders. The multi-level store (like all those in Tokyo) sold used video games and movies. Each floor featured different platforms. My favorite was the 2nd floor which was all retro 8, 16, and 32 bit systems. Piles of Famicoms (NES), Super Famicoms (SNES), Mega Drives (Genesis), and other systems were all around. In the middle of the floor were racks of cartridges.

While there I picked up a couple of Rockman (Mega Man) carts, Super Mario brothers, and even Adventure island.

A US-based NES can play Famicom games since the basic hardware is the same. However, the pin outs are slightly different. Also, US-based NES systems look for a lock-out ship (CIC) that Famicoms don’t have. Fortunately I ran across a project that uses the ATtiny (AVRCICZZ) to emulate the lockout chip. So armed with that and some pinouts, I’ve created an adapter.

Keep subscribed, after a few more touches, I’ll post the EAGLE files as an Open Source Hardware (OSH) project.

An example of when comments would have helped

What was one of the first things you were taught, when learning to program?  “Comment Your Code!”  And of course, like all programming students, you ignored that advice.  Or, if you are like me, you made vague comments as the lines of “variable called var.”

Tonight I opened up some code I haven’t touched in two years.  Code that when I wrote it, made perfect sense to me… at the time.

The code was for my binary clock project, BinBoo.  So I need your help, check out the code below and see if you can help me remember what it does!

Continue Reading »