Wednesday, October 27, 2010

ITG-3200 Gyroscope Library for Arduino

Here's the first revision of a library I made for the ITG-3200 3-Axis Gyroscope made by Invensense.

The sensor communicates using the I2C protocol with other devices, for which I'm making use of the Wire library.

You will have to include Wire.h in your sketches if you plan to use this library.

Here's an example of how to use it (assuming you have already made the electrical connections):

#include "itg3200.h"
ITG3200 gyro;

void setup(){
Serial.begin(9600);
gyro.begin(0x69); // as for SparkFun breakout, all default values
delay(1);
}

void loop(){
Serial.print("X=");
Serial.println(gyro.getX());
Serial.print("Y=");
Serial.println(gyro.getY());
Serial.print("Z=");
Serial.println(gyro.getZ());
delay(400);
}

Running this sketch will make the Arduino transmit the readings for each axis through the first serial module every 400 milliseconds.

To download the library, visit the GitHub repository.

UPDATE: This library has been updated as of January 16th, 2011.

Thursday, October 21, 2010

SMD Resistors Cheat Sheet

Here's cheat sheet for reading SMD Resistors that I came up with recently.
If you have trouble reading these components, try using a magnifier.
Here's the link to view it.

If you think you can't solder these think twice, these are actually pretty easy after you practice a couple of times. Here's an 8-part tutorial from the folks at Sparkfun Electronics.

Saturday, September 4, 2010

Quadcopter Project

A few months ago, my brother suggested that we should build together a Quadcopter.
He showed me a few videos and I automatically fell in love.



This was the very first video I saw about it and perhaps the main source of inspiration.
What you see there is a helicopter with 4 rotors. It uses sonar sensors to measure the distance from the floor, infrared sensors to measure the distance from objects directly to the sides, and much more. It has two modes of operation: acrobatic mode and autonomous mode. The former allows control using a RC transmitter and the latter uses only a microcontroller for autonomous flight.

I'm somewhat experienced with microcontrollers, having designed and built devices with them for a few projects for academic purposes.

Perhaps the first issue I ran into when getting into this was the amount of investment required to put one of these babies above ground level: time and money. But taking it slow, my brother and I have managed to acquire quite some of the electronic components as of today, including all the sensors, GPS, telemetry devices, and the microcontroller itself.

I have a friend who will be helping me with the frame of the Quadcopter, which is yet to be designed and built.

I've designed a block diagram to visualize the whole system. Here's how it looks so far:

Click the image to see it in full size.

In the following posts I will be talking about the Quadcopter and the parts you see in the diagram.

Thanks for reading!

Saturday, July 24, 2010

Seeeduino Mega & ATMega 1280 Pin Equivalence Cheat Sheet

This cheat sheet makes easy to cross check the pins in the Seeeduino Mega board with the ATMega1280.
Very useful if you are using or plan to use AVRLib directly.

The following image is a preview:
You can get this cheat sheet by going to this link.

Comments, suggestions, corrections and complaints are welcome!
If you've used this cheat sheet, I welcome you to share your experience.

Electronic & Electrical Cheat Sheets

Here are the first versions of the cheatsheets I've been making. These are meant to be used as quick reference guides for any electronic/electrical project.
The cheat sheets I've come up with are the following:
  1. Basic Operational Amplifier Configurations
  2. Capacitors
  3. Ohm's & Watt's Laws
Here's a preview of the first one:
The Basic Operational Amplifier Configurations cheat sheet contains the schematic diagram and transfer function for each of the following configurations:
  1. Voltage Comparator
  2. Non-Inverting Amplifier
  3. Inverting Amplifier
  4. Voltage Follower
  5. Inverting Summing Amplifier
  6. Differential Amplifier
  7. Differentiator Amplifier
  8. Integrator Amplifier
To get this cheatsheet, follow this link.

Here's a preview for the the Capacitor cheat sheet:
This cheat sheet shows how to read the tolerance, maximum operating voltage and capacitance in ceramic capacitors, provides a conversion table for capacitance. Just look up the codes for the tolerance and max. voltage in the corresponding table.
In addition, I've included a drawing of an electrolytic capacitor for comparison. They are certainly not drawn to scale.

