Search This Blog

Thursday, July 26, 2012

The Polystyrene Cutter

Having been refered to in this post, a very important tool for easy cutting of the bare polystyrene boards was custom built because of saving some money.

While these can be found on the market, good models with adjustable heat may cost over 30 euros. By analysing the kind of hardware I would need, I found that it wouldn't be such a big problem because I already had most of the stuff in my electronics scrap containers.

The only thing I didn't had laying around was the support for the hot wire, which I had to buy. I just used a metal support with a wooden holder for a conventional saw, which proved to serve the purpose just fine:




One of the challenges would be to get the proper material for a hot wire. While materials such as metal guitar strings can be used (these usually have a high electrical resistance), these however tend to corrode with time and heating cycles. A good material is nichrome wire, commonly used in heating resistances. It doesn't corrode easily, and it withstands a relatively high temperature of about 1400 °C. More than enough for the styrofoam cutter. I was lucky because I had a broken electrical heater which had a resistance made of nichrome, and a very good length of this material (a 2000 Watt / 220 Volt resistor). Enough to replace the hot wire several times.

For safety reasons, and because of the reduced resistance of the length of hot wire needed, it could not be powered directly from the mains power. Otherwise it would blow, and the user be electrocuted (because the metal structure of the cutter is connected to one of the terminals, and the wire is also an exposed conductor).

As such two requirements had to be satisfied: the voltage reduced to a safe level for humans to touch without hazard, and to provide just the current needed by the wire to heat to the point of cutting the styrofoam. A galvanic insulation between the mains and the cutter would also be necessary in order to again, eliminate therisk of shock hazard.
I measured the required length of hot wire to be at around 1.5 Ohms. By doing some research I figured out that the power dissipation had to be at around 10 Watts for the hot wire to properly cut the styrofoam. This meant around 2.6 Amps of current.
I searched though my scrap parts if I had some transformer that would satisfy this current, and found one from an old VCR that seemed to be able to do the job. This was from a time when linear power supplies would be dominant in consumer electronics devices. Currently, these are mostly replaced by their switching mode counterparts.

I still had the problem of how to vary the power. I could add a a circuit to rectify the output from the transformer, switch it through a FET, and control the switching via PWM with the help of a timer such as the 555, but this would add some effort and complexity, so instead I considered a different approach:
I had a light dimmer that didn't use for anything, so  connecting it to the primary side of the transformer should allow a similar result to be achieved. And so it was. Assembled the dimmer and transformer inside an insulated electricity box I also had from a previous project, and tested the entire rig.



It worked perfectly (apart from the minimum position in the dimmer still producing power, actually the level necessary to cut the styrofoam). By increasing the power it enabled the styrofoam residue to be vaporized, acting as a cleaner for the hot wire. Increasing the power even further would get the wire red hot. At this power level it is not however likely to be healty for the transformer, as it may melt the enamel of the windings due to the excess current, causing the primary or secondary coils to fail. I didn't however modified the dimmer to have a power limit. It would also have been interesting to allow a lower or even zero minimum power level, which is not the case. Actually in the minimum position this dimmer provides just the ammount of power necessary to cut through the styrofoam. Maybe in the future this can be fixed.

Thursday, June 28, 2012

Letting it hover...

While the building phase can be an enjoyable experience, grabbing the sticks, putting the chopper on the ground, and gently increasing the thrust until that custom build apparatus starts to appear light on its stands is where the real fun begins. Would we ignore the noise of the struggling motors, and this styrofoam-shielded quadcopter would seem like a magical object for which gravity would be opening an exception everytime we wanted to. There is no magic, just technology, but still there is a sense of victory in tricking gravity in a brute force manner. Not in a magnificent scale as Howard Hughes H-4 Hercules, or lighter than air as Bartolomeu de Gusmão's flying bird, but still admirable for mimicking birds in the size and ability to fly (in a cumbersome way however), and for hovering like few of these animals can.

Here is the inspiring video, that hopefully shall represent the first of many flight ordeals:



