Pages: 1 [2] 3 4   Go Down
Author Topic: motor code error  (Read 2276 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

please help fix it to work with my servo motor
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 46071
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Also are you saying that the stars and slashes are for multiplying and dividing?
That's one use. The other, when they are use together is to start and end comments. Out of context, as your question was, the answers can go either way (or a host of other ways, for that matter). The point of my rather silly reply, was to get you to provide that context.

Quote
I meant the little descriptions next to the code.
int var = value; // Like this?

No, the comments (that's what they are) are not required. Often, they simply state the obvious. But, to a newcomer they explain what the code does. Of course, what is obvious to me and what is obvious to you are miles apart. So, you should provide them in code you share, so that we can see that your understanding of the code is correct.
Logged

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

Quote
I created this code. Although it uploaded just fine without any problems, the motor would not spin
Your code runs a couple of hundred times a second.
What do you expect it to do?
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.

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8922
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
please help fix it to work with my servo motor

The person below seems to have the same problem as you do.

http://arduino.cc/forum/index.php/topic,140752.0.html
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: 238
Posts: 24327
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OP, please stop.
A banning beckons.
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

well AWOL, I did not know that. I am just starting this. Please someone if you can tell me a code for running a motor with ESC. I need one soon. Please also tell me how to run it up and make everything work.

Motor
http://www.parallax.com/Store/Accessories/MotorServos/tabid/163/CategoryID/57/List/0/SortField/0/Level/a/ProductID/814/Default.aspx

ESC
http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/ESC/List/0/SortField/4/ProductID/857/Default.aspx
Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8922
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Once again, you need to read previous post thart contain info on ESCs and how they are armed.

https://www.google.com/search?hl=en&as_q=esc+arm&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Farduino.cc%2Fforum&as_occt=any&safe=images&tbs=&as_filetype=&as_rights=
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: 238
Posts: 24327
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
well AWOL, I did not know that.
Which? That a ban beckons, or that your code loops?

Please, take some time to read replies to your questions before deleting them.
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

the code loops
Logged

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

Why did you think it was in a construct called "loop"?
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

FYI For zoomkat, I did already go to that before when it was sent to me before. The code did not work on the first website. I tried it again now and still nothing happened.

Also AWOL, I do sort of understand the loop thing. Its name is also self explanatory. Please help me with this code soon. I'm running out of time
Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8922
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Below is servo test code which you should be able to use to arm your ESC using the serial monitor. Apparently your ESC has beep codes indicating what it is doing. If you don't know the arming sequence, you should contact Parallax for the information.

Code:
// 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

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

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

probably the best help received so far. THANK YOU. Finally some descent help. When I type in anything between 0-180, it said writing angle: (*number i typed in*). The ESC was beeping the whole tome until I wrote 1500 then it stopped beeping and when I redid everything, it beeped only 2 or 3 times instead of continuous beeping.  During the whole thing, the motor itself never moved.
here is the tutorial that I was trying to use but continuously failed before:
http://techvalleyprojects.blogspot.com/2012/06/arduino-control-escmotor-tutorial.html
Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8922
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Doing some searching, you should be able to do the below with the code I posted. This assumes you have proper wiring and power for the motor/ESC.

"For my ESCs I have to output a pulse of 1000 (uS) for a few seconds until it beeps, then I can ramp it up to maximum speed at around 1800."
 
Logged

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

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

Im hooking it up to a 9 volts this whole time.  My esc sitll  only beeps when I hook it up to the 9 volt. I tried what you gave me again and it still does not work. Any suggestions?
do I need to program or setup my ESC some special way other than coping and pasting motor or servo codes. I just cant get it to work. The wires are connected the right way (I know this) I need help soon
Logged

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