Wednesday, June 17, 2015

USB Current Monitor - Part 1

I, like a lot of other people, enjoy toying around with electronic components and in other ways making powered projects. While just setting up the circuit is fun in itself, I usually want to power it up once I'm done with the wiring. Unfortunately, I don't own any nice power supplies, so my computer's USB port ends up powering whatever I'm currently working on most of the time, through an Arduino or other microcontroller. One of the crucial aspects of any electronics project is how much current it draws, both for diagnostic purposes and power consumption predictions (think battery powered), but if I'm conveniently powering the project from a USB port, there isn't exactly a nice way to stick an ammeter in between the USB port and the connected device to measure the current draw.

So, thus brings rise to the USB Current Monitor project, a device that will allow easy and structured current draw measurements for other USB devices. I saw online that there were plenty of el-cheapo USB current measurement devices, but they all had physical displays on them, which seemed a little silly to me since they are plugged into a computer after all. My device will give accurate measurements, but more importantly they will all get logged on the PC they are attached to, all without interrupting the communications between the computer and the device being measured.

Also, since we are talking about hobby electronics, short-circuits are inevitable. Most computers have built-in protections against this, but if you're like me, you'd rather not risk your expensive laptop's USB port playing around with a few ICs. The USB Current Monitor will also feature a computer controlled current-overload protection circuit, so the device will automatically cut power to the USB port whenever the current draw exceeds a user-controlled threshold (such as would happen in a short-circuit).

This project is just beginning, but here are a few shots of the initial PCB layouts

Those sinkscreens that extend off the board will not be there in the final draft, I promise 

Cinematic isometric view

With the previous project I posted here being done with Eagle, let me just say that Altium Designer is an absolute DREAM to work in. The library structure is easy to work with, from creating schematic diagrams to automatically generating standard footprints with 3D bodies. Oh, and the whole 3D board view just might be the coolest thing ever.

I put in the order for all of the components to begin prototyping today and Digi-Key told me it already shipped! Good on ya, Digi-Key. Can't wait to get my hands on those components!

Thursday, November 13, 2014

Yaesu FT-60 3.5mm Jack Breakout

Some more home etching fun on this one, 3D Printing too!

Along with computers and programming (just did PicoCTF, a hacking competition, SO much fun), I'm also into ham radio. My call is KB3ZKL if you want to give that a google. I have a page set up on QRZ for logging my radio contacts and a little bio info. But anyway, I have the good ole' Yaesu FT60 like a ton of other people do, and it has this cryptic little mic/speaker port on its side. Well, I guess its not all that cryptic, you can seen a pinout of it here courtesy of G4WPW:


But that little clone pin definitely is. Its set up mainly to 'clone' two radios when two have their 3.5mm jacks connected to each other directly. However, it can also be used to program and, to some extent, control the radio over some sort of serial protocol. This is where it gets cryptic, because there is absolutely no documentation on how it actually communicates. There are old circuits online for converting it to the old PC standard of Serial Ports with their +/-12 logic, but none actually explain whats going on it them. That being said, I've kinda run into a road block as far as that data part is concerned until I can procure a digital scope somehow to look at the data in all its raw binary signal form.

However, I still would like to be able to easily connect whatever headset and microphone I want to the device, maybe my own PTT key, and do it neatly. So, I decided to build a breakout board for the radio, giving me 2 standard 3.5mm jacks for headphones and a microphone. Also, for convienence, I'm going to build a PTT key right into the thing along with another audio jack for a simple external key. Here is the circuit I'm using:

Through a process of exporting that as an image, vectorizing it in InkScape, using a plugin there to convert it to an OpenSCAD file, exporting a very thin STL object, slicing that under special settings in my 3D Printer slicer, and finally tricking the printer into tracing out the lines on a blank board with a sharpie, I finally had my board ready to etch. Ha, yeah, it's convoluted, but its the only way I have without special UV sensitive compounds or a laser printer. I really should do a video on it. That being said it doesn't work too bad for this big stuff. After etching it like I did my first board I had my circuit:


