Monday, April 14, 2014

Cheap Drill Batteries! Making a Corded Cordless Drill

This was a quick afternoon project that I worked on a few weeks ago. The beginnings were pretty simple. I was digging through the basement and found an old 12v cordless drill whose batteries had died. Being me, I decided that it would be cool and pretty easy to connect a cord to it and plug it into a lab power supply or other 12V source.


As this project is pretty dependent on the type of drill you have, I will try to include what pictures I took. Also, it is worth noting that as I type this Walmart has plenty of decent corded and even cordless drills for less than $40.

Step 1)
Take apart the battery. Determine the positive and negative leads. On mine white = negative,  black = positive (similar to wiring a house).


Step 2)
Aquire a cord. The wire I scavenged is suspected to have come off of an old vacuum. I would recommend scavenging for this project to keep costs down. I also found some banana plugs to make it easier to connect to a power supply. I considered using some old test lead alligators.

The kind of Banana Jack I used

Step 3)
Remove the batteries and wire together. I actually left some of the batteries in the casing to add some counterbalance. I then soldered on the wire, punched a hole in the case to let the wire out, and hot glued everything together.

Step 4)
Test. My next step was to hook it up to a car battery and test it. It worked! for a few seconds. Then the burnt smell.

The drill did not like being run on a car battery. There is a large diode inside the drill that I burnt out. Luckily, I found a replacement in a box of old hairdryers that we happened to have on hand.

With the replacement diode in, I took it over to a lab and tried it out. It worked fine. There was still a slight burning smell, but I suspect that may just be dust in the motor from years of non use. Overall it seemed to work ok. The video below will give you a peak at the power supply readout during testing.



Some might call this a wasted Saturday afternoon, and they are probably right. However, if you enjoy tinkering with things, making a corded cordless drill might be right up your alley.

-Matthew

Saturday, March 1, 2014

Arduino Shift Register Stepper Motor Controller

This is my first "reader requested" post. A reader sent me an email asking me to do a post about controlling a stepper motor using a shift register, and here it is. In this post I will specifically discuss controlling a 28BYJ-48 stepper motor with a 74HC595 shift register, ULN2003, and Arduino.

First of all, I need to explain what a shift register is. Rather than doing that however, I will differ you to THIS page. It does an excellent job of introducing shift registers and provides some really easy to use sample Arduino code. My code is based off of the functions on that page. I will be using a 74HC595 shift register. I chose it because it is pretty common. I got mine off of eBay, but you can buy them at various vendors.

Second, I should point you to some information on the stepper motor I will be using. It is a 28BYJ-48 stepper motor. It is the same one I used in the two posts(Arduino Control and ATtiny Control). If you need it, those two pages have links to some good reference material.

Third, like in the other cases, I will be using a ULN2003 to drive the stepper. This is pretty common with this board. However, this time I just wired it up on my breadboard rather than using the control board that came with my stepper. I did this because I intended to solder together a whole control board. In the end, I decided I didn't have a need for it at the moment and just left it breadboarded. I can always solder it later.


Now, wiring this project has a few more wires than some of my others, so I threw out all the stops and made a Fritzing schematic. When you look at it, wiring is not terribly complicated; the wires just get crossed easily.



So here is what is going on. The Arduino is controlling the shift register like described in the link I provided above. The shift register outputs are fed into the ULN2003. The ULN2003 acts as a switch and allows the stepper to draw the current that it needs to operate.

One thing you may wish to change, in this diagram I have the stepper being driven by the 5V from the Arduino. It may be wise to drive it from an external 5V source if you are doing more than one. Also, the colors on the stepper (or even the order of the wires) can vary from vendor to vendor. Basically, if the stepper just sits there and grinds against itself, switch the wires.

Another thing that confused me for a little while, the ULN2003 sinks current (as opposed to sourcing current). That is, it allows the output to be a path to ground if the input is HIGH. If you wire the stepper like shown above it should work. The trouble comes when people like me want to test it with an LED before connecting the stepper. I connected the positive end to the ULN2003 and the negative to ground. Eventually, I realized my mistake and switched it. Long story short, to test with an LED, put the "negative" end on the ULN2003 output and the "positive" on 5V.

Here is my setup for this project. The sketch I used is an adaption of one of the sketches from my previous posts. Basically, where there was a digitalWrite I put a setRegisterPin. A potentiometer controls the speed. Get my code HERE

The motor did not turn very quickly (around 10 seconds a revolution), I suppose I shouldn't have expected much more considering all the delays the shift register puts into the system, but if you ever needed to control a large number of stepper motors on only a few pins maybe this would be an option. If you do plan on that, you might note that the ULN2003 only has 7 inputs/outputs, so be sure to get the right number of parts.



Also, it  appears that this sketch could very easily be wrapped into a library. Perhaps the stepper library could be edited to utilize a shift register. Regardless, that is beyond the scope of this post. I leave that to the reader (though feel free to tell us about it in comments).

Hopefully this is useful to someone. If anyone else has suggestions for posts, let me know. The reader requested label is looking pretty lonely.

-Matthew



Saturday, February 8, 2014

DHT11 on ATtiny85

Recently I got my DHT11 temperature and humidity sensor working with my Arduino Mega2560. If you are interested in that, check it out HERE. However, while that was all well and good, I found it a bit impractical. While I may someday decide to create some sort of weather logger using the DHT11, it is unlikely that I would dedicate an entire Arduino to the task. Enter ATtiny85.

The ATtiny85 is great because it is cheap, but the real question is, "Does it work with the DHT11?" Yes it does.

Now in my last post I used the DHT library from Adafruit. While that library served its purpose, it does not work with the ATtiny. Don't ask me why; I did not explore it. HERE is another report of it not working and a description of what will happen if you try it. It reads out all zeros.

What does work is the DHT11 library. To get it working you will need to modify the example code. Basically, you need to change everything that says "Serial" to the Software Serial equivalent. This will allow us to get the sensor readings back from the ATtiny. If you want more information on serial communication on an ATtiny, check out THIS post. Alternatively, you could just download my code (HERE), wire everything the way I say, and see if it works.

Now when you go to compile my example, there is a good chance you will run into a problem. As it turns out,  there is an issue with the tiny core when trying to compile sketches close to the maximum sketch size. Luckily there is a quick and easy fix. I won't go into the details, but follow the instructions HERE.

When that was straightened out I was able to upload my sketch successfully. I used my USBtinyISP and my ATtiny85/45 programming adapter.


The only thing left to do is wire it up and see the output. Basic wiring of the DHT11 is the same as in my last post.

Correct Wiring:
Pin 1: +5V
Pin 2: Signal. Connect to digital IO with a 5k ohm pull-up resistor
Pin 3: Nothing. Some people suggest grounding it if you run into trouble
Pin 4: GND

On the ATtiny side, PB3 is the software serial Rx and PB4 is the software serial Tx. Connect those to an FTDI (or some other serial receiving device). Connect 5V and ground.


Power it up and watch the show!



This of course could be modified to do other things with the temperature data. It could, for instance, transmit them via I2C. Maybe it could log them on an SD card. Those projects I leave to you (for now anyway). If you are interested in more ATtiny projects of mine, check out my ATtiny label. Let me know if this works or doesn't work for you. As always, I'm happy to help.

-Matthew