Archive for the ‘Projects’Category

Configuring Pi 3 with a TFT touchscreen and GPIO buttons

A while back I built a pair of sound-reactive LED towers which were on display a few times, at some local Chicago events.

To plug into the DJ mixer output required a relatively expensive device to get the stereo signals (with external gain control) seen by a computer running processing.org as a microphone input.  Also, it was a relatively bulky affair to have yet another laptop sitting next to the mixer when the artist wasn’t using it to make the music.

Recently I discovered that starting with the 3.1 release, Processing can now run on a Raspberry Pi and has built-in ability to manipulate the GPIO ports.  This blog entry highlights the release.  This is exciting news as now the laptop can be replaced by a Pi 3 with a small touchscreen.

Here is a video of the light towers in action.

The towers each have 8 panels with 60 individually addressable RGB LEDs.  These pictures show off more of the visual esthetic and the cutaway view reveals something of the construction.  The LED strips are hidden in a channel in the wood supports which side illuminate acrylic panels (backed with just a strip of white cardboard).  The acrylic is impregnated with a diffuser which reflects the edge-lit light 90 degrees to exit out of the faces of the panels.  The white cardboard reflects the 1/2 of the light that would otherwise be directed inwards.   The acrylic is produced by Evonik and is called Acrylite EndLighten.  The towers themselves only require 110 VAC power.  The data frames to control the LED strips are sent wirelessly from the processing script using an Open Pixel Control  module which maps points on the processing screen into frames sent to a Fadecandy server running inside a OpenWRT Wifi device which is then physically connected to a Fadecandy board.  I used TP-Link TL-MR3040 WiFi devices to run OpenWRT and added the Fadecandy server application into the img file used to reflash the WiFi devices.  The Fadecandy GIT repository can be found here.

IMG_1689 IMG_1682

This is the assembled Raspberry Pi 3 w/ 2.8″ TFT Capacitive Touchscreen mirroring the HDMI frame buffer in a Zebra case without the top cover.

Pi 3 w/ 2.8" TFT Capacitive Touchscreen HDMI framebuffer

There were a lot of possible paths to follow in getting this build working the way I wanted it to be.  Most of my Google searching turned up outdated examples, particularly due to the changes introduced in the 4.4 kernel with /boot/config.txt use of overlays.  Adafruit had this very nice looking tutorial of how to get the touchscreen working with their version of the Jassie Raspbian os image.  The inclusion of how to use FBCP was of particular interest as mirroring the HDMI output is important for displaying processing scripts with the 2D or 3D graphics libraries.  Their Raspbian image was based on an older kernel and updating the os (sudo apt-get update; sudo apt-get dist-upgrade) turned out not to just work.