Not too bad! I was quite happy with it. On too soldering up the components, and for whatever reason, just sitting down with the iron and soldering away is really relaxing to me. After about a half hour of total soldering I was done.




Notice the resistor I had to *ahem* bodge on after I had the board done. Its a shame cause I could have tried out my new SMD resistors too. Regardless, turns out regular mics have an impedance that's too high to actually trigger the radio into transmit on its own, so you have to add a path of lower resistance from the mic pin to ground in parallel with the microphone to get it to trigger. Eh, at least I got it flush and within the bounds of the board.

Once I get a 4-Pin 3.5mm male to male cable I'll be up and running, but initial test with the debugging pins prove the device works.

EDIT: 4-Pin cable arrived and the device works as expected with headphones and a microphone. Beautiful!

Sunday, September 28, 2014

Directional Antenna for 5.8GHz FPV Video

Just some pictures for this one right now, school is picking up!

Wrap wire around dowel template to get bend correct

Coil slotted into actual antenna support

My RG-402 coax and the RP-SMA connector I used

All soldered up and heatshrunk to look professional


Gap on signal wire before soldering
Antenna all finished up





Saturday, September 20, 2014

Home-Etched Circuit Boards - First Try

I've done a good bit of messing around with hobby electronics: BASIC Stamp when I was in 4th grade, some Arduino during middle school, down to the more obscure Axon II and plain bare-bones Atmel boards that you had to solder up and use an AVR serial programmer with. Its a whole lot easier to have fun with microcontrollers now that Arduino is in the spotlight. Regardless, I had always wanted to make my own circuit boards, the stuff was expensive to me at the time and guides always said you needed a laser printer, which I didn't have at the house. I decided it was time to finally get my feet wet designing and manufacturing my own printed circuit boards!

As I stated above I don't have easy access to a laser printer so my first challenge was coming up with some way to sufficiently protect the copper traces I wanted on the bare board so they could survive the etching process. I really didn't want to pursue the laser printer route because that would mean having to access a computer during school and print something out, and I couldn't choose what paper it was on. If I made some mistake or needed another one I'd have to wait at least a day to print again as well. Another option was this photo-resist compound with a transparency to control what parts of the coating on the bare board were exposed to the UV light. This meant a lot of extra components in the etching process as well as more money and time. I did know however that simply drawing on the boards with a sharpie works well if you do it correctly. This meant that if I could just draw really accurately all I needed was a marker to make the traces on the board. All I needed was something that was computer controlled, moves in 2 axes, and could hold a marker. I had one of these—a 3D Printer.

I didn't want to spend time printing out a mounting bracket for something that might not pan out so a few zip-ties later and I had a sharpie sufficiently mounted to the extruder on the printer.

Sorry about the photo, I had to hold my
camera from the top and hang it
behind the printer

Yeah, its really shoddy, but for some tests it worked just fine. There is pretty much no force on the pen while its drawing.

The next problem, and this was a big one, was how to convert my vector graphics of the board traces into something the printer would understand. Turns out there is pretty much no documentation on how to actually do this. I finally figured something out that I liked and I'll go over it briefly here. I might make a video about it since this should be documented out there and it took far to long for something this simple.

