Propeller Games (P1): Hi Lo

Welcome to the Propeller Games! In a few installments, I’ll present several gaming projects that use the Parallax Propeller chip. The Propeller is perfect for gaming with its multiple CPU cores to handle simultaneous gaming activities and its on-board video generation circuitry.

My first game project is the classic “higher/lower” game, where the computer thinks of a number between 0 and 99 and you guess it. You have probably seen this played as the “Clock Game” on The Price is Right TV show, though some contestants struggle with a basic binary search algorithm. (You can watch videos of the game at YouTube.com.)

This entire project is built on a solderless breadboard. If you are new to the Propeller, this is the perfect project to get acquainted with the hardware and programming. If you are a Propeller guru, you will enjoy the nostalgia of gaming on LEDs and push buttons. Grab your breadboard and follow along.

Parts

What you’ll need:

  • Breadboard and wire
  • 9-VDC wall transformer
  • Parallax PropStick USB
  • Two-digit 7-segment LED display
  • Five SPST pushbuttons
  • Audio speaker
  • Sixteen 200-Ω resistors
  • Five 10-kΩ resistors

The board and basic parts

The Parallax Propeller chip requires a few external components. You need a 3.3-VDC power regulator, a crystal, and a USB-to-serial converter. You also need a serial EEPROM if you want the Propeller to run your program at power up. You can buy all these separately and wire them up on the breadboard. Or you can save time and space with the Parallax PropStick USB. It combines all these external parts on the same footprint as the 40-pin Propeller chip.

I bought the LED display for this project from Mouser Electronics (part number 630-HDSP-521E). The large red segments are common anode (common ground). You supply positive voltage from a propeller port pin through a 220-Ω resistor to light the segments.

I bought the push buttons from Pololu Robotics & Electronics (part number 1400). They are specially designed for mounting on a breadboard. One side of each switch is connected to 3.3 V and the other is connected to a propeller port pin and pulled to ground with a 10-kΩ resistor.

I bought the speaker from Digi-Key (part number 668-1140-ND). The negative terminal of the speaker hooks to the breadboard’s ground. The positive terminal hooks directly to a Propeller port pin.

A speaker, one LED segment, and one switch wired to the Propeller

I placed four of the switches on the corners of the display. These switches are used as up/down inputs for each digit allowing the player to select a number from 00 to 99. The fifth button to the right of the display is the “Enter” button.

The photo above shows the speaker, one LED segment, and one switch wired to the Propeller. I tested the hardware and software incrementally as I hooked it up instead of trying to debug the final system as a whole.

The Parallax Propeller Tool is the free graphical Integrated Development Environment (IDE) you use to develop code for the Propeller. The code editor colors and highlights your work making it easy to see functions and keywords. It also manages indentation. The SPIN programming language uses indentation to identify code blocks much as Python does.

Basic hardware test

The code above is my basic hardware test. The CON (constants) section at the top configures the clock speed of the chip: 5 MHz × 16 = 80 MHz. The OBJ (object) section pulls in the serial terminal driver library. This library object allows you to use the USB cable for both programming and an input/output terminal. The one second pause on line 12 gives you time to switch from the IDE program to the terminal program on your PC once the code is downloaded. The Propeller tool download includes the parallax serial terminal for your PC.

Line 10 sets general I/O pin 0 (P0) as an output (they are inputs by default). Line 17 reads the switch connected to P11 and turns the LED segment on or off accordingly. Line 18 prints the state of the input pins to the PC terminal in an infinite loop.

Parallax serial terminal

It took me a while to warm up to the SPIN programming language. It is syntactically very different from C and its derivatives. But conceptually it is familiar: you break your software up into functions and local/global variables. In the end the simplicity of the syntax and the friendliness of the IDE won me over!

I really like the “Propeller font” used in the Propeller Tool IDE. It includes special symbols you can use to draw circuits and timing diagrams in your code comments. For instance:

Check out the font

Now to wire up the rest of the LEDs and switches. I thought about wiring the left digit to the first port byte and the right digit to the second port byte so that the segments are laid out the same way in each byte. This would make the software easier to write. But the pins for the segments on the display are kind of scattered around at random. The wiring is easier and neater if you wire the segments from the bottom of the display to the bottom of the propeller and from the top of the display to the top of the propeller. You can make up for the scattered pattern with software.

Two tips: Wire the segments from the bottom of the display to the bottom of the Propeller. Wire from the top of the display to the top of the Propeller.

Hi/Lo breadboard layout

That’s it for this installment. Now I’ll clean up all the little wire stripping sprinkles I left around my workbench. In Part 2 of this series, I’ll switch modes from hardware to software and write the Hi/Lo game. Hopefully you are following along. Until next time, may the COGs be ever in your favor.

Chris Cantrell earned an MSEE from the University of Alabama. He writes Java and Flex for Emerson Network Power in Huntsville, Alabama. Circuit Cellar published 10 of his articles between 2002 and 2012: Issue 145, Issue 152, Issue 161, Issue 184, Issue 187, Issue 193, Issue 205, Issue 209, Issue 139, and Issue 260.

