cclogo-sm.gif (4723 bytes)

What’s the best part about being an engineer? Playing with all the gadgets! And, we see a potential project in almost anything, right? Well, Marty’s here to share his vision for an embedded application inspired by a singing fish and a love for practical jokes.


During the summer of 1999, I was living in Hanover, New Hampshire with my roommate Ben Guaraldi. One quiet, sunny morning I woke up late and walked into the living room to find Ben dozing on the couch. At the sound of my entrance, he opened one eye and we looked at each other for a moment, each of us still experiencing a post-sleep stupor. In an uncommon epiphany it was clear to me that I could communicate to Ben the entire contents of my just-barely-awake mind with one single word: pork!

Yes, indeed, the other white meat. Try it, even if you don’t dig swine. You might find that a whole world of human experience can be expressed with this one simple word. Even if you don’t agree, Ben did. So, on that quiet, sunny morning in Hanover, New Hampshire, we had an entire conversation using only the word “pork.”


As time passed, we became more impressed with the dynamic range of the p-word. And, we got creative about how we communicated it. While shopping at the local drugstore, I stumbled upon a talking bass. For those of you who don’t know what I’m talking about, the Bass is one of several “talking fish” toys that have cropped up during the last few years. It looks like a life-size stuffed fish, complete with wall-hanging plaque. When you press the small, red button on the front, the fish comes to life and talks to you. I am serious. In this article, I’ll discuss the Big Mouth Billy Bass (see Photo 1), made by Gemmy Industries, because it seems to be the most widely available toy of this type.

2107022 photo 1.jpg (49740 bytes)
Photo 1—The Big Mouth Billy Bass from Gemmy Industries provides the basis for a fun project.

These Bass are nothing short of little animatronic wonders. Now who’s put two and two together? Pork. Bass. Talking Bass. Christmas was fast approaching and I didn’t have a gift for Ben yet.

Teach a Fish a New Trick
In case you haven’t gotten it yet, these three ingredients should complete the picture:

• WECA’s ISD 1420P solid-state ChipCorder voice record/playback chip [1, 2]
• Atmel’s AT89S8252 microcontroller [3–7]
• Motorola’s MC34119 audio amplifier [8]

The recorder chip stores 20 s of telephone-quality voice. It has nonvolatile RAM, in-system recording capability, and comes in a 28-pin DIP. The microcontroller has 8 KB of flash memory, 2 KB of EEPROM, and comes in a 40-pin DIP.
After removing the screws that hold the back of the Bass’s plaque, I discovered that there’s plenty of room for adding special circuitry. Clearly, I didn’t want to destroy the existing circuit. I wanted to hijack its power drivers for the motors. And besides, the messages it comes with are hilarious, especially after you’ve heard them a hundred times.


An investigation with an oscilloscope revealed that control of the Bass’s head, tail, and mouth is extremely simple. Energize the corresponding motor, and the head turns out and the tail extends or the mouth opens. De-energize the motor, and the corresponding body part returns (by a spring) to its rest state. We have binary actuators here, folks. And, it was clear that I could tie into the gate inputs of the motor drivers with simple diode OR circuitry (see Photo 2).

2107022 photo 2.jpg (94090 bytes)
Photo 2—The innards of the Big Mouth Billy Bass look like this after the addition of Special mode.

After I got the circuits built and debugged, it took only a few minutes to record my message. First, there’s 5 s of silence during which the tail flops around, the head moves out and pauses for 0.5 s, and then the Bass says “Pork!” Then, the head moves back in, followed by 5 s more of silence with its tail flopping.

I wrapped the fish in its original packaging, with the mode switch left at “special” and the batteries inserted. Ben’s reaction when he pressed that button was nothing short of priceless.

Design Details
If you envy Ben and want your own hacked Bass, you’re in luck, because I’m going to tell you exactly how I did it. The hack adds a 20-s re-recordable special message to the Bass. The movements of the head, tail, and mouth are also re-recordable (stored in EEPROM in the ’8252), and the original factory messages are still available.


Figures 1 and 2 show the circuit that I added. Figure 2 is based on a Windbond datasheet and application brief. [1, 2] Photos 3 and 4 show the top and bottom sides of the main added circuit board.

2107022 photo 3.jpg (97293 bytes)
Photo 3—With a top view of special circuit board, you can see the chips. The large chip is the ’8252, the medium-sized chip is the ’1420, and the small chip is the ’34119.
2107022 photo 4.jpg (92069 bytes)
Photo 4—Here’s a bottom view of the special circuit board.