First I took my vector drawing of the traces (.dxf from Eagle or .svg from Fritzing) and opened it up in Illustrator (I'm sure any editor that can work with the files would work). In this I cleaned it all up, which generally just meant joining all of the paths into one shape. This may not have been necessary but I wanted to make sure the file was as easy to use as it could be for the next step. Next I opened up the Illustrator file in Inkscape.

Here's where I kinda cheat at making the printer plot my traces. Instead of going though all of the trouble to convert these paths into gcode in a nonstandard way, I'm just going to trick the printer into thinking its making a 3D object. It's just a really really thin object.

After getting the OpenSCAD Extension for Inkscape I exported the path as an OpenSCAD file and specified a height of .1mm to it. Going into OpenSCAD I opened the file and exported a .stl from it. I now fed this into my slicing program of choice, KISSlicer, and played around with the settings a bit. I set my extrusion width to the width the pen draws and set the extrusion multiplier to zero. This means it wont actually run the extruder while it draws the circuits.  I then set my layer height to .1mm, matching the height of my .stl file. This means it will only draw the design once and not move upwards (off the board) and try to draw again.

Finally and very importantly I set the slicer to perform a large Z-lift while drawing. This means it will actually lift the marker off the board, lower, and move once it is drawing another part of the path. If I didn't do this there would be marks whenever the marker moved to a new starting point of a line, a move where the printer would choose not to extrude if it were printing an object. I had to do some manual changes to the gcode too, like removing the heat up bed and nozzle statements as I couldn't figure out a change to that in the slicer.

Now I opened the gcode in Pronterface and printed away. Of course I had to properly zero the z-axis for the lower pen, getting the depression of the tip just right. I had a used marker, but I still got fairly thin lines. I imagine with a new one it would work much better.


Now to etch the thing. I instantly thought Ferric chloride, but that you could only get in 1 liter bottles from a select few Radioshacks around here and besides, it got used up after a while. Besides, it comes pre-made, who wants that when there's a DIY alternative! And then comes the homemade etchant of choice: HCl + H2O2 Now that's a real etchant! H2O2 is just hydrogen peroxide, we have some of that right now. Next is HCl, and after taking AP Chem I felt reasonably confidant in handling the acid and taking all the necessary safety precautions. I thought it would be hard to obtain however since HCl is some bad stuff; you can hurt yourself pretty easily with it. Almost scarily, it isn't though. And it's in high concentration.

Trip to Lowes and CVS worked out well

Behold, Muriatic acid. Sold to clean brick and control pH levels in a pool this stuff is a whopping 10M. To put that in perspective once you get to ~12M the HCl starts to diffuse out of the solution as HCl gas. Metal dissolving and flesh burning GAS. If you thought it was bad in liquid form imagine having it in the air. You don't mess with this stuff, and if you get this on you, its really gonna burn. Not to mention I have no doubt the fumes of it are bad for you, and you can easily smell it when you open the bottle, so doing this outside I think its a must. There was a breeze and I still had to step back a few times.

I won't go though the mixing and etching process now because there are many other good guides on making this etchant. I liked NurdRage's segment on this in Make 10 Etchants for PCBs.

After a test etch with some stuff I drew by hand on a board came out reasonably well I decided to run my computer plotted circuit though the etchant. The ink was on thicker this time too so I figured it would withstand even better than the test board. I wanted a simple little circuit first, so I just wired some LEDs up to a male header. Unfortunately I don't have a proper PCB drill yet so I had to use something that was three times to big. Not surprisingly it made the soldering come out horribly, but hey, it worked. Trust me my soldering is never that horrible when I'm not trying to bridge huge gaps.

My cutting technique needs a little work

Wow that soldering is embarrassing

This project was really just meant to set me up with a new skill for future use where I need to make my own circuits. I now have a new technique in my arsenal. See ya plastic proto-boards!


Tuesday, September 2, 2014

Drill Writer for Marching Band

Not necessarily for writing drill, but rather for making a quickly accessible reference booklet for drill that has already been written for an entire band.

Some background knowledge: I participate in my high school's marching band fairly heavily. In order to learn the half-time show every year we pay a guy to write "drill," or rather, to map out our positions on the field corresponding to the music. He gives us these complicated looking sheets where every band member is a little tick mark on a graph of the whole field. This is a very compact way to represent everyone at once, but it can be difficult to accurately see one member's single position in a hurry. Since we are always in a hurry in band, there is the necessity to have a quicker reference for every member of the band. Thus, the dot-book. Everyone makes up a small notepad that contains a page for every set of the drill (the show is segmented into many different blocks with a point, or dot, for every member that they should reach by the time the music for that block concludes). Usually kids draw out a little diagram and write down their dot coordinate style. Others take those full drill sheets, cut out the part they're in, highlight themselves, and paste that into a small booklet.

Regardless, all that sounded like quite a lot of work that I really didn't want to do. I thought about how to tackle the issue and decided that I could make a program pretty easily that would graphically write up a page for my dot-book once I entered in my field coordinates and spit out a .jpg of it all. After quickly going over the java docs on the built-in Graphics library and doing some google searches it still seemed feasible. In about four hours I was done with the program, which, granted, is probably longer than it would have taken to write it up manually, but hey, I actually enjoy programming; I do not enjoy mindless writing with a pencil.

Also note that they banned having this all on your phone, the quickest and most obvious choice. To be honest the temptation to go off task is probably too much for most kids in high school, so it's not too unfounded.

The result was the Drill Writer... 5000. I don't know, I just felt like the name needed some sort of pizzazz after it, I usually don't do that. Check it out:

View of the java program without any data entered yet
Every time I hit "Write New Point" the program exports a .jpg to a specified folder with a name that increments with every set number (set1, set2...). After this, I can print out the pictures with windows pretty simply doing them four to a page. From there they are quickly cut out and stapled together. Adding more sets as we get them is quick too—just remove the staples and re-staple it with the new sheets.

To be even fancier, take the pictures to office max. Have them make up one of these for 5 bucks:

My dot-book I used today straight out of my pocket
I'm quite happy with the results. I now have one of the most well done bot-books in the band while it also takes me very little time to add to it. Programming is awesome.

Monday, September 1, 2014

3D Printer

Not really a new project but more of an ongoing endeavor with a really cool hobbyist product. I give you: The Makerfarm 8" Prusa i3 (Thats their updated version, but its pretty similar).


Even though it cost over 600 dollars when I bought it, this thing is not exactly "plug-n-play." In fact, its quite difficult to get it producing really nice prints, like those objects that you see in common media about home 3D printers. I think I spent about 12 hours actually assembling it, but really that's the easy part. Check out all the parts used to construct it:


Yeah, well, there was a lot of parts, but all of that construction was well documented with video instructions. Not a problem besides some "percussive maintenance" requited to fit some of the parts together since the guy's laser cutter he used for the wood was misaligned and the cuts had a slight angle to them. I think a nut on the printer extruder may have also gotten stuck in the plastic and I had to dremel it out as well but I can't remember. Whatever it was it wasn't to much for a 15 year old in his basement with some basic tools. After construction is where the instructions drop off. The calibration procedure was either like a sentence long, I couldn't find it, or non-existent. After scouring the web I found more and more info on these RepRaps, which this one is after all, and I managed to work through the settings which, to be fair, pretty well set up default-wise. I got my first print in no time—a little model of the space shuttle. The quality was absolute crap, but hey, I just turned a 3D model into a real object. That's pretty dang cool.

This is where it gets tricky. There are sooo many settings on these things to tune to get nice prints. It could be the Steps/mm out of whack, the axis acceleration, the filament size, the extruder nozzle size, or a bunch of other things that could all cause very similar problems. Not to mention you could have a hardware issue too.

I went through a bunch of these, and my prints did improve. I was getting sharp corners and clean edges, but but on round edges I noted they sort of flattened out and the extremes in the y-axis. Turned out my belt on that stepper was loose, and its easy too see how the direction change at that part of the print could cause that symptom. This is what is known as "backlash" and is a fairly common problem in devices with 3-dimensional movement like these printers.

Through many weekends it got better and better, and now its pretty good to the point where I'm satisfied, but I still think any holes I print come out just a little too small. I've learned it just isn't worth my time when I can simply over-size the hole in Autodesk Inventor to work on it more. Hey, its working well, why risk breaking something else in the process. Here are some more print and action shots:

Printing Herringbone planetary gears
Little stand-offs for the antenna on
my RC Transmitter
Half way though a print for the
camera mount on my Quad-Copter

Circularly-polarized Antenna Build

This summer I finally got my Quad-Copter set up with an FPV system using Hobbyking's el-cheapo 5.8GHz system (which also goes by the name 'Boscam'). Here is the Transmitter and Receiver. It was actually pretty funny, the bundle of the two costed a good but more than them separately. Anyway, after 3D Printing mounts for them both and soldering up a nice little modular system with the camera and Tx/Rx (which deserves a post of its own) I had a fully functioning FPV system.

However, I was still using the crappy little 'rubber duck' whip antennas that come with all of these things. These are the sorts of antennas you'd find in a walkie-talkie or a cordless telephone, although those manufacturers may get stingy with the space and twist the whip into a helix shape. Regardless, the antennas are linearly polarized which is a big problem for RC fliers. When the Rx and Tx antennas are oriented the same way everything actually works quite well, but when your plane or copter does something crazy, like lets say, turn, the antennas are no longer oriented the same say (barring you don't have a system to actively move them). When this happens, their ability to receive each other's signal drops drastically to the point where you are probably going to lose your video signal if you bank into a turn a good bit and you aren't in the immediate vicinity of the receiver.

