Tuesday, December 30, 2008

This is how I roll...

I printed a plastic wheel hub and wheel molds with integrated funnel. If you want to make custom wheels like these you need to cast them using mold rubber. They have a variety of rubbers you can use to get tackier or more durable wheels.

More information about the casting process and how to use it is available on Smooth-On's website. The resin casting plastic is also very interesting for custom robot parts.

Interesting Actuator Design

It uses a small electromagent coil to twist the rare earth magnet with a linkage or end effector attached. In the video it is being used for a micro-aircraft rudder.

The direction of the current will determine which direction it will rotate while the magnitude of current and the field strength of the rare earth magnet will determine the torque.

HyperPhysics has all the equations you could ever need to determine the required size and shape of the coil and magnet.

Tuesday, December 23, 2008

Smooth 3D Printing

Stratasys has developed a new smoothing station for smoothing the surface of 3D printed parts. This looks like it will produce better results than using acetone or sanding and coating with clear spray enamel. On the downside it looks like it requires compressed air and an air exhaust system so you don't die of industrial solvents. The MSDS as usual is scary and suggests that you do not want to be near this stuff without a respirator. Also, the dimensional accuracy of the smoothed parts is currently unspecified. On the other hand, smooth parts are pretty awesome.

Thursday, December 18, 2008

Cool Tool: Last Chance for Holiday Presents

Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. Give a man tools and he will make a robot to fish for himself. Tools really are the best possible presents.

  1. Brass Sponge
    Never forget to wet your sponge again.
  2. "Smart" Tweezers
    For when you have a pile of surface mount capacitors, all alike, all different.
  3. PCB "Fab-in-a-Box" *
    The best thing for making PCBs other than having lots of money.
  4. Calipers *
    These are the calipers I use, except the face of mine is cracked because I dropped it but it still works.
  5. Screw Chek'R *
    If you ever need to deal with screws this is an invaluable tool.
  6. Weller WES51 Analog Soldering Station *
    This is what I use to solder 0603 and smaller surface mount parts.
  7. microscope
    For surface mount soldering you want something like this... I dont know anything about this seller, do not blame me...
  8. Xacto Black Gripster Knife *
    I like this knife for detail work as I feel less likely to cut myself.
  9. Taig or Sherline CNC Mill
    I have used the Taig and I assume that the Sherline is just as good.
  10. Logic Analyzer
    I am still using an ancient Tektronix logic analyzer but one day I will get a USB logic analyzer.

* = I already bought this for myself.

Wednesday, December 17, 2008

Crash Test: Basic Kalman Filter

Crash Test: We have liftoff!

Here is the video of semi-autonomous flight testing. Since, the GPS is not working yet due to interfacing issues between 3.3V and 5V power, the horizontal motion is not controlled by the flight computer.

Tuesday, December 16, 2008

Crash Test: Ready for launch

More videos later tonight tomorrow.

Sunday, December 14, 2008

Crash Test: Guidance is internal

PID Control system is up and running with data from the inertial navigation system. Autonomous flight videos should be up later this week.

Saturday, December 13, 2008

dsPIC Testing

I wonder if the blue LED is bright enough...

Friday, December 12, 2008

Cool Tool: PCB "Fab-In-A-Box"

So I broke down and bought myself a present, and while the system is by no means fool proof, the PCB "Fab-In-A-Box" from Pulsar ProFX is the solution to making PCB boards you may have been looking for, if you wanted to make PCB boards.

The process is pretty quick and low effort, however there are a few tips.
0) Just buy the laminator, once you know it works you will want to make a lot of boards so using an iron will quickly become annoying. They also offer a money back guarantee, which I did not need to use, but I assume works since their product works. So they probably never have to return any money. I would have been frustrated if I did not get the laminator and would say it is critical to making the system work.
1) Get gloves
2) Get tweezers or tongs to grab the circuit board out of the ferric chloride.
3) Buy three easy to open airtight plastic containers with a flat bottom big enough for your boards, use one for water, one for ferric chloride, and one for acetone.
4) Do not attempt to make a circuit board without verifying the orientation, I strongly suggest putting words on the copper layer somewhere in your ground plane.
5) In the instructions it instructs you to leave 2" of Green Toner Reactive Foil but does not explain why, so you might be tempted to try to economize. The length of 2 inches is required to slide it into the laminator and hold the foil tightly to remove wrinkles.
6) Clear Scotch Tape worked better then regular masking tape at removing extra green TRF debris.
7) Cover the board in acetone and agitate for a few seconds until the green layer starts to separate, before scrubbing.

