User:Dstaub/adruino motor control

''This is designed for a person working on a project for 4 weeks as part of a 3 credit class. Please copy this form to your user page. Then delete everything in italics when filling out this form.''

Write problem/project Goal
To create an easy to follow Arduino tutorial on various types of motors for future classes.

My First Task
What are you going to do for the team this first weekend?

Summary of actual work over first weekend
How is what you did different than what you planned?

Week1 Narrative
Tell a detailed story describing what you did for your team over the weekend.

My Second Task
Record what you are planning on doing for the team during the second weekend.

Summary of actual work over second weekend
''This week I researched 3 different types of motors. DC, Stepper and Servo motors just to get my own personal understanding of what I will be working with, Then I began disecting basic arduino code to hopefully apply to motor control.''

Week2 Narrative
10/24/12 Today I finished my research on the basic different types of motor's. Most of the information I got was from Mr. Foresters Page here. Some important differences I have found are as follows...

DC MOTORS

-Use DC/ Direct Current

-More voltage= more revolutions, less voltage= slower revolutions

-Reversing the current flow simply reverses the direction the motor functions

-Can burn up easily when forced to turn when it is unable to turn

SERVO MOTORS

-Designed to move to a spot and hold it's position.

-Usually has a pre existing circuit to count it's steps.

-Usually contain a reduction gear box.

STEPPER MOTORS

-Divides a full rotation into a specific number of steps.

-Can be commanded to move and hold it's position.

-Are generally close loop communicated.

-Also a type of brush motor.

BRUSHLESS MOTOR

-Generally contain an inverter

-These motors are also referred to as ECM or Electronic Commutated Motor's.''

''10/26/12 Today I took the BLINK code template and broke down what all the code means for my personal understanding.


 * 1) define LED_PIN 13 < This function simply identifies the output pin as pin 13 on the Arduino.

Void Setup { < Setup functions such as this essentially confirm or activate the desired pin port your are going to use

Void loop { < This function in this case is where the code it's self will be written, note that loop means the program will run on a loop

digitalWrite (LED_PIN,HIGH) < Note that this function in this case tell's pin 13 to output a HIGH voltage which on the Arduino is 5v.

delay (1000) < Delay functions will enable the previous digitalWrite function for the set number of mili seconds.

This code can easily be transfromed to do the same thing only with a motor the only difference is instead of blinking the motor will turn left or right. ''

''Here is a link to an arduino database that I have found helpful.

My Third task
Next week I plan on starting with a DC motor and compiling a simple code to make it turn left and right for an x amount of seconds also find out how to differ from a loop function to a one time function.

Summary of actual work over third weekend
''I could not get my computer to read my Arduino at all. It was no where to be found within the device manager. I tried updating other drivers to get it recognized like COM1 and other unidentified USB devices but none lead to the recognition of my Arduino. I found similar problems that other users had online and most of them say if updating the drivers does not work then either a certain chip within my Arduino is conflicted with my 64bit version of windows or it's faulty. ''

Week3 Narrative
11-2-12 Today I signed out a Moto Sheild an Arduino stepper and brushed DC motors. Today I plan on working out my Blink code to work for the motor. After downloading the Arduino software and plugging in the Arduino I set the Board type to the correct type 'UNO' And COM 6 does not show up only COM 1. So I went to device manager to update the driver for the Arduino however upon doing so my device manager does not read the Arduino at all. It reads no devices in my USB port to I re plugged it in cleaned it out, made sure it was still plugged in properly and still nothing. So After some research of similar problems someone suggested updating the COM1 port, which I had in my device manager, but still nothing. Further research suggests that there is a certain chip within the Arduino that sometimes conflicts with 64bit systems but I dont understand why that would matter becuase the Arduino is still getting power from my computer.

11-3-12 Since I could not get my Arduino to connect to experiment with my code I made a clear example of how to tell a DC Brush Motor from a DC Brushless motor.

''What Is a DC Motor?

There are 2 basic types of DC motors, Brushed and Brushless.

Brushed motors require contact between 2 brushes and what is called the commutator. This is how current passes through the motor, through contact of the brushes. Brushed motors are typically found in any number of small toys and RC cars or planes.



Brushless motors are a bit more complicated. Instead of relying on physical contact between brushes to transfer current they rely on an electronic mechanism to transfer current flow. Brushless motors are generally considered more efficient and easier to maintain and can also be found in some toys and RC Cars and Planes but are mostly used in CD-ROM's, PC cooling fans and other computer hardware.

''

11-4-12

Today I made the basic setup for what should be the basic setup for my DC motor in order for it to work.



Here is some basic Motor Sheild Coded used to turn a similar motor CW and CCW that I hope to use with my current setup.


 * 1) define BRAKEVCC 0
 * 2) define CW  1
 * 3) define CCW 2
 * 4) define BRAKEGND 3
 * 5) define CS_THRESHOLD 100