In spite of the 1.26 Kg of All Up Weight (AUW), at about 40 % throttle the propellers would start to support the entire weight of the quadcopter. Some rudder trimming to the left was required, as it slowly started to yaw to the right initially. Minor corrections on the elevator and aileron trims were also applied
to ensure proper stability in the neutral position of the sticks. No gyro gain adjustments were performed so far, as at least for hovering the settings seemed ok (about 50% for yaw, pitch and roll). An outdoor test may allow for a better assessment of this.

The styrofoam strucuture weights approximately 130 grams. An improvement of this will probably be attempted by cutting some styrofoam in some structurally insensitive areas. Maybe a 15-20% weight reduction is feasible.

For outdoor flying, the structure is not so important (unless flying close to people and important objects is necessary), so that it may be detached, resulting in a significant weight reduction, and consequent increase in flight time. Probably stability is improved as well, because of the decrease in angular inertia around the rotor areas, resulting in lower motor output to correct attitude errors, and faster response to increase in motor power for correcting these errors.


Monday, June 25, 2012

Multicopter Madness


R/C airplane modelling exists for several decades, but with late improvements and reduced cost in microelectronics, energy storage, and RF communications, products in this domain have suffered a significant improvement in quality and innovation. We can owe it to the general move of the industry towards miniaturization and delivery of hardware for consumer electronics products, industrial tools, and applications in general requiring microcontrollers, sensors, reliable short range RF communications, motor control, etc. As such, the low cost of R/C hobby products can be associated both to the increasing demand (with chinese manufacturers/sellers pushing the standards), and the use of common components and manufacturing processes as much as possible.

This tendency towards low cost have enabled people with constrained budgets like me to have some fun in this domain, and materialize projects that years ago would be prohibitively expensive, if feasible at all.
In previous blog posts I have shown my first adventures in the R/C hobby world with a 400 size electric (brushless) helicopter. It was a Ready to Fly model from Art-Tech (the Falcon 3D model). This little 90º swashplate helicopter, allowed me to understand about what it would be to fly an helicopter with all the control surfaces, just like the real ones.


After having gained more confidence with this family of flying machines, I have more recently decided to build a flying machine from scratch. This led me to the development of a quadcopter.

Quadcopters are by "definition", helicopters with four individual rotors, each one with a set of propellers of fixed or variable pitch (most commonly fixed). Propellers are usually of 2 or 3 blades (most commonly two). Similar helicopters may have more or less rotors, in varying configurations. Tricopters (three rotors) are not so common, and usually require a servo to tilt one of the motors in order to provide yaw movement. Its efficiency and reliability is usually inferior to the quadcopter.

For increased reliability, stability, and payload capacity, six or eight rotor helicopters are chosen. These however tend to be more expensive, require more battery power, and add extra complexity to the control part. It is however easier to survive single motor failure, and probably even double engine failure, in the case of the octocopter (depending on the all up weight). In a quadcopter there is no redundancy whatsoever. If one motor fails, it is impossible to maintain stability (yaw and pitch/roll control is immediately lost). As there is no decoupling between the motor and the propeller, glide is also not a possibility, and as such the helicopter will fall like a brick.

Still, and having budget as a constraint (impossible not to be, in the course of this nearly global money crisis), I decided to go for the quadcopter.

Having chinese sellers more or less as best friends, I went for the goal of building a reasonably good quality 450 size quadcopter while spending as little money as possible (below 200 USD).

My favourite sellers, definitively Hobbyking, and Dealextreme, as I couldn't find anywhere else in the online market the same products for a competing price.

My selection of parts was:


Later I had to add the ordering of the TX upgrade:
The list of the main required items accounted for less than 200 USD (including shipping where applicable). This is a pretty reasonable price for such a machine. It includes everything that is necessary to have a working quadcopter: control board with 3 gyros (a KK Multicopter board with an ATMega 168 MCU, opensource firmwares available online), one ESC for each motor, battery, frame, blades, power distribution. The radio was not considered in the budget as I already had one. As customs are a bit tricky in my country (orders above 22 Euros tend to be retained and an extra cost be charged), I took this into account in the calculations and decided to place small orders spaced in time to avoid this problem.

During the construction:


