Difference between revisions of "Motor (80A ESC) + Arduino"

From ESE205 Wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
80A ESC motor can be easily controlled with a simple Arduino program in conjunction with a motor controller.
 
80A ESC motor can be easily controlled with a simple Arduino program in conjunction with a motor controller.
 +
 
First, the Servo.h library needs to be included to control the motor’s velocity and orientation. Next, a Servo object should be instantiated and in the setup (), specify from which pin the Servo object takes input from by using attach(int pin_number). Then, in the loop (), a specific integer value needs to be written to the Servo object to control its orientation and velocity using writeMicroseconds(int value).
 
First, the Servo.h library needs to be included to control the motor’s velocity and orientation. Next, a Servo object should be instantiated and in the setup (), specify from which pin the Servo object takes input from by using attach(int pin_number). Then, in the loop (), a specific integer value needs to be written to the Servo object to control its orientation and velocity using writeMicroseconds(int value).
 +
 
The Servo object, using the attach function in Only one type of input value is required to be entered using the Serial Monitor on the Arduino, integer values from 500 to 2500.
 
The Servo object, using the attach function in Only one type of input value is required to be entered using the Serial Monitor on the Arduino, integer values from 500 to 2500.
 
If the value 1500 is loaded to the Servo object, the motor is not moving. Values from 500 to 1499 corresponds to counter-clockwise turn with 500 at maximum angular velocity. Conversely, values from 1501 to 2500 corresponds to clockwise turn with 2500 at maximum angular velocity.  <br />
 
If the value 1500 is loaded to the Servo object, the motor is not moving. Values from 500 to 1499 corresponds to counter-clockwise turn with 500 at maximum angular velocity. Conversely, values from 1501 to 2500 corresponds to clockwise turn with 2500 at maximum angular velocity.  <br />

Revision as of 21:16, 1 May 2017

80A ESC motor can be easily controlled with a simple Arduino program in conjunction with a motor controller.

First, the Servo.h library needs to be included to control the motor’s velocity and orientation. Next, a Servo object should be instantiated and in the setup (), specify from which pin the Servo object takes input from by using attach(int pin_number). Then, in the loop (), a specific integer value needs to be written to the Servo object to control its orientation and velocity using writeMicroseconds(int value).

The Servo object, using the attach function in Only one type of input value is required to be entered using the Serial Monitor on the Arduino, integer values from 500 to 2500. If the value 1500 is loaded to the Servo object, the motor is not moving. Values from 500 to 1499 corresponds to counter-clockwise turn with 500 at maximum angular velocity. Conversely, values from 1501 to 2500 corresponds to clockwise turn with 2500 at maximum angular velocity.
Example)

# include <Servo.h>
Servo esc;
int value =1500;

void setup(){
    Serial.begin(9600);
    esc.attach(9); // attached pin 9 to the Servo object
}

void loop(){
    esc.writeMircroseconds(value);
    if (Serial.available()) {
	value = Serial.parseInt();
    }
}