Get it here.

The third cheat sheet that I've been working on is widely available on the Internet, but since I wanted to have my own personal version, here it is: Ohm's & Watt's Laws.
They help you figure out quick and easy how to calculate current, voltage, power and resistance given two known electrical values.
To view this cheat sheet, go here.

I'm going to explain to you how to use this cheat sheet in case you've never seen this before.
Let's say for example that you want to calculate how much power (in watts) will dissipate a 470 ohms resistor connected to a 9 volt battery.
The resistor is 470 ohms. Therefore R=470\ ohms.
The battery is 9 volts. So V=9\ volts.
Looking at the Watts (P) quarter in the circle (top left one), you can see that there's a formula to obtain P given V and R, which happens to be \frac{V^2}{R}.
Therefore P=\frac{V^2}{R}.
Substituting V and R in the previous formula: P=\frac{9^2}{470}=\frac{81}{470}=0.17\ watts.
And that's your answer.

Hope this helps anyone out there.
Any comments, suggestions, complaints and corrections will be very appreciated.


Wednesday, July 21, 2010

How To Configure XBee & XBee Pro Series 1 on Linux

This tutorial will explain how to communicate with XBee modules using the X-CTU Configuration & Test Utility software from Digi.

Requirements
  1. A computer running Linux with at least one available USB port. I'll use Ubuntu in this tutorial because that's the one I've got. Don't use USB powered USB Hubs, since these may not be able to provide enough power for the USB XBee Adapter. You'll need two available USB ports if you are planning to configure and test the XBees simultaneously.
  2. You will need at least two (2) XBee modules Series 1 for any project.
  3. You will need at least one USB XBee Adapter. You can buy them either from SparkFun Electronics or Adafruit Industries. My personal suggestion is that you get two and not one, so that you can configure and test them simultaneously (you can have the X-CTU utility open many times). Assemble the USB XBee Adapter if it doesn't come fully assembled.
    I got myself the Adafruit version (manufactured by Parallax).
  4. You will need at least one USB A To Mini-B Cable. You'll need it to connect the USB XBee Explorer with your computer. Get two if you are planning to configure and test them simultaneously.
  5. You will need the FTDI Virtual COM Port drivers.
    Up-to-date linux kernels (2.6.9 or greater) have FTDI support built-in.
    If that's not the case, get the Virtual COM Port drivers from this link and proceed to install them.
  6. Download and install Wine. Here's a guide for Ubuntu, or just type sudo apt-get install wine on the command line.
  7. Download and install the X-CTU Configuration & Utility software from this link. Make sure Wine is installed before attempting this step.
  8. Obtain the firmware versions for your XBee modules.
    If you fail to do this step, you will have problems trying to read the XBee module settings and firmware using the X-CTU software. These firmware versions go in the update folder in ~/.wine/drive_c/Program\ Files/Digi/XCTU.
    You can get them in a couple of ways:
  1. Download the firmware versions for your XBee modules from this link.
    Extract it in ~/.wine/drive_c/Program\ Files/Digi/XCTU.
  2. Download, install and run X-CTU in Windows (could be inside a Virtual Box).
    Go to Modem Configuration and click in Download new versions (it make take a while).
    After it's done downloading, open the X-CTU installation folder in Program Files\Digi\XCTU, and compress the update folder located inside.
    Transfer the compressed file to ~/.wine/drive_c/Program Files/Digi/XCTU and extract it.
  3. If it asks permissions to overwrite any files, just agree to every file.