Project Spotlight: “3D-Printed Mouse” Circuitry & Design

I get to meet and interact with creative engineers and researchers around the world who are working on innovative MCU-based projects. Some of them show up at our office to chat. Others I meet with when I travel to California for events like the Embedded Systems Conference. But many of the most interesting people and projects I find are on the Net. A perfect example is David Mellis, whose projects and research grabbed my attention recently while I was browsing the MIT Media Lab website. He is a PhD student in the High-Low Tech research group at the MIT Media Lab.

Mellis gave me permission to write about the projects and post some of the photos from his website, so let’s take a look at one of them—the “3D-Printed Mouse.”

The 3D-Printed Mouse design (Source: D. Mellis)

Check out the mouse strapped to a hand.

The mouse in hand (Source: D. Mellis)

Mellis writes:

This mouse combines a traditional electronic circuit board and components with a 3D-printed enclosure. The mouse is open-source: the original files necessary to make or modify its design are available for download below.

Download

Enclosure
Rhino: mouse.3dm
STLs: mouse-shell.stl, mouse-base.stl

Circuit board
Eagle files: mouse.brd, mouse.sch
Gerbers: mouse-gerbers.zip
Schematic: mouse.pdf

Component Datasheets

Button: SS-P_1110.pdf
Mouse Chip: ADNS2620.pdf

Code: hid-mouse.zip

Mellis notes that the circuitry and code are based on SparkFun’s ADNS2620 Evaluation Board, but “have been modified to include buttons.”

The first prototype with the SparkFun board (Source: D. Mellis)

Click here to access the project site.

 

Wireless Data Control for Remote Sensor Monitoring

Circuit Cellar has published dozens of interesting articles about handy wireless applications over the years. And now we have another innovative project to report about. Circuit Cellar author Robert Bowen contacted us recently with a link to information about his iFarm-II controller data acquisition system.

The iFarm-II controller data acquisition system (Source: R. Bowen)

The design features two main components. Bowen’s “iFarm-Remote” and the “iFarm-Base controller” work together to as an accurate remote wireless data acquisition system. The former has six digital inputs (for monitoring relay or switch contacts) and six digital outputs (for energizing a relay’s coil). The latter is a stand-alone wireless and internet ready controller. Its LCD screen displays sensor readings from the iFarm-Remote controller. When you connect the base to the Internet, you can monitor data reading via a browser. In addition, you can have the base email you notifications pertaining to the sensor input channels.

You can connect the system to the Internet for remote monitoring. The Network Settings Page enables you to configure the iFarm-Base controller for your network. (Source: R. Bowen)

Bowen writes:

The iFarm-II Controller is a wireless data acquisition system used to remotely monitor temperature and humidity conditions in a remote location. The iFarm consists of two controllers, the iFarm-Remote and iFarm-Base controller. The iFarm-Remote is located in remote location with various sensors (supports sensors that output +/-10VDC ) connected. The iFarm-Remote also provides the user with 6-digital inputs and 6-digital outputs. The digital inputs may be used to detect switch closures while the digital outputs may be used to energize a relay coil. The iFarm-Base supports either a 2.4GHz or 900Mhz RF Module.

The iFarm-Base controller is responsible for sending commands to the iFarm-Remote controller to acquire the sensor and digital input status readings. These readings may be viewed locally on the iFarm-Base controllers LCD display or remotely via an Internet connection using your favorite web-browser. Alarm conditions can be set on the iFarm-Base controller. An active upper or lower limit condition will notify the user either through an e-mail or a text message sent directly to the user. Alternatively, the user may view and control the iFarm-Remote controller via web-browser. The iFarm-Base controllers web-server is designed to support viewing pages from a PC, Laptop, iPhone, iTouch, Blackberry or any mobile device/telephone which has a WiFi Internet connection.—Robert Bowen, http://wireless.xtreemhost.com/

iFarm-Host/Remote PCB Prototype (Source: R. Bowen)

Robert Bowen is a senior field service engineer for MTS Systems Corp., where he designs automated calibration equipment and develops testing methods for customers involved in the material and simulation testing fields. Circuit Cellar has published three of his articles since 2001:

Tech Highlights from Design West: RL78, AndroPod, Stellaris, mbed, & more

The Embedded Systems Conference has always been a top venue for studying, discussing, and handling the embedded industry’s newest leading-edge technologies. This year in San Jose, CA, I walked the floor looking for the tech Circuit Cellar and Elektor members would love to get their hands on and implement in novel projects. Here I review some of the hundreds of interesting products and systems at Design West 2012.

RENESAS

Renesas launched the RL78 Design Challenge at Design West. The following novel RL78 applications were particularly intriguing.

  • An RL78 L12 MCU powered by a lemon:

    A lemon powers the RL78 (Photo: Circuit Cellar)

  • An RL78 kit used for motor control:

    The RL78 used for motor control (Photo: Circuit Cellar)

  • An RL78 demo for home control applications:

    The RL78 used for home control (Photo: Circuit Cellar)

TEXAS INSTRUMENTS

Circuit Cellar members have used TI products in countless applications. Below are two interesting TI Cortex-based designs

A Cortex-M3 digital guitar (you can see the Android connection):

TI's digital guitar (Photo: Circuit Cellar)

Stellaris fans will be happy to see the Stellaris ARM Cortex -M4F in a small wireless application:

The Stellaris goes wireless (Photo: Circuit Cellar)

NXP mbed

Due to the success of the recent NXP mbed Design Challenge, I stopped at the mbed station to see what exciting technologies our NXP friends were exhibiting. They didn’t disappoint. Check out the mbed-based slingshot developed for playing Angry Birds!

mbed-Based sligshot for going after "Angry Birds" (Photo: Circuit Cellar)

Below is a video of the project on the mbedmicro YouTube page:

FTDI

I was pleased to see the Elektor AndroPod hard at work at the FTDI booth. The design enables users to easily control a robotic arm with Android smartphones and tablets.

FTDI demonstrates robot control with Android (Photo: Circuit Cellar)

As you can imagine, the possible applications are endless.

The AndroPod at work! (Photo: Circuit Cellar)

Q&A: Dave Jones (Engineer, EEVBlog)

Are you an electrical engineer, hacker, or maker looking for a steady dose of reliable product reviews, technical insight, and EE musings? If so, Dave Jones is your man. The Sydney, Australia-based engineer’s video blog (EEVblog) and podcast (The Amp Hour, which he co-hosts with Chris Gammell) are quickly becoming must-subscribe feeds for plugged-in inquisitive electronics enthusiasts around the world.

Dave Jones: engineer, video blogger, and podcaster

The April issue of Circuit Cellar features an interview with Jones, who describes his passion for electronics, reviewing various technologies, and his unscripted approach to video blogging and podcasting. Below is an abridged version of the interview.

David L. Jones is a risk taker. In addition to jumping off cliffs in the name of product testing, the long-time engineer recently switched to full-time blogging. In February 2012, Dave and I discussed his passion for electronics, his product review process, and what it means to be a full-time video blogger.—Nan Price, Associate Editor

NAN: When did you first start working with electronics?

DAVE: The video story can be found at “EEVblog #54 – Electronics – When I was a boy…” www.youtube.com/watch?v=XpayYlJdbJk. I was very young, maybe six or so, when I was taking apart stuff to see how it worked, so my parents got me a 50-in-1Tandy (RadioShack) electronics kit and that was it, I was hooked, electronics became my life. And indeed, this seems to be fairly typical of how many engineers of the era got started.

By the time I was eight, I already had my own lab and was working on my own projects. All my pocket money went into tools, parts, and magazines.

The electronics magazine industry was everything back then before the Internet and communications revolution. I would eagerly await every issue of the Australian electronics magazines like Electronics Australia, Electronics Today International (ETI), Applied and Australian Electronics Monthly (AEM), Talking Electronics, and later Silicon Chip.

NAN: Tell us about some of your early projects.

DAVE: Given that it was over 30 years ago, it’s hard to recall I’m afraid. Unfortunately, I just didn’t think to use a (film) camera back then to record stuff, it just wasn’t something that you did as a kid. The family camera only came out on special occasions. So those projects have been lost in the annals of time.

My first big published magazine project was a digital storage oscilloscope (DSO) adapter for PCs, in a 1993 issue of Electronics Australia. I originally designed this in the late 1980s. (See “electronics.alternatezone.com, http://alternatezone.com/electronics/dsoa.ht.)

NAN: You have many interests and talents. What made you choose engineering as your full-time gig?

DAVE: There was no choice, electronics has been my main hobby since I can remember, so electronics engineering was all I ever wanted to do to. I’ve branched out into a few other hobbies over the years, but electronics has always remained what I’ve wanted to do.

NAN: The Electronics Engineering Video Blog—EEVBlog—is touted as “an off-the-cuff video blog for electronics engineers, hobbyists, hackers, and makers.” Tell us about EEVBlog and what inspired you to begin it.

DAVE: I’ve always been into sharing my electronics, either through magazines, via my website, or on newsgroups, so I guess it’s natural that I’d end up doing something like this.

In early 2009 I saw that (WordPress-type) blogs were really taking off for all sorts of topics and some people were even doing “video blogs” on YouTube. I wondered if there were any blogs for electronics, and after a search I found a lot of text-based blogs, but it seemed like no one was doing a video blog about electronics, like a weekly show that people could watch … So I thought it’d be fun to do an electronics video blog and blaze a new trail and see what happened.

Being fairly impulsive, I didn’t think about it much; I just dusted off a horrible old 320 × 240 webcam, sat down in front of my computer, and recorded 10 minutes (the YouTube limit back then) of whatever came into my head. I figured a product review, a book review, a chip review, and some industry news was a good mix … I’ve had constant linear growth since then, and now have a regular weekly audience of over 10,000 viewers and over 4 million views on YouTube. Not to mention that it’s now my full-time job.

The complete April issue of Circuit Cellar is now available. For more information about Dave Jones, his video blog, and podcast, visit www.eevblog.com and www.theamphour.com.