Independent+Study

**Alexander Leong - Independent Study, 2011-2012 @ NPHS**
Note that the code below for stepper motors requires an EasyDriver controller. This picture below is the basic outline the Arduino code used to control a stepper motor. In the program, I explained on the side how to change different variables. This code below is an example of how to control multiple stepper motors or two at the same time.
 * Arduino Stepper Motor Control**

This week I finished the programming for my project. I will be using a threaded rod with 20 threads per inch. With that said, I designed the program so that one push of the button will rotate 20 times; this will ensure more accuracy. Also considering that most people will desire using centimeters as their parameter, I programmed a set of buttons that will turn the rod by centimeters. I spent time this week doing final tweaks and minor changes on the XY stage. The only real change I made was using another EasyDriver. Originally, one set of motors were controlled by the same driver. Therefore a bigger voltage was needed to run them. In using another driver, I was able to run the whole system with almost one volt less. The tradeoff was using another driver, but in doing so, I reduced the stress on the driver and motors. I was able to present this project on Wednesday at the EDD's year presentation. Many people were very interested in what I made. They would ask questions from where you would even start to the design of the system. I enjoyed explaining my learning process of programming to understanding the motors and effective designs. Several parents were interested in the design and how I went from worm gears to using the teethed wheel. I had a lot of fun with the presentation and seeing lots of people impressed and enjoying my project. This week I did work on programming. I wrote the the program for my project. This program controls 3 drivers, 3 motors, and 6 buttons. My focus will now be on building this project. Because I am running out of class time to complete this project, my dad and I will work on this at home. The only part I am worried about is the horizontal displacement of the whole system. The motors I am using are relatively small and are not meant to move large objects. With that said, I am not sure if the motor will be able to push/pull the whole station. There are other techniques to boost the torque (external power, multiple motors, etc.); again, I may reach some time constraints. One goal I want to reach for sure is creating a station that will change the height and angle of the test tube. As for the horizontal displacement, I will work on that if I have extra time; I see that taking a lot of time to design and make it work effectively.
 * June 1, 2012**
 * May 25, 2012**

This week I have finalized the X-Y stage project. I worked out all the small kinks in the project. The main problem was the small supply of power that I used to control three motors. To compensate for this, I experimented with using external power in the project. In other words, I used an outside power source rather than the 5 volts given by Arduino. Instead, I used about 7.5 volts DC to power the whole system. I did this by applying this voltage along the red and blue bus lines on the breadboard. This voltage was also enough to power the Arduino board; I did not have to plug the USB into the board. Today I ran into a strange problem, when I plugged the system in as usual with the DC power, nothing happened. All the lights came on signaling power is flowing through, but there was no movement. My first thought told me a wire had to be loose. I checked the system and nope, all wires were in. Now I was really worried and thought maybe somebody else changed something or broke a component. To troubleshoot, I changed motors, EasyDrivers, Arduino boards, wires and I still had the same result. I even went as far to upload the program again and test it on a separate power supply. Unfortunatly, it still did not work. Several minutes before the class ended today, the whole project just started to work and function just as it had before. I was very confused, yet very pleased to see it working. I do not think I will ever figure out what happened to it. Now that this X-Y stage project is completely finished, I would really like to attempt to finish mine. To save some time, as I do not have much left, I changed the design a little bit. Rather than cutting a hole in the top for the system to rest and move, I decided to use a wooden board as a replacement. This board will have 2 holes in it for 2 stepper motors to be screwed into. These motors will then have threaded rods via couplers which I found at my house. On these rods will be an attachment for the test tube (I have found the attachment I need in Lowes, all I need to do is find the right size). A hole will then be drilled all the way through the wood. At each end of the hole, I will put a nut. A threaded rod will then move the whole system. The only problem I see is the weight again. I am confident about this problem though. Unlike the X-Y stage, this system does not require speed; this will supply more torque weith less speed. Also, the external power has significantly increased the amount of torque and possibilites of these motors. With that said, I am very optimistic about this design. My Dad is knowledgeable with designing and manufacturing. In my basement, he has a workshop. Therefore I would like to get a lot of work done at home in order to present an end result by the end of the year. If allowed, I would like to work on this project in the Summer if I do not finish it; I would just really like to have an end product to sum up my year. In addition, I want to write a manual on the Arduino program and wiring for stepper motors. Then Mr. Boyer's students in the following years who want to research with projects like the X-Y stage can easily design similar models with Legos. One last thing I would like to see is another independent study student for my project. The student's assignment would be to create a digital logic circuit based on my project. They could take the button inputs to display the angle and displacements. And eventually, they could program with Arduino to ask for input angles and displacements.
 * May 18, 2012**

