The only code I had was the math for the inverse kinematics. Which actually is not that hard, there are lots of websites that explain how it works. My biggest problem was coding the walking gait. I first wrote a sketch using a for loop and the delay function to move the servos. That was pretty easy. But when you want the micro controller to do a bunch of other things you're in trouble. So I tried dozens of ways to code the gait using the millis timer, after a dozen revisions of my code I finally got it right. I did look at the Lynxmotion code before I built my hexapod, but it's pretty complex. I can't understand much of it. I name it a monster because it uses so much current. I once tried to power it without the UBECs, and connected the servos directly to my lab power supply. I saw the current shoot up to almost 20A. I'm using very cheap metal geared servos (standard size), Towardpro MG996r servos. They cost less then 5€ a piece and have +10kg/cm torque.
My hexapod has an autonomous mode and a remote controlled mode. In the autonomous mode it can track an IR light source using the WiiCamera sensor and avoid obstacles which it detects with 2 ultrasonic sensors. In the remote controlled mode I can let it walk in every direction. I also have a mode to move the body without moving the tips of the legs, this is where inverse kinematic comes in very handy. I also programmed a “fitness mode” where the hexapod lift 3 legs of the ground and moves them up. In the last mode I can control each leg individually, you can see this in the last part of the video. My code is far from perfect, but it works It was not easy to program all these things and let it all work together.
This is a list of parts that I have used in my hexapod:
Hexapod chassis kit (bought on Ebay) 3x laser cut acrylic plates (made by local shop) 6x bearings (to mount the underside of the servo brackets) Acrylic ultrasonic sensor bracket (bought from Rocket brand studios) Pan/tilt kit (for WiiCamera sensor, bought from Rocket brand studios) 18 metal servo horns Lots of M3 nuts and bolts
18x MG996R servos (bought on Ebay) 3x SG90 servo (to move the sensors, bought on Ebay)
3x 8A UBECs (bought from Hobbyking) 3S 3000mAh Lipo battery (powers the 18 MG996R servos) 2S 1000mAh Lipo battery (powers the 3 SG90 servo and sensors) 20A automotive blade fuse (protects 3S Lipo battery, bought on Ebay) In line fuse holder + 1A fuse (protects 2S Lipo battery) Servo power distribution PCB (own design, made by Seeedstudio) Seeeduino Mega2560 ATmega328 board (own design, made by Seeedstudio) nRF24L01 module (wireless control, bought on Ebay) 2x HC-SR04 ultrasonic sensors WiiCamera sensor (bought from Rocket brand studios) 2 x 74HC595 shift registers (to control the 16 leds) 18 blue leds 18 220 Ohm resistors 4 resistors for 2 voltage dividers (analog reading of the 2 Lipo batteries) Perfboard, lots of wires LM2596 PCB (powers the 3 small servos, leds and sensors, bought on Ebay)
I reused the remote control (based on an Uno, joystick shield and nRF24L01 module) from previous projects. This project cost me quite a bit of money. During the building of Bajdupod 996R one servo burned up. Yes only one, I can assure you these servos have had a very hard time. So I am quite surprised that I did not burn up more servos.
Quite a bit of time and money was spent on powering this hungry beast. I initially used 2 8A UBECs and killed them pretty fast. Then I bought 3 more 8A UBECs and designed a new power servo PCB. Then I destroyed a 3S 3000mAh Lipo battery. I had to recharge the battery so many times that the Lipo charger died on me. Luckily I had 2. The hexapod eats Lipo’s for breakfast, lunch and dinner. The battery lasts less then 10 minutes.
Coding this beast has taken up most of my free time the last couple of months. I would have never thought I would be able to program such a complex project one year ago. I have only been playing with Arduino for one year and a halve, before that I had never written a line of code. I’ve never taken any programming courses, everything I’ve learned comes mainly from lots of trying and testing. I can assure you it took me lots of dedication and hard work to accomplish what you see in the above video
De Arduino 5V regulator (ncp1117st50t3g) kan maar 1A max leveren. Ik zou het nooit zover laten komen. En daar moet alles van de arduino van gevoed worden. Dus ik zou ook een aparte voeding maken voor motoren ed.
Die 1A in de datasheet moet je wel juist interpreteren. Die ncp1117 is een lineaire spanningsregelaar. Als de voedingsspanning bijvoorbeeld 9V is en die regelaar moet 1A stroom geven dan zal die regelaar 4W (4*1)aan warmte produceren. Die ncp1117 op de Arduino is een kleine SOT223 package, die kan nooit zoveel warmte dissiperen. Afhankelijk van de voedingsspanning ga je best niet boven de 200-300mA anders zal die regelaar snel zeer warm worden.
I also have 2 of those VS1003 modules. I've found several Arduino libraries and code for that module but I can not get it to play an mp3 from an SD card. I can get it to work in midi mode though with the library from Maniacbug. (Maybe we should start a new topic about the module.)
I have built a couple of hexapods, so have some experience controlling lots of servos. I would suggest you don't use a for loop and totally forget about the delay function. I just use the millis function. It is not that hard, just take a look at the blink without delay example in the IDE.