Sunday, March 30, 2008

Robots in Art

Back in college I and my best friend, Paul Potts, started talking about building a robot. We never did but we came up with a lot of fun ideas.

Paul is an artist and has had a lot of showings locally and is always coming up with some new creative idea. Here's his latest-- robot paintings!



Thursday, March 27, 2008

Say What?

Here's how to interface an ancient, 80's era, General Instruments SP0256-AL2 speech synthesizer chip to a Basic Stamp 2 so you too can give your robot the gift of virtually unintelligible, vintage, synthetic speech! (Listen closely to the audio clip and you can almost make out, "Hello world")

Audio Clip

Data Sheet:
See previous SP0256-AL2 post to download the data sheet.

Circuit Diagram:
sp0256-al2.sch


Note: the LM386 amplifier circuit provided in Robot Builder's Bonanza just wouldn't work. It differed slightly from the one presented in the data sheet. The data sheet circuit is pictured above, but with the addition of a giant 100uF power decoupling cap; the LM386 was apparently drawing enough current with the speaker attached to cause the BS2 to reset similarly to prior motor control problems. A somewhat smaller cap doesn't seem to work -- more investigation needed. The potentiometer above is actually not installed yet; a resistor is in place to prevent clipping that was showing up on the o-scope.

The Code:
SP0256AL2.bs2

' {$STAMP BS2}

' {$PBASIC 2.5}

' SP0256-AL2 Speech Chip
' Control Code

' Text: HELLO WORLD.
' Phoneme: HH EH LL AX OW (PAUSE) WW ER1 LL PA2 DD1 (PAUSE)
' Octal: 033 007 055 017 065 003 056 063 055 001 025 004

' Dec: 27 7 45 15 53 3 46 51 45 1 21 4

text DATA 27,7,45,15,53,3,46,51,45,1,21,4,0
ptr VAR WORD
char VAR BYTE

setup:
' P7 <- SBY ' P6 -> 'ADL
' P0-P5 -> Data

DIRL = %01111111
HIGH 6

ptr = text

PAUSE 2000

go:
' Set char to the next phoneme
' Send it

READ ptr,char
DEBUG DEC char, CR
IF char <> 0 THEN cont
END
cont:
GOSUB pout
ptr = ptr + 1
GOTO go

' Phoneme Output
pout:

' Now just set OUTL P6='ADL=1, (P0-P5) = phoneme byte

OUTL
= char | %10000000
DEBUG BIN ? OUTL

' And set P6='ADL=0 for 2usec to tell the chip to read
PULSOUT 6,1

' Wait for P7=SBY (standby) to indicate chip is done speaking
notdone:
IF IN7 = 0 THEN notdone
RETURN

Quick Code Explanation:
The data sheet goes into this in detail, but in short: the program puts the 6-bit phoneme data on data lines A1-A6, then pulses ^ALD low for a short time to let the chip know data is ready, then polls SBY until it goes high, then repeats until it runs out of phonemes.

That's it. This is just a prototype so there's lots more to do before this becomes useful. For example, wouldn't it be nice if a handy dandy AVR of some flavor could front end this chip and accept data over serial and/or I2C? Maybe even do true TTS?

Sunday, March 23, 2008

Circuit Design on Mac OS X

Circuit design is fine to do on paper for the simplest stuff but a CAD program is nice for everything else. I'd been using TinyCAD on my P3 400MHz, 128M desktop but am trying to move away from this glacially slow system, not to mention minimizing my exposure to Windows. :)

One good answer for Mac users is the free version of CadSoft Eagle running under the X11 windowing environment (follow the link to install X11). While it's not a seamless Aqua interface, it is actually a heck of a nice program once you get use to using it and it has an integrated PCB designer that works quite well. The user interface is a little bizzare, but with some practice I'm getting faster at drafting circuits. So far, the parts library seems to be pretty comprehensive, too.

If you want the app to show up in your Dock, you can write a shell script and use Platypus to create a wrapper application (may take several tries to figure it out) or try mine below which includes the shell script. Click on the link, save to disk, unzip, and copy the Eagle.app to /Applications. This app assumes the EAGLE-X11 folder is already installed in /Applications.

Basic Stamp Programming on Mac

With a pause between school "semesters," I've been neck deep in several projects. One of the smaller ones was assembling a Basic Stamp 2 prototype board that came with the book, 123 Robotics Experiments for the Evil Genius (TAB Robotics). This board features a spot for a solderless breadboard making prototyping 10x easier than the Parallax BS2 board I'd been using (let's just say that wire wrapping sucks).

In a never-ending quest to unshackle myself from Winderz, a Google search followed by a quick experiment revealed that one can program BS2 using my favorite operating system. How? Easy.
  1. MacBS2: This is the IDE. Not fancy but who cares? Download it here.
  2. Keyspan Serial Adapter or equivalent (e.g., Keyspan High Speed USB Serial Adapter ( USA-19HS ) from Amazon -- check to make sure this will work on the MacBS2 website).
After downloading MacBS2 read and follow the install instructions. You'll copy the application to the Applications folder. Using an administrator account, launch the application and when prompted, click to download & install the tokenizer library.

Install your Keyspan (or whatever) software, and plug it into the computer & proto board. Write a program. Click run. Et voilĂ ! Enjoy the magic of BS2 on Mac OS X. :)


