Arduino met ESC en Brushless motor

Hardware geleverd door Arduino
Berichten: 1
Geregistreerd: 31 Jan 2017, 15:46

Arduino met ESC en Brushless motor

Berichtdoor Maikel » 31 Jan 2017, 15:56

Hallo,

Ik ben bezig met het programeren voor een Brushless motor met een ESC. We hebben de volgende website: http://techvalleyprojects.blogspot.nl/2 ... orial.html precies gevolgd en het enige wat de motor doet is piepen. We hebben alles tussen 0 en 180 ingevuld in de seriele monitor en bij niks gaat de motor draaien. Dit zijn alle onderdelen die we gebruiken:
Arduino Uno
Multistar SBEC4A Turnigy 20A
Turnigy 2.2 High discharge Lipo-battery
Propdrive 28-26 1350kV

Naast de codering van deze site hebben we ook heel veel coderingen van andere websites gebruikt en geen van alle werken. Wat kan er fout zijn? Alvast bedankt.

Maikel

Advertisement

Berichten: 4064
Geregistreerd: 16 Okt 2013, 14:31
Woonplaats: s hertogenbosch

Re: Arduino met ESC en Brushless motor

Berichtdoor shooter » 31 Jan 2017, 21:20

gebruik je deze software en hoe heb je alles aangesloten?


deze ESC heeft een beveiliging en je moet dus eerst 0 sturenen dan de ESC pas aan de spanning zetten.
zet de motor eerst even vast met een klem want anders vliegt deze weg.
De ESC heeft dus een servo signaal nodig, dat kan wel maar daar heb je dus een library voor nodig.
ik heb het prog niet nagekeken hoor.
mij lijkt dat ARMING dus startspeed 0 moet zijn.


cpp code
#include "Servo.h"  
#define MOTOR_PIN 9 // This is the left motor
#define MOTOR_PIN_R 10
#define MOTOR_MAX_SPEED 90 // NOT REALLY NEEDED
#define MOTOR_START_SPEED 60
/*
* This is the max/min speed values restriction
*/
int motor_left_minimum = 68;
int motor_left_maximum = 118;
int motor_right_minimum = 68;
int motor_right_maximum = 118;
int motor_current_speed = 0;
Servo motor; // This is the left motor
Servo motorRight;
String left;
String right;
void setup()
{
// 115200 default for blusmirf gold
//Serial.begin(115200);
// 9600 default for the xbee pro series1
Serial.begin(9600);
// Motor
delay(1000);
motor.attach(MOTOR_PIN); // This is the left motor
motorRight.attach(MOTOR_PIN_R);
motorStartAt(MOTOR_START_SPEED); // Arming procedure
delay(1500);
}
void loop()
{
//Serial.println("in loop");
if(Serial.available()>0){
//String myString = Serial.readStringUntil('\n');
//Serial.println(myString);
char ch = Serial.read();
if(ch == 'l')
{
do{
if(ch > 47 && ch < 58)
{
//Serial.print("I have received: ");
//Serial.print(ch, DEC);
//Serial.print('\n');
left += ch;
}
ch = Serial.read();
}while(ch != ';');
}
else if(ch == 'r')
do{
if(ch > 47 && ch < 58)
{
//Serial.print("I have received: ");
//Serial.print(ch,DEC);
//Serial.print('\n');
right += ch;
}
ch = Serial.read();
}while(ch != ';');
else if(ch == 'n')
{
int leftValue = left.toInt();
int rightValue = right.toInt();
Serial.print("Left value is: ");
Serial.print(leftValue);
Serial.print(" : ");// + " and " + right);
Serial.print("Right value is: ");
Serial.print(rightValue);
Serial.print('\n');
Serial.println();
if(leftValue >= motor_left_minimum && leftValue <= motor_left_maximum && rightValue >= motor_right_minimum && rightValue <= motor_right_maximum)
{
if(leftValue == motor_left_minimum)
{
motor.write(60);
//Serial.println("Left motor set to 60");
}
else
{
motor.write(leftValue);
/*Serial.print("Left motor set to ");
Serial.print(leftValue);
Serial.println();
*/
}
if(rightValue == motor_right_minimum)
{
motorRight.write(60);
//Serial.println("Right motor set to 60");
}
else
{
motorRight.write(rightValue);
/*Serial.print("Right motor set to ");
Serial.print(rightValue);
Serial.println();*/
}
}
left = "";
right = "";
leftValue = 0;
rightValue = 0;
}
}
}
// Wrapper function for Servo's ".write(*speed*)" function
void motorSetSpeed(int speed)
{
// Don't let the motor go above or below pre-determined max and min
if (speed > MOTOR_MAX_SPEED)
speed = MOTOR_MAX_SPEED;
else if (speed < MOTOR_START_SPEED)
speed = MOTOR_START_SPEED;
motor.write(speed);
motorRight.write(speed);
motor_current_speed = speed;
//Serial.print("current motor speed = ");
//Serial.println(motor_current_speed);
}
void motorStartAt(int start_speed)
{
int i;
for (i=0; i < start_speed; i+=5) {
motorSetSpeed(i);
//Serial.println(i);
delay(100);
}
}
paul deelen
shooter@home.nl

Terug naar Arduino hardware

Wie is er online?

Gebruikers in dit forum: Geen geregistreerde gebruikers en 8 gasten