Categories
Uncategorized

Traffic Lights

Traffic Lights

I recently repaired the traffic and walk signals at BBCM. The system had been running on a PLC (Programmable Logic Controller) which failed, and rather than find the proprietary programming cable and find and install the PLC Windows software, I decided to just put an Arduino and relay control board in place.

Arduino and Relay Board

I had a Teensy++ 2.0 I had pulled from another exhibit during an upgrade, and an 8 channel relay board on hand. These relay boards come in different configurations from 1, 2, 4, 8, and even 16 relays. Since I really only needed 5 relays (and 5 pins) I could have used an ATtiny85, but I had the Teensy++ 2.0 readily available. The wiring is all done using female to female jumper wires.

Traffic Controller

I mounted everything to a piece of scrap MDF and added mounting holes to that, with the idea that we’d screw the whole thing directly into the wall. The relay board has mounting holes, but the Teensy does not. That’s probably my one complaint about the Teensy boards, is that mounting them isn’t always easy. My Teensy BOB has mounting holes, but for mounting this Teensy++ 2.0 I just used some 3M™ VHB™ tape. (The “VHB” stands for “Very High Bond”). And yes, there are a few 3D printed parts on there. At some point I should make a 3D printed holder/mount for a Teensy++ 2.0

Labels

I try to label things clearly. If I look at this thing in 6 months, or 2 years, or someone else has to look at it, I want it to be somewhat apparent what is what, so there’s not a lot of guesswork as to what is going on. I included a label with the name of the Arduino sketch, and I always like to label power supplies. Sometimes we use 5 volts, and sometimes 12 volts, and they typically have tiny hard to read type printed on the side of the power supply that you can’t see when it’s plugged in.

The one thing I should start to add to the labels is the URL of the wiki page where the thing is documented. (Next time I’ll do this.)

Controller Mounted

Here’s the controller mounted. It’s not pretty. We ended up re-using the mount that the PLC was in, rather than screwing it right into the wall. In my defense, we did this repair on the floor during open hours, and it’s mounted high on a wall behind a TV. Does it work? Yes… Is it awesome, no… but again, it totally works.

The wiring for the lights was all 12 VDC, not 110 VAC, so those thin gauge wires are fine. Also, they were labeled, which was handy. (Thanks previous person who worked on this and labeled things!)

Wiring Diagram

I try to create wiring diagrams for everything. I use Fritzing because it’s simple and awesome and open and free. I often don’t find the components I need, but you can always just use a note and some text.

Here’s the script/sequence for the lights:

  1. Green Light is ON
  2. Walk Light is ON
  3. Waiting 4 seconds…
  4. Walk Light is OFF
  5. Don’t Walk Light is BLINKING (for 5 seconds)
  6. Green Light is OFF
  7. Don’t Walk Light is ON
  8. Yellow Light is ON
  9. Waiting 4 seconds…
  10. Yellow Light is OFF
  11. Red Light is ON
  12. Waiting 6 seconds…
  13. Red Light is OFF
  14. Don’t Walk Light is OFF
  15. (Repeat sequence)

I wrote this up to figure out how to program things. I find it helpful to plan things out before I start writing the code.

At first I just talked through the light sequence with someone and we made some assumptions about how it worked. We were slightly wrong, which I discovered when I dug a bit deeper into traffic lights and walk signals. I read at least some of the (very long) Wikipedia page on Traffic Lights. I also hunted for other info, and found some on the Signals FAQ page on the Minnesota Department of Transportation web site. (As I mentioned with the 911 Phone I really do aim for an accurate and realistic experience with these things.)

It’s been a few weeks and the lights have been working fine. Hopefully that will continue to be the case. If something does stop working we’ll open a ticket for it so we have a record. And yes, we do use an issue tracker for our museum exhibits… doesn’t everyone?

Categories
Uncategorized

The 911 Phone

911 Phone

What looks like an ordinary desk telephone is actually part of a museum exhibit at BBCM that lets kids practice dialing 911. When they pick up the receiver they hear a dial tone, and can then dial “911” (which plays the proper DTMF tones) they then hear the line ringing, and then an operator answers and says “911, what is your emergency?”

Phone

Inside the phone I’ve replaced the guts with a Teensy 3.2 and Teensy Audio Adaptor board. This combination handles the phone receiver being lifted, the keypad being pressed, and the playing of audio.

Teensy Pins