I also tried using the proper tooling for milling PCBs, however the CNC Mill I was using is just slightly out of level enough to make the results useless. Also, milling a PCB takes hours, even for a small one.

Using the PCB "Fab-In-A-Box", I was able to produce a circuit board with 8mil traces in about 30-40 minutes. I was able to verify good results using a microscope for one of my tests, the other test had process issues due to my attempts to use less Green TRF than was suggested.


Actually works
Chemical mess is minimal and containable
Less then 8mil traces, The vendor shows examples of 6mil traces
Fast results

No solder mask
Only 1/2 Oz. Copper Pour is recommended 1 Oz Copper is the maximum.
The recommended board is .032” thick so it lacks some of the typical stiffness one would expect from a PCB so it cannot be used as a structural element. Tested with 0.064" boards. You need to give it a little push but it seems to work fine.

While the board thickness and copper thickness are of interest to those who are working with power or antennas, for the most part this system is unbeatable and I am glad I spent the money on it.

Total cost was under $150 without shipping. I bought mine from Digi-Key to save on shipping.

I'll post a video of the process in the next week or two.

Thursday, December 11, 2008

PPM Signaling

So it turns out the Draganflyer actually uses PPM Signaling which is actually much easier to generate with a microcontroller.

Wednesday, December 10, 2008

12Bit Servo Controller

PIC Microcontroller Code Fragments

Clock shown as pin 2 on JP2 is connected to B7 on the PIC and Reset on pin 3 is connected to C1 on the PIC

Global Variables

// Number of servos
// Due to timing limitations you can really only use 9 servos with a 4017
#define SERVOCOUNT 5
// This is 65536 minus number of clock ticks in 1 ms plus or minus a fudge factor
// This was determined using an oscilloscope
#define SERVOBASE 55067
// This union allows access to the servo timing as an integer and as two bytes
// This makes the interrupt code faster and the whole thing more stable
union ServoTimers
unsigned int position;
unsigned char byte[2];
} servotimer[SERVOCOUNT];
// This is the 12 bit servo value 0=>1ms 2048=>1.5ms 4096=>2ms
unsigned int servo[SERVOCOUNT];
// Servo trims can be used to align the center position of the servo a small ammount
signed int servotrim[SERVOCOUNT];
// Counter for sending the servo signals sequentially
unsigned char currentservo;
// Used to track the state of the Reset signal
BOOL servoReset;
// Used for pulsing the Clock signal
BOOL servoOn;