(To those who celebrate it with me, Happy Easter! Otherwise I wish you a Happy Sunday :))

Thursday, March 20, 2008

Firefighting: Video Clips

I'm hoping to get some more clips and different angles from those present, but for now here's some of the robots (including Pokey :)) from the Ft. Collins Robot Firefighting Competition:


Tuesday, March 18, 2008

Fan Motor Circuit

Thanks to Brij who pointed out some problems with Pokey's fan motor driver circuit that I threw together at the last minute. I stand corrected :)

Going to go back to the drawing board and pull out the old school textbooks. I pulled the original post for now.

UPDATE! I started a new series of articles on revising this fan motor driver using SPICE modeling.

Monday, March 17, 2008

Flame Sensor

Quite a few people have asked questions about Pokey's flame sensor (the big, cylindrical yellow and black thing in the picture). Here's the rundown.

First and foremost, the design uses infrared LEDs for sensing infrared radiation. Yes, that's right, LEDs. Of course LEDs emit radiation when voltage is applied, but a little known fact is that they also generate a voltage in the presence of radiation -- and specifically radiation in the frequency range that they emit. I tried UV LEDs but they weren't sensitive enough to detect UV output of a candle. The pile of IR LEDs I ordered happened to generate about 0.5V max when pointed at incandescent lamps, candles, etc.

The only problem? Range. By themselves IR LEDs are a bit too limited in range to provide a strong signal from across the largest of firefighting rooms. I had the idea of using some kind of optics to increase range and after some experimentation the solution was to use the reflector off of a $3.50 Eveready lantern flashlight with the LED replacing the bulb. Range was increased to at least 8' -- plenty.

This device has the added benefit of limiting field of view, making the sensor less sensitive to IR sources outside the arena, but very sensitive to candles within the regulation height range. I installed dual IR LEDs in the housing hoping to give the sensor directionality but this didn't work out. A single LED works just as well.


Finally, to give the MCU's Analog to Digital Converter (ADC) a little more voltage range to work with, the signal from each LED runs through half of a simple, single-source op amp amplifier (LM258 or equiv) as pictured above. The resistor and capacitor in parallel seemed to help stabilize the LED signal when I was experimenting, taking ADC readings directly from the LED.

I used aluminum tape to block off the sensor's view to the side, essentially improving the "peakiness" of the sensor's response when scanning a room, making it easier to pinpoint the direction of the candle.

Edit: Brij asked why not use an IR phototransistor or photodiode (see comments). At the start, I tried several different sensors, actually. The phototransistor was too sensitive; pegged out too easily. Didn't think to try a photodiode. The LEDs showed a fairly linear response, just enough sensitivity. In short, they work great!

Sunday, March 9, 2008

The Competition

Ended up leaving around 8:40 having just tested scanning for and extinguishing a candle in the living room. Arrived up in Ft. Collins by 10:10, with plenty of time to adjust floor sensors, test the robot in the arena and tweak code.

SHARC and FRR made a great showing with lots of competitors and spectators. The room began filling up with kids to watch the event. While all this was going on, my robot kept misbehaving right at the starting circle, making a left turn into the wall about 75% of the time. I couldn't figure it out.

Then my batteries died. While I swapped them out, the wires to my battery tray broke loose again! I had to jerry rig a solution: strip the wires and manually wrap them around the end terminals. Stressed out, fumbling around, trying to block out the noise and chatter of the crowd, I got that fixed and it held together for the rest of the competition. By now there was a good sized crowd of small spectators and quite a few adults as well.

My first run was a disaster. Even though the candle was in the first room in Pokey's list to visit, the robot careened off to the left again directly into a wall. Others in the competition had problems with navigation at first, too. Pokey went back to the bench for diagnosis. For some reason the IR rangers, which had been dead solid in every condition I'd tested, were giving jittery readings and popping above and below the threshold for detecting the presence of a wall. This tricked Pokey into thinking he was farther along on the course than he actually was. With new threshold values Pokey was ready for the 2nd run.

This time around the odds were seriously stacked against the little red robot. The candle was in one room he'd never made it to before was the one directly adjacent to the start position, the last one on the search path. Though Pokey got to both the first and second rooms, his poor wall following set him off in the wrong direction for room 3.

By this point, George had put out a candle with water, and Anthony did as well! Very awesome to see these robots working so well!

Back on the bench, I did some additional minor code tweaks and put Pokey on the home circle for the third and final trial. The candle was in the 2nd room on his itinerary so there was a good chance for success.