As you see, I added four switches. SW4 toggles the Bass between Normal and Special mode. In Normal mode, the Bass should behave as it always has. In Special modes, operation depends on the settings of SW1…3, which set the current sub-mode. Currently there are six sub-modes: Record Voice, Record Mouth, Record Head, Record Tail, Play (button only), and Play (button or motion).
The Record Voice mode records a new message up to 20-s long. Only one special message is supported at a time. When the button on the front is pushed and held in, any sound will be recorded until the button is let out or 20 s passes. New special messages can be recorded as often as you like; doing so will erase the existing special message and reset all head, tail, and mouth movements.
You can record mouth movements with Record Mouth mode. Press and release the button on the front to start playback of the special message along with any existing recorded tail and head movements. While the message is playing, press and hold the button to open the mouth. Release the button to close it. The mouth movements recorded will be played back subsequently whenever the message is played in Play, Record Head, or Record Tail modes.


It can be difficult to get the timing right, so it helps to have a digital stopwatch on hand. And, you can, of course, rerecord the movements as many times as you like. Rerecording the movement does not erase the current audio or movements of the other body parts.


Record Head mode allows you to program movement of the head (either flat against the plaque or turned to face you). Operation is similar to Record Mouth mode.


Record Tail mode records tail movements. And again, operation is similar to Record Mouth mode.


When the button is pushed and released during Play (button only) mode, the currently stored message is played back along with any recorded head, tail, or mouth movements.


The last sub-mode, Play (button or motion), is the same as the button-only mode except the motion sensor will now also trigger playback. For this to work, the original Big Mouth Billy Bass motion sensor enable switch must be on.


If you build the circuit according to Figures 1 and 2, the Special mode switches work as shown in Table 1.

 

Special sub-mode SW1 SW2 SW3
Record Voice Short Short Short
Record Mouth Open Open Short
Record Head Open Short Open
Record Tail Short Open Open
Play (button only) Open Open Open
Play (button or motion) Open Short Short
Table 1—There are six sub-modes to choose from when the Bass is in Special mode. Set switches one, two, and three according to this table to pick the one to use.


There is also a knob for adjusting the volume in Special mode (visible just above the ’34119 in Photo 3) and an LED (useful during software development). It’s possible to use the speaker as a microphone, but to keep things simple I added a separate microphone to the Bass to support recording sound.

Power Supply
The Bass is designed so that it can be either powered from four onboard C cells or a wall wart power transformer. The Bass actually comes with batteries and a female coaxial power jack for the wall wart.


I originally planned to use a 7805 regulator to supply power to my added circuit from either the batteries or wall supply. But, I quickly discovered that the 6 V from the batteries does not leave enough voltage headroom for a regular 7805, especially when the motors are energized (because the high current drain causes the battery voltage to dip significantly). It may be possible to circumvent this issue by using a (low dropout) LDO regulator, but I didn’t have one.


It turns out that a regulator is unnecessary for this circuit when powered by the batteries. Be careful though because the specified maximum operating voltage of the ’8252 is 6.6 V, and some freshly charged cells may surpass this. However, unless you get a regulated wall wart (which is less common than the unregulated variety), regulation is necessary when using the wall wart.


So, I moved the 7805 to the wall wart jack. This way when the wall wart is connected, the Bass is supplied through the regulator. But when the wall wart isn’t present, the juice comes directly from the batteries. I found a 9-VDC, 500-mA wall wart from JDR (part TR09-DC) that works well. Polarity isn’t standardized for all wall warts. Be careful to use one that agrees with the Bass (center positive).


Internally, the coaxial jack has three terminals. One carries positive voltage in from the wall wart, one is system ground, and the remaining one is battery ground. The terminal with the lone black wire going to the negative side of the battery pack should be battery ground. The one that connects to the outer conductor on the coaxial jack should be system ground. And the remaining terminal should be +VIN (it had a pink wire attached in my Bass).


The jack has a switch that automatically connects auxiliary ground to system ground when the wall supply plug isn’t inserted and disconnects it when the supply is inserted. This effectively isolates the batteries when the wall supply is connected. Be careful not to mangle this switch; doing so could inadvertently cause the wall supply to drive current through the batteries, which would be a bad thing. Before and after you finish your work, verify the proper operation of the switch with a continuity tester: When the wall wart is inserted, there should be no continuity from the negative terminal of the battery pack to system ground.


