Solenoid Engine

I got the solenoid engine working tonight. I filmed a video of it in action, starting out around 5.5v and increasing to 7.5v. This has a dramatic effect on the engine’s RPM.

The solenoids only got a little warm during the filming of the video, so that’s a good sign. Next steps will be to diagram the circuit in EasyEDA and get a PCB made, then mount the whole thing on a pinewood derby car body. But this is good for now.

Optical Commutation

I finished putting together an optical commutation circuit on a breadboard tonight. It uses an IR emitter/detector pair to trigger timer chips that ultimately turn on power transistors to drive solenoids. The solenoids are logically opposite, so they alternate as the IR beam is made and broken.

The timer chips aren’t strictly necessary, but they prevent the solenoids from staying on too long and burning up. You can see this in the video below when I am blocking and unblocking the IR path using a playing card–I sometimes leave the card in or out for a few moments, during which time whichever solenoid is powered returns to a resting state after about one second.

I’ll use this circuit to drive the two solenoids in my solenoid engine, which will have a rotating half-moon to block and unblock the IR beam.

Solenoid Engine Prototyping

I’ve started thinking about how I might build a solenoid engine. I bought a couple solenoids on Amazon, Uxcell brand, and they seem to have quite a bit of zip to them, so I’ve been looking into how to mount them to a block in a way that would allow them to rotate around an axis, eliminating the need for the connecting rod to rotate with the piston head, which in this case is just the armature of the solenoid.

Pictured below is the first three attempts at printing a little box to hold a solenoid. The little wings on the side have 1/8″ holes in them that will fit over a rod, allowing the solenoid assemblies (I plan on having two of those) to lie directly over the crankshaft and rotate back and forth with the cranks.

You can see the design process as it unfolded, first with no venting on the sides, then with vertical venting and finally diagonal venting to allow the solenoids’ windings to cool off better during operation. I don’t know how much of a problem heat will be, though, since I’ll be running somehow around half the rated service voltage of the solenoids, at 50% duty cycle to boot.

I did melt the diagonal vents a little with a heat gun while trying to de-string the object. Oops.

RGB LED Sectional Chart Weather

I worked on this project for my brother. It was inspired by something he found online. The idea is to mount a paper aviation sectional chart (it’s like a special map) on the wall and place RGB LEDs at the locations of airports you care about on the chart. Every so often, a Pi checks the weather conditions at those airports and changes the colors of the LEDs, allowing you to see the weather conditions at the various airports in your area at a glance, right there on the wall.

I designed a custom circuit board for interfacing with a NeoPixel light strand I got from Amazon. The circuit uses a level-shifted chip to adjust the Pi’s GPIO output 3v3 voltage to the 5v level expected by the NeoPixels. The circuit also incorporates a barrel-plug adapter and a 5x20mm fuse holder. It’s pictured below and can be viewed on EasyEDA here: https://easyeda.com/ditchwater/sectional-chart-board