Running X-CTU on Linux and testing the XBee module and the USB XBee adapter
  1. If you have already added the COM ports to Wine, skip the next step.
  2. Wine allows us to map serial interfaces to COM ports easily.
    Wine reads COM ports from the "
    dosdevices" folder, which is located in ~/.wine in Ubuntu.
    In Ubuntu, the USB serial ports will appear as
    /dev/ttyUSB0 for the first one, /dev/ttyUSB1 for the second, and so on.
    Open up the terminal, and create a soft link to the
    ttyUSB0 like this:
    ln -s /dev/ttyUSB0 ~/.wine/dosdevices/COM4
    If you are going to connect two USB XBee adapters, you might want to add COM5 too.
    ln -s /dev/ttyUSB1 ~/.wine/dosdevices/COM5
    Make sure you type COM in upper case otherwise Wine won't recognize it as a serial port. (Thanks Tyler for pointing this out)
    This will map the first USB serial port to COM4 and the second to COM5. Remember this, as we will need to type it in later.
  3. You will only need to do this step ONCE, as the soft link will persist.
  4. Insert the XBee module into the USB XBee adapter correctly, if you haven't already.
  5. Connect the USB cable from the USB XBee Adapter to the USB port on your computer.
  6. The USB XBee Adapter power leds should light up.
  7. Open up X-CTU using Wine. In Ubuntu, it will be installed in ~/.wine/drive_c/Program\ Files/Digi/XCTU.
    cd ~/.wine/drive_c/Program Files/Digi/XCTU
    wine X-CTU.exe
  8. In the X-CTU software, go to PC Settings > User Com Ports.
  9. In the "Add User Com Port" field type COM4 and hit the Add button.
    Repeat steps 7 and 8 to add more COM ports.
    You will have to do steps 7 and 8 every time you open the X-CTU, a minor nuisance, in my opinion.
  10. Select the previously added COM port in the list above by clicking it. It should appear as User (COM4).
  11. Hit the Test / Query button to test communication with the XBee module.
  12. Wait a couple of seconds. It should output a window displaying the Modem type and Modem firmware version of the XBee module. For me it was type XBP24 and firmware version 10E6 because I have the XBee Pro 2.4 GHz Series 1 model.
    If you failed to select the COM port in the list, it will tell you that it was unable to open the com port.
  13. And there you go, you have established communication between the X-CTU and the XBee module.
EDIT:  Made some corrections that Tyler pointed out in the comments.


Thanks for reading! And don't forget to share your thoughts in the comments!

Saturday, July 17, 2010

Workshop: The Storage


With a lot of tools it's easy to run out of storage. That's why I decided on getting a 72"H x 36"W x 18"D storage cabinet with 5 shelves.
I did not buy the cabinet myself... but here's a link to one I found on the internet. This one was a gift for me of one of my aunts.

To the left is the image of how it looks in real life.

The handle has no security locking mechanism, so I had to buy a hasp and staple, plus a combination lock from Truper. This is by no means thief proof, but it will keep the hands of the common passerby off my stuff.

This cabinet came with no wheels and moving it was a two-man job. I then added wheels to it.



Here's the first shelf (from top to bottom). Here I'm keeping the Dremel Work Station with Dremel itself, the Iluminaded Magnifier & Desk Lamp, a Duracraft Fan, a vise from PanaVise, the screwdriver bits of the Denali Cordless Screwdriver, and in that black box back there, the Black & Decker Drill.

The second shelf is the one that will be easiest to access while standing straight. Here I've got: the Kawasaki Heat Gun, different sorts of tape, assorted capacitors, LEDs, transistors, sockets, relays, etc., spray paint, lubricants (silicon & multi-purpose), rubber cement, a cable dispenser (which also has solder wire), a multimeter and a graphic calculator.

The small cabinet is way too small for the amount of components I currently have, so I'm considering purchasing one Akro-Mils Plastic Storage Cabinet.

This is the third shelf, here you can see the soldering iron with its base and my Denali Toolkit bag. There's also a box with sorted resistors, a plastic storage cabinet that contains lots of screws, nails, washers, etc., and another plastic storage box that contains USB cables, AC adapters, SATA cables, ASDL filters, phone cables, etc.
The soldering iron goes in the second shelf, not the third... I left it there by mistake.
The lower shelves contain miscellaneous spare parts, cables, "leftovers" and the like.

Here's an overview of the whole thing:

As you can see I've organized almost everything from mostly used and relevancy, from top to bottom.

