Wednesday, May 15, 2013

Robotic Camera Turret Controlled by Wii Nunchuk via Arduino Uno!



Been VERY busy this last week.  I explored a little deeper into how to manipulate the real world using the Arduino Uno and a couple of servos.  The control is the 3-axis accelerometer from from a Wii game system. The remote actually does have a thumb controlled Joystick on top and although the video does not show it, I can swith over using the "C" button and control the turret using the joystick. The "Z" button rapidly lights a blue LED.

  To start, I ordered a Servo Turret kit from DFRobot, The 15kg one with the intention of actually mounting a paintball gun and a camera onto it.  It will hold a paintball gun and even a .22 Cal Revolver, but at the extreme angles you can hear the servos straining.  No delay in movement, but makes me uneasy that it could fail during use.  So that idea is going to have to wait till I can afford some larger, industrial  servos.
  The project started with we writing code for the servos and the wii nunchuk separately.  The servos were no problem, as simple as looking up commands and tweaking the setting.  For the nunchuk, I had nothing but trouble even trying to get the serial communications to work.  I tried dozens of example codes online and every possible tweaks and I just could not get it to communicate. The trouble was I tried to save a couple bucks, I bought an aftermarket controller thinking there could not be any difference.  There is a big difference in the actual programming of the aftermarket controllers.  Don't use them unless you want to reinvent the entire process!
  When I walked in with the Original Wii controller, all of my samples lit right up and had no problem!  One right after the other, almost all of them worked.  The sample I decided to use was one that is recently posted on the Arduino site, not because it is the best, but because it is so close to the hardware I am using.  This one includes sample code from most of the others I had tried, so it is an accumulation of the best pieces of each. It didn't just run straight out of the box, had to spend a couple days rewriting it for my purposes as well.  For the most part, Raymond Willis Jr. did most of the hard work for me! Thank you Raymond!
  I don't think this project will go much further than cleaning up the wires and eventually incorporating it into the project for the Raspberry Pi to Host. I need to smooth it out a bit, not so damned responsive and of course connecting it to a remote operator via a radio of some description.  So it's not the end of this project, it looks like it will be built upon in the future.   As it is, it would be very useful on a Robot with a remote control to a camera or a weapon.
  For others doing similar things, the problems I ran into... The Wii Nunchuk, absolutely spend the extra $4 and go with the real deal.. it makes a BIG difference! Secondly, one servo worked great, the second one took the entire system down.  Both servos became jittery and were uncontrollable to the point of no control.  This problem was a power issue.  If you are going to run servos, run them on their own power.  Any problem with a servo?  Check it's individual power!  Low power to a servo can make just about anything happen... weird behavior from the board, jittery to no movement/control... it could be that there is not enough power to run the servo/system together... so just start by running the motors on their own power. (be sure to ground it to the common ground!)
  I have a couple sets (4 total) 12 volt, geared motors that I salvaged from the children's ride on toys.  My son had these when he was a kid and you could not stop him.  I have always thought they would be perfect for an autonomous vehicle. That is where I am eventually headed, so this weeks project and the lessons learned will definitely help out in that regard. Everything will be used for this one.  Except it is going to be Run by the Raspberry Pi and a couple Arduinos might be used for motor and sensor control. Well, that's an upcoming post, but wanted to let people know where this is headed.
Pi Hard! (With the Arduino...)

No comments:

Post a Comment