Of course, as in any mixed signal circuit, keep separate power and ground nets for the analog and digital portions. Keep them separate until as close to the supply points as possible. If you have audio noise problems, especially if they occur only when the motors are energized, check your supply voltages.


The special circuit draws about 13 mA when powered. However, the ’8252 is programmed to shut down everything after about 25 s of inactivity. In this Low-Power mode, the special circuit draws only about 0.3 mA. C cell batteries typically have capacities around 5000 mAH, so the Bass should be able to sit idle for months before it drains its batteries. And, when you do need to change the batteries, you’ll be happy to know that both the memory of the ’1420 and EEPROM of the ’8252 are nonvolatile. So, you’ll lose neither the audio nor motions of your carefully recorded message.

Programming the ’8252
The AT89S8252 is mostly backward-compatible with the original ’8052 microcontroller. All of the code that runs on the ’8252 is contained in the assembly language file bass.asm (available online).


I used the freely available assembler as31 to produce an Intel format hex file (bass.hex) from the assembly code. [6] Well, sort of. Actually, before I ran bass.asm through as31, I passed it through the C preprocessor. One reason I did it this way is because it allowed me to define bit addresses as named symbolic constants (which as31 does not handle well). Another reason is that it allows for conditional assembly, although I’m not using this yet.


However, the C preprocessor is not an ideal solution. Unmatched single or double quotes anywhere in bass.asm will make the C preprocessor choke (except if enclosed in C style: /* code comments */). Comments on the same line after #define statements will misbehave. And when you get an assembler error, the line number reported actually refers to the post-C preprocessed file (bass.p.asm). And, take a look at the last few lines of bass.asm for a laugh. A more generic preprocessor like M4 probably would be a better choice.


The good news is that I provide a make file with the design documents, so if you’re on a Linux system, all you need to do to build bass.hex (after installing as31) is type:

> make bass.hex

It also should be possible to build bass.hex from bass.asm on any system in which both the C preprocessor and as31 run, however I’ve tried it only on Linux. You can probably get the code to build with a different assembler if you make some syntax adjustments.
Of course, if you’re not interested in playing with the code, you should be able to use just the Intel hex file, which you can send directly to a programmer. Don’t have a programmer? No problem. It’s easy to build one that connects to a PC parallel port. That’s the major reason I chose the AT89S8252 for this project (I didn’t have a programmer either). Get yourself a 40-pin ZIF socket for the ’8252 and connect it as shown in Figure 3.

2107022Fig3.gif (140120 bytes)
Figure 3—This is the schematic for the Atmel AT89S8252 parallel port programmer.


Now, you need a program to run on your PC that twiddles the bits on the parallel port so that the contents of your Intel hex file get transferred to the ’8252. A few searches on the Internet turned up a guy named Rob Melby who wrote such a program, called 89prog, for Linux. I added some improvements. For example, now the timing is independent of the machine you run it on, and it runs under DOS as well as Linux. For Linux, you need Linux kernel or higher 2.0. The DOS version runs under most versions of Windows, but not NT.


Source code (89prog.c) and compiled executables (89prog for Linux and 89prog.exe for DOS) are provided with the design documents on Circuit Cellar’s web site. Hook up your programmer to the parallel port, insert your ’8252, and power up the programmer. Run 89prog, feeding it your Intel hex file like this:

> 89prog bass.hex

If your parallel port is not at the common address of 0x378 you need to specify the address explicitly on the command line. Run 89prog without arguments to get a usage message that explains how to do this.


Sometimes my programmer fails with an “invalid checksum” error message. Reinserting the ’8252 a few times often fixes the problem, trying 89prog each time. (I haven’t gotten to the bottom of this yet, so please let me know if you have any ideas.)

Construction Notes
It’s tricky to mount the toggle switch, mode switches, LED, and microphone. You need to get creative here. I recommend trying to mount everything on the rear surface of the Bass’s plaque, so that from the front the Bass doesn’t appear to be modified. Be sure to have some gap-filling superglue and hot-melt glue on hand.


When attaching things that stick out the back of the plaque, keep in mind that if you want to be able to mount the Bass on a wall, whatever you attach needs to protrude less than the mounting feet do. This can complicate things. For example, in order to mount SW4, I ended up soldering a stiff wire loop to its knob so I could mount the switch parallel to the back plate of the plaque (see Photo 5).

2107022 photo 5.jpg (71965 bytes)
Photo 5—Use this mounting technique for SW4.