As planned, I have completed the X-Y stage project. There are only very minor problems that I will fix on Monday. I started this week by putting a lot of effort into the design that used two motors to guide a third motor; this third motor was placed on a teethed track. This teethed track rested completely on top of the two teethed wheels which rotated via the first two stepper motors. I tested this design and it worked, but not entirely functional. Even with some support and guide rails for the third motor on top, the system could not handle the weight of the third motor. I then decided this design could not work because the third motor would eventually need a additional attachments to provide the other axis direction. All of that would mean more weight would have to be added. At this point, I decided this design would not work and to let it go. As a result, I decided to make a smaller and hopefully more efficient design. The main difference I wanted to make in this design was to make the third motor from the first design on the side rather than on the top. The advantage I saw in this was having more of the weight placed on the ground rather than entirely dependent upon the two motors. By coming into school early, I was able to get this design fairly quickly. I was able to test this design today and it worked very well. The motors were able to handle a much higher speed. With this smaller design and side placement of the motor, there was only one small problem. When the motors push/pull the third motor, the whole system rotates a little bit. This is because of the equal and opposite forces exchanging as I have learned from physics. This will be easy to fix. The minor problems I was talking about is needing a more secure and level holder for the motors, making the third motor design lighter to yield maximum speed, and final programming for the project. This week I learned two new things about stepper motors and their drivers. 1) to reverse the direction of a motor, switch the polarity by reversing the order the wires are in. Why do this instead of programming it? This technique is useful when having two motors spin simultaneously or when driving them from the same driver, but you want them to rotate in separate directions, which brings me to the second thing I learned. 2) With this project, I have 3 stepper motors, but I only need 2 drivers. This is possible because two of the motors are always rotating the same direction. By attaching the 4 wires of the two motors to the driver, I am able to save myself another driver and some programming.
 * May 11, 2012**

This week I continued to experiment with the stepper motor and teethed wheel. This design works by rotating the teethed wheel on a similar teethed surface. When the wheel rotates, it pushes the track in the direction of it's rotation. The speed of this track compared to the wormgear is much faster. While it cannot support a great amount of weight on the track, it does move much faster. To compensate for this loss, I put a second stepper motor to push the same track. Most of the week has been spent improving the design and performance of the system. So far, I have made a system that can support more weight ontop of the track. This same system can also maintain a relatively fast pace. Because the stepper motors I am using are small and not as strong, I found it important to either impose a second motor or build supporting guide rails to relieve some stress off the motors. My next step is to build the section of the system that will move perpindicular to the first track. Again, the main issue is the weight it will place on the first track. The only solution for that right now is to support it with other Lego pieces. Building these support structures tend to be complex and time consuming; I am very close to finishing though. By the end of next week, I would like to see this project finished. My only problem is the low torque output on the motors, but I am working around it. The final system will move a plate in a square motion. The past week has had a lot of shortened class time but I was still able to complete some work. I started off by finishing the X-Y stage. The system was fully functional; I could program the square plate to move in any direction. At first, I was only able to move the plate one direction at a time. After some programming, I can now move the plate diagonally with various slopes. When I say I can move the plate diagonally with various slopes, I mean that rather than spinning both motors at the same speed; I can spin the motors at different speeds to manipulate the direction (For example, if the plate was on a graph, I can have the position change along the line of y = cx where the variable c can be any constant number). Despite having completed the X-Y stage, there was still a problem. The two other students I am working to develop this with need the whole system to be faster. I talked with them and said I'll do what I can, but the stepper motors we have now may reach their limit mechanically. Additionally, I know that the stepper motors can only put out so much torque and speed. For motors, these two variables are inversely proportional (Meaning as one goes up, the other must go down). This was bad news for me because I knew that the top speed mechanically for my motor was not fast enough even when it was not pulling/pushing objects via wormgear. I began to brainstorm some possible solutions. My first thought was to attach two stepper motors on either end of the K'Nex threaded rod to combine torque. This was plausible and the only programming needed was to spin one motor opposite the other motor because they were facing each other. I knew the speed would probably not be the desired speed for the other students but I gave it a try. I built this and it was a complete success, but it was //still// not fast enough. It was definitely faster, but not enough. I then started to look at the physical limitations that were holding back speed. I took note that one problem could possibly be the wormgear itself. Because the K'Nex wormgear had so few "threads" per inch, I thought perhaps the motor was doing so much work to only move the station a small distance. I consulted and shared my thoughts with David who suggested using the real threaded rods and couplers. I agreed, though I was cautious because if the K'Nex threaded rod and teethed pieces were exactly proportional to the real threaded rod and coupler, we would have a problem. On one side I predict that nothing will have changed except the positioning will be more accurate. On the other side I predict that because the real threaded rod has 20 threads per inch, then one rotation would move 1/20 of an inch, right? The second prediction would then make the motor much slower. The Lego wormgear has maybe 7-10 threads per section (Each section may be an inch, I am not entirely sure), so one rotation of that would move roughly 1/16 of an inch. I am not sure what to expect, but I feel that using the real threaded rod will not yield a significant increase in speed. To test my predictions I will gather exact measurements of threads-per-inch and distance it can move an object with one full rotation. The main physical problem as I said above, is that the motor is doing so much work to move the station only a little bit. My next idea was to buy a new, higher performance stepper motor. However stepper motors get expensive really fast. For example, if you wanted to buy a simple motor with 200 steps per revolution, it may cost you 15 to 20 dollars at least. So before I decide to go spend money on a motor that //might// rotate fast enough, I was definitely going to look for other alternatives. Again, my main problem was the proportion of rotations to distance moved. Then I realized that if I wanted to see a significant boost in speed, the wormgear is probably not the best choice. I stared at the box of Legos and tried to think of different solutions. During the end of 5th period Monday with just a few minutes left (I have lunch 5th periods sometimes, so I go to Mr. Boyer's class to work on this), I took the whole wormgear off and instead attached a teethed wheel onto the motor shaft. I plugged it in and it moved so fast that I was having trouble keeping up with it to feed it teethed track pieces. The teethed wheels come in different sizes, so one wheel may have 16 teeth around it while a larger one may have up to 48 teeth. I used the largest wheel because it obviously would yield the most speed. I was not able to build much of it though as the class was ending. I am very excited to work on this because the large wheel has maybe a 4 inch circumference, so that means every rotation moves the station 4 inches! That is only with one rotation! As I said, it even moved //too// fast when I originally plugged it in. I am really eager to come to class and design a new model with this. Today is Wednesday; I should be able to build a working model by Friday.
 * May 4, 2012**
 * April 25, 2012**

