Saturday, May 3, 2014

Delaying Startup Programs Until Idle on Windows 7

The other day I was starting up my computer in a rush before class. As I waited for all the "necessary" startup programs to start up, it hit me. Wouldn't it be great to be able to a prioritize the way my computer starts up? More than that though, I want to be able to tell some programs to not launch until my computer isn't being used. They can load up after I leave for class. If I need them I can just launch them manually.

A few Google searches yielded a few programs (some free some not), but I am always hesitant to hand over important things like startup procedures to an unknown program from the abyss. Then I found my answer.

Enter Window Task Scheduler. I had encountered Windows Task Scheduler before on Windows 8 but hadn't ever directly used it on Windows 7. It does exactly what I wanted! Using the task scheduler it is pretty trivial to create a task to start a program after startup and whenever the computer is idle. However, I thought I could make it easier.

I decided to create a batch file to launch my secondary programs (KeePass, iTunes updater, etc.). Then all I have to do is create one scheduled event in the task scheduler to launch the batch file. Even better, I can put the batch file somewhere convenient (the desktop, documents, etc), so it is easy to change. If you're reading this, I will assume you know how to find the startup programs you have on your computer. Make sure you don't get delay an important one.

Anyway, here is the batch file code. The best way to see what is going on is to just open a command window and type HELP START. This will give you all the commands you need. Note that if you are using a location that has spaces you will need to put it in quotes with a /D preceding it.

@ECHO OFF

START /B /D C:\Users\Matthew\AppData\Local\Google\Update\GoogleUpdate.exe
START "Startup Batch Window"  /B  /D "C:\ProgramFiles(x86)\Seagate\SeagateDashboard2.0\DBAgent.exe"
START "Startup Batch Window"  /B  /D  "C:\ProgramFiles(x86)\KeePassPasswordSafe2\KeePass.exe" 



And here are some screenshots of me making my scheduled event.
Create New Task


Adding a Trigger

Triggers for My Event

Adding Action to be Triggered - Launch Batch File


Hopefully this is useful to someone. As my Calculus II professor always said, "What is that American expression? There is more than one way to skin the cat?" If I missed a much easier, more effecient, or more logical one feel free to comment. This just seems to work for me.

-Matthew

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