The solution to this problem, well the easiest, is to use antennas that are not linearly polarized like this, but are rather circularly polarized. This way the antennas can be rotated about any axis and not lose any signal at all—as far as the system is concerned nothing has changed. After flying already pretty successfully in close range I decided it was time for an upgrade so I wouldn't have to worry about this issue once I wanted to fly further.


The one on the right is for the receiver and was after the other one. That time around having learned some things turned out much better and actually got heat shrink. The other one would benefit from some electrical tape, but I'm thinking that some of that liquid tape stuff would work quite nicely for sort-of "potting" the joints and exposed metal. I need to get some of that stuff...

Since we're working within quite tight tolerances here for the lengths of the elements, like half-millimeter precision, and doing this by hand I had to get a little inventive to get the lengths right. I figured out that I could actually use the end of my calipers meant for measuring inside diameters to actually bend the wires around if I held them in place. After accounting for the wire width in the measurements I was quite happy with my results. Almost every double-check of the lengths landed the caliper probes right in the middle of the copper wire ends. As far as I could tell visually, they were pretty close to perfect.

After some finicky yet still fairly relaxing soldering of the elements to the shield of the coax it was onto the center conductor. The bending of the elements into the signature "clover-leaf" patters went smoothly and the solder sweated the ends right onto the center conductor very nicely.