The past week and previous three days from the week before have been very successful. Not only have I found a solution for multiple motors, but I have also greatly improved the Lego model. Much of my time has been devoted to assisting two other students in Mr. Boyer's Engineering Design And Development. The two students and I are working to develop an X-Y stage station. The function of this station is to move the collection plate in a square movement throughout the nanospinning process. The programming for this also requires more than one stepper motor which relied on me to find a solution. Luckily I was able to find a solution by creating a separate block off code specifically for the other motor. The other student, David, and I then moved forward with a Lego model for the X-Y station. Even though I have lost some time working on my project to do this, I feel that it is good to have this extra practice for my own. In helping David, we both exchanged ideas and designs with each other which helped us both. I also enjoy working with the other students because I like sharing what I've learned. Building the X-Y station has reinforced and strengthened the whole engineering process for me. Since I started with David, I was presented a problem, worked on ideas, drafted solutions, created the product and soon to be testing it. We currently have one directional axis performing well with the other axis to be finished by the end of next week hopefully.
 * April 15, 2012**

Apart from that project, I am trying to push forward with my own by searching for material parts such as threaded rods, nuts, partially threaded rods, clamps, etc. During Spring break, I visited Lowes. At Lowes I did find 1/4-20 threaded rods; they were sold out of the two foot lengths though. Before any purchases I do still need to measure the rod lengths I need. If I had to estimate, I would most likely purchase the two foot lengths and cut them to an appropriate size. The next item I searched for at Lowe's were clamps for the test tube (I had to keep in mind as previously wrote before; the clamps, or at least one of them, could not be stationary because the distance between the contact points of the rods would be different depending on the angle). I did find the exact clamp I needed which I drew out as a sketch in my notebook. These clamps were circular with rubber tracks and a hole for a rod at the end. This fulfilled one clamp for me, next time I will search for another clamp once I determine more exact parameters. My next stop in Lowe's was to the plumbing section. No I did not need a toilet or sink as one might suspect when I say plumbing. Accessories in the plumbing area included specific couplers, threaded attachments and many different parts. I did not make any purchases, but I did find a few parts I will definitely need in the coming weeks. The one part that I thought would be impossible to find was there, just in a different size. This part is an attachment on the threaded rod that will also have a threaded hole perpendicular to the rod. I was very pleased to find this part. Visiting Lowe's and their hardware/plumbing areas gave me more ideas and different capabilities.

Next week I will hopefully be finishing up with the X-Y station, there will definatly be pictures on that. Then after more Lego model testing, I want to begin building with sturdier, more secure materials.

I have not made as much progress as I wanted to this week. I did not solve my programming problem yet but I am definitely close after troubleshooting all week. This week I also transferred the circuit to a bigger bread board since the whole circuit was getting a little too big for the board mounted next to Arduino. I will eventually need the extra room anyway since the final test of the circuit will have 3 EasyDrivers and 6 buttons. I currently am still trying to solve the same problem I had last week. Earlier this week I thought I found a solution, but after I transferred the circuit to the bigger board I had some problems. My first few problems only required some rewiring and modifications. Then when I pressed the buttons to turn rotor, the rotor rotated very, very slowly. The rotation was so slow that it was almost hard to see the rotation at all. I was confused at first because this program had worked previously. After checking the wires and program, I still had the same problem. I worked on this for a couple of days and made no progress. By reaching no solution after a few days, I decided the next step should be to go back to the original program before any modifications. Today I uploaded the original program and had no problems. Next week I will continue move forward with this and reach a solution before Spring break.
 * March 30, 2012**