As the X quad configuration seemed my personal favourite, I reflashed the board with the most common XXcontrol_KR_XCopter v2.5 firmware:

http://www.kkmulticopter.kr/multicopter/firmware/XXcontrol_KR_XCopter_v2_5.zip

I just used the simple parallel port programmer (DAPA) together with AVRDude, just like I did in previous AVR projects:


Reading the instructions was fundamental, together with adjusting everything and testing WITHOUT the propellers attached. It is never too much to remind of this important detail. The untrained user may easily underestimate the damaging power of brushless motors and 10 inch props spinning at several thousands of RPM. These things can cut fingers, so some respect is important. First finished version:



The first flight was not entirely successful. Radio glitches produced nasty instabilities. I soon discovered the receiver was faulty and not picking up the PPM signals properly. I had a second one in my Collective Pitch Helicopter, but it was at home, so I didn't had the chance to replace on the field. Still I managed to figure out that apart from the glitches, the quadcopter seemed pretty stable, and promised to be easy to fly (for someone experienced with RC helicopters) with a proper radio. Anyway for initial training, and for possible indoor testing I found it was important to add a guard for the dangerous propellers, to protect myself, other people and objects, and the helicopter from colisions. As such I designed a styrofoam structure that would offer protection, and add the marginal benefit of the ducts around the propellers (even though the extra weight most likely will cancel the benefit and reduce flight time). Cutting styrofoam is a bit messy using knives or saws. The ideal tool is a hot wire, rendering nearly perfect cuts, depending almost entirely of the steadiness of the user hand. As I didn't had such tool, and buying one would be a little off budget, and hard to find in local stores, I went for another DIY project (which may deserve a separate blog entry later) just to make the tool.


With this tool cutting styrofoam is literally like cutting through soft butter. In a couple of hours I had a nice structure ready to be coupled to the helicopter:


So far I did a small indoor test, and everything seems fine (video still to be added). For a more solid solution for the radio problem I decided to go a little bit further, and while standing below the 200 USD budget, upgrade my crappy art-tech radio (a E-FLY 100C) with a proper TX module. The module have been ordered and for now I'm waiting for it's arrival. It's a FrSky V8HT DIY, and it's designed to fitted into any transmitter that produces a PPM signal. This page shows an example of the module being fitted to a radio similar to mine:

http://kenbuys.com/frsky-v8ht-diy/

This module is entirely digital, using spread spectrum for radio spectrum management. Is uses great components such as the CC2500 radio chip, and the Texas Instruments MSP430 microcontroller. The module plus the receiver cost me 31 Euros including shipping. It is a great price considering it turns a crappy radio into a very decent device. Moreover it provides glitch free control, a superb range of up to 2 km, and a failsafe feature, for configuring proper model behaviour on signal loss.

Sunday, April 1, 2012

Sensing the Heart Beat

Among the most basic forms of biometric data we may collect from ourselves is the heart beat.Wether to control our body response to sports activities, keep track of our health or to observe involuntary response to external interaction, this is one of the important parameters that is collected by physicians, and specialists of a multitude of health-related areas. What I am describing in this post is just the implementation of one of simplest forms of obtaining a waveform that represents the heart beat of an individual. The human heart beat can potentially be collected through numerous different methods. Among these we can identify the following:
  • Optical - transmissive or reflective optical pickup based on the blood flow through the finger;
  • Electrical - acquisition of the weak pulses that trigger the myocardial muscle;
  • Doppler ultrassound - either detection of the reflected signal from blood vessels or from the heart moving structure;
  • Audible acoustic - direct acoustic detection of the heart beat;
Each method has its advantages and disadvantages, and the context where the heart beat is to be collected will ultimately define the selection of the best method.

The optical method, the one I am describing here is one of the simplest, and offers a very good level of reliability.It is also simple to implement and doesn't require exotic hardware. It relies on the combined use of an infrared diode and phototransistor or photodiode. These are mounted on the user finger (tipically the left or right index finger), and taking advantage of the moderate transparency of the finger to IR and visible light, the variation in the light that is absorbed or reflected (depending on how the emmiter and sensor are mounted around the finger) will relate to pace of the blood flowing in the vessels, and as such this will provide a signal clearly indicating the heart beat. The electronics to pickup the signal are simple, as the amplitude obtained is high enough, and there is also no significant source of noise.

