So this happened a while back but I haven’t found time to blog about it until now. My friend and I finished off the Nerf Auto-Turret and it has had been remarkably successful by all accounts.
For some reason, the turret wasn’t rotating as well as it had been so we took action to make rotating more efficient. The main change, other than some more grease, was to replace the six D batteries with four AA batteries. The batteries in question are responsible for powering the firing mechanism and as you’d expect, with a lower voltage, the mechanism took longer to fire (0.7s up from 0.2s) but it still fired in an acceptable time for our purposes. We also hot-glued a pulley in place to regulate the belt tension, rather than using the previous method.
I have very little to report about the facial recognition software other than that it was implemented rather quickly and was mainly composed of open-source libraries.
One final tip before the video of the finished project: if you want a pin on an arduino to behave like an input then you had better make that clear to the arduino!
If you have any questions about this project, don’t hesitate to get in touch via the comments!
I haven’t had much time to work on the turret today as I’ve been mountain biking (first time!) and have therefore only had a few hours to spare on it. Nonetheless, progress has been made and so, a blog post must also be made.
Again, the progress has been mainly coding. I’ve re-written the clockwise and anticlockwise functions for the Nano to avoid using delays. See this page for why that might be beneficial. I have also discovered and started using interrupts! I’ve got two interrupts now, one for allowing rotation (hooked up to an SPDT switch) and one for sending the wireless firing commands (hooked up to an SPST switch and a pull down resistor). The only problem with using interrupts is that they are hardware driven. Eventually, the firing and rotation functions will be called purely by commands sent over a serial line. This means the way in which the functions are called will need to be re-thought later on, but for now, the system is working well.
One consideration for the future is how the turret rotates. At the moment, the rotation function has an input argument which is the time for which the gun should rotate in a particular direction. The function handles the stopping of the rotation too. When finished, the current plan is for the turret to ‘scan’ in a given direction until a target is found, then stop and track. This means the duration of the rotation doesn’t really matter. My current thoughts on that matter are to have a function which sets the gun to rotating indefinitely and then one to stop rotation. The current speed of rotation is probably too fast to enable reliable camera scanning so it might need slowing down but that won’t be a problem as the motor is supplied from a variable voltage supply.
That’s all for now. I’ve got a busy schedule for the next two weeks to progress will be very slow indeed.
Today the Arduino Nano arrived and I was finally in a position to start working on the wireless control of the gun.
The wireless transmitter and receiver kit I have proved problematic when transmitting serial data from one to another. I have no idea why I can’t get it to work but instead I have used a different solution: pulses of different length.
So far, the only pulse needed is one to fire the gun and I have that configured up and working reliably. There is little to show for all the work I’ve done as most of it has been purely coding (not my strongest suit).
Until Mr CompSci returns home for his holiday, there isn’t all that much to do now. I suppose the rotation needs to be driven by commands given over serial. Now I look at it, the display on the gun had stopped updating properly so that needs looking at also.
So for now, this is more or less it. More updates to follow when work is started on the image processing.
My recent lack of activity is down to the fact I was cycling the Coast to Coast, but the day before I left, I did make some progress, at least with the design.
I have finally solved the problem of interfacing rotating components with static ones. Before I explain the solution, I should make clear exactly what is required of each part of the assembly:
Rotating parts: These control firing and measure distance-to-target and angles of rotation. Basically, everything attached to and including the gun.
Static parts: These control the rotation of the gun. Basically the motor driving the rotation of the gun and the image processing laptop.
Now, given that the final build will have a wireless camera (probably a mobile phone) fixed to the gun RIGIDLY* i.e. no relative rotation between the camera and the gun, there is actually no need for the static parts (motor controller) to know about the actual angle of rotation. The final system, camera included, will have a stationary laptop telling the motors to move the gun in order to scan, and then, once a target is identified, tell the motors to stop or track or whatever. From here, once a target has been identified, all that needs to happen is the rotating parts (gun) are told to fire. This means only one-way communication is required. Also, messages can be sent to the rotating parts to update the display which would be a nice touch.
So, after the calamities of Day 3, today has been less frustrating. Sadly, I am still waiting for the Arduino Nano to arrive. The nano will be used to control the motors and to send instructions to the gun as described previously. I’ve wired up the distance sensor, tidied up the code and the display a little. I also got the gun to fire via the Arduino by replacing the 12V relay with a 5V one from the board of broken relays. I’ve wired up the wireless parts as best I can without having the Nano. It was supposed to arrive on Monday, and still hasn’t arrived but after a short chat with my friend Sunny at Amazon Customer Care, I should have one very soon and therefore start making more progress very soon.
*I am aware that the original specification stipulated for relative rotation between the gun and the camera, but the decision has been made to override this because it wouldn’t really add anything. If there is time maybe I will look at adding it back into the design.
How should I sum up today’s efforts? Did you ever have one of those days where you spend lots of time working on something but pretty much everything you do either makes things no better, or actually makes them worse? Well today was one of those days.
About the only thing I managed to do was cable tie the Arduino to the gun. I spent hours calibrating the accelerometer trying to get it perfect. I got a reasonably good result, but certainly not perfect. I then moved on to
linking up the measured rotation with the motor control. At this point, I ran the same script from yesterday to test the motor (just pulsing clockwise and anticlockwise) and neither of the relays would energise. I then spent more hours (literally hours) trying to make these two stupid relays work.
So I tried to get the trigger contacts wired up to another relay (one I recovered from an old washing machine circuit) and then realised the coils wouldn’t energise with the 5V from the Arduino…
So I had a small cry, complained to the people who sold me the relays that seem to have mysteriously broken, and that is about it for things I have successfully done today.
In terms of functionality, there isn’t that much to be done:
Write a function to move the gun to a given orientation.
Make the circuit for this (requires functioning relays)
Incorporate distance sensor into code.
Sort out trigger relay
After that is done, it is basically just waiting to incorporate the facial recognition stuff and start expanding functionality. Perhaps add a second axis of rotation.
As I mentioned at the end of the last post, one of today’s jobs was to wire in another switch contact so that the gun could be fired without actually pulling the trigger. This wasn’t actually as much hassle as I had feared but it wasn’t exactly easy. After taking off the extremities such as the cocking handle, the carrying handle, and the firing chamber cover, I noticed that the switch in question was located behind the bulk of the firing mechanism and not simply directly behind the trigger as I had hoped.
So I set to removing the firing mechanism. This proved surprisingly easy and the whole thing simply lifted out after removing a few mounting screws. From here it was a relatively small job to solder on a wire to each switch contact. I also made a small hole in the base of the handle so that the wires could make a discreet exit from the innards of the gun. I replaced the firing mechanism and the cover and even managed not to have screws left over at the end!
Following this I did a small test to ensure I has actually brought out the right contacts and proof, if my word isn’t good enough, can be found in the video below.
As a small aside, I also mounted the LCD screen and the small breadboard. Soon it will be used for status readouts e.g. ammo remaining. The breadboard will be used to mount the ultrasonic distance sensor and accelerometer.
By far the most time-consuming task of today was figuring out a way of mounting the motor in place. I tried a lot of different ways, some better than others, but the one that finally worked reliably is shown below. You might notice some paper wedged in there to finetune the belt tension. Furthermore, there is a cable tie between the beam holding the motor and the beam across two of the tripod legs; this is to adjust the belt angle and keep it horizontal.
Finally, I wrote a test script to rotate the gun clockwise and counterclockwise. Given that I only have a unipolar power supply, I used two relays to switch the polarity supplied to the motor i.e. switch the direction of rotation. The relays were energised using the Arduino.
I am tremendously pleased with the operation of the turret so far. From here, it is mainly going to be electrical work.
Next time I am going to be hooking up an accelerometer to enable precise control of the rotation, hopefully to within 1 degree. Another interesting problem will be figuring out how to interface the rotating components with the static ones without getting seriously tangled up!
Oh, and it looks like CompSci friend has a few weeks off work so facial recognition is back on the cards!
This summer I’m going to be doing possibly the coolest thing I’ve ever done. I am going to be taking a Nerf gun and making it into an automatic turret. Originally, I planned to do this project as a joint effort with my Computer Scientist friend, in order to add facial recognition to the turret’s list of tricks. Sadly, he has a work placement over most of the summer and so can’t help out as planned.
The Nerf gun in question is a Havokfire BBF-25, though you may know it simply as ‘the chaingun one’. The original specification is as follows:
Rotation about axis perpendicular to the floor (1st axis)
Rotation about axis perpendicular to gun barrel (2nd axis)
LCD display for status indication
All the hardware interaction will be done using my Arduino Mega.
So today I started work and the first problem I encountered was that the tripod which comes with the Havokfire did not allow for rotation about the second axis because in certain orientations of the first axis, the gun rotated about an axis parallel to the barrel, not perpendicular to it as shown below.
To overcome this, I decided to sacrifice rotation about the 2nd axis, at least for the moment, by fixing the tripod in the horizontal position thereby removing both 2nd axis and the unwanted 3rd axis rotation. This was fairly straightforward and all it took was some well placed blocks of wood and a few cable ties to fix them in place: not a pretty solution, but functional.
At this point, the gun could rotate 360 degrees very stably without any rotation about any of the other two axes. The next step was to do this using a motor. A while back, I took apart an old printer to salvage parts from it and I saved a pretty chunky motor and the toothed belt used to move the printhead. With the belt under enough tension, it should grip onto the plastic of the tripod and rotate the gun as shown below.
I noticed straight away that the motor struggled to turn the gun a little in one direction and quite a lot in the other direction. There was also an audible click at regular angular intervals. I decided to take apart the rotating section of the tripod to see if I could do something about this clicking and perhaps free the mechanism a little. After having opened the casing, I found that there were some sprung bits of plastic which were the cause of the clicking noise. I removed these and also added a bit of grease for good measure.
When reassembled, the gun rotated equally freely in both directions and performed well being driven by the motor at 12VDC.
Having had enough of mechanical work, I decided to start some of the electrical stuff. The first order of business was to get a readout from the joystick which took longer than it should have but nonetheless, I figured it out in the end!
The next step on the electrical side of things is to wire up a new switch contact into the gun’s existing circuitry. This means taking the whole thing apart and as far as I can tell, that is going to be a huge job and so I’ve left it for another day!