This week I have a lot of progress with my K'Nex model. I started the week by building a Lego housing for a second stepper motor. This second motor is mounted on top of the first motor. I did this to simulate the section of my design that would manipulate the height and angle of the test tube. I successfully made this including somewhat of a K'Nex "test tube". While on the wormgears, this test tube had some limitations on the angle I could reach. These limitations on the angle were due to some flaws on the K'Nex test tube; I don't expect to have the same problem occur when using real gears/materials. I first tested this whole design by turning the rotors with my hands manually to examine how the test tube design would handle itself in different positions. Besides the angle restrictions, the design worked properly in different angles and heights. Next I connected the design to Arduino with the program I had the previous week (This program controlled one stepper motor by rotating the rotor clockwise and counterclockwise an assigned variable number of steps). I played around with this by changing which motor I plugged into Arduino and modifying the K'Nex pieces. I found that my K'Nex couplers had a tendency to slip off the rotor. Periodically I just had push them back together again and it would be fine for a bit. Now I decided it was time I use the stepper motors simultaneously together. This would require four buttons (two motors, two directions each) and two EasyDrivers (one per stepper motor). I opened the program I had for one motor and modified it by assigning variables to the second driver and pair of buttons. After doing that and copying some blocks off code, I started to write the //if// statements into the //void loop// function. This is where I encountered my main problem I am still currently working on. I will do my best to explain, but it may seem a bit confusing at first. My program has three main blocks of code. First is the assigned variables and //void setup// part. Next I have a function called //void step//. This function takes the normal step command, and assigns changing variables where constant numbers usually are. The third block of code is the //loop//, this is the part where the if statements for each button are. To rotate one motor, I program the code to read the state of the button (pressed or not pressed) and then use an if statement. " if btn == HIGH { step (true, 50); ". From Arduino to English, it basically means that if the button is pressed; rotate the motor in the true (true means clockwise, which was programmed in the //void step// part of the code) direction for fifty steps. So now to include four buttons and two drivers, it would make sense to just create another set of pins for the driver; and two more if statements for the two additional buttons (I have not tested this program with another driver and buttons but I can already theorize a problem). I began typing the if statements and realized, how will Arduino recognize which motor I want to rotate? I have separate drivers and separate buttons; those are easy to program. What I don't have is a method of telling Arduino to exclusively only rotate one motor. The if statement says step a certain direction a number of steps. It doesn't say specify which driver, which doesn't specify which motor to control. I believe that if I uploaded and tested this program, each pair of buttons would rotate both motors one direction. I realized this problem Thursday and I still have not come to a satisfying solution. The only solution I can think of right now is using another Arduino board to control each motor independently on each board. However this would force me to use three Arduino boards and only using eight pins from each. The upside is that it is a definite solution, and would solve a possible problem of one Arduino board not handling three drivers. The downside is that it would be a inefficient to use three boards and so few pins from each. I don't wish to take this solution and will only have it as a last resort method. I know that there must be another way to control two stepper motors, eventually three, from one board. My first idea is to look into other possible codes that use a different techniques to control the motor. Another idea is to just concentrate on the code I have now, and find commands that will differentiate each driver from driver. I feel that if I just focus on the problem like I did with the problem last week, I can find a much better solution. Next week I will search for a better solution because I really, really do not like the idea of three seperate Arduino boards. I am sure other people have run into programming problems like this before. I hope to solve this problem by Wednesday at the latest because I want to really start to move from the K'Nex phase to threaded rods and real couplers.
 * March 23, 2012**