I wrote some Python code that will hit the US’s aviation weather web service to get the weather data and update the lights. I’ll post the code here. I made a last-minute untested change to it, but it should be pretty close to working. The code is permissively licensed (https://opensource.org/licenses/MIT). It is based on the CircuitPython library here: https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel.

Note: Make sure you pass the station identifiers to the web service in all capitals. Otherwise, you may get a confusing error saying station_id is not a valid field.

# Copyright 2019 Kyle Hansen
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import json
import urllib.request
import urllib.parse
from neopixel import *
import xml.etree.ElementTree as etree
from ledgfx import gfx

PURPLE = (155,0,155)
RED    = (15,0,0)
BLUE   = (0,0,155)
GREEN  = (0,155,0)

# LED strip configuration:
LED_COUNT      = 18      # Number of LED pixels.
LED_PIN        = 18      # GPIO pin connected to the pixels (18 uses PWM!).
#LED_PIN        = 10      # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0).
LED_FREQ_HZ    = 800000  # LED signal frequency in hertz (usually 800khz)
LED_DMA        = 5      # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 255     # Set to 0 for darkest and 255 for brightest
LED_INVERT     = False   # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL    = 0       # set to '1' for GPIOs 13, 19, 41, 45 or 53


def get_color(ceiling, visibility):

    try:
        visibility = float(visibility)
    except Error as e:
        print('ERROR could not parse visibility: %s, defaulting to 10 SM' % visibility)
        visibility = 10.0
        
    if visibility < 1:
        return PURPLE
    elif visibility >= 1 and visibility < 3:
        return RED
    elif visibility >= 3 and visibility < 5:
        return BLUE

    # at this point visibility must be OK, so check ceiling
    if ceiling is None:
        return GREEN
        
    try:
        ceiling = int(ceiling)
    except:
        print('ERROR could not parse ceiling: %s, defaulting to 3000' % ceiling)
        ceiling = 3000
        
    if ceiling < 500:
        return PURPLE
    elif ceiling >= 500 and ceiling < 1000:
        return RED
    elif ceiling >= 1000 and ceiling < 3000:
        return BLUE
    else:
        return GREEN

with open('airports.json') as f:
  airports_json = f.read().upper()
airports = json.loads(airports_json)

request_string = 'https://aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&stationString=%s&hoursBeforeNow=2&mostRecentForEachStation=constraint&fields=station_id,sky_cover,cloud_base_ft_agl,visibility_statute_mi' % '%20'.join([airport for airport, led_index in airports.items()])
print(request_string)
 
f = urllib.request.urlopen(request_string)
response = f.read().decode('utf-8')
print(response)
root = etree.fromstring(response)

# Create NeoPixel object with appropriate configuration.
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
# Intialize the library (must be called once before other functions).
strip.begin()
for i in range(LED_COUNT):
    strip.setPixelColorRGB(i, 0, 0, 0)

for metar in root.iter('METAR'):
    station_id = metar.find('station_id').text.upper()
    print(station_id)
    ceiling = metar.find('sky_condition').get('cloud_base_ft_agl')
    visibility = metar.find('visibility_statute_mi').text
    print('Visibility, sm : %s' % visibility)
    print('Ceiling, ft agl: %s' % ceiling)
    print('Setting light %s to %s' % (airports[station_id], get_color(ceiling, visibility)))
    color = get_color(ceiling, visibility)
    strip.setPixelColorRGB(airports[station_id], color[0], color[1], color[2])

strip.show()



What a fascinating modern age we live in

I have entered the modern era with a 3D printer. In particular, it’s an “Original Prusa i3 MK3,” kit version. Assembling the kit was not complicated or confusing, but it was a serious test of my limited dexterity and took about 20 hours of focused work.

Nevertheless, the printer is assembled and working, and in case it ever helps anyone, problems with X-axis length errors and XYZ calibration can possibly be resolved by loosening the screws holding the back-plate on the extruder assembly. That plate puts pressure on the X-axis bearings and can cause your extruder to not slide as far as it should on the X axis. If your Auto Home check is correct in Y but not X, maybe look into this.

Below are some pictures of my first couple results and some videos showing the printer in action.

He did what in his cup?

I have been working on several things since my last post. First, I made a vertical shooter game on that LED matrix. I don’t have a good video of the finished product yet, but for now below is a video demonstrating the custom controller.

I also stumbled onto some really nice craft steel material at my local fleet farm store. These metals are from K&S Precision Metals (http://www.ksmetals.com/) and they are fantastic. I got a stainless steel rod and a stainless tube that would fit around it, and the fit is about as perfect as a non-machinist can get for making homemade pistons. Then I bought a cold-rolled 1/8″ rod to use for a piston rod.

Why make pistons? To make a model steam engine, naturally. I managed to craft a rough cylinder, piston, and rod (complete with mounting hole in the end) using just my Dremel (for cutting and grinding) and my drill press. The mounting hole I accomplished by grinding halfway through the 1/8″ rod on one side to make it flat, then drilling a 1.5mm hole. Below are some pictures, followed by the promised LED video.

Success is the enemy of progress

I didn’t post for a while, and I blame this on the success of the car project.

Since then, I have assembled and tested the binary clock, which works great except for one bum connection in the hours digits: it rolls over at 28:00 instead of 24:00, which anyone familiar with binary will understand. I tried to just mangle the board into a working state, but that doesn’t look like it’s going to work, so I need to order new boards. A simple fix, but it will take weeks to arrive.

In the meantime, I bought a 16×16 Neopixel matrix and have enjoyed working with that. I created an animated display for a big party we had, and now I’m working on an interactive game with a custom-built controller. More on that later.

The car moves

I did it: the car moves. It drives right across the kitchen floor, picking up speed. That said, it does not handle carpet very well (no surprise).

I can’t get a very good video of it by myself, so I’ll work on that soon. In the meantime, I’ll post a still.

I made a couple changes near the end:

  • Changed the gearing. The motor just doesn’t have enough torque to move the car with a 1:1 ratio, so I pressed some old Erector crown and pinion gears into service.
  • Added a toggle switch to turn the power on and off.

Future improvements would include a higher-voltage battery and a proper connector for it (so I don’t have to gator-clip the motor to the battery).

Updated motor circuit

I have updated the motor circuit with the changes I’ve made. Notably:

  • Introduced a 5v linear regulator (LM78L05A) to provide supply voltage to the S-R latch, the inverter, the Hall-effect sensors, and the Vcc for the level shifter.
  • Replaced the CD4010B with a CD4504B and connected its select pin (pin 13) to ground.

These were rookie mistakes. The latch and inverter chips need 5v in, not the 15-20v I plan to supply, and the buffer/level-shifter was entirely the wrong kind of chip (it was a high-to-low instead of a low-to-high; we want to go from the 5v logic level to the 15-20v level). Live and learn, I guess. The new schematic is pictured below.