After consulting the docs for the Teensy Audio Adaptor board I knew which pins were used for the adaptor board, and which I could use for the receiver switch and the keypad. From what I could tell 11 pins were available (0, 1, 2, 3, 4, 5, 8, 16, 17, 20, 21) and I needed seven for the keypad and one more for the receiver switch. Plenty of pins!

I chose to go with a (perhaps slightly odd) method of having some pins point up instead of down so that I could attache female jumper wires to them. I’m not 100% happy with this solution, but it worked for this.

Teensy Wiring

The female jumper wire headers are nearly as tall as the Teeny + Audio board combined. You can also see a potentiometer used for controlling the volume, and a 1/8″ audio jack which goes to the speaker in the handset.

Receiver switch

I re-used the existing receiver switch and wired it into the Teensy. The switch is NC (Normally Closed) instead of NO (Normally Open) so I just reversed the logic in the code when looking for the switch to trigger. When the receiver is lifted the dial tone sound plays. (Also, if you leave it off the hook too long, it will play the annoying off-hook tone. (I aim for realism with this stuff!)

Keypad back

The keypad was also re-purposed (once I figured out the wiring) and wires were soldered onto the tiny thin wires, and the heat shrink tubing was added. The keypad runs to a small piece of perfboard which is used to connect to the Teensy, along with a few resistors in the mix.

Keypad Notes

Notes on how to wire up the keypad. I originally used a SparkFun Keypad for testing and development before I had a (broken) phone to tear apart.

Fritzing Diagram

Here’s a quick wiring diagram showing how it’s all put together. (I try to match wire colors in diagrams with the real-world wire colors, at least before any maintenance/repairs happen.)

Connection Board

The connector board allows for easily removing the Teensy if that’s ever required, or replacing the keypad if it goes bad. It also adds in the resistors necessary for the keypad to function properly.

Magnet Mount

For mounting the Teensy into the phone I opted to use an old hard drive magnet with a piece of wood attached. The Teensy is screwed to the wood (which is a good insulator) and the magnet is also screwed to the piece of wood, and then attaches strongly to the steel base of the phone. (There’s also gaff tape on the base of the phone, as extra protection between electricity and metal surface.)

RJ9 Wiring

I found this diagram for the speaker wiring from the handset, and wired the appropriate lines to a 1/8″ audio plug that goes into the adaptor board.

One other thing I did was add code that only accepts “properly dialed/formatted” phone numbers. So if you pick up the receiver and dial “4738911”, you didn’t dial “911”. You need to hang up and try again, with a proper “911”. There’s a buffer that looks for 3 digits (or 7 digits) and if you can’t get that right, it doesn’t work. As I said, I aim for realism with these things…

(Note: I may have left in a few numbers from testing. I’ll have to ask Jenny or Hannibal for the details.)

Categories
Uncategorized

Teensy LC BOB v1.2

Teensy LC BOB v1.2

Update: If you’d like one of these boards, there’s a newer version of this board, and you can purchase it on Tindie.

Woohoo! My new boards came in from OSH Park. The Teensy LC BOB v1.2 looks good! It’s purple, it has labels, it has places to put screw terminals and holes for mounting… There’s even a version number now.

Teensy LC on Perma-Proto Board

If you saw my previous post, I mentioned how I was doing things, which looked a bit like the photo above. There’s nothing wrong with this, but I wanted it a bit cleaner, hence the Teensy LC BOB PCB.

Teensy LC BOB v1.1

Here’s a photo of one of the v1.1 boards in an interactive museum exhibit. I had to drill the holes a bit larger to get it mounted, which is the reason the new version is v1.2.

I’m still not totally sure about the pin I labeled “17v” as it could be mistaken as “17 volts” but it’s really “pin 17 at Vin voltage”. This means the thing labeled “17v” will be whatever your input voltage is… and if you plan on using Neopixels, it should probably be 5 volts. I’ll assume users can read about the Teensy LC and figure it out.

OSH Park

And hey, you can order this PCB now! Get it from OSH Park. It’s shared publicly on the site. There doesn’t seem to be a way to set a license on OSH Park, but I’d consider it Open Source Hardware. If I had known how to add the OSHW logo, I would have. (Of course the Teensy itself is not open-source, but hey, not everything can be. It is a great piece of hardware, though!)

Note: The needed screw terminals are 2.54mm pitch, so these or these will work.

Categories
Uncategorized

Video Installation (times six!)

Video Installation

Last summer Ray Chi got in touch with me about an installation he was doing for the Milwaukee Art Museum. He wanted a video screen that could be activated to play a video by touching a metal plate. Well, actually six videos and six video screens and six metal plates.

I told him I’d figure out how to get it all to work the way he wanted. I came up with a few ideas, one of which was using Processing, which I did get working, but at the time Processing wasn’t really running on the Raspberry Pi, at least not officially (or very well) and since the Pi was what we ended up choosing, I needed another solution.

For an installation that’s going to be running for years, simplicity and reliability are key. I had used Pis in the past many times for video players using omxplayer. Typically I’d just launch omxplayer on boot and have it play a video, looping, forever. For this application we wanted the video to play only when the metal plate was touched by a human hand (and then stop playing when someone stopped touching it) which meant capacitive touch.

Rather than spend a lot of time coming up with something that might work, I went with something that I was 98% sure would work. I used Adafruit’s Standalone Momentary Capacitive Touch Sensor Breakout attached to a Teensy LC. Why a Teensy LC? Because it’s a low-cost (LC!) Arduino-compatible microcontroller and it can emulate a keyboard.

Yes, a keyboard! If you have a USB keyboard connected to a Raspberry Pi computer while omxplayer is playing a video, you can just hit the space bar to play the video, and then hit it again to pause the video. Those are the two things we needed to do.

Video Player Controls

So, Raspberry Pi, running omxplayer to play the video, with a Teensy LC attached programmed to work as a USB keyboard, and triggered by a capacitive touch sensor, which was then connected to the metal plate. Simple!

There was this issue of……. timing.

So in theory, the Teensy would just need to send a space character to play the video, and it would do this when you touched the metal plate. But! (And it’s a Big But) the issue was that we wanted the video to start playing at boot and then pause at the beginning and sit there waiting… for someone to touch the metal to start the video playing. Rather than fire up the video via the typical Linux methods, we ended up just starting up the Pis, auto-logging in, and having them wait at the command line… yes, just sit their waiting, doing nothing… Sort of.

When the Pi booted up, it provided power to the Teensy, which then started running its sketch. The sketch would start at boot, wait 45 seconds to ensure the Pi was booted up and sitting there waiting at the command line, and then it would type:

/bin/bash /boot/video.sh

So we actually used the Teensy to send the text to the Pi (just as if a human typed it) which then fired up the script and started the video playing. The sketch would then wait 2.4 seconds and type a space character, which would pause the video. This set the state of things exactly where we wanted them. The video way paused, just waiting for the next command from the Teensy, which was… space, of course!

Now, there’s the concept of “rising edge” and “falling edge” when it comes to pressing buttons. A rising edge is the transition from low to high, and a falling edge is the transition from high to low. That’s a fancy way of saying we can tell when the button is being pressed, and when it’s being released. It’s best to use debouncing for this, and there’s a library for that.

Video Players Mounted

So with everything mounted in place we still had to deal with one issue. The HDMI displays worked find as long as they were turned on before the Raspberry Pi computers. If they were turned on at the same time the resolution wouldn’t set right, and the video would be letter-boxed. There were two options, one would be using two different power strips to get power to everything, with instructions for museum staff to follow a specific order. This wasn’t ideal, so we went with option two. I used a time delay relay so that one single power strip could be turned on, which would turn on the HDMI displays, and then a few seconds later turn on the computers. It worked. (And yes, I found out later I probably could have fixed the issue in software. Duly noted.)

Are there things we could have done better? Yes. Did we get the project done on time, and within (or under) budget? Yes. Was it fun and challenging? Yes and Yes. You may read this and think “Hey, you totally could have solved problem X by doing Y!” and you’d probably be right. I’ve found a number of things I’d do slightly differently if I were to do something like this again. That’s all part of experience, and learning, and sharing… right?

Video Player

When the installation was all done and tested, I got photos of everything, and then set to work on documenting it all. I delivered a 14 page manual on the construction and operation of the video players, along with the code and instructions on how to use one of the backup SD cards that was prepared in case of failure.

Besides, now I can (sort of) say that my work is in the Milwaukee Art Museum. ;)

Categories
Uncategorized

Because, 3D Printer…

Because when you’ve got a 3D printer… You might as well print things…

3D Printing

3D Printing

3D Printing

3D Printing

3D Printing

3D Printing

3D Printing

3D Printing

3D Printing

3D Printing

Also… OpenSCAD.