The past week and two days in class, I worked on completing a small Arduino project. I wanted to build and test a working wormgear with buttons. There are two buttons, one for each rotational direction for a certain number of steps. I programmed this using Arduino. My first step to doing this was to make a small housing for the motor. The original one I had was wobbly/unstable and had a weaker "K'Nex coupler" than I wanted. Next I moved to the programming phase. I was a little rusty with the programming, as I haven't done much since the first marking period. Luckily, I had my notebook and old sketches to refer too. After reviewing them, I remembered how to program and wire the button with Arduino. Now I was finally able to complete a program for this project. I ran the sketch in Arduino to check for errors; I wasn't surprised that there were some. The first few problems were easy to fix; they required a bracket or parenthesis to fix. The next error occurred during one of my statements for the button value. I checked it several times, and matched it with previous programs that worked before. It still did not work. I then took a random guess and changed the variable name. For some reason that I still do not understand, it fixed the problem. I ran the sketch again and it worked fine. I wired the buttons and put finishing touches on the wormgear prototype. Everything had seemed to be correct; except the motor would constantly spin in one direction regardless the state of either button. When I pressed the button for the opposite rotation, the motor would just rotate a small distance each way. To me, it was evident that one button must be shorted out causing Arduino to read the button pressed; which made the motor rotate in one direction constantly. Then the fidgeting the motor did when I pressed the button for opposite rotation would be explained because Arduino would read both buttons as pressed; forcing the rotation to fight each other. Though when I checked the wiring, everything was correct. Confused, I decided to use the continuity tester. I suspected that the button had a mechanical problem inside, but the continuity tester proved that it didn't. I then tried switching the buttons to ensure 100% that it was not a mechanical problem in the button. I found again that the problem was not the button. Again I checked the wiring and it was fine. Next I set up the Serial Monitor in my program. I programmed the Serial Monitor to display the value of the button (1 or 0). As I expected the button was reading a 1 constantly, regardless of whether I was pressing it or not. Frustrated, I pulled all the wires/components out that were in the faulty circuit. To my surprise, the Serial Monitor //still// read a 1 (Even when there were no components connected to the assigned digital pin). This added even more confusion. I decided it had to either be a problem in my wiring (which I am 99.99% sure it is not), or an internal problem with Arduino. I was sure that the programming was 100% correct. Originally I thought this project would only take about 3 days, but it has ended up taking my whole week. So now I decided to completely rewire everything and use different pins. This is where my week ended. I have to finish this project because it is a major part of building my final product. So hopefully this will not take too much longer to fix as I want as much time as I can to work. This week I have also been able to get some real couplers, made by Mr. Voicheck (Thank you Mr. Voicheck). They are custom made to fit onto my motors. I will soon get some threaded rods to make my prototype even more real. Next week I will finish this project and continue building a full prototype of the final project.
 * March 15, 2012**

This week I have been improving the design and building a prototype design. Using Legos and small building parts, I was able to make a wormgear design that worked in the last few minutes of the period. I am planning to go to Lowes or Home Depot so I can get some ideas and look at some parts that I may need. I will mostly be looking for couplers and clamps. I want to take a look at some couplers to get an idea of what I need and to just physically see what I would be working with. I need to look at clamps for the test tube. This problem was the main focus of my work this week. I need a clamp that will... Fit around the test tube Pivot with the changing angle Easily be removable, as students will need to work with the test tube My solution to this problem so far is to have the clamps permanently be mounted on the test tube with an open hole in the clamp. A partially threaded rod will slide into there, and the threaded side will screw into an attachement on the threaded rod which attaches to the stepper motor. The only problem is that the clamps will have a changing distance between each other when the angle of the test tube changes. I have had several ideas so far. Mr. Voicheck and I discussed some ideas about using a hinge or similar device that the stepper motor can pivot on. Another possible idea is to loosen one clamp (Probably the back clamp). This way the clamp can slide along the test tube with varying distance; the front clamp will hold the the test tube securely. Both these ideas will be tested and designed in my prototype before I commit to using them, as problems in the design may arise. Next week I will be improving the prototype. I will start by working more with the wormgear; then program buttons into the system to control direction/rotation of the system. I will use the Legos to build/design each part of the system, then bring it all together into my final product (a Lego/cardboard prototype). The final product will require real couplers, guide rails, threaded rods, and various small hardware parts. The hardware part I may have trouble finding is the attachment I mentioned above. This attachment will ride on the stepper motor's threaded rod but will screw securely into the partially threaded rod. The non-threaded side of the rod will have the clamp's hole slide onto it. This piece will look somewhat like a T. I do not know if Lowes or Home Depot will offer what I will need. If that is the case, I may see if I can have it manufactured through some friends in the class. If that doesn't work, I may have to purchase a custom piece online; I doubt it will come to this. Next week I plan on testing almost all my design parts through Legos, looking into how to integrate the guide rails, and near completion of my prototype. I will definatly be going to a hardware store during the week to get some ideas, possibly buy some specific parts I need, and begin finding exactly what I will need.
 * March 2, 2012**

The stepper motor from the hard drive works, provides more torque, and carries a much higher resolution. My original motor took 768 steps to achieve a 360 degrees rotation. This motor, with the assistance of the EasyDriver, uses 1600 steps per 360 degrees rotation. That means if I were to take one step on this motor, it would equal 0.225 degrees. With this motor, it will become useful if I need a higher resolution or torque.
 * February 24, 2012**

After working the motor, I focused on drawing the design for the final product. The pictures below represent //how// the stepper motor will be attached to the threaded rod. By using three of these devices, the test tube will have the ability to change horizontal and vertical displacement along with the slope. (This is a draft and rough idea of what it will be, the final product is likely to change) To change the //horizontal// placement, I will cut a rectangular hole into the glass on top of the nanospinning station. Mounted parallel and attached to the stepper motor device will be a stationary nut of some type that will not move. This whole system will be on top of the nanospinning station with the nut mounted and the motor hovering over the hole. To support the weight of the hovering motor, there will be a plate attached on the motor that contacts the top of the station. Under this, two more stepper motors will be attached.

