Showing posts with label arduino. Show all posts
Showing posts with label arduino. Show all posts

Tuesday, January 8, 2013

DIY X-ray CT scanner controlled by an Arduino


I built a CT scanner from an x-ray tube that I bought on eBay, a stepper motor, a large ring bearing, and an Arduino. I used a phosphor screen and my camera to capture x-ray shadow images of a frozen chicken, while the Arduino and stepper motor rotated the chicken by 8 degrees between shots. The resulting 45 images were combined via filtered back projection to create a 3D volume reconstruction of the chicken.

Software used:

Panasonic SilkyPix (for .RW2 development)

Adobe Bridge/Photoshop for image perspective correction

Cygwin/Octave for filtered backprojection

Cone Beam Computed Tomography algorithm
http://www.mathworks.com/matlabcentral/fileexchange/35548-3d-cone-beam-ct-cbct-projection-backprojection-fdk-mlem-reconstruction-codes-for-matlab-students

3D Slicer for visualization and volume rendering
http://www.slicer.org/

Monday, December 10, 2012

Jukebox color wheel synchronizer




I built a system to synchronize the two color wheel motors in a Wurlitzer Model 1015 jukebox. Originally, the jukebox used two synchronous clock motors, and the designers assumed that the motors would stay synchronous and keep the colors wheels at the same orientation after manually setting it. As it turns out, the torque required to spin the color wheels is enough to cause the motors to slip. Eventually, the color wheels get out of sync, and the left and right side of the jukebox do not match in color.

My upgraded system uses two small DC gearmotors that interface with the original drive mechanics via a nylon gear from McMaster. I drive the two motors via a PN2222A transistor and sense the position of the color wheels with the optical sensors from an old computer mouse. An arduino controls the motors via PWM (20 or 30 KHz), and runs a phase-locked-loop routine with P-I control. This system could use a little tuning, but it's pretty close.

Sunday, December 19, 2010

Fiberoptic joystick with quadrature encoders and arduino

I have designed and built a joystick that contains no electronic parts -- only fiberoptics. The motion is sensed via quadrature encoding, and the signal processing is handled by an arduino microcontroller.

Here is a similar project for linear position tracking:
http://benkrasnow.blogspot.com/2010/02/linear-position-tracking-with.html


This joystick is designed for use in MEG and MRI scanners where the electronics may interfere with the scanner's operation.


Fiber transmitter and receivers:
Avago HFBR-2412TZ (mouser)
Avago HFBR-1414TZ

Quadrature decoder:
Avago HCTL-2032-SC (mouser)

Fiberoptic cables:
62.5 um glass fiber custom cables from http://www.ecablemart.com/

Code wheel from http://usdigital.com/

Sunday, September 5, 2010

Web-controlled watering can and vortex tube

UPDATE: Code added at the bottom of this post.


This is an interactive art project that I have been building for an upcoming exhibition. The idea for a web-controlled watering can come from the first "iphone watering can" that I helped build with a friend for Maker Faire a couple years ago. Search the internet/youtube for "iphone watering can" for details.





This new version uses a different drive mechanism and a PD control loop to make the watering can track the desired position in realtime. The interface works with any webkit browser. My collaborator and I have discussed using the iphone or android accelerometers to achieve control through phone tilting. I'm not sure if the tilt data is available to the web browser, though, and we are trying to make the interface run on as many platforms as possible. Any ideas?

The siteplayer webserver is extremely old technology and has many problems, but does work. I would explore using a hacked WRT router in the future for similar projects.






HTML file from Siteplayer webserver:
http://www.magconcept.com/watering/can.htm.txt

SPI file from Siteplayer webserver (simply to establish a server response):
http://www.magconcept.com/watering/serial.spi

Arduino code to get serial data from webserver and effect the PID control loop
http://www.magconcept.com/watering/watering_can.pde

Sunday, August 29, 2010

Universal motor speed control by a microcontroller

I am showing a method of using a CdS photoresistor to control a standard triac dimmer circuit that is wired to an electric drill motor (a universal motor). The CdS photoresistor is driven by an LED that is controlled by a PWM pin an an arduino microcontroller. This system provides a very easy way to control 120V AC devices with a single PWM pin, and not use any timing code or worry about zero-crossing of the AC power since this is done intrinsically in the circuit. It also offers true electrical isolation between the AC line voltage and microcontroller.