/* VNH2SP30 pin definitions xxx[0] controls '1' outputs xxx[1] controls '2' outputs */ int inApin[2] = {7, 4}; // INA: Clockwise input int inBpin[2] = {8, 9}; // INB: Counter-clockwise input int pwmpin[2] = {5, 6}; // PWM input int cspin[2] = {2, 3}; // CS: Current sense ANALOG input int enpin[2] = {0, 1}; // EN: Status of switches output (Analog pin)

int statpin = 13;

void setup { Serial.begin(9600); pinMode(statpin, OUTPUT);

// Initialize digital pins as outputs for (int i=0; i<2; i++) {   pinMode(inApin[i], OUTPUT); pinMode(inBpin[i], OUTPUT); pinMode(pwmpin[i], OUTPUT); } // Initialize braked for (int i=0; i<2; i++) {   digitalWrite(inApin[i], LOW); digitalWrite(inBpin[i], LOW); } // motorGo(0, CW, 1023); // motorGo(1, CCW, 1023); }

void loop { motorGo(0, CW, 1023); motorGo(1, CCW, 1023); delay(500);

motorGo(0, CCW, 1023); motorGo(1, CW, 1023); delay(500); if ((analogRead(cspin[0]) < CS_THRESHOLD) && (analogRead(cspin[1]) < CS_THRESHOLD)) digitalWrite(statpin, HIGH); }

My Fourth task
''This last week I will need to kick it into overdrive to make up for not being able to use the Arduino this weekend. In class I will be able get the arduino working and finally work out a simple code to get this motor moving. ''

Summary of actual work over fourth weekend
''This weekend I was hoping to get into more of using the motor shield and potentiometers to control speed and direction but I could not get the necessary materials in time. So I mainly focused on the very basics of turning the motor on and off for a specific amount of time and how that can be done with a higher voltage motor. ''

Week4 Narrative
''11/10/12 Below is one of the simplest ways to get a small motor to function. This first tutorial will spin a small DC motor on and off for a repeated amount of seconds in one direction. All you need is...

-Arduino/ Usb cable

-Small DC Motor (less than 5v)

-2 wires

Step 1

Connect one wire to any pin # (in this case pin 10)

Step 2

Connect the second wire to GND

Step 3

attach the two wires to the leads on the motor (it dosnt matter where + and - connect to the motor)

Step 4

Upload the simple 'Blink' code found within the Arduino program or from below.

/* Blink Turns on a motor for one second, then off for one second, repeatedly. This example code is in the public domain. */ // use pin 10 as the output pin // give it a name: int motor = 13;

// the setup routine runs once when you press reset: void setup { // initialize the digital pin as an output. pinMode(motor, OUTPUT); }

// the loop routine runs over and over again forever: void loop { digitalWrite(motor, HIGH);  // turn the motor on (HIGH is the voltage level) delay(1000);              // wait for a second digitalWrite(motor, LOW);   // turn the motor off by making the voltage LOW delay(1000);              // wait for a second }

NOTE: COPY AND PASTE THIS CODE FROM THE EDIT WINDOW.

''

Now lets say you have a bigger motor that requires more than the 5v the Arduino outputs, here is where we get into transistors. A transistor is basically an electronic switch and in this case it can handle more voltage rather than if the signals were put through the arduino. In this tutorial we will be using a 'TIP-120' transistor.

You will need:

-Arduino

-Bread Board

-DC Motor

-9V Battery

-TIP-120 transistor

-1K resistor



This setup is a little more tricky than the previous but still a simple setup.

Step1

Connect the 1k resistor from your designated digital pin (in this case pin 2) to the middle lead on the transistor.

Step2

Connect the GND wire of the motor to the left lead on the transistor and the positive lead of the motor to positive on the battery.

Step3

Finally connect the negative end of the battery to GND on your Arduino also connect it to the right lead on your transistor.

From here you should be able to upload the previous blink code to the Arduino and get the same results only difference being you can now use it to control higher voltage motors.



Complete Team Page
Arduino Motor Control/P2-501 CDMN