To change the //vertical// placement, the two stepper motors mounted under the plate will hold the test tube. These two motors can spin together to change the height; or one at time to change the slope/angle.

Some problems I am still working on... How to attach the test tube and threaded rods together The nanospinning station uses a range of several kilovolts to do the the process of nanospinning. My stepper motors only need about 1.5 volts. Having everything being metal, especially the threaded rod, causes an obvious problem. I would need to find out from Mr. Boyer exactly if this voltage is somehow isolated safely from my rods and motors. If not, the solution would be to use a plastic threaded rod which has more resistance.

Next week I will be solving these problems, then finalizing and reviewing the drafts. Then I will draw/measure everything to scale using a software if available; to find out what size rods, couplers, and nuts. I hope to have that whole process done in the next week and a half to two weeks so I can buy the materials I need and start building.

This week I've worked drafting what the final product will look like. So far, the rough idea of it is to have two stepper motors attached to the test tube via wormgears, couplers and threaded poles. These stepper motors are planned to be mounted from the top, as the test tube stand is very heavy and trying to change the distance with that attached would not only require a lot of power, but a new stepper motor and stepper motors aren't exactly the cheapest device around when looking for one with much torque. The purposes of the poles are to manipulate the height and angle of the test tube. I still need to sit down with Mr. Boyer and discuss the exact functions of what the project should be able to do (i.e. resolution, horizontal movement, vertical movement, angle range, etc.). I am very confident that the design I described above //should// have enough torque to move the test tube. However I was able to obtain a stepper motor from an old hard drive. Towards the end of the week I worked on pulling the stepper motor off the drive, resoldered it and will be testing it on Monday. This motor, granted it works, has a much higher resolution and operation. Should I need any "muscle" in the project, this motor will be very useful. Next week I will continue researching ways to use couplers, wormgears and testing the motor. Also, I may be able to work on making my own coupler that is custom for my motors.
 * February 9, 2012**

Finally I have found the code that lets me control the stepper motor's direction, speed and number of steps it will take. Also, initially the stepper motor took 48 steps to make a full 360 degree rotation. The EasyDriver however increases the resolution and the motor now takes 768 steps for a full rotation. So far I have been able to get the resolution to position down to every 3 degrees and should be able to get it down to an even better resolution. With this step accomplished, it is only a matter of putting buttons into the program that move the rotor a variable number of steps and direction. My next step in the whole process is designing the entire physical project. Depending on the design I may be using 2 stepped motors and therefore another driver. I am relatively new at the whole process of physical designing and building, but I look forward to researching this phase of my project.
 * February 2, 2012**

This week I have been working with the EasyDriver. When I first used the driver, I was able to upload a sample code and get the motor to spin. Unlike the motorshield I had used, this driver only uses two power pins and two to six digital pins; the shield took all the pins. Next I used some header pins that were available to attach to the driver. I needed to do this because the PCB had only holes for the wires to be soldered/connected to, when I originally used the motor I had to wiggle and hold the wires/PCB carefully in order for it to work. Mr. Voicheck was able to give me a few header pins he had, however I was short two or three pins. So then we found an old DVD player that we took apart and salvaged the pins. At this point I had all the pins connected and ready to fit into the breadboard. But then when I connected the same circuit I had originally (or so I thought) the motor did nothing. I reviewed the code, tested connections with the continuity test, measure voltage and I still could not find the problem. Now I was worried I had accidently overheated something while I used the soldering iron to connect the header pins. Then I decided to use a different code, because the site I was using was unreliable and had clear problems in their setup. This code used a different approach, using Boolean Algebra, something I will be looking more into. Though when I uploaded the code, the motor seemed to vibrate quickly and moved the rotor slightly. So once again I thoroughly checked the circuit. After that I decided it must be the code. I found that in their example, they had used a different stepper motor which was not entirely compatible with mine. So with a slight change in the delay of their code, the stepper motor worked perfectly fine. With this accomplished I should soon have a code for controlling the position of the motor, then work on the design and putting everything together to make the final product.
 * January 27, 2012**

- Alex, I ordered the stepper motor driver tonight. You'll have it for class on Wednesday taking into account the approaching 4 day weekend for you guys. Mr.V

Mr. Voicheck,

[] This website has several drivers specifically for stepper motor controllers. If you scroll down there are several types of controllers and drivers we could use, most of them are very similar to the one we were looking at this morning. The one we were looking at this morning is on this website as a 4.2 and 4.3 version (If the version is not labeled on the site, the schematic will tell you the version). They do not have the 4.4 version, however the 4.4 version is on this website [] I do not see much of a difference between the boards. The sparkfun website above also has some links for using this with the stepper motor.