As shown in Photos 2 and 3, I used a JALPC-3 perfboard that can be soldered from Hosfelt Electronics to build most of the circuit. Point-to-point wiring is used throughout. Use sockets for each of the ICs, and complete all soldering and check everything twice before you insert them. If you plan to modify the code, you may want to get an additional 40-pin ZIF socket to install in the Bass. Just plug it into the regular 40-pin socket that you have for the ’8252. This way it’s easier to move the ’8252 between the programmer and Bass while doing the assemble-burn-test dance.

You’ll find that there are many wires to connect the circuit boards and other parts together. Use stranded hook-up wire, and be careful about strain-relieving it at each end. For example, when attaching a wire to the added board, you may want to slightly enlarge one of the holes, pass the wire with insulation through the enlarged hole (from the component side to the solder side), and then solder the wire. When connecting the head, tail, and mouth control wires to the original board, use plenty of hot-melt glue for strain relief. In fact, you should also put big blobs of hot-melt glue around the solder points of the original wires.


It’s likely you’ll do a lot of rearranging and it would be annoying if during all this you overstress and break off some wires. It’s also annoying if you accidentally allow superglue to wick its way to the inside of your switches.

Future Work

I hope you find that your hacked Bass has all the functionality you need. However, if you’re looking for a challenge, consider trying to implement one or more of the following features: in-system programming, serial interface, or multiple messages.

An Atmel application note contains useful information for people who want to make their projects in-system programmable. [7] This note also is a good read for general information about serial programming the ’8252. For ISP, the main issue is that you may need to externally latch the outputs of the ’8252 that connect to the Bass and ’1420 during programming.


Currently, the ’8252 has a UART that you aren’t using. So, you can hook up a MAX232 level converter and a connector to communicate directly with the Bass from a PC.


As it is, only a single 20-s or less special message is supported. Because the ’1420 is addressable, it should be able to support multiple messages that add up to 20 s or less.


Please let me know if you complete any of these modifications or if you think of any other fun ones to tackle. Good luck and happy hacking!

Marsette “Marty” Vona is a graduate student in Electrical Engineering and Computer Science at Massachusetts Institute of Technology. His research is in the field of precision metrology for mechatronic systems. You may find him on the Internet at www.ai.mit.edu/~vona.

SOFTWARE
The design documents, a parts list, and code files are available on the Circuit Cellar web site.

SOURCES
AT89S8252
Atmel Corp.
(408) 436-4270
Fax: (408) 436-4314
www.atmel.com

Big Mouth Billy Bass
Gemmy Industries, Inc.
(972) 550-7979
Fax: (972) 550-0495
www.gemmy.com

JALPC-3
Hosfelt Electronics
(800) 524-6464
(740) 264-6464
Fax: (800) 524 5414
www.hosfelt.com

IC distributor
JDR Microdevices
(800) 538-5000
(408) 494-1400
Fax: (408) 494-1420
www.jdr.com

MC34119
Motorola, Inc.
(847) 576-5000
Fax: (847) 576-5372
www.motorola.com

ISD 1420P
Windbond Electronics Corp. America
(800) 677-0769
(408) 943-6666
Fax: (408) 544-1789
www.windbond-usa.com

REFERENCES
[1] Windbond Electronics Corp. America, “ISD1400 Series Single-Chip Voice Record/Playback Devices, 16- and 20-second dura           tions,” April 1998.
[2] ———, “Stand-Alone/Parallel Interface Products: Good Audio Design Practices.”
[3] Atmel Corp., “8-bit Microcontroller with 8k Bytes Flash—AT89S8252,” rev. 0401E, February 2000, www.atmel.com/          atmel/acrobat/doc0401.pdf.
[4] Intel Corp., MCS 51 Microcontroller Family User’s Manual, 272383-002, February 1994.
[5] Atmel Corp., “8051 Flash Microcontroller Data Book,” 0522B-12/97/65M, December 1997.
[6] P. Stoffregen, Paul’s 8051 Tools, Projects and Free Code Offerings, www.pjrc.com/tech/8051/#as31_assembler.
[7] ———, “AT89S8252 In-System Programming,” December 1997, www.atmel.com/atmel/
acrobat/doc0898.pdf.
[8] Motorola, Inc., “Low Power Audio Amplifier,” rev. 1, MC34119/D, 1996, e- www.motorola.com/collateral/
MC34119.pdf.

© Circuit Cellar, The Magazine for Computer Applications. Reprinted with permission. For subscription information call (860) 875-2199, email subscribe@circuitcellar.com or on our web site at www.circuitcellar.com.