The electrical method is simple in concept, but involves more complicated signal detection and conditioning. The heart muscle is triggered by electric signals. At the muscle tissues these signals are intense enough for the heart function to be accomplished. But at the skin level, these signals are extremely weak because of the thick layer of organs and tissues that separate the heart from the skin. As such special instrumentation amplifiers, capable of magnifying signals in the order of microvolts are necessary. Besides amplifying signals it is also necessary to attenuate or entirely reject spurious signals (some of greater amplitude than the desired signal) that affect the detection. Normally band bass filters are added, but one important technique consists of using common mode noise rejection. Adding electrodes in other parts of the body, and electronically cancelling the signals that are common to all electrodes, efficiently allows the heart beat pulse to be isolated. The cancellation process can either be acomplished through analog circuits or using digital signal processors.

The ultrassound doppler method is commonly used to acquire the fetal heart beat, but can also be used to directly detect the patient heart beat.Like other structures in the body, the blood reflects part of the energy of the pulses transmitted by an ultrassound probe. As blood flows inside a vessel, it produces a distortion in the reflected signal, or a shift in the frequency. This is the doppler effect. By continuously measuring this shift, as the blood travels at speeds that vary with the heart cycle, so does the shift, producing a direct indication of the heart beat. This method is available both in dedicated equipment (in a doppler monitor or in a CTG instrument), or as an extra feature in a ultrassound scanner.The later is tipically capable of producing an audible representation of the heartbeat, and provide more detailed information such as flow direction and volume for a particular blood vessel (vein or artery).

The audible acoustic method is just the direct hearing (e.g. through a stethoscope) or through a microphone and amplifier.

Below is the prototype implementation of the first method. I have used an infrared diode (the one in the top of the finger), and a phototransistor as the sensing element. In this case a CNY70 was used as the phototransistor element. It also features a built-in infrared diode, but using it did not produced measurable results (direct pickup of emmited light completely overwhelms the sensor).
Below is the waveform that is obtained at the output of the circuit. It accurately reflects my heartbeat at the moment of the test (around 75 bpm).

Tuesday, March 27, 2012

New layout

After way too much time with the same layout, finally and in sync with Blogger restructuring and connection to Google+, I present you with a bit of a nicer look, which is at least is clearer for reading. Stay tuned, as some new posts are on the pipe, with updates on various topics, such as:
  • Geiger Counter - full schematics and firmware source code will soon be posted;
  • Time Lapse Photography - some new scenes of nature at its best will soon be made available.

Saturday, March 24, 2012

Simulation mode for the Geiger Counter




While obtaining samples of materials radioactive above background is not an easy task (fortunately for the sake of human health), I had to find a way of testing the dose measurement algorithm in a different way. As I have explained in a previous post, the device is divided in two modules: a UI module, and the detector device. Each has its own digital logic, and communicate with each other through an I2C bus. As such creating a simulation mode would be a simple mather of programming a new function in the detector that would allow randomly spaced pulses to be generated, instead of being triggered by the Geiger tube. This have been done simply by using the Atmel standard libraries random() function. Using the interrupt generated by the watchdog timer overflow, the following code is executed periodically:


ISR(WDT_vect) {
int i;

disable_wdie();

if(current_time.value < MAX_SHORT)
current_time.value++;
else
current_time.value = 0;

if(simul_mode) {
new_event = (random() % 2 == 0);

if(new_event) {
if(rad_count.value < 0xFFFF)
rad_count.value++;
else
rad_count.value = 0;

for(i = 0; i < 3; i++) {
cbi(PORTB, PB1);
_delay_us(570);
sbi(PORTB, PB1);
_delay_us(570);
}

new_event = 0;
}
}

enable_wdie();
}


Basically it checks if simulation mode is enabled, in this case getting a new random value every 16 millisseconds. Depending on the value being divisible by 2 or not, a pulse is produced, and just like in normal operation, the event counter is increased. As such on the UI module, these are treated just like real events.

