Introduction: Servo Controlled Labyrinth
Do you know this classic wooden labyrinth game with two knobs for X and Y rotation?
So, I've decided to modify one by connecting two standard servos to the knobs and let a microcontroller (ATmega32) play the game.
- To CarlS www.instructables.com/id/Servo-Controlled-Marble-Maze/ for inspiration.
- To the AVR freaks www.avrfreaks.net especially Dean (aka abcminiuser) for his excellent tutorials.
Please, feel free to write ideas for improvements and modifications.
Step 1: Materials, Parts and Tools
I found all the materials for this project laying around at home and there were no plans nor designing. I just took the materials and thought how I can assemble them altogether.
You can use other materials and basically it's a good practice to design and make plans beforehand.
1 wooden Labyrinth - 280/230/60 mm
1 wooden board - 400/350/20 mm
4 pieces of wood – 30/30/10 mm
2 pieces of wood - 150/155/10 mm each
2 pieces of wood, L shaped – 120/27/4 mm each side
4 pieces of wood, L shaped – 34/32/8 mm & 18/32/8 mm each
600 mm long strong silk string
8 pieces of rubber – 30/30/1 mm each
4 L brackets, stainless steel – 32/32/1.5 mm each
8 bolts (40/5 mm) with nuts and washers
A bunch of small wood screws and nails
a piece of paper, A4 for example
2 Hitec HS-311 Standard servos
AVR ATmega32 and a programmer – I use the AVR-LIP (EC-AVR) by DeccanRobots
2 straight switch knobs
Some wires and pins
saw, screw-driver, hammer, sharp knife, scissors, clamp etc.
Step 2: Labyrinth Modifications
Cut the servo horns (#13 R-D) just to make it symmetrical and use a hot glue to connect it to the switch knobs (90 deg. to the knob's pointer).
Replace the two wooden side knobs with these switch knobs in order to calibrate the labyrinth easily.
To improve the strings/bars friction, replace the two nylon strings with a strong silk string and put some contact adhesive around the steel bars.
Put insulating tape on the inner side of each labyrinth's hole and round pieces of paper on the outer side so the ball will stay on the board as long as you test the game.
Step 3: Servo Modules
Each servo sits in its own holder and each such servo module connects to the main board with bolts, nuts and washers. This way it's easy to adjust the servo to the labyrinth knobs.
Just follow the attached photos and you'll understand how to assemble it all.
Now, few things:
- Don't drill holes for the servos before you know the proper height acording to the knobs.
- You will have to make room for the servo's cable, do it carefully.
- Drill the holes on the main board much wider than the bolts of the servo modules.
Finally, Add the two long wooden "L" to the main borad.
Step 4: The Controller
A standard servo operates at 50Hz which means it needs to get a pulse at its control line (Hitec - the yellow one) every 20ms.
The width of the pulse in its active state (duty cycle) determines the angle of the servo.
This modulation of the pulse width known as PWM - Pulse-Width Modulation.
1.25 ms - 0 deg.
1.50 ms - 90 deg.
1.75 ms - 180 deg.
The best method - correct me if I'm wrong - to create PWM with ATmega for two servos is by connecting the 1st servo to OC1A and the 2nd one to OC1B and program each of these timers to output PWM.
Now, the development board I have and use is AVR-LIP (ECAVR) and OC1A and OC1B are already taken by the LCD and by the piezo buzzer.
So - with the help of [frakk2136] www.avrfreaks.net/index.php - I used different method.
I programmed OC1A to produce fast PWM and used interrupts while the servos are connected to PA4 & PA5.
You'll have to modify the code according to your system.
Three versions here:
The game automatically played according to a set of instructions.
The code works great, but the labyrinth mechanism just cannot be calibrated well enough.
Now, add some physical factors like gravity, friction, tension (especially this X-factor) etc. and, well, sometimes the ball fall into this hole and sometimes to that one.
The microcontroller gets instructions from the PC keyboard (arrow keys) through the serial port.
The AVR-LIP works at 4Mhz so the maximum baud-rate that it can handle with no errors is 19200 which is too slow and not so comfortable.
Four switches are connected to the AVR.
[ X ] Analog Joystick
[ X ] Digital Joystick
[ X ] Accelerometer
[ V ] Switches
[ X ] Computer Vision
* ([ X ] | [ V ] = Status)
We have a be nice policy.
Please be positive and constructive.