Welcome
Username or Email:

Password:


Missing Code




[ ]
[ ]
Online
  • Guests: 28
  • Members: 0
  • Newest Member: omjtest
  • Most ever online: 396
    Guests: 396, Members: 0 on 12 Jan : 12:51
Members Birthdays:
One birthday today, congrats!
Simon Barsinister (63)


Next birthdays
05/24 Simon Barsinister (63)
05/27 Daniel Davis (54)
05/29 Zonalklism (34)
Contact
If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.


Special Thanks To:
  • Aaron Holmes
  • Aaron Wheeler
  • Adam Horden
  • Alan Scrimgeour
  • Andre
  • Andrew Haynes
  • Anonymous000
  • asabase
  • Austin Weil
  • barney
  • Barry
  • Bert Hickman
  • Bill Kukowski
  • Blitzorn
  • Brandon Paradelas
  • Bruce Bowling
  • BubeeMike
  • Byong Park
  • Cesiumsponge
  • Chris F.
  • Chris Hooper
  • Corey Worthington
  • Derek Woodroffe
  • Dalus
  • Dan Strother
  • Daniel Davis
  • Daniel Uhrenholt
  • datasheetarchive
  • Dave Billington
  • Dave Marshall
  • David F.
  • Dennis Rogers
  • drelectrix
  • Dr. John Gudenas
  • Dr. Spark
  • E.TexasTesla
  • eastvoltresearch
  • Eirik Taylor
  • Erik Dyakov
  • Erlend^SE
  • Finn Hammer
  • Firebug24k
  • GalliumMan
  • Gary Peterson
  • George Slade
  • GhostNull
  • Gordon Mcknight
  • Graham Armitage
  • Grant
  • GreySoul
  • Henry H
  • IamSmooth
  • In memory of Leo Powning
  • Jacob Cash
  • James Howells
  • James Pawson
  • Jeff Greenfield
  • Jeff Thomas
  • Jesse Frost
  • Jim Mitchell
  • jlr134
  • Joe Mastroianni
  • John Forcina
  • John Oberg
  • John Willcutt
  • Jon Newcomb
  • klugesmith
  • Leslie Wright
  • Lutz Hoffman
  • Mads Barnkob
  • Martin King
  • Mats Karlsson
  • Matt Gibson
  • Matthew Guidry
  • mbd
  • Michael D'Angelo
  • Mikkel
  • mileswaldron
  • mister_rf
  • Neil Foster
  • Nick de Smith
  • Nick Soroka
  • nicklenorp
  • Nik
  • Norman Stanley
  • Patrick Coleman
  • Paul Brodie
  • Paul Jordan
  • Paul Montgomery
  • Ped
  • Peter Krogen
  • Peter Terren
  • PhilGood
  • Richard Feldman
  • Robert Bush
  • Royce Bailey
  • Scott Fusare
  • Scott Newman
  • smiffy
  • Stella
  • Steven Busic
  • Steve Conner
  • Steve Jones
  • Steve Ward
  • Sulaiman
  • Thomas Coyle
  • Thomas A. Wallace
  • Thomas W
  • Timo
  • Torch
  • Ulf Jonsson
  • vasil
  • Vaxian
  • vladi mazzilli
  • wastehl
  • Weston
  • William Kim
  • William N.
  • William Stehl
  • Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Forums
4hv.org :: Forums :: Projects
« Previous topic | Next topic »   

AVR 2-Servo Walker

Move Thread LAN_403
flannelhead
Tue Feb 10 2009, 01:01PM Print
flannelhead Registered Member #952 Joined: Mon Aug 13 2007, 11:07AM
Location: Finland
Posts: 388
I decided to post my little non-HV side project, a walking robot.

1234263085 952 FT0 Overview2

I still don't have a website of my own, so this post is written in quite good detail. However, there's also a shorter description for those who don't want to read all the technical stuff.

Short explanation
The robot is controlled by a ATtiny2313 microcontroller, which can be programmed from a computer. ATtiny2313 seemed quite a good choice for the purpose because of its low price and a 16-bit timer with two outputs capable of doing a PWM signal -> just enough to control two servo motors. The robot moves forward by moving its legs as pairs (front legs, rear legs). The legs are moved by regular RC model servo motors. The controller sets the positions of the servos with a PWM signal.

Youtube video: Link2

In detail

Electronics
1234263085 952 FT0 Circuitry
The circuit board in the picture above is the brain of the bot. Notice that there are quite few components on the board. I like Atmel AVR microcontrollers quite a lot, because they don't need too many surrounding components. In fact, even the resistors could be left out. They're there to protect the parallel port from getting damaged in case something shorted out on the circuit board. Notice the black connector. It is the programming connector. I didn't want to include a big parallel port connector on the board, so I made this kind of a programming cable:
1234263085 952 FT0 Cable
It connects the 5 pins needed for programming to the right pins of the parallel port. They can be seen in the schematic below.
1234263085 952 FT0 Schem
There's nothing special about the schematic. The usual colour coding of servo motor cables is:
red: +
black: -
yellow or any other colour: PWM

