Let's Make Robots!

Bibi the quadruped

Walk with 4 legs (2 DOF) and scan the environment. If an obstacle comes close (treshold programmed) the robot searches for a new direction to go.
Bibi.zip24.12 KB

This is my 3rd robot and I thought now it was time to make one that walks!

For this robot I used the Keil uVision4 compiler evaluation version. I also used the STM firmware library from ST.com which is called STM32F10x_StdPeriph_Lib_V3.5.0

This lib has a ready to go project structure which can be opened with the Keil compiler. A number of fixed files are required to make it work. Their names and where to put them can be seen in the image here:


These files you must put in the directory STM32F10x_StdPeriph_Template

In the KEIL compiler you must open the project located one dir higher in the folder MDK-ARM.

My files / sourcecode I'd like to this project but does anyone know how??

I would like to thank the maker of robot Cane, I used his algoritm/design to make my robot walk. Before that it looked awfull haha!

Some background info on the code. In main after setting all timers for their pwm modes (servo's for legs and knees as well as the pan servo) and interrupts I go in an infinite while(1) loop. Here the robot takes one step, checks a FLAG which indicates wether there is an obstacle detected or not and if so it executes a piece of code to avoid it.

The glowing of the body I do with bright green leds connected in parallel to a channel of TIM2. In an irq routine I increment /decrement a variable which I use for dutycyle and so the leds dim on and of in a peaceful manner.

The ultrasonic distance sensor works as follows: in the main function infinite while(1) loop I trigger a measurement simply by bitbanging a pulse of 10uS high. The sensor issues 8 ultrasonic 40khz pulses. TIM15 is configured in input capture mode on both edges. The echo (response) pin of the sensor I connect to one of the TIM15 input channels. On rising edge I reset the CNT register of TIM15. I also configure the other channel to monitor if the TIM15 overflows. I have it running on 1Mhz so 1 count is 1 uS. Since the sensor goes no further then 500cm of distance aka 29000 uS (so 29000 counts), an overflow means we have a bogus value. Als a value between 29000 and 65535 is invalid so I check for that as well. On the falling edge of the echo pulse I readout the capture value. This number is the pulse HIGH time in uS. Divide this by 58 and you have the distance in CM! Last, I compare the distance just measured to a treshold valua and set a FLAG variable if it is over the limit. In the main program while(1) loop I check for this flag to see if we need to do an evasive manouvre or not!

The making of the mechanics and make it work took me a lot of time.

The acrylic body I designed myself using a CAD program. I used the so called FAB-LAB initiative from MIT, known in my city Utrecht as protospace.nl to make the body. They have a laser cutter which on certain days anybody who wants to design stuff can use. GREAT that something like that exists!

Enjoy my robot. I will go develop it further, I'm thinking of mounting a camera but since I know nothing about this I still did not start... I want to experiment with line flollowing or object tracking.



update 26-3-2012: added the sourcecode. You require Keil uVision4 and the STM firmware lib mentioned in my description above



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I like this robot. It has a cool look to it. Both the physical looks and the way it moves as well. (Wherever you got the code in the first place, I'm sure you had to adapt it for your own 'bot.)

 -and the way the chassis light goes up and down is most likely PWM.


(My dictionary has the word "Quadruped".)

I started with the STM firmware lib and took the example where they make PWM signals with TIM3.

I kept building and building on top of that, also PWM with tim2 then PWM for the LEDS (indeed its PWM-ed), then I added interrupts to do some tasks on a regular basis and I ended with the ultrasonic sensor and interrupt handling of the echo with TIM15. Everything comes forth from the ST examples which I finetuned and altered for what I needed and what resources I had left in the ARM processor.

The legs moves I got from Cane, not the code just the idea of lifting the diagonal legs right front and left back while moving the opposite legs. Its actually when I think about it the way horses, dogs and cats walk (every animal with 4 legs)

What is a Quadruped? Is that the correct word instead of Quadropod?


That is very cool about being able to use the laser cutter when it is available.


As to how the legs move, it actually depends on how fast they moving. That is to say that different gaits move an animal forward at different speeds.

Consider the horse:

Walk - In the walking gait, while there is a little overlap in the movements, only one foot is off the ground at a time. First the left front moves forward, then as that foot touches down, the right rear leg comes forward. As that one ends, the right front is brought forward, and finally the left rear. As it touches the ground, the left front starts to move to repeat the cycle.

Trot - This is the gait you mentioned. Opposite diagonal legs are off the ground and hit down at the same time. By sound, this is a two-beat gait.

Canter (or Lope) - This one may seem odd to a two legged person, by it works well for the horse, propelling him faster than the trot. The sound of this gait is three beats and a pause. How he moves is that one foreleg (Whichever the horse uses as his lead foot) steps forward, followed by pushing off with his other foreleg and it's diagonal opposite in the rear, and last, the remaining rear leg is brought forward by itself. The lead leg takes the most weight as the horse moves forward and so as the horse gets tired, he may switch which leg he uses as his lead leg,

Gallop - the fastest of the four (common) gaits of a horse. The sound of the gallop is four distinct hoof-beats with a pause in between. The gallop is very much like the canter, except that at the greater speed, the two legs that operated together, cannot stay in sync. They become separated, so the foreleg hits down slightly before the opposite rear leg. During the pause I mentioned, most horses actually have all four legs off the ground at the same time (but only for an instant) before the lead leg touches down. Likewise, before lifting the first leg, all four legs are pushing at once, which is what makes the gallop the fastest gait. One of the rear legs will be the last to stop pushing as it lifts into the air, just before the first foreleg touches down. Very few robots are capable of a gallop.

There are other gaits which are only seen in certain breeds of horses, but all types of horses share the four gaits listed above.

To make a robot gallop, takes stronger servos or stepper motors to be sure. They have to be strong enough to propel the robot off the ground. This leads to a fifth "gait", Jumping, where the forelegs come off the ground followed by the rear legs. You see horses do this when leaping over hurdles. While cats, dogs and other living quadrupeds can do this, I have only seen this employed in two robots. Most robots are not programmed for it, and might not have the strength to accomplish the move anyway.

Hope there is something there that may help in your future design mods.


Yes, "quadruped" is the correct word and means any four footed creature /animal.  "Quadropod" may get the point across, but is an "unofficial" word (ie slang), which is usually used in connection with inanimate things such as four-legged camera "tripod"s. (a conflict in terms to be sure.)

I wish I had read such info before I made my quadruped (I will change that in the title!). My chrismas holiday was spent trying to make 35 hours of mechanical preparations walk. (milling those brackets takes a long time but I thought it would be much cooler to make them myself since I own a milling machine and brackets from like lynxmotion are expensive)

Next time I make the legs a bit different. These legs come from the ground in the same direction as the robot walks, foward or backward. I think robot Cane had a better design where the legs come off the ground to the left or right respectively. This gives less friction.

Hi robodve. Nice bot, i like it. You can share your code when you go to EDIT your project and then choose the last line "File Attachments"...just upload it and it will appear under your introduction.

Tnx Lumi that was it, I've looked over this link I guess...

You are welcome. Frankly I also had to search again, even I did use it already for my projects. It should be more dominant ... but maybe it will in LMR v4 ;-)

its very hidden but its also very important!


I love the look of this robot.  The blue glow coming out from the bottom of it is very sexy.  Its pretty fast to.  Great job!  -Hal (kingart3)

Tnx Kingart3! I got some space left in the glass body for 4 more leds. I'm thinking of bright red ones so I can make the robot turn red when it encounters an object or error!