After much tinkering, these are the steps that worked for me.  (note that I working with OSX 10.11)

  1. Download the latest Raspbian Jessie image here.
  2. Extract the .img file using “The Unarchiver.app” as opposed to the built-in “Archive Utility.app” as I saw many comments that the default app caused issues.
  3. I chose a 32GB Samsung EVO Plus (model MB-MC32D) micro SD.  It has a red background.
  4. Flash the SD card with the extracted image file.  Instructions for doing this can be found easily.  I used the following procedure:
    • open a terminal window and change to the directory with the extracted image file
    • $ diskutil list
    • note the device path of the SD card (eg: /dev/disk4)
    • unmount the SD card, replace disk4 with what was discovered in the previous step
    • $ diskutil unmountDisk /dev/disk4
    • flash the SD card, again update rdisk4 and also make sure the if= filename is correct
    • $ sudo dd if=./2016-05-27-raspbian-jessie.img of=/dev/rdisk4 bs=1m
    • this will take at least 5 minutes to complete, but it is possible to see some status without interrupting the transfer, by pressing ctrl-t
    • exit the terminal window and eject the SD card
  5. Insert the SD card into the Pi and hook it up to an HDMI monitor.  You will need a keyboard and mouse as well.
  6. Open a terminal window
    • disable power management for the onboard WiFi module for stability
    • $ sudo nano /etc/network/if-up.d/wlan0
      #!/bin/bash
      iwconfig wlan0 power off
      
    • $ sudo chmod +x /etc/network/if-up.d/wlan0
    • $ sudo raspi-config
    • select Expand Filesystem and reboot
  7. Configure the WiFi as usual from icon at the top of the desktop
  8. Open a terminal window
    1. install updates
    2. $ sudo apt-get update
    3. $ sudo apt-get dist-upgrade
    4. install build utility
    5. $ sudo apt-get install cmake
    6. fetch the FBCP source, compile and install
    7. $ git clone https://github.com/tasanakorn/rpi-fbcp
    8. $ mkdir ./rpi-fbcp/fbcp/build
    9. $ cd ./rpi-fbcp/fbcp/build
    10. $ cmake ..
    11. $ make
    12. $ sudo install fbcp /usr/local/bin/fbcp
    13. configure the touchscreen by uncommenting, changing or adding the following config entries
    14. $ sudo nano /boot/config.txt
      # match console size
      framebuffer_width=640
      framebuffer_height=480
      
      # force 640x480 VGA on HDMI
      hdmi_force_hotplug=1
      hdmi_group=2
      hdmi_mode=4
      
      # 2.8" Capacitive 320x240 Touchscreen
      dtoverlay=pitft28-capacitive,rotate=90,speed=80000000,fps=60
      dtoverlay=pitft28-capacitive,touch-swapxy=true,touch-invx=true
      
    15. expose touchscreen events
    16. $ sudo nano /etc/udev/rules.d/95-ft6206.rules
      SUBSYSTEM=="input", ATTRS{name}=="ft6236", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
      
    17. select an easier to read console font
    18. $ sudo dpkg-reconfigure console-setup
      • UTF-8
      • “Guess optimal character set”
      • Terminus
      • 6×12 (framebuffer only)
    19. remove extra GLES library see this issue
    20. $ sudo aptitude remove libgles2-mesa
    21. install processing
    22. $ curl https://processing.org/download/install-arm.sh | sudo sh
    23. disable auto monitor-off
    24. $ sudo nano /etc/lightdm/lightdm.conf
      xserver-command=X -s 0 -dpms
      
  9. Reboot

The touchscreen should now display the 640×480 desktop scaled down to the 320×240 PiTFT screen.  This makes things look less crisp but has the advantage that connecting to an external HDMI display will work and that most apps need the larger dimensions be usable.  Note that many HDMI displays will not be able to handle a 320×240 HDMI signal.

FBCP stands for frame buffer copy, which rescales and mirrors the HDMI framebuffer (/dev/fb0) onto the PiTFT framebuffer (/dev/fb1)

The version of the 2.8″ PiTFT I got from Adafruit, comes with 4 buttons and I created this test Python script to demonstrate not only how to use the RPi.GPIO library, but how to manipulate the PiTFT backlight (so as to not burn-in the screen), use multi-threaded event handlers, and shutdown the os to safely disconnect the power.