All the EasyDriver board's specs seem to be able to have enough voltage and current to supply enough power to the stepper motor. The price from version to version is the same from what I've seen. You can look to see which one you think is the best but I will keep looking for more drivers this weekend and put a post here if I find anything more.

This week I finally interfaced Arduino with the stepper motor. The motor shield attaches on top of the Arduino board. The motor shield's purpose is to supply enough power to drive the stepper motor; as the Arduino board alone cannot supply enough voltage for the stepper motor to function. To use the motor with Arduino I downloaded a library, or a source of additional commands in Arduino, which then made it easy to program/control the stepper motor. The basic commands changed the speed of the motor and the direction, displacement and the stepping type. The stepping types consist of techniques called single, double, interleave and microstepping. Single stepping is the type that uses only one coil to rotate the motor. Whereas double stepping uses //both// coils to rotate the motor. What's the difference? Using double increases the torque because both coils are holding the motor in place; single stepping has a slightly higher resolution with about 70% less torque. Interleaving combines single and double to try to achieve the best from both. Microstepping has more accuracy, smoother rotations, and functions quieter. Microstepping uses PWM (Pulse Modulation Width) to increase the resolution. For my purposes, double stepping is what I will be using. This is because my end product will be holding more weight than the other techniques can handle. After researching some more, I may find a way to increase torque so I can use microstepping and be very precise as to what position I want the motor to be. Signing off, till next year...
 * December 23, 2011**

After a lot of troubleshooting and research, I figured out how to make the stepper motor rotate 360 degrees. I also found that my statement last week was incorrect; the labeled degree value on the motor is 3.75 degrees. However, after finding how many steps it took for the motor to rotate 360 degrees, I found out that 3.75 degrees is the half step, 7.5 degrees is one step. More importantly, I now understand how to make the motor rotate in positions 0 to 360 degrees. My motor has four wires. As I explained last week, applying voltage to one set or the other set of two wires, the motor will move due to the electromagnetic attraction between the stator magnet and the rotor's teeth magnet. This week, I used only one set of wires to rotate the motor (The other set of wires would rotate the motor in the other direction). During my troubleshooting, I found that if I reversed the current every time a step occurred, the motor would rotate in one direction step by step. At this point, it was set up directly from the power supply so I was manually switching the polarity. After that, I breadboarded the whole circuit so that I could apply power to the motor and then reverse the polarity via pushbuttons. To physically monitor the movement of the rotation, I attached a piece of tape on it; like a flag. I then noticed that it took 48 steps to rotate 360 degrees (That is how I know each step is 7.5 degrees, 360 / 48 =7.5). When I operate the motor with both sets of wire, it will take 96 steps to complete a rotation. The next weeks I will be interfacing Arduino with the stepper motor and using the motor shield which attaches to the Arduino board.
 * December 16, 2011**