The timer started, Pokey was off. He made it into the first room flawlessly, scanned, then exited and made his turns into the second room, stopping a bit short, then he scanned... but missed the candle and left the room! My last minute coding of the scanning routine just wasn't solid enough yet. So close...

In the end, George took 1st and Anthony 2nd. Congrats to them and to all the competitors. It's not easy building a robot for a competition and everyone who fielded a machine can be proud of that accomplishment.

Heck even those who didn't field a machine but have a start on one ought to feel pretty good. And since SHARC is going to host a firefighting challenge in April we all get another shot at this. (Well, unless it happens on the same weekend as my trip to Moab for four-wheeling).

In the meanwhile, I'll share what I've learned, post up code and circuit diagrams and other fun stuff. Once I get all the video and pictures from folks I'll edit together a video and post that too.

Thanks to everyone who has been reading this saga, your support is much appreciated!

Saturday, March 8, 2008

7:25AM

Fan's interfaced, mounted, and working. Puts out a flame at 2 feet away. Extinguish routine moves robot back and forth while running fan so it can't miss. Looks good.

Will test room scan code, ensure it drives fairly straight to candle (or at least to white stuff. Majorly crossing my fingers. About 0.002% chance that this will actually work in the competition, but no worries. Leaving ~ 8:15.

5AM

Got up at 5, brewed an iced latte and am now tinkering with the robot at the last minute while dosing on caffeine. I have a fan, prototype driver circuit, and an idea or two on how to mount it.

I know Pokey doesn't stand any chance at all, but I'm hoping against hope that maybe I can get a fan bolted on and interfaced before I have to leave in 2.5 hours for the competition.

Will post pics and story of the competition a bit later.

Thursday, March 6, 2008

Almost

After Monday night's session, I realized due to school and other obligations there was only one more hacking session left. My robot could barely make it into the first room, let alone navigate anywhere else.

On Tuesday I just about gave up. I contacted my friends and told them it wasn't worth driving to Ft. Collins to watch me fail. I'd still go up there, of course. Maybe I could hack on some code to make the robot find and drive to the candle and do a demo run. I didn't mind being unable to compete. What was really demoralizing was busting my tail for 2 months and having virtually nothing to show for it.

I went to the Wednesday session for no other reason than to deliver flame detection components to one of the guys in the club. But, figuring why not, I sat down and reluctantly opened some source code... played around a little... things started to come together. Fast. By 9:30pm I left the scene after video taping this:



Funny how quickly things can change from almost gave up to almost got it...

I'm still unlikely to have a competitive robot but now there's a tangible result from all the hard work.

Tuesday, March 4, 2008

Pokey

I made a little progress yesterday after a marathon hacking session at Steve's. The robot can sometimes enter the first room, scan it, and orient itself to the nearby wall, pointing in a direction that makes it possible for it to leave again, and bash its way to the second room. But it's inconsistent and sensitive to starting position, and glitchy.

As a last ditch effort last night, I set the speed a bit slower. All along I've stubbornly insisted on the robot being really fast. It can run into walls much faster than any other robot! So... I am going to finally give up on speed and may even gear it down another 3X.

I shall name him Pokey. :)

Only 4 days and two hacking sessions left to pull all the pieces together. Quite a cliffhanger, eh? I can't wait to see what happens...

Sunday, March 2, 2008

Not Good...

Things are not going so great. After three hacking sessions, I've made a little progress but there's a long way to go. I'm finding that robot coding is quite frustrating. And it's not just me.

The robot can get from the home circle to the floating room. (Or, it can get from the home circle to the room to its right). From the floating room, it can get to the next room if it starts in the correct direction-- pointing out of the floating room.

But stitching these actions together is turning into a big challenge. I am still working out how to properly orient the robot to start and stop scanning a room and how to orient itself to leave a room properly. Doing this without encoders is proving to be quite tough.

On the plus side, the robot can spin and scan (indefinitely) until it detects a candle. It can point at the candle and even move towards it and stop once it's on the regulation white circle surrounding the candle.

I still don't have a fire suppression system built.

Some physical glitches keep coming up that are rather trying. Earlier today, the sensor wires broke loose from the connectors wasting an hour of coding time while I soldered everything back together (burning my hand in the process).

Then one of the power filter capacitors on the LV168 board popped off! Fortunately this isn't having a major impact. I sent a note to Pololu-- they already responded (on a Sunday evening after 5pm, mind you!) with advice. They are going to ship out a replacement board. If I haven't mentioned it lately, Pololu absolutely ROCKS!!

For the second time, a set screw came loose in the geartrain. A little bit of Loctite may be in order.

The weather here was great yesterday making for a pleasant Saturday afternoon of coding.

As is typical of Colorado, everything changed. It snowed today and was pretty cold, windy, and icy. The drive to and from Steve's wasn't too bad, though.

So, here I am, running out of time, I/O pins, ideas, and flash memory...