Simple Embedded Architecture for Robot Learning and Emotion

I’ve been working on a paper about robot learning for over a year now, more as a place to organize my thoughts than anything else. This paper outlines some ideas I’ve been having about how to implement a learning system that let’s a robot relate state-action sequences to a result. It’s still extremely sketchy, but I thought I’d make it public:
Simple Embedded Architecture for Robot Learning and Emotion
Sorry for the shoddy formatting, but that results from publishing a Google Doc as HTML.

I also have a few background documents that may be interesting* to some:

Senses/States Matrix
Emotional Effects on Outputs
Robot Emotions versus Movements

My current mental obsession is an ALife simulation running under Linux, and I thought I would try out this learning architecture in a simulated environment on a capable processor.

*I find this stuff extremely interesting, but then according to my teenage daughters I’m weird. Of course they think weird is a compliment.

Perl for Puzzlers

I was working on creating a puzzle a couple of weeks ago and needed sets of a dozen 5-letter words that all “interacted” in a certain way (sorry, don’t want to give away too much).  One of the software guys here at work suggested a Perl script to find sets words, specifically Strawberry Perl. I have been programming since I was a kid (basic on a VIC-20) but lately have been resistant to learning new languages because I can usually accomplish my goals with the languages I already know. This time I decided to take his advice and was pleasantly surprised with the simple learning curve and thought I’d pass on a bit of intro on how to set up and start using Perl to help create puzzles.


#mazetrix video 1

I spent about 4 hours programming last night trying to simulate the physics of a rolling ball on the AVR. I think it turned out pretty well:

Here’s the timer interrupt that services the analog to digital converter and the multiplexing of the LEDs:

static unsigned char activeLine=0;
static unsigned char adcChannel=0;
case 0: x_accel=(ADCH-x_flat)/10;
if((x_loc<500)&&(x_accel<0)){ x_accel=0; } if((x_loc>7500)&&(x_accel>0)){
case 1: y_accel=(y_flat-ADCH)/10;
if((y_loc<500)&&(y_accel<0)){ y_accel=0; } if((y_loc>7500)&&(y_accel>0)){
// y_vel=0;
case 2: z_accel=(ADCH-125);
default: adcChannel=0;


And the main loop:


if(x_loc<0){ x_loc=-x_loc; x_vel=-x_vel; } if(x_loc>7999){
if(y_loc<0){ y_loc=-y_loc; y_vel=-y_vel; } if(y_loc>7999){
x_pos=(unsigned char)(x_loc/1000);
y_pos=(unsigned char)(y_loc/1000);


Mazetrix Update

I received the pcbs for Mazetrix and started the build. After 4 1/2 hours of troubleshooting I realized that I connected the SCK line to the wrong pin and finally managed to get AVR Studio to recognize the processor. Then I wrote enough code to verify the LEDs would all light up.  However I then started having problems with the firmware. Finally, during my 15 minute lunch today, I found the problem was the fuse settings in the ATMEGA128 (either 103 comaptibility mode or JTAG enabled).

I just added the 3-axis accelerometer, but haven’t soldered on the supporting components. Also I still need to add the Li-Po charge IC. I am currently using the STK500 both to power and program the board.

So without further ado, here are some pics…

Mazetrix project

Mazetrix project

Mazetrix Bottom

Mazetrix Bottom

Mazetrix Top

Mazetrix Top

Welcome to the Mazetrix

So, I just got an email from BatchPCB that my board has been shipped, so it looks like I’m switching gears again.

My board is for a project based on the Tiletoy, and incidentally not unlike the Space Invaders Button, the Awesome and 64Pixels.

Many moons ago I managed to score several 8×64 Red-Green matrix displays salvaged, evidently, from a casino display. Even though I had managed to reverse engineer them and figure out how to display nifty messages, they were just too large and too COTS for me. I removed the 8×8 LED matrices (matrixes?) and designed a small board to run them. The display is run directly from an ATMega128, using a half-H bridge on each column so I can use the entire matrix as a sensor. Additionally, I have added a MMA7260 triple axis accelerometer. Last but not least is an IR LED pointed in each of the cardinal directions, also connected to be used as an input and an output, for communicating to neighbor modules(PDF link).

The ultimate goal is to create tiles with a red maze and a green “ball” than you can manipulate by tilting, just like the good old labyrinth game. When you get to the edge of a tile, you can connect another, which will attach magnetically, and the maze will continue on the new tile.

I’ll add more updates when I start building.

Here’s a few images to satisfy the curious:



Mazetrix Layout

Mazetrix Layout

Let there be…. uh…. color

I am having so much fun with this PDA/Tricorder project! Although the 128 X 64 mono LCD is cool and all, I just had to buy the 128 X 128 color LCD from Sparkfun that I’ve had my eye on. I wired it to my ATmega128 breakout board and powered the whole thing with my STK500 set to 3.3V

Voila! I had a nifty color LCD for my project. Here are a few screenshots:

Icons Flower World Setup

I also picked up a few Hammond electronics enclosures ( I love electronics enclosures! I collect them…) from Allied. I get a great deal through work, plus free shipping. I got the 1553B and the 1455J1201. Of course I am also considering putting the electronics into an actual tricorder case. I bought a scratch-build kit from GMProps (look him up on the tricorder props forum), but it proved to be too much for me. Maybe I’ll try a Playmates Tric from Ebay.

Useable accelerometer data

Here’s a few places I found good stuff about filtering…


Toward a Buttonless Interface

I have been struggling for a while with the lack of user input on the PDA project. I had considered adding an interface through the RF transceiver, but that would mean I would need to be near a PC. I have been unable to find any pushbuttons that I like to install on the face. So I did the next best thing. A sharp sideways tap on the right side of the enclosure brings up a menu, with a small circle next to the selected item:


Tilting the unit in the y direction moves the selection circle, and another tap selects the item. It still needs a bit of tweaking. It seems much easier to tilt in the x direction, because I tilt the unit towards my face when looking at the screen, and that makes the selection circle move down the llist.

Here are links to a few thing I found during my research into tiny user interfaces:

From the “Because I can” Department…

While waiting for my RF boards to arrive from Sparkfun, I started another project (ooh, look! Something shiny!). I have always liked building things that I could carry around with me, so I decided to build my own PDA. I had the graphic LCD and plenty of processors laying around. I figured adding an RF link back to the PC would not only make it more functional but also help produce code that would be useful for the Spoka project. I also figured that I could combine it with my Tricorder project (notebook pages 3-12) and add as many sensors as I could fit in this little OKW enclosure.
Inside Size Comparison Screenshot PC RF Base

The processor is an ATMega32. I have added a 128 X 64 graphic LCD, a 2.4GHz RF Transceiver, battery-backed real time clock, 2 axis accelerometer, linear Hall effect sensor, and a white led flashlight. The IR receiver is not connected yet. I still plan to add an RGB color sensor and an IR transmitter.

The source code was compiled with WinAVR and is available here. The library for the graphic LCD is from Gregor Horvat ( for the compatible HD61202 controller. After updating a few deprecated commands, it worked first time! I can’t remember where I got the library for the DS1307 clock that I converted for the DS1305. If anyone recognizes it, please let me know. The defines for the NRF24L01 came from S. Brennen Ball.

As you might be able to see from the screenshot, I am currently reading the battery voltage (upper left), magnetic field strength (upper right), x and y acceleration (lower left), and the current time (lower right). The cross-hairs and “bubble” in the center of the screen form a 2-axis level. See the picture of it in my hand for an example with the unit tilted on one axis. The RF transceiver is working well and capable of exchanging data with a PC base unit that connects via serial at 115200 baud.

(BTW, my order arrived from Sparkfun, but I’m having so much fun with this project, I may not get back to Spoka)

Spoka Pt. III – Choosing current limit resistors & color mapping

I was just realizing that I didn’t put values in for the LED current limiting resistors on the schematic, so I thought I would add a little detail regarding their values and how I chose them. I decided from the start to limit the current through each LED to 15 mA. Each PIN on the AVR can source 40 mA so no problem there, but the entire chip can only source 200 mA total. 7 LEDs X 15 mA = 105 mA. Should be no problem. Plus room to spare when the device is AC powered.

First and easiest was the red. I placed my meter in diode check mode and measured the voltage drop across the LED (Vf) as 1.74V. Measuring the battery output as 3.8V, we get a margin of (3.8-1.74=2.06V) which must be limited to .015A. Dividing the two we get (2.06V/.015A=137Ohms). Putting a 220 and a 330 in parallel gives me (220*330)/(220+330)=132. Close enough.

The blue and green LEDs had too high of a Vf for my meter to read in diode check mode. I knew however that the blue LEDs in the original circuit had a 20 Ohm resistor, so I figured that anything larger should be OK, so I scrounged around and found some 47 Ohm resistors. I soldered these to the LEDs and applied the power, then used the meter to measure the voltage across them. I got 3.16V for the green and 3.07 for the blue.

Green: (3.8V-3.16V=0.64V) (0.64V/0.015A=42 Ohms) Just leave in the 47 Ohms.

Blue: (3.8V-3.07V=.73V) (.73V/.015A=49 Ohms) Again, just leave in the 47 Ohms.

Worst case voltage should be 4.8V when the AC is plugged in. This will give (4.8-1.74)/132= 23mA for the red, (4.8-3.16)/47=35mA for the green, and (4.8-3.07)/47=37mA for the blue. All within the per-pin limit of 40mA. Total output would be (3*23)+(2*35)+(2*37)=213mA. Hmmm, I wouldn’t put out a production unit with numbers like that, but for a hack, it’s not too far off.

I was explaining to my wife the kinds of things I could do with this when it is PC controlled, like changing color according to the speed of a download. This reminded me of an article I saw a while back, “Rainbow LED Indicates Voltage with Color.” This article gives a nice mapping of value to color for the range of 0-255, but it is centered around 128. In other words 128 gives black (all off), <128 gives bluish tints, and >128 gives reddish tints. This might be handy for some things, but not for others. So I did some research on “color scales” and here are a few interesting links:

Next Page »