Mechanics
The chassis of the robot is made out of plexiglass. I chose it mainly because it looks cool, but it also provides a solid base for mounting the servos. It was quite easy to machine. Bending was done by heating it with a hot air gun.

The legs are made out of coat hangers. My leg design is far from optimal, but works well enough for me. The legs are attached to the servo shafts like this:
1234263085 952 FT0 Leg Attach
Notice the blue heatshrink tubing in the tips of the legs in the first picture. It is needed to prevent the legs from slipping. They still slip a bit so perhaps I'll have to invent something better.

Programming interface
One advantage of the AVR chips is that they can be programmed while they're in their actual circuit. So no more need to take the chip out of its socket for programming. In this project I am using 'dapa', direct parallel port programming, which is quite outdated but still works well. I tried serial programming, but it ended up with some verification errors, maybe caused by my USB-to-serial programmer. There are a plenty of different interfaces for programming AVRs. Ladyada has some excellent articles about programmers and programming: Link2 Link2
The whole AVR tutorial is also recommended reading.

Actual programming and firmware
1234263085 952 FT0 Chip
So how do you actually program a microcontroller? First, you need to choose a programming language. If we are going to use open-source software, we are limited to C and asm. C suits well for this purpose because of its easily understandable syntax and effectiveness. We need a special compiler, called avr-gcc. Linux users can just install packages avrdude, binutils-avr, avr-libc and gcc-avr from the package repository. Windows users will have to download and install WinAVR which should contain everything you need.

What does real AVR code look like? Here's an example:

TCCR1A=(1<<COM1A1)|(1<<COM1B1)|(1<<WGM11);
TCCR1B=(1<<WGM13)|(1<<WGM12)|(1<<CS10);
This is what it's all about. Registers and bit manipulation. Don't be scared by the cryptic letter combinations, they will be all explained in the ATtiny2313 datasheet. It really isn't that complex at all.

]Download the source files[/file]

So how do you control a servo motor?
A servo motor needs a 50Hz PWM signal with pulsewidth varying from 1 to 2 milliseconds. 1.5ms is where the shaft is at its center position, 1 and 2 ms are the extreme positions. So all that the program has to do is to rotate the servos from side to side.

The sourcecode has to be first compiled with avr-gcc. Then it is converted to Intel HEX (ihex) format with avr-objcopy. Then the hex file, containing the firmware, is uploaded to the chip with avrdude. I've wrapped this procedure in a makefile, so anyone building this robot won't need to worry about that part.

Did you read this far? Congratulations! Now go to build your own robot, it's pretty easy and a great fun. smile

TODO
  • better grip for the feet
  • improve walking routine

I am currently developing light sensors for the robot, so it can be programmed to be afraid of light or seek light, you decide tongue

Links - further reading
ATtiny2313 datasheet
Ladyada's AVR tutorial Also check out the projects section

If you have any questions, feedback, comments, ideas for improvements, feel free to ask! I'll do my best to make this article easy to understand.
Back to top
3l3ctrici7y
Tue Feb 10 2009, 02:18PM
3l3ctrici7y Registered Member #1806 Joined: Sun Nov 09 2008, 04:58AM
Location: USA
Posts: 136
That looks pretty cool :)

Pencil eraser refills might work as feet to reduce the slip. A spot of glue could be used to hold the eraser in place on the tip of the leg.
Back to top
aonomus
Tue Feb 10 2009, 03:23PM
aonomus Registered Member #1497 Joined: Thu May 22 2008, 05:24AM
Location: Toronto, Ontario, Canada
Posts: 801
Or alternatively just a big gob of hotmelt glue....

Nifty walker, do you have any other plans such as sensors, or is this just a tiny toy for kicks?
Back to top
flannelhead
Tue Feb 10 2009, 03:31PM
flannelhead Registered Member #952 Joined: Mon Aug 13 2007, 11:07AM
Location: Finland
Posts: 388
aonomus wrote ...

Nifty walker, do you have any other plans such as sensors, or is this just a tiny toy for kicks?
I'm planning to equip him with light sensors, so it could be made to seek light or be afraid of light.
Back to top
Tom540
Tue Feb 10 2009, 05:29PM
Tom540 Banned on 3/17/2009.
Registered Member #487 Joined: Sun Jul 09 2006, 01:22AM
Location:
Posts: 617
Hey that's cool, I used to be all about this kind of stuff. Pretty much were I started in electronics. Mine were mostly BEAM though.

I see you already got heat shrink on the feet. What I used to do is bend the ends of the legs backward so they are kind of like barbs and will dig in more when the bot pushes back but wont get stuck when moving the other direction. If you know what im trying to say. I can post a pic later.

-Tom
Back to top

Moderator(s): Chris Russell, Noelle, Alex, Tesladownunder, Dave Marshall, Dave Billington, Bjørn, Steve Conner, Wolfram, Kizmo, Mads Barnkob

Go to:

Powered by e107 Forum System
 
Legal Information
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.