Accelerating at the Speed of g*

Adventure is sometimes a one step forward, two steps backward affair. Building a quadcopter is definitely such an adventure.

Babe in Robotland
4 min readSep 8, 2014

I could not find my Arduino sketch. I searched via every method the Linux terminal made available to me. Forlorn and exasperated, I nearly put my sensor+Arduino setup away, content to just lay on my bed and count the dots on the ceiling.

Thankfully, I did not do this. I decided giving up was the quick and easy path, but a quadcopter that would not make. So I forced myself to re-write the code I had finished last weekend. When it came to testing it, I remembered that running the Arduino IDE on Linux requires running it using sudo from the terminal so that I can access the port (I think I could change some user permissions to avoid this…but alas….). I reloaded the software and suddenly my file returned! I was relieved, to say the least. I thought perhaps there was a virus on my computer, or that during an update the file was deleted. No. Instead, my file had been saved in the root home directory. So now I have two versions of the same code.

I did make progress today with the accelerometer (ADXL345) on the sensor stick. I am officially getting readings in g’s which is fairly exciting. I also figured out the orientation of the coordinate system. Mostly, I recognized that gravity acts in the z-direction, so of course I should only see a value in the z-direction if my x-y plane is flat on the table. This hypothesis was proved correct when I rotated the device in the direction I believed would orient x or y in the direction of gravity. On a side note, it’s kind of freaky that an electronic device with capacitors in it can even sense that.

A lopsided recording of my accelerometer’s reading. Sorry it’s sideways like that.

The video shows the scrolling of values coming from the accelerometer. My apologizes for not having the brains to turn the phone sideways. I’ll improve that in the future. (Yes that’s taken from Snapchat, I’m keeping with the hipster theme here.)

The nice thing about learning is that you don’t have to do it alone. The internet is your guide. Or my guide. I decided to build a quadcopter with nearly zero engineering background (I’m a final year undergraduate physics student, however). So I don’t have much of an education in I2C or communicating between devices with bit addresses, or even bitwise operations for that matter. All I know is how to program and build a computer. I do know how to solder. That’s true.

I am trying to give a thumbs up to the internet here, but like all selfies, I only managed to feed my narcissistic ego.

My point is, without the internet, I would not have been able to get this far because reading the datasheet is tricky. I really didn’t understand how to go from least significant bit to g’s (g = 9.8m/s^2). I also had no idea how I was supposed to combine the two values for each axis. I learned, though (you have to shift the first one over 8 bits—the least significant bit is on the far left—and then do an OR operation on it, which will essentially combine them into one giant 16 bit binary number, that’s the number you convert to a decimal value, this really only seems to matter when you are dealing with negative decimal numbers). So the intertubes gets special kudos.

I suppose that’s really all that I accomplished today. It really doesn’t seem like a whole lot. The amount of understanding I had to absorb was the most challenging part! The code is actually very simple. I would also like to mention that sprintf() does not really work well with Atmel microprocessor. It does not understand floats. Perhaps it’s the bootloader? I don’t know, to be honest.

Anyway, here’s a better shot of the code, in case that video was too obnoxious to look at. Next week I will work on communicating with the gyroscope. That should be fun, I really have no idea how a gyroscope works other than I think it has something to do with self-correcting so it is always upright.

Until next time! — Margot.

*Ok, I realize g is not a speed, but it sounded nice. Sue me.

--

--

Babe in Robotland

Trying to explore and document (like a good scientist) my foray into the world of robotics. I really want a 3D printer.