I learned the hard way that leaving the your tools in the outdoors (even if it's below a roof and inside a metallic storage cabinet) has serious consequences... specially if you live near the equador. Some of my tools are getting rusty and moldy due to the high air humidity.
There's not much I can do because this cabinet does not fit anywhere else around the house... the best solution I can think of right now is getting a dehumidifier or lots of silica gel pouches.

That's it for now folks!

Friday, July 16, 2010

Workshop: The Tools

Without the right tools, it's hard to accomplish really anything.

I'm on a budget, so I had to spend my money wisely on the right tools that will help me get the job done and that will also last long enough.

I'm the kind of guy who likes to etch his own PCBs, so I needed a tool to make the pin holes for the electrical components, and this need led me to the Dremel 300. It came with 24 accesories that I'm slowly finding use to. In the electronics lab where I used to take classes, we had a work station to use the Dremel, and it was as easy as pulling a lever to make those pin holes straight. That led me to finding necessary the Dremel 220 Work Station. The Dremel 300 came D.O.A., but I shipped it to the Dremel facilities with my proof of purchase, and they returned it back fixed at no extra cost to me.

Sometimes you need a strong and steady hand to hold your PCB when drilling or soldering, and since I had already seen a vise at the electronics lab, I knew what I had to get. The PanaVise 301 was my choice: it is heavy and has nice grip.


After you have a tool like the Denali Cordless Screwdriver, friends will tell you how lazy you are.
But in my case, I don't care! I removed a motherboard, power supply and drives from a computer case in just a few minutes, a task that would have taken me about 3 times that with a simple screwdriver.
It comes with a wall charger that you can hang on the wall with two screws. It's not very powerful, but will get the job done in most cases... but you wouldn't want it to be too powerful either, right?

This is the kit I got so that I didn't have to go buying all the standard tools separately. From the image you can see what the Denali 115-Piece Tool Kit is all about. The carrying bag is pretty handy. The two things that I found missing here are the mini/small pliers used in electronics and the precision screwdrivers, so I had to get those separately.

For the tough holes, I got the Black & Decker DR550 Drill, it's quite powerful when in use, and sounds like a turbine because of the design used to take the heat out of it.

It's hard to desolder boards without the right tool, so I got the Kawasaki 840015 Heat Gun, which does the job nicely. It's packed with a few jets for scraping and the like, as well as scraper handle. You can also use this baby with shrinking tubes... it is indeed a bit big for such task but it just works.

To strip wires, I bought the Irwin Self-Adjusting Wire Stripper, which I found a bit pricey for what it does but in the end it was a good decision. No longer I have cut wires while trying to strip it with pliers. You can adjust the length of the wire that you want exposed with this tool.

Thanks for reading.

Thursday, July 15, 2010

Workshop: The Workbench

I started building a small workshop at home to satisfy all my "electronic engineering" needs.

But no workshop is functional without a table or a workbench.
So I needed one... and it was either buying or building one. I went for the latter.

My friend Wellington Lizardo was kind enough to help me build it.
It took us a few days to get the job done, and it was our very first time doing such thing.

Here's how it looked in the end!
It is made of treated pinewood. The dimensions for the table are 5'x2'.
We used 1" and .5" phillips flat head wood screws to secure all the wood pieces together.
To secure the workbench to the wall, we used six 2" hex bolts. Since the wall is made of old concrete, we had to drill a lot. Yes, a lot.
I got a separate breaker box, fed directly from the power lines. This picture was taken before I had installed a Voltmeter Panel on the breaker box.
You can also see the Tripp Lite PS4816 16-Outlet Power Strip. That baby can provide a total max current of 15 Amps.
Also, hooked on the table is the charger for the Denali 3.6-Volt Lithium-Ion Cordless Screwdriver, which I believe is very convenient.

First Entry

Hello there!

Since this is the very first post, I believe it would proper to start by introducing myself.
My name is Ricardo Arturo Cabral and I'm an electronics engineer and a software developer.
I was born in June of 1988; lived for the most part of my life in Santo Domingo, Dominican Republic and about two years in Miami, Florida.

Ever since I was a little kid I've always enjoyed building things, to understand how things really worked from the inside out. This motivation led me to gain a deep interest in programming and electronics.

Being an autodidact, I taught myself programming, and developed my skills through practice (Oh, those sleepless nights). Did I mention that I really enjoy programming as much as playing a game?

I graduated from the "Instituto Tecnológico de Santo Domingo INTEC" at the age of 21 in Electronics Engineering and Communications.

I'm currently working full-time for WIND Telecom (a telecommunications company based in Dominican Republic).

Enough about myself!