After building my walking robot, I had figured out how to control servos using a PIC, but I wanted to do something on a larger scale. The snakerobots.com website caught my eye – the S5 robot was especially intriguing, since it could both slither and sidewind. I decided this was an interesting project to try on my own, so I decided to make a similar robot using 40 servos. My design started from scratch, the only thing borrowed from the S5 design was the universal joint and opposing servo arrangement to get the necessary axes of freedom. Otherwise, my hardware and software design is completely new.
Below is a picture of the snake and the Hitec hobby radio control used to steer it and activate the various modes. There is also a detail view of the head section, including the RC receiver and master processor, and a detail view of a slave processor section. The snake robot is powered by 24 NiMH batteries. 4 cells run all the processors, and 5 cells each run the banks of 10 servos. When the servos are switched off, the 5 cell banks are combined in series into 10 cell banks to interface with my charging system. The charging system is based three MAX712 chips from Maxim. The charger fast charges all the snake batteries in about 30 minutes and automatically switches to a trickle charge mode once the cell voltage levels off.
Here’s a view of the underside. The snake robot rolls on Lego wheels. Did you know that you can get almost any Lego component individually in quantity? See http://www.lugnet.com/. Note that the motion of the robot comes entirely from the slithering action, the Lego wheels are completely free-wheeling. These wheels were chosen because they have a good lateral (side-to-side) grip while rolling quite smoothly and being very durable.
The charging system is the same one that is used with my balancing robot. The charger connects to the two motor battery banks as well as the processor battery and charges everything simultaneously. When the green and red lights go out, the batteries are fully charged.
The design is implemented as a multi-processor system that runs on six 16F876 PICs from Microchip Technology, Inc. Two of the PICs comprise the master processor and there’s one PIC each on the four slave processors. The LEDs were included in each slave section to ensure that everything is working, and also give a neat light show in the dark. After all, a snake is a machine for bending wire, and that means that wires can break – so the LEDs help to visually ensure that everything is connected and working properly. RC servos are controlled by varying the width of a pulse sent out at a 50 Hz (20 msec) rate. A narrow pulse will position the servo to the left. A wide pulse will position the servo to the right. Anything in between will position the servo to the desired place. By carefully controlling the pulse width, very smooth motion can be achieved. The standard RC receiver is designed to do all this for you just by plugging a servo into the connector, but my snake robot design breaks that link and decodes the receiver output, processes it as commands to the robot, and then creates the necessary pulse outputs to control to 40 servos in this system.
The software design was based on a few simple observations about snake-like locomotion:
- The snake slithers when a sine wave is propagated along its length in the horizontal plane.
- The snake turns when the sine wave is compressed at its start or end.
- The snake sidewinds when a sine wave is also propagated along its length in the vertical plane.
The trick is to make the software transition between these motions all very smoothly so the servos aren’t jumping all over the place when the controls are moved.
Below are the schematics for the various parts of the snake:
- The system block diagram showing how the batteries are switched between running the robot and charging mode.
- The master processor which consists of two PICs. One decodes the RC receiver PWM outputs and passes the results to the other PIC, which computes the positions for the 40 servos in the various modes and sends serial data packets to the four slave processors.
- The four slave processors which each control ten servos. They receive their commands through a serial link. All the software was written in PIC assembly language.
- The processors get a stable 5V supply from the batteries through a Maxim MAX756 chip.
- This interface circuit connects to the master processor and provides communication ports for monitoring and debugging the software.