Archive for Arduino

Photographing a Speeding Bullet

I’d like to start with a big thanks going to Chris Callander.  When he saw the Camera Axe project he shared his idea for a new sensor with me.  I took his ideas and developed this new projectile sensor and updated the Camera Axe software to support it.  I doubt I would have ever came up with this new sensor idea without Chris.  The ideas that get shared in the open source community are great!  The hardware and software for this project are shared under the Creative Commons Attribution 3.0 License.

You can purchase the Camera Axe and this projectile sensor at this store or built it yourself (parts list below).

This new projectile sensor is designed to help photograph speeding bullets on the Camera Axe platform, but since I used the Arduino development environment, anyone using an Arduino could easily adapt the this hardware and software to their purposes.

This new sensor has two IR sensors spaced exactly two inches apart.  The user inputs the distance from the sensor to the desired position of the projectile when the picture is taken.  Based on the time it takes the projectile to travel those two inches between the sensors, a velocity for the projectile can be determined.  Since bullets and other projectiles basically travel at a constant velocity, it is easy for the microcontroller to calculate the delay in microseconds until the picture is taken.   I ran into a few gotchas in the software while I was writing it.

  • Needed to use digitalRead() with the sensors and not analogRead() (analog read is too slow at 100 us)
  • Used integer math because floating point math is very slow in Arduino
  • Had to be careful with my order of operations or I would overflow 32 bit unsigned integers in certain cases

I’m very pleased with the results.  I’ve tested it with an airgun that travels at a relatively slow 500 ft/sec (half the speed of sound), but my calculations show that the Camera Axe’s 16 MHz ATmega168 chip can easily predict the position of a high speed riffle (several times the speed of sound) to within a fraction of an inch.  I had known that this should work, but it was still amazing to see it working perfectly in the real world, considering all the micro fluctuations that I didn’t account for in the calculations.  In the end, things like gravity, air resistance, and quantum forces just didn’t matter :-)

