The Casio EX-F1. Handy for taking high-speed video of your golf swing or a dripping tap. Boring! Let's see what happens (in the interest of science) when you shoot a flaming butane can with a .22 LR hollow point.
Wednesday, 13 August 2008
Wednesday, 13 December 2006
Lava lamp automation
Monday, 13 November 2006
Wednesday, 5 July 2006
Here in the ikordo offices, we're faced with many of the challenges that face a typical Web 2.0 company. Principal among these is the problem of how to connect your electro-mechanical monkey to the software bus, so he (or she) can let you know when, say, a new customer signs up. You might think that there would be a couple of active sourceforge projects and a GOF pattern for it, but sadly no. We'll be using Wowwee, our Wowee Alive!, upgrading him from being just a loveable pet into something much more useful. At this point, I should mention that Wowwee Alive! has never been that popular with gadget magazine reviewers or anyone really, to the point where the only source (in the UK at least) these days seems to be eBay. Bad news for the Wowwee corporation, good news for monkey fans. It also meant that we were able to buy Wowwee a companion, Zowwee, but that's for another post. Now, on to the chimperface.
Having decided not to interfere with Wowwee's internals, hacking the remote seemed like a good idea. The controls are pretty straightforward - buttons and microswitches in a 4-way joystick configuration. Typically, the buttons are for vocalisations, the switches for actions. If I'd been more patient, I would probably have taken out all the connections from the controller PCB. As it was, I went for 3 buttons, a couple of switches, V+ and Gnd.
![The Chimperface](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5Vcqn8cNnZSwHxWrjfoA8sfkn17mtjF0jc27zHoAt7jU_-ljXuo9bqWC86hOLFp8EFo5dShPJO9GZSbbQxKRTrI13Y-7SBvn4IAZ7L8G2l8mUddPPCq6_lv-UoG_SKMtf_4kNyeui714/)
Like most engineers, I previously bought a microcontroller development kit, wrote a program to flash the LED, then, disgusted at having to use a parallel port, stuck it in a cupboard. As it turned out my Atmel MR-8 CPU Board from Active Robots was just the ticket for the chimperface, with a hardware UART and 20 I/O lines. I stuck the MR-8 in an old breadboard, added a MAX232-based level shifter, an LM7805 regulator to drop the 9v controller supply to 5v and wired up the MR8 PORTC bits to the custom remote connector.
With a bit of sawing and drilling (and biting), I managed to stuff the whole thing into an old iPod nano case.
![remote connector](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7pHSVo0faySoTkFdU4aVRTMJhS4HrwRvvfvgz3XG4mcTEJolJEmhYjD7lTZ1Kjyq6aPsDARlMbvPc4TebbgN3VXs-v5gNRG4Zzy6FnV1AcYY77nV3eeXELd7VgfGeSREeC7CH5hseWCk/)
I needed a simple protocol for communicating with the chimp. It goes like this: issue a command "a" to "h". In response, the microcontroller pulls the appropriate PORTC pin high for 100ms and responds with "OO!". If there's an error, it returns "AA!". The whole thing looks like this:
I used the demo version of the excellent BASCOM-AVR. Yes it's BASIC. So what? Server-side software Back in the comfortable world of Java, only the dirty details of connecting to the chimperface's serial port remained. I was somewhat pissed to discover that javax.comm only supports Unix boxes these days. Luckily, the fine folks at rxtx stepped in to plug the gap.
The chimperface unit tests look like this:
Production code looks more like this:
That's it! For the future, I'll do a proper wiring job on the controller for greater monkey expressiveness. If there's even the slightest interest (you never know), I'll provide schematics so you can pimp your own chimp in safety.
The Wowwee Alive! controller
Having decided not to interfere with Wowwee's internals, hacking the remote seemed like a good idea. The controls are pretty straightforward - buttons and microswitches in a 4-way joystick configuration. Typically, the buttons are for vocalisations, the switches for actions. If I'd been more patient, I would probably have taken out all the connections from the controller PCB. As it was, I went for 3 buttons, a couple of switches, V+ and Gnd.
The Chimp Interface box
Like most engineers, I previously bought a microcontroller development kit, wrote a program to flash the LED, then, disgusted at having to use a parallel port, stuck it in a cupboard. As it turned out my Atmel MR-8 CPU Board from Active Robots was just the ticket for the chimperface, with a hardware UART and 20 I/O lines. I stuck the MR-8 in an old breadboard, added a MAX232-based level shifter, an LM7805 regulator to drop the 9v controller supply to 5v and wired up the MR8 PORTC bits to the custom remote connector.
The custom remote connector
With a bit of sawing and drilling (and biting), I managed to stuff the whole thing into an old iPod nano case.
ChimpOS
I needed a simple protocol for communicating with the chimp. It goes like this: issue a command "a" to "h". In response, the microcontroller pulls the appropriate PORTC pin high for 100ms and responds with "OO!". If there's an error, it returns "AA!". The whole thing looks like this:
program monkeyio
dim key as byte
dim crlf as string[3]
dim msg as string[20]
sub procedure pulse(dim portId as byte)
PORTC.portId = 1
Delay_ms(100)
PORTC.portId = 0
end sub
main:
crlf[0] = chr(13)
crlf[1] = chr(10)
crlf[2] = 0
USart1_Init(9600)
Delay_ms(10)
DDRC = $FF
PORTC = $00
msg = "Monkey API 1.0"
strcat(msg, crlf)
Usart1_Write_Text(msg)
while true
while USart1_Data_Ready=0
wend
key = USart1_Read
select case ( key )
case "a","b","c","d","e","f","g","h"
pulse(key - "a")
USart1_Write_Text("OO!")
case "*"
USart1_Write_Text("OO!")
case else
USart1_Write_Text("AA!")
end select
wend
end.
I used the demo version of the excellent BASCOM-AVR. Yes it's BASIC. So what? Server-side software Back in the comfortable world of Java, only the dirty details of connecting to the chimperface's serial port remained. I was somewhat pissed to discover that javax.comm only supports Unix boxes these days. Luckily, the fine folks at rxtx stepped in to plug the gap.
Code
The chimperface unit tests look like this:
package com.volutio.ma.chimp.io.test;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import com.volutio.ma.chimp.Chimp;
import com.volutio.ma.chimp.ChimpException;
public class ChimpTest {
private static Chimp s_chimp = null;
@BeforeClass
public static void setup() throws ChimpException {
s_chimp = Chimp.discoverChimp();
Assert.assertNotNull(s_chimp);
}
@Test
public void goNuts() throws ChimpException {
s_chimp.rollEyes();
s_chimp.makeBirdSong();
s_chimp.actFurious();
s_chimp.actRandy();
s_chimp.actTerrified();
}
}
Production code looks more like this:
public ChimpConsole() throws ChimpException {
// Create chimp
_chimp = Chimp.discoverChimp();
if (_chimp == null) {
throw new ChimpException("No chimp available");
}
// Add sniffers
_sniffers.add(new NewUserActivatedChimpSniffer().register(this).startSniffing());
}
Conclusion
That's it! For the future, I'll do a proper wiring job on the controller for greater monkey expressiveness. If there's even the slightest interest (you never know), I'll provide schematics so you can pimp your own chimp in safety.
Subscribe to:
Posts (Atom)