Pages: 1 2 [3] 4   Go Down
Author Topic: motor code error  (Read 2788 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25875
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know it is a bit late in the game, but do you have the grounds connected?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i learned much of the basics now. Now I need to know How to send PWM through port 9 (because it supports PWM).
I found out that my if off when it is at 1500 and at full speed when it is at 2500. Do I need to use analogWrite or somehow be able to use the serial monitor or something else?
How do I set PWM?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25875
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As far as the Servo library is concerned, all pins support PWM.
Don't think about using analogWrite with a servo or ESC.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what do I have to do then ?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25875
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have no idea.
What are you trying to do?
What does your code look like?
What does it do that you don't want it to, and what doesn't do that you do want it to?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need the PWM TO BE 2500
zoomkat gave me the code below. It does not do anything but was the best help  I've had so far. he said that I put the values for angle milliseconds, etc in the serial monitor but when I do, nothing happens just my esc's beeps change each time i type in a number

// zoomkat 10-22-11 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// for IDE 0022 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h>
Servo myservo;  // create servo object to control a servo

void setup() {
  Serial.begin(9600);
  myservo.writeMicroseconds(1500); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control
  Serial.println("servo-test-22-dual-input"); // so I can keep track of what is loaded
}

void loop() {
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string
    int n = readString.toInt();  //convert readString into a number

    // auto select appropriate value, copied from someone elses code.
    if(n >= 500)
    {
      Serial.print("writing Microseconds: ");
      Serial.println(n);
      myservo.writeMicroseconds(n);
    }
    else
    {   
      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo.write(n);
    }

    readString=""; //empty for next input
  }
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ALL i NEED TO DO IS TO GET THE MOTOR TO SPIN
(i FORGOT TO MENTION THAT IN MY LAST POST)
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25875
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It does not do anything
What do you mean by that?
You are entering numbers in the serial monitor, aren't you?

( when posting code, please use code tags, and please don't SHOUT)

This
Code:
if(n >= 500)
    {
      Serial.print("writing Microseconds: ");
      Serial.println(n);
      myservo.writeMicroseconds(n);
    }
    else
    {   
      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo.write(n);
    }
isn't really necessary; the Servo library does it for you - any value sent to the Servo write method greater than about 540 is automatically sent to the writeMicroseconds method.
« Last Edit: January 05, 2013, 10:25:57 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

lIm entering numbers like 1500 and 180,etc.
Nohthing happens except the ESC beeps. The motor does not spin.
It is giving really akward beeps now.
The capitals are accidental and I only realize it when it is too late
sorry for the long wait
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 604
Posts: 33432
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The link you posted to the ESC said that it was controlled by PWM. The servo library produces PPM (pulse position modulation). You need to find out more about what signals your ESC is expecting.
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The below is the ESC info. I think that there are too many possible issues that are currently beyond the OP's ability to sort out. the ESC beeps, so it apparently recognizes the commands. No telling what is going on with the wiring, power supplys and such. The OP may require some local help from a parent or hobby shop person to verify wiring and such.

Quote
Electric Speed Control (ESC) for Brushless DC Motors

For use with the ELEV-8 Quadcopter Kit.  ESC's are used on most RC equipment for controlling the speed of a brushless motor.  It is also compatible with a wide variety of 3.3 V and 5 V microcontrollers.  Compatible with a standard RC receiver or any 3.3 V or 5 V microcontroller running the proper pulse-width modulation (PWM).

Features:

Programmable with an ESC programming card so you don’t have to use your controller and count the beeps! 
5 V BEC (Battery Eliminator Circuit) 
High Current rating enables worry free operation of varying sized motors   
Compatible with any standard RC receiver that you may have at home
Three-phase electronic control
Cells: 2-3S LiPo Input
Specifications:

Power Requirements: 7.4 – 11.1 VDC
Continuous Maximum Current: 30 A
Communication: PWM
Dimensions: 1.9 x 1.0 x 0.3 inches (48.26 x 25.4 x 7.62 mm)
Weight: 27 grams
 
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25875
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@ OP, I've just deleted yet another new post from you on this same topic.

Don't repeat. Last warning.

Cross-posting WASTES TIME.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

then  someone just help me
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25875
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
then  someone just help me
Help us to help you.
If you start new threads, the people who helped you here may not read your new thread, so overall, you're wasting yours and our time.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: 1 2 [3] 4   Go Up
Jump to: