Robot Eye Expressions using LED Matrix Display

RobotEyes_IconI was exploring ways to make a future robot project more appealing and came across a number of articles about animated robotic eyes created to convey expression or mood. This looked like a bit of fun and quite achievable using the LED matrix modules that I have been playing with for a while. Here’s the result.

Hardware

This project works well with all the standard LED matrix modules supported by the MD_MAX72xx library, so no special hardware is needed to run the software.

However, I decided to build a dedicated 2-module unit for the displays, as I am planning to integrate this into a mobile robot in future. The design is based on the Parola modules I designed some time ago, but this time using a surface mount version of the MAX7219 IC to make the PCB smaller. Using Eagle CAD it was a simple process to copy and duplicate the existing design to create the required circuit, shown below.

RobotEyes_Schematic

RobotEyes_BoardThe PCB footprint was designed to be the same size as the 2 LED matrix modules (at right, click to enlarge) and was manufactured at SeeedStudio’s Fusion PCB service. It took about 2 weeks from design through receiving the 10 neatly packed PCB prototypes in the mail.

The PCB was quickly populated and worked first time, as expected for this repeat design. The only issue was that the distance between the two sides of the LED matrix pins was too close and the outside pins need to be angled into the socket. Not a big deal and it does ensure that the matrices butt tightly against each other in the middle. An updated version of the Eagle CAD schematic and PCB layout files for this project can be downloaded here.

The images below show the PCB front and back, and the populated PCB with one matrix removed to show the components underneath.

 

 

Software

An animation is a basic sequence of images that, when played one after the other as ‘frames’, convey a sense of movement. In this instance the target is to animate the images for two eyes so as to convey mood.

To simplify the software, the eye animations start from a neutral expression (ie, eyes open looking forward) and progress through a series of intermediate frames to the main frame that conveys the desired ‘look’. After some time, the sequence can then be reversed back to the neutral expression. In this way, only half of the sequence needs to be defined, as the second half is just the same sequence in reverse.

It is also worth noting that some expressions are identical for both eyes (eg, a blink), others are completely independent of each other (eg, a wink) and still others have a reflected symmetry around where the nose would be (ie, they have a left and a right side). This means that the eyes will need to be independently animated, possibly unsynchronized.

Also, to make the neutral expression more life-like, the software should occasionally just blink the eyes rather than keep a spooky fixed stare.

Using the MD_MAX72xx library, each eye is just an 8×8 bitmap that can be defined using the font editor, described in this previous blog article. A simple sequence for a blink, starting from the eye wide open, is shown left to right in the figure below. The eye opening again is the reverse of this sequence.

Robot_Eyes_BlinkSeq

This architecture allows the software to define animations sequences as tables of pairs of bitmaps and display duration. The tables are all managed using straightforward code leveraging the font handling features of the MD_MAX72xx library. In fact, all the data for the application can be set up in tables, making it easy to adapt and change the available expressions.

All this is implemented in a class that hides most of the detail from the calling program. As a bonus the class also allows text messages to be scrolled in the LED matrices.

This implementation is available as an example of the MD_MAX72xx library. The video below shows the example program running.

 

All-in-all a fun project that was easier than I expected, mostly due to being able to leverage existing infrastructure provided by the MD_MAX72xx library.

 

 

Advertisements

2 thoughts on “Robot Eye Expressions using LED Matrix Display

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s