Showing posts with label circuits. Show all posts
Showing posts with label circuits. Show all posts

Thursday, January 22, 2015

Sharing Resources

I added a list of links to the right-hand side of the blog site (labeled "Misc Resources") as a spot to put some of the better various sites, guides, etc. that I find particularly clear or useful.

To start, I put up two pages I've been using heavily of late:

  • Krondo Twisted Introduction: This is a fantastic (albeit lengthy) introduction to asynchronous programming, specifically in Python and using Twisted. Dave Peticolas does a hell of a job taking what can be a very tricky abstract concept and breaking it down into digestible chunks, rather clearly explained and with a twist of humor throughout. And to top if off, he provide all of his example code conveniently organized in a GitHub repo! 
  • Lessons in Electric Circuits: Tony Kuphaldt churned out six "volumes" of textbooks providing a very detailed introduction to electronics and circuits, all available for free (including PDF copies). While the text is a bit excessively thorough and tedious for my purposes & interests, it's so well organized that skimming through to get high-level ideas and work towards the topics of interest to the reader is made really easy. There's an abundance of diagrams and examples, with every phenomenon and lesson very accessibly elucidated. 
I'll try to remember to add in great resources as I come across or recall them. And maybe every once in a while, I'll do something like this post, and provide a summary on recent additions to the list. 

Friday, December 12, 2014

Getting Physical: Learning to Interface Python & Hardware

I've always been more of a software guy then a hardware guy. But a litany of factors have resulted in me finally putting a lot of real effort into making an old idea of mine become a reality, so now's the perfect time to start getting hands-on experience working on the hardware side of things!

In short, I need to create a device that can take some real-time distance and motion measurements. Ideally, this device will be small, inexpensive, simple to setup/install, and wireless (which means wireless communication and wireless power). To start, though, I'm just getting a functional prototype going for proof-of-concept, so I'm not worried about the size, wired vs wireless aspect, etc.

It's Alive!

Maybe I'll get a chance to go into some more detail at a later date, but for now I'll skip to the cool part: version 0.2 is operational! (I arbitrarily used v0.1 to getting the accelerometer working, and v0.2 has the distance sensor as well).
Device v0.2: RaspberryPi + GY-521 MPU-6050 accel/gyro + HC-SR04 range sensor

Since I went into this pretty blind (no idea what I'm doing at the outset) and a with low expectations (circuits was one of my worse courses in physics undergrad), I made some choices that erred on flexibility. For one, I started with a Raspberry Pi B+ model. Choosing a RasPi instead of an Arduino came down to two key differences:  1) RasPi is an all-in-one computer while Arduino is a much simpler microcontroller, so the former has a lot more functionality while the latter is intended for a single or fewer uses; and  2) Arduino's programming environment is in C, while Raspberry Pi runs a parred-down Linux, so I can code in just about anything I like: Python, Perl, Java, C, etc. 

There are a wealth of helpful tutorials for getting started in RasPi and interfacing it with various sensors & equipment. For the accelerometer/gyroscope unit, I used a Kootek GY-521 MPU-6050 (also bought a couple ADXL-345 units which were popular on blogs & tutorials). And for distance, I'm used an HC-SR04 ultrasonic range sensor. I'll make a note to come back at a later time and link out to the best tutorials I found, but a simple Google search gives you plenty. 

Oh, and for the Raspberry Pi board itself, I went with a starter kit from CanaKit, which provided a lot of the important peripherals in addition to the basic RasPi board (e.g. power supply, wifi dongle, enclosure). As a complete idiot when it comes to DIY circuits/electronics, I can say the CanaKit package was a really great place to start. 

In the end I'm actually a bit surprised that once I learned the basics of build-it-yourself electronics, the hardware aspect of my project was a surprisingly small portion of the hours I've put into it so far. So I'm already going back to the coding stuff I love! My next task is to start learning multi-threading & queuing in Python, so I can have the two sensors running in parallel and controlled by a single program.