I created this script as: /home/pi/pitft_buttons.py  (chmod +c pitft_buttons.py to make it executable) and test by typing ./pitft_buttons.py.  Note that pressing the bottom right button (#27) will ask for authentication for powering off the Pi.  See below to set this script running as a service, in which case, the user will not be asked for authentication.

#!/usr/bin/env python2.7

# example code tested with Pi 3
# Raspibian Jassie (4.4 kernel): https://www.raspberrypi.org/downloads/raspbian/
# Adafruit 2.8" Capacitive Touchscreen: https://www.adafruit.com/products/2423
# for running on startup see: https://learn.adafruit.com/running-programs-automatically-on-your-tiny-computer/systemd-writing-and-enabling-a-service
# make sure to update the ExecStart= entry in the Adafruit script after copying from the example

import subprocess
import time
import RPi.GPIO as GPIO

# list of BCM channels from RPO.GPIO (printed on the Adafruit PCB next to each button)
channel_list = [17, 22, 23, 27]
backlightOn = True

# event handler to toggle the TFT backlight
def toggleBacklight(channel):
    global backlightOn
    if backlightOn:
        backlightOn = False
        backlight.start(0)
    else:
        backlightOn = True
        backlight.start(100)

# event handler to manage button presses
def buttonEvent(channel):
    startTime = time.time()
    while GPIO.input(channel) == GPIO.LOW:
        time.sleep(0.02)
    print "Button #%d pressed for %f seconds." % (channel, time.time() - startTime)

# event handler to manage Pi shutdown
def poweroff(channel):
    startTime = time.time()
    while GPIO.input(channel) == GPIO.LOW:
        time.sleep(0.02)
    if (time.time() - startTime) > 2:
        subprocess.call(['poweroff'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# initialize GPIO library
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel_list, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(18, GPIO.OUT)
backlight = GPIO.PWM(18, 1000)
backlight.start(100)

print "Button #17 exits."
print "Button #22 toggles the TFT backlight."
print "Button #23 displayed the time the button is pressed."
print "!!! Pressing button #27 for at least 2 seconds, powers down the Pi !!!"

GPIO.add_event_detect(22, GPIO.FALLING, callback=toggleBacklight, bouncetime=200)
GPIO.add_event_detect(23, GPIO.FALLING, callback=buttonEvent, bouncetime=200)
GPIO.add_event_detect(27, GPIO.FALLING, callback=poweroff, bouncetime=200)

try:
    GPIO.wait_for_edge(17, GPIO.FALLING)
    print "Exit button pressed."

except:
    pass

# exit gracefully
backlight.stop()
GPIO.cleanup()

To install pitft_buttons.py as a service,

# pitft_buttons service file, start a daemon on startup
# file: /etc/systemd/system/pitft_buttons.service

[Unit]
Description=Start PiTFT buttons daemon

[Service]
RemainAfterExit=true
ExecStart=/usr/bin/python -u /home/pi/pitft_buttons.py

[Install]
WantedBy=multi-user.target

Run a processing sketch from a script or from a terminal window or ssh session.
$ DISPLAY=:0 processing-java –sketch=/home/pi/HelloWorld –present

16

07 2016

CNC Birdbath Bowl

I recently completed my most ambitious ShopBot project to date: casting a concrete birdbath bowl in a mold that I CNC’d. This was also my first attempt at producing a video about a project as I’m working on it. Watch the video below:

05

07 2016

So you want a smart thermostat but don’t have a ‘C-Wire’

Background

You are rent/own a condo/apartment and you want a smart thermostat to keep track of your spending on heat/cool, or want a thermostat with remote sensor support.  You pulled the current thermostat off the wall and looked at the wiring and you have a 4 wire system (R, Y, G, W) but no ‘C-Wire’ and the thermostat you want to use requires a ‘C-wire’ but you don’t have one.  You look at the Ecobee3 that supports 4 wire systems but you don’t have access to the HVAC unit because its in a locked closet/on the roof and you don’t want to have to deal with your landlord/association to get access to it as it probably means having to spend a few hundred more bucks to have a professional installer do the work.  Don’t worry though you can still have that smart thermostat you want, but it’s gonna be a little ugly but you can still have what you want.

What is a ‘C-Wire’ and why do thermostats need them?

HVAC control systems are based on 24V AC control signals, in a combined heat/cool unit you have 4 or 5 wires (we are going to concentrate on the 4 wires here because if you had 5 then you probably would not be searching for a solution for this problem.  In a 4 wire system you have one common supply wire (R) when the thermostat wants to request a function from your HVAC unit it connects one of the other 3 wires to the common supply wire to complete the circuit for that feature. 4-Wire ‘pins’

  • R – Common supply line
  • G – Fan request
  • Y – A/C Request
  • W –  Heat Request

The 5th wire in the system is C this is the second common wire and is connected to the other side of the 24V transformer in the HVAC control system, its used to power accessories such as a thermostat.  Your system probably does not have a C-Wire as your thermostat is battery powered.  ‘So how does the Nest manage to work without the c-wire?’ I hear you ask, well it scavenges power to charge an internal battery/capacitor by using G wire in short bursts to complete its charging circuit.  ‘Ok so why don’t other thermostats do that?’ Well if your HVAC system is to sensitive it can cause your fan to turn on and off for very short periods of time, this can be very bad for the longevity of your blower motor.

Imagine this simplified control board diagram:

 

hvac-control

So can’t I just hook up a second PSU to the thermostat and hook it up from R to C?

Short answer, no!  Long answer if you are are VERY VERY VERY sure that the phases of your HVAC unit and the outlet you use are in sync it is a very bad idea to just hook up a second PSU to the system, you will damage both your thermostat and HVAC control board.

So what is the solution?

To get the system to work you have to create an interface that will mimic a thermostat to the HVAC control board and mimic a 5 wire HVAC control board to your smart thermostat.  To do this we need 3 relays with a coil voltage of 24V AC, a 24V AC PSU, some screw terminals, a proto-board and some form of case.  I used the following relays and PSU:

  • Relay RT314524  – Newark P/N 03P2422
  • Triad Magnetics WAU24-200 – Newark P/N 96M0310 (Note this item is discontinued once stock levels are depleted so you may need to find an alternative)

Once you have the parts you need to assemble the following circuit:

 

interface

Put it in a case and hook it up to your system.  Now you can enjoy your 5-wire requiring thermostat with your 4 wire controlled HVAC system.

 

IMG_0545

IMG_0546

You should also design a better wall mounting solution into your case so you don’t have to use blue painters tape to hold it to the wall, this will be being rectified with some double sided foam mount tape in the future.

05

06 2016

Yes, You Can (Document Small Projects)!

light cube

WP-White-Bar-550x10

Mohamed Dardiri took a professional looking photograph of a laser cut design he made and it was getting likes on Pinterest within minutes. You can do this, too! Photographing small projects using one of our light cubes gives you a nice, even lighting without any harsh shadows.

Read the rest of this entry →

30

05 2016

‘Balance’ Coffee Table

Here’s a summary of my coffee table project that many of you have seen me work on (or struggle with) over for the last several months.

DCIM138GOPRO

I like furniture that can flex or modify it’s position to address different needs. I’ve seen coffee tables that raise to eating height before, but I wanted to design one that really expresses the mechanism and plays up the physics behind it. Back in October I made a 1/2 scale mock up of the design to understand the motion.

BCT-MOCKUP

Then it was back to designing a full size mock-up.

MOCK-UP-FULL

 

I realized it wasn’t going to be stable enough with just one set of arms, so I decided two sets would still look good. Everything was designed in Autodesk Revit. The software allows you to figure out volume, then with a given density of materials I could get weights from the various parts. This allowed me to determine the balance. I didn’t want it to be perfectly balanced with the counter-weight, but have enough weight to assist the movement.

COFFEE TABLE BALANCE-v2 side     CTB REVIT

First I started making the frame out of aluminum. It’s fastened using a pneumatic riveter.

FRAME-01FRAME-02

Painting the steel arms.

ARMS

CNC cutting the concrete forms out of pink foam

FOAM-01 FOAM-02

FOAM-03

Creating the concrete counter-weight form

counterwight-01

Failed attempt to CNC cut aluminum for brackets. I’ll skip the rest of these struggles…

counterweight-02

Casting the concrete base

casting-01

Casting the counterweight (nice and sloppy)

casting-02

The base assembled.

casting-03

casting-04

casting with arms

Frame is attached.

assembled-01

There were many tweaks after testing it. There was some wiggling around the axles, so I widened the holes in the steel arms to put nylon sleeve bearings in for a tighter smoother fit. There was still some shifting after putting some weight on the front, so I designed a locking mechanism with a latch.

CTB LATCH

Lots of struggle with this latch at the top of the photo. (FYI, learn the cold metals milling machine if you need a part like this)

locking mech

And finally… a video…

By Josh Myers

10

05 2016

Power Racing Series Meeting

This Saturday, April 30th, we will meet at 9pm in the shop to discuss our entry into the Power Racing Series. Its a friendly competition between hackerspaces where we modify ride on kids toys and race them at Maker Faires.  We have a car that works great but is in need of TLC. We have a race in San Mateo in a few weeks time and need to get it ready.  We will be discussing what needs to be done for that race and races to come. If you have experience with welding, electronics, fabrication, you are more than welcome. If you don’t have experience, come by and get some.  Read the rest of this entry →

29

04 2016

CNC Beer Part 3 – Fusion 360 and Waterjet Overkill

Waterjet cut box and panel insert

Waterjet cut box and panel insert

[Go back to Part 2….]

I had a plan for how to blog about this project, but I’m going to step out of order and talk about the latest development since it pertains to the last Fusion 360 Meetup. So to catch up in a hurry: I’ve already constructed a control box containing an Arduino Mega 2560 and a Raspberry Pi, power supplies, relays, etc. all mounted on DIN rails. This is the “brains” of the system, and the Pi runs an open source control framework called EPICS. The control box sits on a separate stand on wheels that I welded. In keeping with the “Beer Church” theme, I suppose this is the “Beer Pulpit”.

Beer control box and stand

Beer control box and stand

I realized early on that the control box was out of room. I want this brewing system to be modular so that I can attach different equipment and reconfigure everything via software. To that end, each device needs to connect to the control box with its own sturdy, detachable connector. The original BrewTroller project (which isn’t online anymore) made use of XLR jacks. These are ideal. Nearly every device I’m interfacing with uses 3 or, in some cases, 2 wires. The OneWire serial bus, which is used for measuring temperatures, uses a 3 pin M12 connector; these are chained together using splitters. A few use cases need more than 3 wires: multiple pressure transducers on one board (used for fluid level sensors) and stepper motor drivers (used for controlling gas needle valves). For these, I’m using 8 pin mic connectors. But I don’t have enough panel space on the control box for all of these jacks, especially now that I’m considering adding a small touch screen. Nor do I have room inside the control box to mount a 120 V to 24 V transformer; 24 VAC is a HVAC standard, and the propane burner valves need it.

Read the rest of this entry →

21

02 2016

Group Project: Making Toolboxes

20160121_232528Last Monday, NegativeK got the funny idea that he wanted to do a project to practice his sheetmetal work. 20ga mild steel sheet was ordered, and we collected in cold metals to make some very expensive tool trays.

 

Making a project like this, is a bit of a puzzle. Before we get to the tough stuff, we first do layout. 20160121_213737 Here’s Toba wishing we had a printer that would do the layout for him.

Once we all finished drawing lines all over our sheetmetal we had to come up with how we were going to make all the cuts.
20160121_201027That’s an 8″ shear. It makes cutting sheemetal a magical experience. It’s quiet, smooth, and pretty easy to control. The only thing to remember, is it’s like working with the tip of a pair of scissors. It cuts a long way in front of where you “see” it cutting, and if you reach the end of the cut, it makes a punch mark. Just… it’s steel instead of paper.

That does mean making inside cuts is a bit of a challenge. We all had unique approaches to dealing with the inside corners. Now that we have three and a half toolboxes, I think that the “best” method, would have been drilling holes at each inside corner. Instead, I twisted and wiggled out the metal, and used a file to clean up the corner.
20160121_213731Here’s my tool tray blank. All of the fold lines are marked, and it’s sitting on top of my tool tray handle. I didn’t get good shots of how we did the handles. They were definitely easier than the body of the tool tray. To go from that flat sheet of metal, to a three dimensional tool tray, requires a sheet metal brake.

20160121_221810Here’s Toba setting up to do his bends. NegativeK found that our brake won’t do seams well. As if that would stop us. We all ended up using a hammer to finish those folds.

Those folds were simple in description, but not so simple in practice. None of ours look machine made. But they do hide the sharp edges, and make the tool trays safe to use.
20160121_231527The handles, and sides were affixed to each other with the space’s spot welder.

Spot welding is a very quick method for joining metal. I’m glad we’ve got that tool in the space. I had suggested that we might rivet the parts together, but between drilling and attempting to rivet, we’d have spent two or three times longer affixing the parts together.

The welds also have the air of “professionally made.” Or at least “not in a garage” made.

20160121_232535At the end of the night, Here’s what we had. TachoKnight, Toba, NegativeK, and My boxes.
20160121_232418In the future, we won’t put the short guy furthest from the camera.

 

22

01 2016

CNC Beer Part 2 – System Design

[Go back to Part 1….]

Ryan with Beer SystemDesign Sources

A number of commercially available and hobbyist-built computer controlled brewing systems already exist that solve many of the issues I mentioned in my previous post on this topic. They have a number of similarities, but address the problems in different ways. I’m going to describe a number of methods used for computer controlled beer brewing, which improve up0n repeatability by reducing deviations in the mash process. These systems range from simple thermostat / standalone PID controls to microcontroller-based devices. I’ll also list my own design decisions when building this system and my reasoning. Note that my design decisions aren’t necessarily best, there are plenty of valid arguments for and against many of the solutions presented here, and as I write this, I’m kicking myself for some of the mistakes I made along the way.

I’ve examined a number of systems. Our local homebrewing store operates one. I’ve paid particular attention to open source and published plans for hobbyists, given that these offer the most information. Two of my primary sources:

  • Brutus Ten – Website here. Build pages here and here. This is a popular brewing system due to plans published in Brew Your Own. It consists of a welded steel frame and propane burners driven by standalone industrial temperature control modules.
  • BrewTroller – The original website was oscsys.com which features an Arduino-based open software and control electronics framework for brewing. The website hosted the software, documentation, a web forum for users, and an online store where one could purchase electronics, actuated valves, switches, temperature probes, etc. It is not locked to any single brewing system design; rather, it is flexible enough to support a wide variety of brewing hardware configurations. While the original site shut down, a user took this over at this site.

Read the rest of this entry →

28

12 2015

CNC Beer Part 1 – Overview and Theory

CNC Beer Brewing System

Overview

A bit over a year ago, I began a project to build a computer-controlled beer brewing system that Beer Church (Pumping Station: One’s homebrew club) could use to brew all-grain beer. I had no idea when I started this project that it would lead to visiting people from multiple countries, two synchrotron radiation sources, and a nuclear research reactor, or that control systems engineers from international labs would provide assistance. While it still isn’t ready to brew beer yet, I’ve recently reached a milestone in integration testing, and I’m rapidly approaching the point where the first test batch will be possible. Unfortunately, I haven’t been blogging about it, so a lot of catching up is needed….

So, why would someone want to make what could be called a CNC machine for beer? First, it’s not about eliminating humans. The goal isn’t automation to the level of “push button, get beer.” Humans will still need to load the ingredients and monitor the process. We don’t want a hose breaking, resulting in 12 gallons of beer wort on the floor and a propane burner melting the bottom of the resulting empty stainless steel keg. Rather, the primary reasons are:

  1. Repeatability. I want to eliminate human error. Repeatability often is the domain of commercial brewers, but for hobbyists, repeatability still is critical. Transitioning from good beer to great beer means experimentation. And that requires having good control over all the variables. How do I know if that different yeast I used made my beer taste better, or if it could be explained by sloppy temperature control in the mash process?
  2. Predictability. Shareware and free beer design software exists that acts like CAD for beer. You can design your grain bill based on a library of ingredients, enter a mash and hop schedule, yeast, fermentation temperature, etc. and it will simulate the process, telling you what you can expect in terms of initial and final specific gravity, percent alcohol, color, bitterness, etc. You can tune the model based on the efficiency of your brewing system. But prediction works only as well as the repeatability of your process.
  3. Capacity. Right now, we are limited to 5 gallon batch sizes. While we certainly can buy larger hardware, it makes sense to upgrade to automation at the same time. With a system based on 15.5 gallon beer kegs, we can produce 10 gallon batches at a time.

And, well, there are plenty of secondary reasons that can best be described as “Because hackerspace!” I’ve wanted to learn more about industrial control electronics and the EPICS software environment. It was a great excuse to learn to weld. I had acquired authentic cold war indicator lights from actual nuclear missile systems that needed to be put to an awesome new use. And I could do all that while brewing beer!

To describe the CNC beer system, I first need to explain all-grain brewing and the issues inherent with our current brewing method. To be clear, these issues affect repeatability, not quality. We are already making really good beer. Nothing is wrong with what we’re doing. This new system likely will improve beer clarity (and that is important in homebrewing competitions) but otherwise it won’t do much on its own to make the beer better. Start with a bad recipe and you’ll end up with bad beer; the new hardware just makes it repeatably bad! Rather, it will provide state of the art tools to anyone who wants to experiment, and this could be very useful to brewers wishing to be competitive in homebrewing contests.

Read the rest of this entry →

25

12 2015