Quick test of the video while I rotated the receiver every which way gave no change in the video (which was a bit static-y as I had 5.8GHz going though a cinder block wall). Success!  

Kinect on Raspberry Pi

Recently I decided to take another crack at getting the Microsoft Kinect to work with the Raspberry Pi. Last time I went at it, it was about a year ago. After a grueling failure to get the depth information, that is, what actually makes the Kinect see in 3D, it seemed that the online consensus was that the USB drivers on the Pi were simply not up to snuff when it came to getting all of that information out of the Kinect.

This time, however, there was a new library available called 'librekinect' that supposedly allowed yo to get that depth stream right as a camera device on the pi. This meant it could essentially be used exactly like a USB webcam and, more importantly, be quickly integrated into any Python OpenCV code. After allowing the pi almost a whole day to compile the code and through various different build errors I was able to have the final 'make load' command execute. The result was a sparkling grayscale depth feed out of the Pi. To allow the human eye to better distinguish the different levels I can also feed the image through a OpenCV color map. Check out the VNC remote view of the feed (note that those views are not from the same time):


This will hopefully make it easier for our robotics team to implement the Kinect on small linux platforms in the future or simply some other project I decide to do!


Hello

Figured it was about time I start documenting all of the projects I do, with computers, electronics, planes, all that good stuff. A blog sounded like a nice place to start.