BalancingRobotArduino
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:This is the Arduino version of the code for my balancing robot/segway
#### Developed by Kristian Lauszus, TKJ Electronics 2012

The code is released under the GNU General Public License.
_________

# This project is deprecated

This project is no longer maintained as I will instead focus on a Balancing robot kit, the Balanduino. For more information see the new repository:  and the Kickstarter campaign: .


This is the code for my balancing robot/segway. It's a ported version of the code for the mbed board which I original used. The original code can be found at the following link: [https://github.com/TKJElectronics/BalancingRobot](https://github.com/TKJElectronics/BalancingRobot). The code will work for all boards that features an ATmega328p (Duemilanove, Uno, Pro, Pro Mini etc.) - it's not directly pin compatible with the larger Arduinos (Mega, Mega 2560 etc.) as I use the port registers to save processing resources - see [http://www.arduino.cc/en/Reference/PortManipulation](http://www.arduino.cc/en/Reference/PortManipulation). But just take a look at the pinMapping pages for comparison: [http://arduino.cc/en/Hacking/PinMapping168](http://arduino.cc/en/Hacking/PinMapping168) and [http://arduino.cc/en/Hacking/PinMapping2560](http://arduino.cc/en/Hacking/PinMapping2560) and figure the pins out yourself - for instance OC1A and OC1B are not located on pin 9 and 10, but at pin 11 and 12 on the Arduino Mega. I have used the registers to set up 20kHz PWM, Phase and Frequency Correct on pin 9 (OC1A) & pin 10 (OC1B) with ICR1 as TOP using Timer1 - see the [datasheet](http://www.atmel.com/Images/doc8025.pdf) page 128-135. I use a 6DOF IMU from Sparkfun: [http://www.sparkfun.com/products/10010](http://www.sparkfun.com/products/10010), though I only use one of the gyro axis, but any IMU can be used. For instance the very popular MPU-6050, see this [example code](https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/MPU6050/MPU6050.ino). For more info about calculating the pitch see my post at the Arduino forum: [http://arduino.cc/forum/index.php/topic,58048.0.html](http://arduino.cc/forum/index.php/topic,58048.0.html). For more information about the Kalman filter see my blog post: [http://blog.tkjelectronics.dk/2012/09/a-practical-approach-to-kalman-filter-and-how-to-implement-it/](http://blog.tkjelectronics.dk/2012/09/a-practical-approach-to-kalman-filter-and-how-to-implement-it/) and the source code: [https://github.com/TKJElectronics/KalmanFilter](https://github.com/TKJElectronics/KalmanFilter). To steer the robot, I use a [USB Host Shield](http://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino/) together with my SPP Bluetooth Library for Arduino: [https://github.com/felis/USB_Host_Shield_2.0/blob/master/SPP.cpp](https://github.com/felis/USB_Host_Shield_2.0/blob/master/SPP.cpp). More information can be found at the blog psot: [http://blog.tkjelectronics.dk/2012/07/rfcommspp-library-for-arduino/](http://blog.tkjelectronics.dk/2012/07/rfcommspp-library-for-arduino/). You can either use an Android app I wrote: [https://github.com/TKJElectronics/BalanduinoAndroidApp](https://github.com/TKJElectronics/BalanduinoAndroidApp) or the [Processing Application](https://github.com/TKJElectronics/BalanduinoProcessingApp) to control the robot. For information about the hardware, see the wiki: [https://github.com/TKJElectronics/BalancingRobot/wiki/Hardware](https://github.com/TKJElectronics/BalancingRobot/wiki/Hardware). Also check out the youtube video of it in action: [http://www.youtube.com/watch?v=N28C_JqVhGU](http://www.youtube.com/watch?v=N28C_JqVhGU) - this is actually the mbed version, but they behave the same way. For more information see my blog post at [http://blog.tkjelectronics.dk/2012/03/the-balancing-robot/](http://blog.tkjelectronics.dk/2012/03/the-balancing-robot/) or send me an email at kristianl@tkjelectronics.dk.

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。