This week I have been studying the stepper motor. A stepper motor is an electric motor, but is very precise in the positioning of where it is. The stepper motor I am working with moves to every 3.75 degrees, or "step". However it is also possible to achieve a half step, 1.825 degrees. My stepper motor works by using 2 magnets called stator magnets. Between these magnets is the rotor, the rotor is like a regular gear except for that the teeth are polarized by magnets (Every tooth is a positive, then negative, positive, negative, etc..... When power is applied to one of these magnets it attracts the rotor to a certain position. When power is applied to BOTH, a half step is performed. More accurate stepper motors have rotors with smaller and more teeth; and the have more stator magnets which also boosts the holding torque of the motor. So far I have wired the motor and I can make it widget back and forth. Next week I will be learning how to control it and have it turn all the way around.
 * December 9, 2011**

Finally I have succeeded in using two pushbuttons to control the direction of the servo. Using this week and the short week during Thanksgiving, I programmed the servo to rotate in one direction (negative) when I press one button, and the second button will rotate the servo in another direction (positive). Throughout working on this project, I found the Serial Monitor from Arduino (Displays the value of a specified variable) to be very useful. I used the Serial Monitor to test my two buttons and make sure they worked properly and gave me the type of input I wanted. Next I used it to display my angle variable. This allowed me to see what value Arduino was producing. After troubleshooting various commands and functions such as for, do, while, etc. to control the servo I realized I made the program much more complicated than it needed to be. Rather than trying to test the button, change the angle value and rotate the servo in one or two commands; all I needed were simple if/else statements. Below is the essential part of the program I used. { if (BS1 == HIGH) { angle = angle ++; } else { angle = angle; } if (BS2 == HIGH) { angle = angle --; } else { angle = angle; } } Also, to vary the speed of the servo rotation, a delay can be inserted to slow the speed down. A problem however is I wouldn't be able to set a desired angle, such as 30 degrees. My buttons rotate the servo but do not set a position. Next week I will figure out how to do that and begin my work with stepper motors. Want to see it work? I can set it up for you.
 * December 2, 2011**

In starting a new marking period, I will now begin to work with stepper motors. These are motors that turn in very small and precise positions. My goal is to combine the stepper motor and Arduino. To start off I am using servos, similar to a stepper motor. I learned how to change the speed and positions of the motor. After that I'm now trying to use the push-to-close buttons to control the servo's positions. However I have come into a few problems uploading and getting the servo to do what I want. Hopefully next week I will have successfully used buttons to control the servo. Any tips or suggestions? Let me know.
 * November 18, 2011**

This week was short in having one day off and other work to do, but I did some more work with the multicolored LED. As you know, the LED has only 3 different colors it can emit. However I found a way to manipulate the LED so that it can produce other colors. When you flash an LED at a fast rate, you eventually find out that it blinks so fast you do not even realize it. I applied the same process to the multicolored LED except now I am blinking the LED at such a rate between the different colors of the LED. In doing so you can "mix" the colors of the LED. I will have pictures posted soon of the LED producing purple and turquoise. Along with the pictures posted soon I will try to further manipulate the LED colors by using PWM. This means I will be able to "mix" different colors at different levels. For example, now I am just mixing a gallon of red and a gallon of blue. Soon, I will be mixing a gallon of red and a quart of blue. Pictures soon!
 * November 4, 2011**

This week I have looked into using multicolored LED's. This LED has the ability to change from green, blue and yellow. It works the same as other LED's, except the cap color is clear and there are 4 pins out of the bottom. The longest pin is ground, and each of the other pins will emit a different color. After seeing how it works, I typed a program to use it. In the program I wanted to change the color of the LED depending on the value being read from the photoresister. To do this I put the photoresistor in series with a 10k ohm resistor. After telling Arduino to read and store the value, I had a series of if/else statements to turn on different LED colors. Want to try? Use the program below. Be sure to use resistors in series with the LED! You can also use the serial monitor if you want to manipulate the values.
 * October 28, 20****11**



int val = 0; void setup {Serial.begin(9600); pinMode (BLUELED, OUTPUT); pinMode (GREENLED, OUTPUT); pinMode (REDLED, OUTPUT); } void loop { Serial.println (val); val = analogRead (1); if ( val < 100 ) { digitalWrite (BLUELED, HIGH); } else { digitalWrite (BLUELED, LOW); } if ( val > 100 && val < 250) { digitalWrite (GREENLED, HIGH); } else { digitalWrite (GREENLED, LOW);} if (val > 250) { digitalWrite (REDLED, HIGH); } else { digitalWrite (REDLED, LOW); } if (val >500) { digitalWrite (0, HIGH); } else { digitalWrite (0, LOW);}}
 * 1) define BLUELED 5
 * 2) define GREENLED 6
 * 3) define REDLED 7

What is PWM? PWM, or pulse modulation width, is a technique that blinks an LED at a very fast rate. This makes the LED appear as though the LED is on. Why do this? You can change the brightness of the LED by varying the time between the LED staying on and off. In Arduino, the command to //change// the PWM is analogWrite " (pin#, value) " In the command, the pin# must be 3, 9, 10, or 11; and the value must be between 0 and 255. By setting the value in analogWrite as a variable between 0 and 255, I was able to create a dimming LED. Want to try it? Use the program below, note the pins used. (Unable to copy program into wiki, I will paste it soon) Next week, multi-colored LED's.
 * October 11, 2011**

The first step in doing my Independent Study Project was to become familiar and comfortable with the Arduino Programming. My first two weeks were spent reading the “Getting Started with Arduino” book, which introduced me to the basics with Arduino. These topics included the process of Arduino, the language of Arduino, and how Arduino works. The majority of my second week was spent learning the language and writing programs. On September 21st I started the actual hands-on part of the work. The next day I was able to type and assemble a blinking LED on my own. That same week I was able to type and assemble a traffic light on my own; green LED to yellow, to red, continuously. I then moved onto understanding the switch and how to program it. By using the ohmmeter, I learned the switch was a push-to-close and had continuity to its opposite side even without the button pressed; all leads connected when button is pressed. Finally, after a few trial and errors, I was able to construct and program the LED to turn on while the button is pressed. Rather than using the switch in series, I incorporated it as a sensor. This means Arduino would process if the switch was pressed rather than placing the switch as a connection in series with the LED. This was the first sensor I have used. The rest of my time up until now has been spent attempting to keep the LED on after the button is pushed and released. This took many trials and errors as I attempted to type the program on my own. And just today I have succeeded in doing so. My next step will be to use other sensors and become familiar and comfortable with programming and using them. While in this phase, I will understand how to bring data into Arduino through the sensors. All the while I expand my knowledge on the Arduino language. -AL
 * October 3, 2011**