How To Control the WowWee Alive Elvis From An External PCPosted by Evilis on Friday, 21 November 2008
This the first of four articles about adding a "parasitic" microcontroller to the WowWee Elvis Alive that allows control of this device from an external PC via a serial interface. The external PC is also the source for the audio for the Elvis Alive speakers. This hack allows the Elvis Alive to either function in its original "Elvis Alive" mode or in the new "parasitic" mode of being controlled externally. Once you perform all the surgery to the Elvis Alive main CPU board, you can reinstall it and still (if all goes well) have a completely functioning unit! The only sacrifice in the original "Elvis Alive" mode is a cost in battery power since the new circuitry will still be present. So, the AC adapter is recommended, or you can add an external switch to turn off power to the added microcontroller board if you wish. The image below shows the modified main board reinstalled along with the added custom microcontroller board mounted to its right. All images for this four part article can be downloaded in a higher resolution from here (http://www.mediafire.com/file/tdkncywmzld/PCElvisImages.zip ).
A WORD OF CAUTION! I only paid $60 for my Elvis Alive (including shipping) so if you are not accomplished at throwing together electronic parts for fun, and paid full price for your Elvis, I would not recommend this hack to you.
This first article stands on its own to provide an external interface for Elvis Alive for anyone's microcontroller to do the controlling. The main requirement for a controller would be a sufficient number of I/O lines (@3.3 Volts) to run the interface. Also included in this article is a "lite" version of the interface which does not allow keeping the original "Elvis Alive" mode but requires just a 34 pin ribbon cable.
The second article will cover building the added micro controller board. The third article will cover the C software for the microcontroller. The fourth article will cover custom Windows PC software to be driven by a MIDI music editor using embedded audio files. This will be used to create and play new performances for the modified Elvis Alive.
For the curious who do not want to wait for article 2, the microcontroller chosen for my version of this hack is the PIC18F4620 with 33 I/O lines, a 32 MHZ clock (without using any external components), 64K of EPROM memory, almost 4K bytes of RAM, 1K bytes of EEPROM, several external interrupts, one USART for serial communications, and an additional serial interface for later expansion via a SPI or I2C interface. You can get the pdf's for this chip as well as the C18 compiler used to develop the C software for this hack free from the microchip.com site. At stated above, you can certainly make your own choice for a microcontroller with similar capabilities and use the C-Source from future article three as a guideline to write your own control software if needed. So article 1 of this hack is generic. Articles 2 and 3 will be specific to this hack. For Step 4 the PC Windows software should be generic as long as the hack still uses a serial interface for control and the serial commands are the same.
Now for the particulars. This hack involves removing from the base the main board that contains the CPU, cutting 8 traces, gluing two 16 pin DIPs and a DPDT relay upside down to the main board ("dead bug" style), touch soldering about 50 wires to the main board including a ribbon cable. The ribbon cable will connect to the "parasitic" microcontroller board which also holds a RS-232 converter chip, and a local voltage regulator. Urr, not so bad right? If this is not your cup of tea, then you will probably want to check out the articles on this site for a hack that only involves working through the memory card interface. This other hack will allow you to still create custom sequences for you Elvis Alive without performing this "surgery" but the results are more limited. My goal is eventually add more sensory input and to have some greater level of interaction of the device with its environment other than the IR sensors already in place. The schematic for this interface is below.
The list of the items needed build the interface is as follows:
2 - 74HC157 (16 pin DIP, 4 x (2 to 1 multiplexer))
1 - DPDT 5V Relay (DIP style)
2 - 10K 1/4 watt resistors
2 - .1 uf capacitor (DIP mount preferred)
1 - 2N2222 transistor
1 - small signal diode such as a 1N4148
1 - 2 pin connector to PC board (to power the added microcontroller board, in step 2 )
1 - 34 pin cable (I used an old floppy cable from an obsolete PC)
30 gauge wire wrap wire
22 gauge hookup wire for connecting power (red and black colors)
Silicone glue (aquarium sealant or similar)
wire wrap tool, soldering iron, solder, X-acto blade, etc
For the "lite" version, a 34 pin ribbon cable and a two wire power connector to go to the microcontroller board will do the job!
Okay, now for the surgery! Open up Elvis by removing all the screws on the bottom of the base other than the battery compartment screws. You can refer to the excellent article on this RoboCommunity site (The Elvinator) that describes the complete disassembly of this unit. After removing all the screws, you can lay the bust down in back of the upright base. You will need to pull off some wires hot glued in place and maybe cut one cable tie to allow enough slack in the wiring to completely lay down the bust. Unplug all the connectors going to the main CPU board, then unscrew and remove this board from the base. I numbered the connectors with a marking pen when I first removed them, but the color coding and pin arrangements are unique enough that this is probably not necessary for most people.
Note that if mounting devices "dead bug" style on circuit boards in too crude for you, you can maybe move these devices to the added circuit board in step 2 or just go with the "lite" version. I just wanted to make sure the higher frequency signal lines did not get corrupted by sending them off board and back again for the normal Elvis Alive operation. In addition this allows this first step to stand on its own and still have a working Elvis Alive. This also reduces the number of signals in this interface so that a smaller surplus 34 pin ribbon cable can be used.
Lay the just extracted main board down on a soft surface such as a folded up towel with the memory card interface sticking up and proceed to cut the 6 signal traces (A,B,C,D,E,F) shown in the picture below. These traces connect to the CPU pins (5,63,64,65,66,and 55). I used a x-acto blade and just made many repeated short strokes. You definitely want to avoid cutting any thing else doctor. These six signals do the following:
signal A (CPU Pin 5) - CE line enables/disables the control signals from the CPU
to the motors
signal B (CPU Pin 63) - START1 line enables communication with the SNAD01
converter on the main CPU board.
signal C (CPU Pin 64) - START2 line enables communication with the SNAD01
converted in the head.
signal D (CPU Pin 65) - CLOCK line to clock the data to/from both the SNAD01 A/D
signal E (CPU Pin 66) - DIO line is for data to/from both the SNAD01 A/D converters.
signal F (CPU Pin 55) - routes the external audio input (front audio jack) to the
Locate a length of these traces (except F, we will get it off of a connector pin), out from the CPU where they can be scrapped free of their protective covering. Use something dull like a small screw driver or an instrument that is pointed but not too fine of a point. You want to make repeated scrapes with it over the targeted area of trace until about 1/4 of an inch length is exposed (you see shiny copper) but not cut the trace. Make the exposed trace areas not adjacent to each other (staggered) so that shorts are less likely in the next step.
Cut Six 1 foot lengths of wire wrap wire and remove 1/4 inch of insulation from one end. Using tape to hold each wire in place where the line can be soldered to the exposed trace, solder each of these wires to the main CPU board at the exposed traces for A,B,C,D,E. In some cases you may need to re-scrape after attempting to solder since the protective covering can burn back over the area. Touch solder the wire for trace F onto the soldered joint for the third pin of the 8 pin yellow connector (J14). This pin is labeled "out_sel" on the board and is shown in picture #1.
Cut six more 1 foot lengths of wire wrap wire and remove 1/16 inch of insulation from one end. Add some solder to the pads next to the CPU pins for these six signals and then touch solder these six wires to these 6 CPU pads on pins 5,63,64,65,66,55.
Flip the CPU board over and place it on top of the edge of something (a book, table, etc) so that the memory card interface can fit over the edge pointing down and the main CPU board can lay flat with the top side up. Locate the traces labeled G1/2 and H1/2 in the picture below and cut them where indicated. Scrap 1/4 inch length of the protective covering from the trace on each side of the cut and solder four more 1 foot wire wrap wires to these 4 locations (each side of cuts). These signals are used by the CPU to turn off power to extraneous circuitry and the speaker amplifier for power savings (or for when some parasitic processor is attempting to take control!).
Using the silicone glue, glue the 74HC157 #1 and the DPDT relay with their "legs" up in the air (dead bug style) in the areas (shown in the picture above) next to the central chip which is the flash memory. Glue a 10K 1/4 watt resistor to the PC board near the relay with its leads bent up for wire wrapping later. Also glue the 74HC157 #2 in the small area above the 8 pin yellow connector (J14) on the lower right corner of the board. You may want to bend in (or cut off) pins 9,10,11,12,13,14 on this second '157 so that these unused pins are out of the way and do not touch each other. Place this board aside for drying overnight. Be sure and remember where PIN 1 is on all of these glued devices and maybe mark them with a marking pen.
After the glue dries, you can to run at least 10 of the 12 wires soldered to the CPU pads and the traces on the back of the board through the two central holes in the board where the CPU resides. These holes were convenient to locate these wires where the "dead bugs" are installed instead of going around the outside of the board. You may want to label them after you pull them through with tape so you can easily know where they go. Any that do not fit will just have to go around the outside of the board.
Determine the correct pins on either the relay or the two 74HC157's where these wires should go according to the schematic shown above and cut them to allow enough slack to still reach these devices. Remove about 1/4 inch of insulation using the wire wrap tool and wire wrap this short length to the correct pin for all 16 of these attached wires (from front and back) according to the schematic. Once all the wiring is complete and tested later you can add a little solder to make these connections more permanent.
Add the diode to the relay (if needed, some relays already have a diode on board) by soldering it across the coils pins observing the correct polarity. This is a small signal diode so you should be able to fit it easily if the coil pins are both located on one end of the relay. Solder the transistor's collector to the relay's ground coil so the transistor can be bent out of the way. The transistor on my setup just hangs off the relay by the single lead but make sure it will not get any movement that will cause it to short out something. You may want to silicone it in place after every thing is wired.
Extract 2 wires from the 34 pin ribbon cable wire about 6 inches long. There is extra wire but just keep about 12 inches of the ribbon cable intact from the one connector without the in-cable wire flip and this will be used later. Use these 2 wires to pull power for the relay's coil from the largest capacitor of the main CPU board. The lead of the capacitor attached to the cross hatched area on the main board is ground. Leave room to add the 22 gauge power wires for the added microcontroller board you will build later.
Add power to the 74HC157 #1 also using two wires from extra wire pulled off the 34 pin ribbon cable. Touch solder them to the location (I) in the picture using the identified polarity. Add a 10K pull-up to PIN 1 from power on the '157. I was able to make loops in the resistor's leads and suspend it across the require pins of the DIP. This will keep Elvis as himself until you add the new CPU to override it. Also add a .1uf capacitor between Vdd and Vss (PINS 8,16). I used a DIP form factor capacitor that could also be glued "legs up" to the end of this chip but you could still just hang a disk between leads or glue one flat to the board with the leads sticking up for wire wrapping. It's not pretty but it works if you are careful about not causing shorts.
Add power, ground, and the PIN 1 signal of the first 74HC157 to the pins on the second 74HC157 next to the yellow (J14) connector. You can run wire wrap wires over from the first '157. Add another .1uf disk capacitor across power and ground to this chip.
Again, lay the CPU board down with the card interface up and towards you. Line up the 34 pin ribbon cable (cut to about 12 inches in length) with the end connector about 2 inches out from the right edge of the board. Pin 1 of the ribbon cable, the red wire should be away from you and the memory card board that sticks up (See picture below). Beginning with pin 1, separate the ribbon cable into a group of 11, 6, and 4 wires to go to connectors J45 (10 pin white) ,J44 (6 pin yellow) , J47 (5 pin white) on the CPU card. Note that 11 wires are needed in the first group because pin 5 is not used. You can fold over the groups of wires to line up with bottom of the connectors you will be touch soldering them to. DO NOT SOLDER ANYTHING TO THE CONNECTOR PINS ON THE TOP SIDE, just the underside since you will be plugging the connectors back in when you reinstall this board! After cutting each group to a good length to reach the connectors, remove about 1/16 of an inch of insulation from the wires. Add an extra amount of solder to each soldered connector pin and then touch solder the correct wires in place per the schematic.
Run the remaining single wires from the ribbon cable to the correct pins of the two encoder connectors (J55 & J78), to the two 74HC157's and to the relay.
Cut two 14" length 22 gauge wires (colors RED and BLACK preferred) and remove 1/4 inch of insulation from each. Solder one end of the wires around the same leads of the largest capacitor that the relay power was pulled from. Again, the cross hatched lead is ground and use the black wire for this. Connect the other ends of these wires to a connector suitable for sending 5.5V power to the circuit board you will build in the next step (article 2).
Check your wiring 5 or 6 times, check for shorts 5 or 6 times, then remount the CPU board in the base. It always amazes me how much I can miss wire something right under my own nose! Reattach all the connectors. Check for any cables that might get in the way of the mechanics and use some cable ties if needed. Power it on and Elvis Alive should still be Elvis Alive!
If you were successful, sit back and relish in the first step of your accomplishment. If not successful, sorry ,maybe you should have done the memory card hack. Go back and check your wiring again and also look for shorts again.
Pictures of my completed board are shown below. Not pretty but functional!
This completed interface has the following signals. All signals are @3.3 Volts. All but 22,24,and 25 are inputs.
Pin Signal Name
1 EYES UP
2 EYES DOWN
3 EYES LEFT
4 EYES RIGHT
6 LEFT LID UP
7 LEFT LID DOWN
8 RIGHT LID UP
9 RIGHT LID DOWN
10 LIP UP
11 LIP DOWN
12 BROW UP
13 BROW DOWN
14 JAW UP
15 JAW DOWN
16 NECK LEFT
17 NECK RIGHT
18 HEAD UP
19 HEAD DOWN
20 HEAD SHIFT LEFT
21 HEAD SHIFT RIGHT
24 HEAD UP/DOWN ENCODER OUT
25 HEAD SWING ENCODER OUT
28 ELVIS ALIVE MODE
29 DIO/AD01 POWER
30 AUDIO ON
Here's an explanation of how this interface is used.
When the ELVIS ALIVE MODE signal is set high, Elvis is his old self. This signal is pulled high with a 10K resistor so that everything functions normally without anything plugged into this interface. When the ELVIS ALIVE MODE signal is pulled low (Parasite Mode), the 74HC157's switch all the signals of the traces you cut from the on board CPU to the external CPU. One of the signals switched is the Chip Enable for the on board 74HC574's which is switched to being a High level which disables the '574s. These chips drive all the motor control signals for the Elvis Alive. When these chips become disabled, Elvis essentially becomes paralyzed at this point and in his own words "leaves the building". So always set the ELVIS ALIVE MODE signal low before the external microcontroller's signals become outputs (keep in high impedance mode until used). Also return them to high impedance mode when returning to Elvis Alive mode.
All the motor control outputs act in toggled pairs to run the 10 different motors forward or backwards. The motor signals are all active high and should be run in a clocked duty cycle to control the speed. The duty cycle for the stock Elvis Alive was observed to be about 130HZ. For the controller in my hack I will divide the control of this into 1/10th of a cycle so my main control loop will run about 1300 times per second.
The limits for these motors must be observed by the control software to know when to stop. Otherwise the stripped gear noises may become unpleasant for some motors. This is where the existing onboard A/D converters can also be utilized for 8 of the motors. The onboard SNAD01A A/D chip has a 250KHz conversion rate with 8 bits accuracy. It is similar enough to the SNAD01B,C versions that the pdf specification for the later versions can be used for programming them. ( It can be found here at http://datasheet.digchip.com/805/805-3-152276-SNAD01B.pdf) I never could locate a pdf for the (A) version of this chip. Just remember to initialize the 4 bits of the SNAD01 control register to all 1's (my experience). Otherwise, the results are the same as documented. The 4 signals DIO, START1, START2, and CLOCK are used to read both of these A/D chips. There is one on the main board and one in the head. The DIO line is special in that it is used as bi-directional to both send commands and receive the data. This is why a relay is used to switch this signal between modes instead of the 74HC157's like the other control signals. So in order to read the A/D's externally, the relay must also be activated and to do this you would set the DIO/AD01 POWER signal to high.
The second set of contacts on the relay are not wasted and are used to switch power back on to the A/D converters and to the audio amplifier since the on board CPU will turn this power off if it cannot control the unit (because the interface cuts off the control signals). This is also useful to do an initial reset to the A/D's by turning power off and sending all other input signals to the A/D's to a low level for a short time (1-2 seconds).
There are encoders on two of the motors for head up/down and swing movements instead of A/D feedbacks. The HEAD UP/DN ENCODER OUT and HEAD SWING ENCODER OUT signals for these encoders are the only two outputs from this interface other than the DIO signal. These are just clock signals that must be counted to be useful so sending them to interrupts on the added microcontroller would be a good way to keep track of these two motor movements. In addition there are four limit switches for these two motors that are read from one of the A/D converters. These read 255 as OFF and 0 as ON. You must perform an initialization sequence in your microcontroller code using these switches to calibrate your encoder counters. Then you can stop movement before you reach these switches using your encoder counters.
The AUDIO OUT signal is set to high to route the front audio jack input to the speakers. So this can act as a audio mute when needed. And I might add that you can get a BIG BOOMING voice from these speakers from a computer verses the weak voice put out by the stock unit.
The Lite Version of This Interface
The last picture below is the "Lite" version schematic using just a 34 pin ribbon cable. The only difference in this interface version's signals is that the ELVIS ALIVE MODE signal is no longer present so the stock Elvis has left the building and he ain't coming back. I did wire up this "lite" version as well and it does work. All you will need to do is cut the 8 traces shown by the red lines in the pictures, add a two pin power connector off the large capacitor for your controller board described above in step 16 and solder the 34 ribbon cable lines to the board per the schematic. Remember to keep the orientation of the cable as described above in step 14. Note that the C, D, and E traces can instead be soldered to pins on the bottom of J21. Also the H-2 trace can instead be solderd to a pin on the bottom of J73 and the G-2 trace can instead be soldered to a pad that resides on the bottom of the board near J73. So you can reduce the number of traces to two that you have to scrape clean to solder wires to (just A and B). Just use your ohmmeter to verify the correct spots. This puts all the ribbon cable connections to the bottom of the CPU board which makes for a neater and a safer hack.
Addendum Just When you think you're finished you get pulled back in! I was preparing to make a demo video and did some cleanup on my microcontroller code including removing a serial bootloader. The 2 second delay in the bootloader was doing me the service of hiding one more modification. It turns out that the Elvis Alive CPU pins reading the encoders do not always act as benign inputs unless you stop Elvis in his tracts about two seconds into his startup sequence when he is initializing his encoders. Stopping him any later results in the encoders intermittantly being pulled high by the Elvis CPU pins which prevents the added microcontroller from being able to read them. The end result is no changes for the regular interface since the microcontroller code can just wait for the encoder inputs to start clocking before cutting Elvis off during the startup sequence. However, if you are attempting the "Lite" version of this interface it will also be neccessary to cut the two traces between the Elvis Alive CPU and the encoder inputs (J,K) shown in the picture below. This makes a total of 10 traces to cut for this "lite" interface. My suspicion is these CPU pins are part of a port that is being reinitialized as a whole for another purpose and these pins have to be toggled between uses.
Just When you think you're finished you get pulled back in! I was preparing to make a demo video and did some cleanup on my microcontroller code including removing a serial bootloader. The 2 second delay in the bootloader was doing me the service of hiding one more modification. It turns out that the Elvis Alive CPU pins reading the encoders do not always act as benign inputs unless you stop Elvis in his tracts about two seconds into his startup sequence when he is initializing his encoders. Stopping him any later results in the encoders intermittantly being pulled high by the Elvis CPU pins which prevents the added microcontroller from being able to read them. The end result is no changes for the regular interface since the microcontroller code can just wait for the encoder inputs to start clocking before cutting Elvis off during the startup sequence. However, if you are attempting the "Lite" version of this interface it will also be neccessary to cut the two traces between the Elvis Alive CPU and the encoder inputs (J,K) shown in the picture below. This makes a total of 10 traces to cut for this "lite" interface. My suspicion is these CPU pins are part of a port that is being reinitialized as a whole for another purpose and these pins have to be toggled between uses.