Hi all,this post is an "how to" for an Arduino pan and tilt camera moved by a Nintendo Wii Nunchuck.Here's the video so you can check how it'll be the result. The most important thing is the precision and responsiveness of the system.Here it is for all that asked me in the past and for those interested in putting something similar in their UAVs.It's an "old" project I've posted the following video on YouTube more than a 5 months ago but never had the time to post schematics and the code online, even if a lot of people asked for it.I use an Arduino Diecimila board to have a Nintendo Wii Nunchuck control a camera mounted on a pan and tilt mechanism with two servos (Hitech HS-422).Nunchuck's accelerometer (an ADXL330) is used to move the camera.As you can see, if the Nunchuck's "Z" button is pressed, the camera position is locked.Here is picture of the pan&tilt mechanics with servos:
The code is here.You can find more infos about the code in the two links I mentioned before, but feel free to ask.The only section you should customize to adapt to your servos an need is a list of variables:refreshTime (set to 20) - minimum refresh time for servo pulseminPulse (set to 1000) - minimum pulse value for servo 1minPulse2 (set to 500) - minimum pulse value for servo 2dtime (set to10) - delay (in milliseconds) for each looppwbuffsize (set to 10) - how many values has to be buffered and the averaged (that's the same value for both servos)Next post will be regarding the evolution of that interface: changed camera and servos with a smaller and ligher one (this one) and made the connection between the Nunchuck and the camera, wireless.Hope that can be helpful and feel free to ask anything about that.Thank you and ciao,Andrea
Can't we modify the code? Instead of using pinout 6 & 7 output 2 single servo pulse for controlling 2 servos,we use pinout 6 or 7 ONLY to send out a series of 8 channel pulse train(channel 7 & 8 for camera pan & tilt controls).then we can hook it up to Futaba remote with trainer connection .We can build our own head tracking camera control for FPV piloting.
Can someone answer the above post please? I am having the same problem with vista.
I get the error message:
Couldn't determine program size: C:\Users\albert\Desktop\arduino-0011\hardware/tools/avr/bin/avr-size: 'C:\Users\alber\AppData\Local\Temp\build3482.tmp\wiinunchuck.hex': No such file
hi I am trying to duplicate what you are doing it is very cool. I am new to this and I can't figure out how to get the code to upload to the arduino. It keeps giving me messages like this
"/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:266: error: expected unqualified-id before 'int'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:266: error: expected `)' before 'int'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:266: error: expected `)' before 'int'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:267: error: expected unqualified-id before 'int'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:267: error: expected `)' before 'int'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:267: error: expected `)' before 'int'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: '__put' was not declared in this scope
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: expected primary-expression before 'char'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: expected primary-expression before 'struct'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: '__get' was not declared in this scope
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: expected primary-expression before 'struct'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: initializer expression list treated as compound expression
Couldn't determine program size: hardware/tools/avr/bin/avr-size: '/Users/IanCivgin/Documents/Arduino/sketch_080619a/applet/sketch_080619a.hex': No such file
avrdude: can't open input file /Users/IanCivgin/Documents/Arduino/sketch_080619a/applet/sketch_080619a.hex: No such file or directory
avrdude: write to file '/Users/IanCivgin/Documents/Arduino/sketch_080619a/applet/sketch_080619a.hex' failed"
Help would be greatly appreciated. If there is an error in your code or if you know how to fix it just let me know.
I'm sorry. I got problems in cutting and pasting the code. Some parts of the code is cutted by the blogging platform.
I'll put on my website to be dowloaded.
Thanks,
Andrea
9: error: #include expects "FILENAME" or In function 'void setup()':
In function 'void nunchuck_init()':
In function 'void send_zero()':
In function 'void loop()':
In function 'void printNunchuckData()':
In function 'void muovi()':
i get all these errors when i try to compile the code?
Appreciate the response! I will definitely let you know. And if you have any other suggestions on good video/still cameras (and if any have decent zoom capability), please let me know. I'm currently looking into ways to automatically identify herd animals in various terrain and zoom in to conduct herd counts as well as basic physical assessments. Cheap is good, but for my own learning curve, any info would help. I have only basic electronics and programming experience...most of my experience is in health, veterinary medicine, and web-based applications.
the lock inplace has been implemented as at first the pan&tilt camera was meant to be installed on a qudricopter, so able to stand still (almost) at a certain position. And in that situation the "simple" lock of the camera does the trick.
But for airplanes it's totally different. You want a "lock on target" and it's definetly not an easy thing to do with cheap equipment.
But if I'd have a low budget to implement something similar you have to do use a different equipment.
First you have to put a 360° servo at the base (for panning). If you think to install the mechanism at the bottom of the airplane (best position for lock-on-target camera) you should do the same for tilting servos as well.
Second, you should use an intelligent camera. A programmable one, as the CMUCam3 for example. Face recognition/following algoritms has been already developed and I think it can be possible to do the same for a lock-on-target one at certain conditions for the target, as colour, speed etc.
It would be very interesting to develop such a system. I'm not going to do for my UAV, not for now :)
Hope to have helped you and if you decide to develop something similar let me know, and let me know how I can help you,
Comments
I get the error message:
Couldn't determine program size: C:\Users\albert\Desktop\arduino-0011\hardware/tools/avr/bin/avr-size: 'C:\Users\alber\AppData\Local\Temp\build3482.tmp\wiinunchuck.hex': No such file
Thanks
"/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:266: error: expected unqualified-id before 'int'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:266: error: expected `)' before 'int'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:266: error: expected `)' before 'int'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:267: error: expected unqualified-id before 'int'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:267: error: expected `)' before 'int'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:267: error: expected `)' before 'int'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: '__put' was not declared in this scope
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: expected primary-expression before 'char'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: expected primary-expression before 'struct'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: '__get' was not declared in this scope
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: expected primary-expression before 'struct'
/Applications/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdio.h:420: error: initializer expression list treated as compound expression
Couldn't determine program size: hardware/tools/avr/bin/avr-size: '/Users/IanCivgin/Documents/Arduino/sketch_080619a/applet/sketch_080619a.hex': No such file
avrdude: can't open input file /Users/IanCivgin/Documents/Arduino/sketch_080619a/applet/sketch_080619a.hex: No such file or directory
avrdude: write to file '/Users/IanCivgin/Documents/Arduino/sketch_080619a/applet/sketch_080619a.hex' failed"
Help would be greatly appreciated. If there is an error in your code or if you know how to fix it just let me know.
Thanks
I'll put on my website to be dowloaded.
Thanks,
Andrea
In function 'void nunchuck_init()':
In function 'void send_zero()':
In function 'void loop()':
In function 'void printNunchuckData()':
In function 'void muovi()':
i get all these errors when i try to compile the code?
you can download a "starting guide" about arduino and arduino programming from here (pdf) and here (pdf).
Those docs are a very good start for Arduino microcontroller.
Otherwise I can suggest you books like "Making Things Talk" and "Physical Computing: Sensing and Controlling the Physical World with Computer" by Tom Igoe.
Online there are a lot of infos... I suggest you to start with that links:
http://todbot.com/blog/bionicarduino/
http://www.ladyada.net/learn/arduino/
http://www.freeduino.org/
http://itp.nyu.edu/physcomp/Tutorials/Tutorials
I think that should be enough for now :)
Let me know if I can help you somehow.
Andrea
Appreciate the response! I will definitely let you know. And if you have any other suggestions on good video/still cameras (and if any have decent zoom capability), please let me know. I'm currently looking into ways to automatically identify herd animals in various terrain and zoom in to conduct herd counts as well as basic physical assessments. Cheap is good, but for my own learning curve, any info would help. I have only basic electronics and programming experience...most of my experience is in health, veterinary medicine, and web-based applications.
Thanks again!
C
the lock inplace has been implemented as at first the pan&tilt camera was meant to be installed on a qudricopter, so able to stand still (almost) at a certain position. And in that situation the "simple" lock of the camera does the trick.
But for airplanes it's totally different. You want a "lock on target" and it's definetly not an easy thing to do with cheap equipment.
But if I'd have a low budget to implement something similar you have to do use a different equipment.
First you have to put a 360° servo at the base (for panning). If you think to install the mechanism at the bottom of the airplane (best position for lock-on-target camera) you should do the same for tilting servos as well.
Second, you should use an intelligent camera. A programmable one, as the CMUCam3 for example. Face recognition/following algoritms has been already developed and I think it can be possible to do the same for a lock-on-target one at certain conditions for the target, as colour, speed etc.
It would be very interesting to develop such a system. I'm not going to do for my UAV, not for now :)
Hope to have helped you and if you decide to develop something similar let me know, and let me know how I can help you,
Andrea
-
1
-
2
-
3
of 3 Next