Thursday, July 16, 2009

Experimenting with a "liquid lens"

A couple months ago, I started to investigate building an auto-focus mechanism for cameras that could operate in high magnetic fields. This was for a work project (where I build MRI-compatible devices). Inside an MRI machine, the base magnetic field is usually 1.5 or 3 Tesla. At these fields, any motor or solenoid that relies on manipulating a local magnetic field will not work. Unfortunately, manipulating magnetic fields is one of the easiest ways to convert electricity into physical movement, so most auto-focus assemblies are built this way. There are some
alternatives, though:

Piezo "ultrasonic" ring motors. Many high-end DSLR (and SLR) lenses have silent ring motors that vibrate at ultrasonic frequencies to create rotation. Great! The only problem is that they are built from steel, and the steel cannot be used in the MRI environment. They are also too big -- I need a tiny lens about 1/4" in diameter, not 2" like a DSLR lens

Piezo wiggler motors. Looks interesting, but getting a sample is near impossible. The screw assembly is probably steel, and the system requires a fairly rigid and complex slide system

Liquid lenses. These lenses are built by sealing a small amount of water and oil inside a shirt button-shaped capsule. The walls of the capsule are metal with glass windows on the faces of the button. The water and oil will not mix, and the boundary between the fluids will bend light because the two liquids have different refractive indices. If the walls of the capsule are charged with electrical current, the shape of the water droplet will change because of electrostatic attraction. (check this out: http://www.youtube.com/watch?v=p1f6zLysilU ) The oil is made up of non-polar molecules, so it does not share this same attraction. By controlling the voltage on the capsule walls, the shape of the water can be controlled and thus the focal length of the lens formed by the water-oil interface. Neat!


The liquid lens is the metallic button-shaped thing on the left. I built a holder for the lens out of 1" squares of copper clad board.

There are only one or two manufacturers of liquid lenses: Varioptic, Philips, and maybe Siemens. Philips and Siemens would not discuss the liquid lens and would not sell any samples. Varioptic would send samples -- only $340 for each lens! What?! The evaluation kit was a mere $4000, while the full developer's kit was $12,750. I kid you not. What kind of company would charge a potential customer $12k for the privilege of testing their products? Insane!

Anyway, since I couldn't deal with any of the manufacturers directly, I set about finding an off-the-shelf product that contained a liquid lens. After many hours of searching, I found an actual product that had the Varioptic lens in it: Digitus DA-70817. There were many other prototypes and press releases for other liquid lens products, but it seems the Digitus camera is the only mass-produced device right now. Unfortunately, it is not available in the USA. It's not on eBay. Amazon.de has it, but will not ship to the USA. After many more hours of searching, I got in touch with a German distribution company called Assmann (no joke). I exchanged a few emails with a friendly person there, and she sent me five of these cameras (about 25 euro apiece with the usual outrageous international shipping charge).

I removed the lens from one of the cameras and mounted it between two pieces of copper clad board. To make the lens change focal length, I need to supply 0-70V AC to the lens. AC is required to prevent the liquid in the lens from polarizing over time and losing effectiveness. The voltage needs to be fairly high to deform the water drop sufficiently, and also needs to be changed rapidly for quick changes in focal length. Fortunately, there are two companies that make ICs specifically designed to directly drive liquid lenses. Unfortunately, one of the companies, Maxim, will not sell samples of their chip, and they will not even give out datasheets for it. Take a look: http://www.maxim-ic.com/req_full_ds.cfm?action=request&id=5949 How rude is that? WTF?! The other company that makes liquid lens drivers is Supertex. They will sell samples of their HV892 at a reasonable price, but the chip is only made in a 10-lead 4mm x 4mm DFN package with .65mm pitch. Apparently, this SMD footprint is so unusual, there are no DIP converters available from anywhere. Geeeez! I ended up designing my own PCB for the chip and having them made at http://www.expresspcb.com/. Here it is:

I interfaced the chip to an Arduino Duemilanove. The Arduino sends a value between 1 and 255 to the HV892 via the I2C bus. The value controls the HV892 output voltage, and hence the lens's focal length. I am not sure what the mathematical relationship is





I used a laser pointer to show the different focal lengths that the lens can achieve.

Sunday, May 24, 2009

DIY dosing pump for reef aquarium

Part of the daily maintenance on a reef aquarium is controlling the calcium and alkalinity levels in the water. Calcium is used by reef inhabitants to build their skeletons, and it is also precipitated abiotically (calcium deposits on pumps, heaters, etc). Even though this rate of calcium utilization is fairly slow, it must be replenished to ensure there is always a sufficient supply, and having a very consistent level is beneficial to the inhabitants.

The alkalinity level of the water is a measure of how resistant the pH is to fluctuations. It too must be replenished to keep the pH of the water stable. If you are curious about marine calcium/alklainity, search the web. There is a ton of information available, and it is quite complex and interesting.

There are a few ways to maintain proper calcium and alkalinity levels, but I prefer to use a two-part alkalinity and calcium supplement called B-ionic. My aquarium is 5 gallons, and so it only requires about 1 mililiter of each solution (alk and ca) added each day. The exact amount varies, and the two solutions may need to be dosed in unequal quantities. Well, this gets a little tedious after a while, so I built a device that would slowly add the desired amount of each of the alk and ca solutions over the course of a day:I bought two "syringe pumps" on eBay for under $15 each. The pumps consisted of a leadscrew assembly, split-nut, and holder for the syringe. There was no motor, but I knew that they were originally intended to be run by a clock motor. The speed of the motor was constant, hence the only way to control the dosing rate was by changing the motor or the syringe diameter.

I hacked up the syringe pumps a little, and fitted them with two stepper motors that I got at a surplus store for $17 each. The motors are unipolar (6-wire), 1.8*/step, 24V per phase at 300mA.
The motors are mounted to the leadscrews with a short length of Delrin shaft. This allows a necessary amount of flexing, since the motor shaft and the leadscrew are unlikely to perfectly aligned. This is a very low-speed low-torque application, so the strength of the delrin shaft is not an issue.



The motor driver circuitry is built from PN2222A transistors that are wired between the motor windings and circuit ground. Each transistor has a clamp diode and filter capacitor on its collector. Each transistor base is driven by a pin on the Arduino Duemillenove microcontroller board. There are four phases for each motor, so this took a total of eight pins on the Arduino. The Arduino is also connected to a 4x20 LCD screen via 6 pins (4-bit interface). I also wired two potentiometers to the Arduino's analog input pins. The pots are setup as variable voltage dividers between ground and 5V.

The Arduino runs code that reads the positions of the two knobs, translates the positions into timing intervals, and advances each of the stepper motors when its respective time interval has elapsed. I also added code to de-energize the motors 1/2 sec after they have been advanced. In this application, the time between motor steps ranges from 40 seconds to 3 minutes. I tested this power-save feature, and it appears the system has no tendency to push the motor backwards while it is unpowered. Thus, power is only necessary when the motor is moving, and it can be deactivated when it is waiting for the next step.

The circuit and motors are powered by a 20VAC wall transformer. I rectified this with 4 diodes, and used a 7805 to supply 5V to the Arduino and LCD. The motor windings get unregulated DC voltage about 20V, since the load from the LCD's backlight is substantial. The 7805 required a large heatsink for this same reason.


For display purposes, the Arduino code translates the motor timing interval to mililiters/day. Turning the knobs provides a very responsive update of the LCD value. It is easy to set the device with .01 mililiter/day precision, although I doubt the device mechanially has that level of precision.

I calibrated the device by turning the stepper motor a specific number of steps, and used a very sensitive scale to measure the mass of water that was pumped out of the syringe. Later that day, I setup the device running normally with its output directed over a vessel on the scale. I learned that my scale must have an anti-drift feature, as it did not register any mass! Instead, I measured the water with a small syringe, and it came it at 4.75 mL (should have been 5). I am not sure if .25mL evaporated, or if .25mL stuck the sides of the vessel, or if the system is inaccurate. Maybe it's all three. The .25mL discrepency is not too important, since the settings will be tweaked based on water testing results once it is up and running.

I am still testing the system, as I really want to be sure it is stable. If the device malfunctioned and dispensed all of its calcium in one blast, it might kill everything in the aquarium. The code is pretty simple, but the Arduino clock function will rollover every 49 days, and it's difficult to test what will happen at that time.

I'll make another post when I install the system on the aquarium.