Interrupt Code
void HighPriorityISR()
// If Timer0 Interrupt is Flagged
if (INTCONbits.TMR0IF) {
// Reset Interrupt Flag
INTCONbits.TMR0IF = 0;
// If the servo has been reset hold C1 low for almost 20ms
if (servoReset) {
servoReset = 0;
TMR0H = 0xF8;
TMR0L = 0xAF;
LATCbits.LATC1 = 0;
// Otherwise bring Reset/C1 high briefly and start clocking
// servo data out via Timer 3
} else {
servoReset = 1;
TMR0H = 0xFF;
TMR0L = 0xF0;
TMR3H = 0xFF;
TMR3L = 0xF0;
LATCbits.LATC1 = 1;
if (PIR2bits.TMR3IF) {
PIR2bits.TMR3IF = 0;
// For each servo pulse set Clock/B7 high momentarily
// then hold B7 low for the current servos desired pulse width
if (currentservo < SERVOCOUNT) {
if (servoOn) {
TMR3H = servotimer[currentservo].byte[1];
TMR3L = servotimer[currentservo].byte[0];
LATBbits.LATB7 = 0;
servoOn = FALSE;
} else {
TMR3H = 0xFF;
TMR3L = 0xF0;
LATBbits.LATB7 = 1;
servoOn = TRUE;
// Otherwise dont call this interrupt for a while
} else {
TMR3H = 0x00;
TMR3L = 0x00;
LATBbits.LATB7 = 0;
servoOn = FALSE;

Servo Control Functions

void ServoInit(void)
int i;
servoReset = FALSE;
servoOn = FALSE;
// Center all servos and zero all trims
for (i=0; i<SERVOCOUNT; i++) {
servo[i] = 2048;
// UpdateServos must be called after servo[i] or servotrim[i] is modified
currentservo = 0;

void UpdateServos(void) {
int i;

// Convert each 12 bit servo position into interrupt timing
// The maximum time for an interrupt to overflow and trigger
// with a given prescaler and clock is with TMRxH and TMRxL
// set to 0, a timer setting of 0xFFFE will trigger the interrupt instantly
for (i=0; i < SERVOCOUNT; i++) {
servotimer[i].position = SERVOBASE - (3*servo[i]) + servotrim[i];

This setup allows the servos to be positioned with 12bit resolution.
servo[0] = 0 => 1ms => Left
servo[0] = 2048 => 1.5ms => Center
servo[0] = 4095 => 2ms => Right

The trim control is done independently of the servo position setting and does not effect the positional resolution. The actual resolution will vary between different manufacturers and models and this controller unfortunately does not work with the Draganflyer.

Tuesday, December 9, 2008

Crash Test:: Progress in the face of adversity

It turns out I didn't fry the diode.

After some advice troubleshooting, it turns out that I burned out one of the traces.

After desoldering and scraping it clean, copper foil tape is cut to size and applied to the damaged area.

Resoldering the copper tape helps ensure conductivity.

Reassembled and successfully tested.

This post was brought to you by 3M, the makers of electrical tape.

Crash Test: Flight testing & Servo Problems

The servo controller was glitching due to interrupt problems.
I should have known better, but I have learned my lesson and will not use WriteTimer3 inside an interrupt ever again.

Sunday, December 7, 2008

Circuit Board Milling Attempts

Today various experiments were made to produce circuit boards, and many of them failed.

Interesting lessons; nail polish does not work as a solder mask, I hate soldering without a solder mask, and if you plan ahead getting boards printed is cheap. I would probably not try this again unless someone can explain what exactly I did wrong.

Cool Tool: USB to RS232 TTL

In some ways I might be sad to see the serial port go, but I have to say this USB to RS232 3.3V TTL 5 volt tolerant cable looks pretty awesome.

Also, let me add my serial port haiku

I type plus plus plus
then I type eh tee haych zero
I hate serial

Friday, December 5, 2008

Milling Carbon Fiber

Milling custom carbon fiber robot parts is possible if you have the proper safety equipment and tools. While carbon fiber dust has not yet been proven to be carcinogenic, its safe to assume that you do not want to inhale it or get it in your eyes, so both eye protection and a respirator are required.

A CNC mill and a bur were used to route the carbon fiber parts. While cutting, the carbon fiber is kept wet with lubricant to prevent dust formation while being vacuumed. A speed of 10000 RPM and a feed rate of 50 mm/min were used with good results on a plate 0.059" thick. The edges were finished with wet sandpaper to prevent injury due to splinters.

Thursday, December 4, 2008

Wednesday, December 3, 2008

Tuesday, December 2, 2008

PCB Milling Test

A 30 Degree Conical Burr was used as the cutting tool mounted in a CNC mill to cut a copper clad board.

The cutting path produced is approximately 0.5mm wide, so it should be possible to produce layouts for SOIC and other surface mount footprints. Smaller separation between pads may be possible as the 1oz copper pour is only about 1.4 mils thick.

Canned air worked fairly well to remove the copper debris from where the path was cut and this looks like an interesting calculator for PCB trace widths.

Tomorrow's experiment will be to manufacture an actual circuit board and to test how well nail polish acts as a solder mask.

Monday, December 1, 2008

Weekend Round-up

Interesting Personal Pages

While I am not sure I like the name physical computing, I do like the idea of making the job of programming embedded systems easier.

Tomorrow's project is to figure this out.

Here is a great quote.

Jewelry and Metalworking store in NYC

Thursday, November 27, 2008

NYC Hobby store

America's Hobby Center 1931 has sadly left Manhattan so it is time to find a new hobby store.
Big Apple Hobbies in Queens looks like a good one.

Crash Test: Draganflyer with Sensor Payload

Monday, November 24, 2008

Optical Flow and Computer Vision

Here is a good example of optical flow

This video uses the OpenCV Library for optical flow.

This seems to be a fairly robust real-time 3D tracking system, that has obvious robotic applications.

Saturday, November 22, 2008

mikroElektronika PIC Microcontrollers Free Online book

mikroElectronic offers a free online book about PIC Microcontrollers. The book is very well illustrated and cleary written with good examples.
While it mostly focuses on using the PIC 16F887 microcontroller with assembly, large portions of the book are also applicable to other PIC microcontrollers. They also sell a print copy with CD for $24.

Friday, November 21, 2008

A Mazing Robot

The Pololu 3pi Robot is a line following and maze solving specialist. The 3pi uses an Atmel AVR ATmega168 processor and is Arduino compatible and has expansion boards available for adding additional features. The most interesting thing about this robot is the speed at which this robot is able to follow lines without any odometery information. The package with everything you need is available for $119.95.

Thursday, November 20, 2008

Mechanism Design Software

Linkages, 4-bar mechanism, and other multi-bar mechanisms are useful for many robotic applications such as robotic grippers, payload bays, arms, legs and a variety of other robotic limbs.

The WATT Mechanism Suite from Heron Technologies provides a software solution for designing mechanisms from arbitrary motion paths.

The user interface was easy to use and I was able to produce a simple four-bar mechanism design in under an hour. WATT outputs a variety of information such as the path error and velocity in excel format and can export geometry information in DXF. While, it was not initially obvious to me when the software encountered a problem due to the mechanism jamming, the software generally produces good results for a wide variety of cases.

The list price for a single-user copy is 1575.00 Euros, however there is a 50% educational discount available for qualified organizations.

If you are on a budget you may want to consider The Geometer's Sketchpad which is available for $39.95. The Geometer's Sketchpad is a software program designed for use with "smart" whiteboards. The animation mode can be cleverly used to cheaply produce motion simulations for multi-bar mechanisms without having to resort to pieces of cardboard and Brass Fasteners.
The linkage library provides some good examples of what the software can do if you are persistent enough to figure out the interface. It is helpful when learning how to use the software to remember that "smart" whiteboards are lucky to have one mouse button, and that a line can be defined by two points. Once you manage to figure out the horrible user interface, The Geometer's Sketchpad turns out to be a pretty good program for the price.

Analog Devices IMU now available with integrated Magnometer

The ADIS16365 Inertial Measurement Unit has been updated to include a magnetometer as we had previously hoped.

The new ADIS16405 now includes a 14-bit 3 axis magnetometer allowing for even more accurate inertial measurements for your aerial robotics project.

Analog Devices promises "0.05 degree rate-sensor orthogonal-alignment-accuracy" for the alignment of the gyroscopes.

The new sensor is pin compatible with previous versions so the only design updates, besides swapping out the sensor, will be software changes.

Estimated pricing for the ADIS16405 sensor is $412 for quantities of 1,000 units.

Hopefully, they have already thought of integrating a barometric pressure sensor for use as an altimeter.

Tuesday, November 18, 2008

Problems and Solutions

Is this problem hardware or software? or both?

The solution to trying to troubleshoot this is a Tektronix 1230 Logic Analyzer or maybe a more modern logic analyser.

PIC SPI Bus Example

Here is some example C code for connecting to a LSI/CSI LS7366 32-bit counter from a PIC 18f4550 using the C18 compiler.


Unfortunately, Blogger does not seem to like bit-fields.

Friday, November 14, 2008

Thursday, November 13, 2008

NYC Robotics

While the Big Apple may not yet be know for its robotics, Here is a quick roundup of cool robotics and Engineering related things in the city.

League of Electronic Musical Urban Robots
Music by robots, for robots and humans.

Awsome foam core aircraft

NYC Resistor
Brooklyn Hacker collective near MetroTech

Art + Technology

Robot Village

The place to go for your child's robot themed birthday

Our big list of NYC Resources , let use know if we missed anything.

The spam turing test below will provide the email address.

Wednesday, November 12, 2008

Do Not Modify : 4 of n

Here is the demo of the targeting system in action during a talk on computer vision.

Here is a demo of another robotic targeting system, albeit not quite as harmless.

Tuesday, November 11, 2008

iRobot opens brick and mortar store, while Lely cleans up

iRobot has opened its first retail store, possibly hoping to provide an alternative to troubled retailers.

Press release

What people really need is a Hello Kitty sticker on their Roomba...

iRobot has also recently announced a $3.5 million dollar order from the Army for 26 PackBot robots

I saw a video once that almost brought me to tears, where a little robot rolled up to an IED and tried to disarm and it ended up kicking the bit bucket. I thought to myself, "that robot saved a human life". In the future I hope our robot overlords will think kindly of me...

If the iRobot Dirt Dog
is not powerful enough to clean up your mess, you may want to check this out.

Somewhat surprisingly, Lely had sales of 273 million euros while iRobot had sales of about 249 million dollars. I was not expecting the market for farming robots to be doing this well, but I guess the labor costs are much lower and the cows seem to be happier with automatic servicing.

Saturday, November 8, 2008

How To: Screw Threading Die

Round - Dies Thread Size: 4-40 Thread Type: NC Outside Diameter: 13/16 Material: HSS Style: Split Adjustable
Stocks Holders - Dies Style: Die Stocks Die Outside Diameter: 13/16

Machinery's Handbook Toolbox Edition (Machinery's Handbook)
This book has all the information necessary to calculate the outside diameter of the part to be threaded, or you can guesstimate by measuring the outside diameter of a similar screw.

Poly-Cal Electronic Caliper-English/Metric/Fraction - 74-101-175 by Fowler - Fowler - 74-101-175
These are good entry level calipers, and probably the most commonly used tool in my toolbox.

Friday, November 7, 2008

Do Not Modify : 3 of n

More progress

Thursday, November 6, 2008

Wednesday, November 5, 2008

Do Not Modify : 2 of n

Quickcam 9000 Pro Tactical Nerf Targeting System

Tuesday, November 4, 2008

Do Not Modify : 1 of n

"Do not modify darts or dart blaster"

Thursday, October 2, 2008

Open Source Digital Servos

The open source hardware and software designs available from OpenServo look to be a viable alternative to the expensive digital servos used in building a Robo One class robot. The OpenServo replaces the analog control board in a low cost analog servo with a digital controller based off of the Atmel AVR. This digital control board allows for better control and feedback from the servo.

In other news it looks like Microchip is trying to buy Atmel. Which probably wouldn't change much of anything, but it is still strange.

Wednesday, October 1, 2008

High-Precision Tri-Axis Inertial Sensor

ADIS16365: High-Precision Tri-Axis Inertial Sensor

For those of you in the robotics community interested in the progress in the micro-electro-mechanical systems (MEMS) world, Analog Devices has managed to fit 3 accelerometers and 3 gyros into one package, and they have started sampling the latest version. This is a significant improvement to the design and development of many autonomous robots. About the only thing keeping it from being perfect, for my application, is that it is missing a magnetometer and maybe an altimeter. They did however provide an auxiliary 12bit ADC that could be used for those sensors.

This inertial sensor provides analog to digital conversion at 14 bit resolution via SPI Bus at up to 819.2 Samples per second. Keep in mind that this is preliminary information and subject to change and many of the specific parameters are still to be determined.

There are two critical advantages to this sensor; the first is the small size of the sensor which is 23mm on a side and that it connects via a flex connector so you do not have to deal with trying to solder BGAs, secondly by integrating the MEMS devices in the same clean room facility and possibly on the same silicon wafer they should be able to reduce the angular misalignment and non-orthogonality between the axes.

Even better though is that an older model is already available with similar specifications. However according to our contact at Analog Devices, the new sensor has several significant improvements. The new sensor improves the bias stability of the gyros by more then 50% and increases the maximum saturation of the accelerometers to 18g, up from earlier 1.7g and 10g versions. Faster data transfer rates using SPI burst mode and external sync options are also available.

ADIS16365: High-Precision Tri-Axis Inertial Sensor

ADIS16354: High Precision Tri-Axis Inertial Sensor
ADIS16354AMLZ $325.86

Aerial Robotics

Draganfly Innovation's new six rotor co-axial Draganflyer X6 helicopter is now available for only $14,995.00 USD.

Rotomotion UAV Helicopter


After you buy or build your own it's time to check out the rules for the International Aerial Robotics Competition's 5th Mission.

Also, it looks like the JAUS protocol will become the standard for UAVs and ground robot communications, with both the IARC and the International Ground Vehicle Competition being used as undergraduate testing grounds where the real world problems can be worked out before JAUS support is mandated for military contracts.

Tuesday, September 30, 2008

UAV Damage Control

Rockwell Collins demonstrates adaptive control system for UAVs capable of compensating automatically for battle damage.

Rockwell Collins' Automatic Supervisory Adaptive Control (ASAC) technology Press Release

This appears to be based on a conference paper titled "Application of Relay Tuning Methods to UAV Autopilots" which was presented at the 2006 AIAA Guidance, Navigation, and Control Conference and Exhibit.

It looks like that by using relay tuning methods they are able to recompute the PID controller gains for the UAV Autopilot quickly enough to maintain stable flight, this system should also work with morphing aircraft.

A similar concept might also be applicable for ground robots being damaged or traveling on varying terrain.

Wednesday, September 24, 2008

Books for Robots: Quaternions & Rotation Sequences

If rotation matrices are not working out for you due to the gimbal lock problem or poor speed performance, you could consider using quaternions.
The advantage is that the rotation operations are much faster and more accurate due to the rotations simply being multiplications without using trigonometric functions. Strangely, quaternions use a four dimensional vector with three imaginary numbers and one scalar, whose product is non-commutative.
This book somehow does the impossible and clearly explains something that seems crazy. Additionally the book has some of the best figures for explaining Euler angles I have seen.

Saturday, September 20, 2008

Robotics Sea Snake

Amphibious snake-like robot "ACM-R5"

Developed by the Hirose Lab at the Tokyo Institute of Technology, his amphibious robotic snake moves with surprisingly natural movements on both land and underwater. The robotic snake is not quite small enough to crawl through smaller plumbing pipes. Its main body is 80mm in diameter without the fins, and has a total length of 1.75m. Interestingly it looks like it uses regular hobby servos for its joint actuators, perhaps they are using the high torque versions.

[From: Fuji Sankei Business i.]

Thursday, September 18, 2008

Wednesday, September 17, 2008

Product Design & Development Review

Product Design & Development magazine
Score: 3.8 / 5
Difficulty: 2.5 / 5

Product Design & Development magazine usually has one or two interesting articles, and the rest of it is ads and advertorials.This isn't really the type of magazine you read for the articles if you know what I mean... Every issue has at least one product listed that I had never even thought to look for that could definitely be useful for a project.
For example, I found the LSI/CSI 32-Bit Multi-Mode Counter with Serial Interface Part #LS7366R in one issue. I didn't even think to look for an integrated circuit that could interface between a quadrature encoder interface and SPI Bus. Unfortunately I found this after I implemented the same thing with a PIC microcontroller using sampling. They have full issues available online as well.

Tuesday, September 16, 2008

Analog to Digital Conversion

This tutorial covers some of the basics for connecting an analog sensor to a PIC microcontroller.

In this case we will be using a potentiometer as our sensor, but accelerometers, gyroscopes, temperature sensors, and most other analog sensors will work in a similar way.

As the potentiometer is rotated approximately 315 degrees from left to right the signal voltage will vary between 0 Volts and 5Volts, In this example the output signal will be connected to pin AN0 on the PIC microcontroller. The equivalent circuit shows how the potentiometer can be represented as a voltage divider.

By making the assumption the RL is very large, the output signal voltage is a function of the input voltage and the position of the potentiometer knob.

In practice your input voltage is almost never 5 Volts, and your sensor is never absolutely linear, so probably the best thing to do is to calibrate in software or use a high precision voltage reference. The voltage reference setup is a little more complicated so it will be left for the reader, however here is a series voltage reference from Texas Instruments that would probably work well.
2.5V 100ppm/Degrees C, 50uA in SOT23-3 Series (Bandgap) Voltage Reference
This App Note from Maxim has more information about choosing a voltage reference if you are really interested.
Series or Shunt Voltage Reference?
So ignoring the problems for now, we can determine the sensitivity of the potentiometer.

The range of motion of the potentiometer is estimated to be 315 degrees and the full voltage range is considered valid.

On a PIC 18F4550 the A/D Converter is 10 bits, on the 18F4553 it is 12 bits, these values are substituted in for n.

With these values, the number of degrees of rotation can be determined from the value returned in software by ReadADC()
Keep in mind that you will not get 12 bits of accurate data without some serious work. If you really need 12 bits then you should read the following PDF by Bonnie Baker from Microchip.
Techniques that Reduce System Noise in ADC Circuits

So again skipping the complicated bits, connect the sensor to the PIC microcontroller. In this case we are using Create USB Development boards, but there are many other choices out there.

{tex}$\theta=ADC_{in}*Resolution/Sensitivity\approx ADC_{in}*.3077${/tex}
Theta will be considered to be a positive angle when rotated clockwise from the center position, and a negative angle when rotated to the left.

Using the Microchip USB Framework here is the code fragments necessary to get things working.
the variable x listed in the code below is assumed to be a global float but if you need more speed and less accuracy you can change it.

void UserInit(void)
// set AN0 to input

// etc...

void ProcessIO(void)
// User Application USB tasks
// if((usb_device_state < CONFIGURED_STATE)||(UCONbits.SUSPND==1)) return;

if (lastcount != count) {
Delay10TCYx( 5 ); // Delay for 50TCY
ConvertADC(); // Start conversion
while( BusyADC() ); // Wait for completion
x = ReadADC(); // Read result
x -= 512; // 512 = 2.5Volts ie. Center Position
x *= 0.3077; // convert from mV to degrees
CloseADC(); // Disable A/D converter

// etc...