[Update: Alan Sailer correctly pointed out the IR transistor I'm using only works at 15us, this would limit photos to around 2x the speed of sound, see the comments for options on faster transistor options.]

Below is a schematic of this new projectile sensor sensor and here are the Eagle files.

If you’re planning to build your own, then this is my parts list

Here is a list of updated files:

  • Updated Camera Axe label.  Nothing special here.
  • Updated Camera Axe source code to support this new sensor.  One nice feature of the projectile code is that I print out the feet/sec or the cm/sec that the bullet was traveling.  While this wasn’t needed for photography; it is still fun to see the numbers.
  • Updated user manual to include the software changes.

Using the Projectile Sensor with the Camera Axe

First, visually line up the IR LEDs to the IR transistors so that they are pointing at each other. Then just plug the 3.5mm cord from Sensor1 on the Camera Axe to Sensor1 on the projection board. Next do the same for sensor2. Plug a flash into Camera/Flash1 on the Camera Axe. Turn on the Camera Axe and go to the sensor menu. (Optional if you want to change from inches to centimeters press [Menu]+[Set]+[Left] while turning on the Camera Axe to enter the special menu to change from English units to Metric units.) In this menu you can set the distance from the sensor to where the projectile should be on the picture (0->999 cm/inch).

You can test your the projectile sensor’s set up by putting your finger in front of the first sensor. After one second a message will display saying that the “second trigger failed”. After this message goes away, put your hand in front of the second sensor and then your other hand in front of the first sensor. This will basically simulate an infinitely fast projectile and the Camera Axe will display the speed of a fast projectile (something more than 45 times the speed of sound).

This sensor should generally be placed at the end of the gun barrel so you don’t need to worry about the bullet hitting the circuit board or sensors.  The bullet/projectile must pass through this sensor before it hits the target.  In my setup I have everything firmly bolted to a table and trigger the gun with a string from a safe distance.

Pretty Pictures

Last but not least, here are a few of the pictures I took with this new sensor.  Taking these pictures was possible with the Camera Axe before I had the projectile sensor using a microphone or a laser sensor, but it involved a lot of trial and error.  With the projectile sensor, every picture is what I was shooting for (pun intended).

First, visually line up the IR LEDs to the IR transistors so that they are pointing at each other. Then just plug the 3.5mm cord from Sensor1 on the Camera Axe to Sensor1 on the projection board. Next do the same for sensor2. Plug a flash into Camera/Flash1 on the Camera Axe. Turn on the Camera Axe and go to the sensor menu. (Optional if you want to change from inches to centimeters press [Menu]+[Set]+[Left] while turning on the Camera Axe to enter the special menu to change from English units to Metric units.) In this menu you can set the distance from the sensor to where the projectile should be on the picture (0->999 cm/inch).

You can test your the projectile sensor’s set up by putting your finger in front of the first sensor. After one second a message will display saying that the “second trigger failed”. After this message goes away, put your hand in front of the second sensor and then your other hand in front of the first sensor. This will basically simulate an infinitely fast projectile and the Camera Axe will display the speed of a fast projectile (something more than 45 times the speed of sound).

Comments (41)

Camera Axe 3.0

Purchase the Camera Axe at this store.

I’ve done a lot of refinement since releasing the original version of the Camera Axe.

The Camera Axe is a tool for photographers to trigger cameras or flashes based on signals from various sensors. In this version there are two ports for sensors such as a microphone, a motion detector, or light sensor; and there are two ports for camera/flash devices. The Camera Axe is useful for stop motion photography where an action happens too quickly for human reflexes (photographing a popping balloon, lightning, or a milk droplet splash). Other uses can be to catch things photographers don’t want to wait around for such as birds flying to a bird feeder or surveillance of people walking down a hallway. The possibilities are endless. The hardware and firmware for this device are all open source under Creative Commons Attribution 3.0 License meaning that it’s possible to adapt this platform for specialized uses.

Below are a few links important links for this project:

  • Build Guild – Detailed step by step information on how to build your own Camera Axe (includes full BOM and suggested part suppliers).
  • User Manual – Describes how the software menu works, lists sensor/accessors, and gives some example use cases.
  • Image Gallery – Pretty pictures taken with Camera Axe Hardware.
  • Dreaming Robots Store – My online store where I sell Camera Axe kits, sensors, and other accessories.
  • Firmware Source – Source code that controls the Camera Axe (designed to be loaded via Arduino bootloader).
  • Camera Axe PCB Eagle Files – Circuit board source files.

List of improvements for this version:

  • Decided to use smart sensors. This means instead of having a special port on the Camera Axe for a Microphone that has the amplifier built into the Camera Axe, I’ve decided to put the amplifier on the sensor. This gives maximum flexibility in sensor combination, reduces the number of ports, and makes it simpler to use the Camera Axe.
  • Flash and Cameras use the share 2 ports. This means you could use 2 flashes, 2 cameras, or one of each. In the original version you only had the option to use one of each.
  • Removed the active port LEDs. These didn’t seem too useful and I was running out of pins.
  • Added power transistors to control whether the sensor ports are receiving power. This is useful to turn off things like a laser beam sensor just before taking a photo. A way of controlling this was also added to the software.
  • A reset to factory default and a way to control LCD back light brightness were added to software.
  • Large clean up of software source to make using it and modifying it easier.
  • Left out the remote control option since it was expensive and had little demand.
  • Lots changes to the electrical components used to reduce cost and make assembly easier.
  • Much better documentation (Builders Guide and User Guide).
  • Added a store to sell it because of a demand for this from the original version.

Feel free to discuss this or other topics at my forum.

Some of those following this project might be asking what happened to version 2.0. I got to the point of ordering a batch of PCBs and I even built one. I had gone with the mentality that more is better. This monster had 6 ports and each port had a different task. While I was writing the software for this version I decided that it was going to be too confusing to use so I stopped working on 2.0.  A simplified 3.0 version was born which tried to add new functionality while keeping it simple to use.

Comments (36)

Cheap Arduino Wireless Communications

I was looking for a way to handle wireless communications between two Arduino boards. Other options like Xbee or Bluetooth were going to cost $50 to over $100. Then I found a cheap RF transmitter and receiver at Sparkfun. The total cost is only $9!

Here are a few limitations to RF solution:

  • Communications is only one way. If you wanted two way communications you’d need to buy two receivers and two transmitters which would raise the cost to $18. This is still cheaper than other solutions I found.
  • The variable gain on the receiver causes it to pick up lots of background noise. I had to do some processing with the Arduino to filter out this noise. More details about this below in the code section.
  • Bandwidth maxes out at 2400 bps, but there is a version with 4800 bps. A large portion of this bandwidth is used for network protocol I wrote that handles error detection.
  • Range is limited to a max of 500 feet.

The advantages are that it is cheap and it is pretty easy to use.

Below are some images showing how I hooked up the receiver and transmitter to two different Arduino boards. When wiring the receiver/transmitter you only need is to give them power/ground and then a pin for the TX (serial transmit) or RX (serial receive) pin. I also wired a button to the Arduino doing the transmitting, and used the LED on pin 13 that is built into my Arduino boards on the receiver so I could test this setup. The test app just flashes a button on the receiving board when a button is pressed on the transmitting board.

Here’s a picture of the my actual bread boarded circuit.

Code

Since the receiver is constantly picking up random noise I add a few extra bytes to every data packet. I add two bytes to signify the start of a data packet. Then I send the a byte address. This address allows multiple devices to work in the same area without interfering with each other. Next is the data (in my example code it’s an unsigned int (2 bytes). Lastly I send a checksum which is a simple xor of all the data bytes to make sure the data got received without being corrupted.

I broke the Arduino code into two files. If you’ve never used two files before with Arduino all you need to to is keep both files in the same directory and the Arduino IDE merges them for you. Here is the full code for the main application, and here is the full code that does the network error catching.

Increasing the Range

I did all of my initial testing without any of these improvement and everything worked fine with these devices inside the same room.

  • Add an antenna. All you need is a 23 cm piece of wire. I did this and it made it so I could reliably transmit data from one corner of my house to the other (3 floor town house).
  • Increase the voltage for the transmitter. The transmitter can use 2-12 volts. With 5 volts I got pleanty of range for my use case, but increase this if you need more range.
  • Reduce the baud rate. My test app runs at 1200 bps out of the max 2400 bps. You could drop this even further to something like 300 bps and that should help reduce transfer errors and hopefully increase range.

Thanks

I got a lot of help from the transmitter/receiver data sheets, and from this article.

I’ll mention an even cheaper idea I had while doing this. If you will always have line of sight between your devices you could setup something very similar to this with an IR LED and IR transistor. It would work like a TV remote. It won’t work for me because I want this to go through walls, but if line of sight is fine for you then you could use this code and an IR LED/transistor would probably cost under $3.

Comments (107)

Realtime Graphing of Accelerometer/Gyroscope Data

During my naive days as a university student the only time I graphed data was when some professor required a graph in the lab report. Back in those days I always just looked at the numbers to see what what was happening. It wasn’t until I worked on much more complex real world problems that I admitted graphing the data can help. It’s ironic that as I’ve become a better engineer I’ve realized how important it is to take advantage of every crutch I can fine. These days I graph just about every kind of data I see. Want to know when all the office birthdays are? Let me graph that out for you…

Graphing data lets my mind understand what is happening much faster/better the raw numbers. I know there are some less experienced programmers/engineers that need to learn this. The holy grail for software is real time graphing of the data your application is using. So often people add this sort of feature in at the end, but I think there are benefits to doing it first since it reduces debugging time. At my job we have a whole team dedicated to real time graphing of the data processed by our 3D graphics processors. I am always extra friendly to the people on this team because I fully realize how much easier they make my job. In short I’m a graphing fan boy so it should be no surprise that I wrote some graphing software for my hobby projects. I did this as the first step in a much larger autonomous flying vehicle project that I’m working on.

Since my ultimate goal is a flying vehicle I knew I’d need an inertia measurement unit (IMU). I wanted something with accelerometers to measure acceleration and gyroscopes to measure rotation. After some research I found the ADXL330 is a good accelerometer and the IDG300 is a good gyroscope. I use this Sparkfun 5 degrees of freedom (DOF) device that has both of these chips integrated onto a single small board. These chips measure acceleration along all three axises (x,y,z) and the gryroscopes measures pitch and roll. This means I am missing yaw, but I decided I can add an electronic compass in the future to get this data. I have an Arduino so that is the microcontroller I used.

With all the hardware figured out I already knew that taking this many inputs into a project and expecting it to do what I want was not going to happen on my first try. So to make the debugging less frustrating I decided to graph out all these signals. I will probably add some derived data to these graphs in the future as I get further on this project, but I think it makes sense to share this simple version of the generic graphing software before things get overly complicated.

I used the open source Arduino SDK to compile the code for my microcontroller. Here is the code I wrote for the Arduino. This code reads the sensors and then writes this data onto the serial bus. This software lets you figure out the frequency you want to refresh this data and then will sample the sensors as many times as it can while hitting this refresh frequency. Multisampling helps reduce sensor noise. The reason I didn’t want to send every sensor value over the serial bus is because that it too much data. For my uses I limited the refresh frequency to 100 times per second.

The graphing was done with the open source Processing language. I had never used Processing before, but I found it very easy to use and in a few hundred lines of code got some pretty nice graphing functionality. In a nutshell Processing is a java based language with a bunch of drawing and IO helper functions. Here is the graphing code I wrote for Processing. Besides graphing the data in real time, this software also supports logging all the data to a file and applying a smoothing filter to the data. I wrote this code pretty cleanly so it should be easy to add and remove more data to the graphs.

Here’s a movie of me shaking the sensors in a few different directions and you can see the graphs react accordingly. I’ll let you derive your own conclusions, but it looks like I have a good deal of work ahead of me.

Comments (26)

Camera Axe

I made a new version of Camera AxeHere is my store where I sell them.

Camera Axe is open hardware and open software project that helps you get some of those difficult to capture photographs. It can use various sensors like light triggers and sound triggers to activate a camera or a flash. Here are a few sample images of the things this hardware has captured.

Here is a gallery with more pretty pictures. I apologize that some of them are a little blurry. I dropped and damaged my flash about a week ago and don’t have the funds to buy a new one right now. The flash now does a few micro pre-flash outputs before the full flash is triggered. This is is why some of the images have a weaker ghost images in them causing a blurry appearance. (UPDATE: Here is are some new photos I shot once I got my flash repaired. And here are some more.)

These are just a few images I’ve used to test this software/hardware. The possible uses range from taking pictures of wildlife while you’re not there to photographing a bullet piercing an apple. The fact that everything is open source offers advantages over solutions that are being sold today (beyond the cheaper price). As an example lets say you want to take pictures of wildlife at sunrise/sunset. You could modify the software so the light sensor only actives the camera at light levels that represent sunrise/sunset and then you could use the microphone to actually detect animal movement. Since the hardware is easily understood you can add new sensors as needed, one sensor I’ve thought about making is piezo pressure sensor.

Camera Axe Component List

Here is a list of the components you need to make Camera Axe.

Sparkfun
Break Away Headers $2.50
Mini Push Button Switch $0.35
Serial Enabled 16×2 LCD $24.95
16 MHZ Crystal $1.50
ATmega328 with Arduino Bootloader $5.50
DIP Sockets Solder Tail – 28-Pin 0.3″ $1.50
5V Voltage Regulator $1.25
Optoisolator with Darlington Driver – 1 Channel $1.25
0.1 uF Capacitor (4) $1.00
22 pF Capacitor (2) $0.50
10 uF Capacitor (3) $1.35
RF Link 2400bps Receiver – 315MHz $4.95
3-Pin Screw Terminals 3.5mm Pitch (2) $3.00
Super Bright LED – Green (4) $3.80
DIP Sockets Solder Tail – 8-Pin $1.50
Diode Rectifier – 1A 50V (2) $0.30
Custom Circuit Board PCB $21.43
Mouser
NPN Transistor (2) $0.54
Plastic Enclosure $7.62
3.5 mm Audio Jack (4) $1.40
Push Button Switch (6) $7.80
1M Ohm Potentiometer $0.90
Op Amp $0.33
9V Battery Holder $1.05
1/4 Watt Resistors * 47 (1) * 220 (4) * 1K (1) * 10K (14) * 100K (1) $2.52
McMasters Carr
#2 Spacer – 3/16″ OD, 3/16″ LENGTH (4) $1.04
#4 Spacer – 3/16″ OD, 5/16″ Length (4) $1.16
Undersized 4-40 Nut (4) $3.28
Undersized 2/56 Nut (4) $5.23
2-56 Bolt – 5/8″ Length (4) $4.64
4-40 Bolt – 3/4″ Length (4) $5.09
Total Cost $119.23

Getting the bill of material cost significantly under $70 should be pretty easy if anyone want to make 10′s of these. Many of the parts above start significant volume discounts at pretty low quantities. Also some of the hardware from McMasters I only needed 4 of something but I had to buy a pack of 100 so building multiple (or finding a supplier where you could buy 4) would decrease the price by about $15. You could reduce the cost the the PCB from $21.43 to about $6.50 if you ordered them in quantities of 17 from BatchPCB’s supplier Gold PhoenixPCB (I’d really suggest using BatchPCB until you know what you’re doing). Lastly, redesigning the board to use surface mounted parts would lead to large cost savings.

Camera Axe Hardware

I designed this circuit and PCB board in Eagle. Eagle is a powerful circuit and PCB design tool. You can get a free version for non-commercial use. This is the first PCB I ever designed and must say that Eagle combined with these four great Sparkfun tutorials (1, 2, 3, 4) really got me up to speed. I then sent my design to BatchPCB. It took a little over a month to get my test board back, but it worked great. Here are my eagle files for this project and the Girber files I sent to BatchPCB. If you install the free version of Eagle you can look at and modify my schematic and board layout. Below is a picture of this boards schematic for those who don’t want to install Eagle to look at it.

Being my first board I made a few mistakes with the PCB that I’ll correct if I ever print more boards. Luckily all my mistakes were minor and the board I printed works fine.

  • Rename “Light” to “Sensor” on the silkscreen since that is a better description.
  • One of the bolt holes is one grid point off center so I should make sure all the bolt holds are centered.
  • I should label the value of the Potentiometer on the silkscreen (1M ohm).
  • The silkscreen for the RF receiver is missing +5 for one of it’s pins.
  • The LEDs are too bright and the 220 ohm resistors should be replaced with something larger.
  • The schematic is correct, but the parts I used for the focus and shutter are ECB transistors.  These have an odd pin layout for transistors (1=emitter, 2=collector, 3=base).  Switch these to a normal transistor (1=collector, 2=base, 3=emitter).

After I got the PCB back, it was just a matter of soldering all the components in place. If others want to build this and want more detailed directions on soldering the circuit board components into place, I may be willing to write an instruction guide to assist in this.

Enclosure

To make the enclosure I designed the holds I needed to drill and the few places I needed to cut with my Dremel in Inkscape. Then I just printed that out onto some sticky paper and had the pattern I needed to cut out on the box. This worked out pretty slick. Here is the cutout pattern I designed (drill/cut template, final sticker template).

Software

I used an ATMega328 with the Arduino bootloader for my microcontroller. This means I could use the very popular and easy to use open source Arduino development environment. I used version 0014, but newer versions are usually backwards compatible with older ones. You can download the Arduino development software here.

In order to download software to this board you will need this programming dongle.

Here is the software I wrote for this project. I’ve created this video that demonstrates some of the features of this software.

Flash Trigger

Female Hotshoe (Cheaper ones available, but this one has is good quality) $16.50
3.5 mm Extension Cord $5.24
External Flash (I assume you already have one)
Total Cost $21.74

This allows you to plug the flash into Camera Axe. While Camera Axe can trigger your camera directly, if you need an instantaneous capture you should use the flash. This page gives the expected shutter lag for many cameras. The flash reacts to it’s triggering in well under a millisecond.

Notice: Camera Axe assumes you have an EOS compatible flash. Some older flashes use high voltages to trigger them. If you use one of these high voltage flash units you will likely blow Camera Axe’s optoisolater and need to replace it. I use a Canon 580EX flash, but there are many other options. Here is a list of flashes that should be safe.

Camera Trigger

Plug to trigger your camera (Price varies by plug (see below) under $5.00
Audio cord with 3.5 mm plug $3.15
Total Cost $8.15

The higher end Canon DSLR cameras (20D, 30D, 40D, 50D, 5D, 1D) have a a special Canon Plug called N3. I have not been able to find this plug for sale anywhere, but you can buy a cheap Chinese trigger for these cameras on Ebay for under $5 and use the N3 plug from it. I have a 30D so this is what I demonstrate here. Canon’s lower end cameras (300D, 500D, 1000D) use the much cheaper and easier to get 2.5 mm jack. I’m not sure what Nikon use, but I’m sure a little research will figure that out.

Sound Sensor

Electret Microphone $0.95
Audio cord with 3.5 mm plug $3.15
Total Cost $4.10

Electret microphones like this need some serious amplification. Luckily I put all that amplification on Camera Axe’s PCB. You can adjust the sensitivity of the microphone with the potentiometer on Camera Axe’s PCB. Just play with it until you find a sensitivity you like.

Light Sensor

Photo Transistor $0.42
Audio cord with 3.5 mm plug $3.15
Total Cost $3.57

Most photo transistors filter out visible light and only trigger on IR light. I did some searching and found this one that triggers on visible and IR light. This is nice because one of the uses I had for this was to use it in conjunction with a cheap $5 laser pointer (search Google or Amazon) to create a laser trigger. All you do is point the laser at this and when the beam is broken you trigger the camera or flash.

Another good use of the this sensor is taking pictures of lightning. It will make getting night time lightning less work and you can even get daytime lightning which is something human reflexes can’t manage.

Remote Control

RF Link Transmitter – 315MHz $3.95
Other parts ???
Total Cost ???

I put a receiver in Camera Axe so I could trigger it remotely. The transmitter I put in along with this receiver should have a range of about 200 ft, but I have not verified this distance yet. I did verify the remote works at closer ranges by putting together a breadboard circuit to verify it. The circuit is extremely simple since this device just needs power, ground, and a serial transmit wire to send the it the signal. Maybe I’ll make a nice remote someday, but until then you’ll need to design your own if you need this feature. Here is the Arduino software I used to test this feature.

Comments (76)

« Previous Page« Previous entries « Previous Page · Next Page » Next entries »Next Page »