Simulation mode can be enabled or disabled just by writing commands via I2C. The current status (simulation or real mode) can be read by reading the corresponding register through the I2C bus as well.

As such the firmware on the UI module was modified to include this as a new menu function.

The video below demonstrates the new function in operation.



A tone sequence is now triggered during bootup to test the audio amplifier and provide the user an indication of the current volume level.

Saturday, March 10, 2012

More in Time Lapse

And to add to the party, another bit of playing around with time lapse. This time zoomed in on the Tagus river, and obtained this interesting sequence. To achieve it, the intervalometer was set to take a picture every 10 seconds. Again, automatic settings such as ISO sensitivity and aperture were chosen. Only the focusing was kept manual.

Sunday, March 4, 2012

The timelapse intervalometer - the technology behind the device



With the results having been posted in a previous post, it is now time to flesh through the details that led to the creation of this simple yet useful device.

I started with the optimism that my Fujifilm S9600 camera would have some form of remote control possibillity other than the mechanical shutter release that is supported in the shutter button itself. Obviously I wanted something electronic, easy to interface with a programmable device such as a microcontroller. By doing some web surfing, I found that someone had hacked the original RR-80 remote, which connects to the camera mini-USB connector, and managed to do other things such as triggering via IR (http://www.trafficshaper.com/RR-80/RR-80.html). While this was not the scope of my project, the
detailed pictures allowed me to understand how the remote control would operate.

It is 100% passive, having just three resistors and a special push button that just like in the digital camera (and some auto-focus analog cameras), when half pressed it triggers the focusing and when fully pressed triggers the shutter. As such the button has two independent circuits, and is of the normally open type. A schematic of the circuit is described by the following diagram:



This is pretty simple, and I found that it could be easily interfaced with a microcontroller using just a pair of bipolar transistors to do the switching.

I wanted to do it as simple and with the fewest components as possible, in order to make it an efficient and cheap device. As such I selected a pretty cheap microcontroller, the PIC12F683.
While not being the cheapest of all, it is very affordable, and yet powerful enough for a variety of uses. More than enough for an intervalometer.

I had however the problem of how to interface with the device, and tell it what interval setting I would want in each shooting session. As it had only 8 pins, from which only 6 available for GPIOs, I was quite limited in options. From the six available pins, I knew that 2 would be required for the camera interfacing, one for a push button to activate the triggering, and one for a status LED. This would leave me with 2 pins for the interval selection mechanism I would adopt. I could use some encoder switch, but the firmware would be a bit complex, and it would not retain the position after cycling the power (unless it would be stored in EEPROM). Another approach which seemed interesting, and one that I had seen from previous designs, was to use a 12 position rotary switch with a resistive divider. It would work a kind of like a potentiometer, but with discrete steps. As the PIC had an ADC, recognizing different steps would be a simple matter of adjusting the expected range of values in the firmware. Piece of cake! And this way we would have 12 distinct modes to select from.

At the end I came up with the following design:



The selected transistors were a couple of 2N2222, enough for the low current necessary for the interface in the camera side. A 9 volt battery would suffice for a few tens of hours of operation. Without much optimization I obtained an average of 8 mA of consumption.

The finished device ended up fitted into a box that once belonged to an ADSL filter:



The veroboard assembled circuit, featuring an 9 Volt battery as the power source:



Bill of materials:


  • 1 x PIC12F683;
  • 1 x 78L05 linear regulator;
  • 2 x 2N2222 bipolar NPN transistor;
  • 1 x 3 mm green LED (active);
  • 1 x 3 mm red LED (focus);
  • 1 x 330 nF capacitor;
  • 1 x 10 nF capacitor;
  • 1 x 0.1 uF 10V capacitor;
  • 1 x 10K 1/4 W resistor;
  • 4 x 1K 1/4 W resistors;
  • 1 x 100K 1/4 W resistor;
  • 1 x 12K 1/4 W resistor;
  • 1 x 39K 1/4 W resistor;
  • 1 x 82K 1/4 W resistor;
  • 11 x 470 Ohm 1/4 W resistors;
  • 1 x single circuit 12 position rotary switch;
  • 1 x push button (normally open type);
  • 1 x lever switch SPST;
  • 1 x MicroUSB male connector;
  • 1 x 9V battery receptacle;
  • 1 x female DC connector (for external power supply);
  • 1 x Veroboard;
  • 1 meter of 2 conductor cable (for camera power and USB connector);
  • 1 x plastic case to contain the circuit and battery.


In my assembled version, the DC connector and power cable were added, so that both the camera and the intervalometer could be powered from the same supply. In this case I used a 2 Amp 5 Volt power supply from a Sony PSP, which suited just fine. In order not to damage the linear regulator with reverse voltages, the DC connector was put in parallel with the input. Given that this input is 5 Volts, there is a drop to approximately 3.5 Volts at the regulator output. Still this has proven to be enough to power the PIC and remaining electronics without issues.

In a final post about this subject I will provide some info about how the firmware was written. I can mention that the first stable version of MPLAB X was used together with the Hi-tech C compiler for PIC 12 MPU's.

Saturday, February 25, 2012

Time lapse shooting - moving into more professional results...

While the first videos seemed pretty cool in spite its mediocre quality (maybe because of the time domain wonder of perceiving things that we normally wouldn't given the different time scale we live in), now I had to move one step further.

The idea was to use a better camera, one offering photographic quality in every single frame.

So I took my bridge camera out of the closet (a Fujifilm S9600) and started to investigate how I could operate it continuously, with an abitrarily high number of frames being captured at constant intervals.

Unlike many modern SLR cameras, this one didn't have a built in intervalometer, so I had to get a way of obtaining this function from somewhere else. I learned that the camera had in its mini-USB connector, an extra pin (on of the 5 pins of the connector) dedicated to the shutter function (normally for the USB standard only 4 pins are used). From reading some documents on the web about this pin, I found that triggering the shutter would be a simple matter of closing the circuit between this pin and the ground in such way as to produce different voltage drops depending on the
required function.

So with this in mind I elaborated a circuit driven by a PIC, powered by a battery, and using Bipolar transistors to provide the appropriate switching for the camera.
The circuit will be better described in a later post. For now I will just stick to the results, with the video below having been caught with the intervalometer triggering the camera shutter every 30 seconds. For nearly 24 hours the camera was kept shooting photos at this pace. This resulted in 2698 2 megapixel photos.

Using virtualdub, these were combined into a video to be rendered at 30 fps. This means each second corresponds to 15 minutes of real time. The entire 24 hours are as such narrowed down to 1 min 30 seconds.

Friday, January 27, 2012

From morning until dawn - and entire day described in seconds

Time lapse video sequences can render exciting results, for the visual impact these provide. While simply being a sequence of frames more separated in time than in a conventional video, once played back at the rate the human vision considers smooth (30 frames per second) these provide a view of the world that a human cannot easily perceive directly, given the comparatively fast rate at which he summarizes and retains information. For instance a cloud in its pass has very complex yet slow changes in shape and trajectory. These are very hard for average humans to perceive, memorize and mentally reconstruct as an animated sequence of events. In general, slow changing processes are inherently hard for humans to characterize in its dynamic nature.

As such it is not surprising that a video containing nothing more than a reproduction of the real world can be appreciated by humans as being somewhat surreal, when simply the only difference is the rate at which information is sampled and later reproduced.

The first video contains about 20 hours of footage shrunk to 32 seconds. It reveals one angle of the Almada city at the south of Lisbon, where part of the 25 de Abril bridge and the Cristo Rei can be seen. It is a typical winter day in Portugal, where the fog floods the morning and a passing of dense clouds fulfills the entire afternoon. This typical day is however solitary in a atypical winter month padded with bright sunny days and mild temperatures.



The second video taken during the 27th January 2012, reveals a clear night transition to a bright winter day in the city of Almada, just south of Lisbon the capital city of Portugal. At the bottom right, the horizon is cut by a huge rectangular crane belonging to a long time decomissioned shipyard.Its name was Lisnave and would once be an important maritime reference for large ships and oil rigs which would stop by for major repairing and overhauling.