Pages: [1] 2   Go Down
Author Topic: trying to get the ESC to beep...  (Read 4075 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 186
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been reading about using the servo library and I am using it and trying lots of examples and posted code, modifying it to use pin 7 as that is what I arbitrarily chose on the MEGA 2560 I am doing this on. I have a HANG-IT R/C ESC that seems pretty standard - the small wires are red, black and white, hooked to Arduino 5V, GND and pin 7 respectively. I have 12v power and ground going into the ESC.

Here is a snippet of instructions a guy I am working with gave me:
Quote
The ESC will need to receive a series  of 1 millisec pulses (low throttle) before it will trigger  - this is to prevent a dangerous full throttle startup.  The amount of low throttle pulses an ESC needs before it will trigger does vary, my guess is somewhere between 5 and 10 seconds worth.  Most ESC produce a tone when they trigger,  and I am certain that the ones you have do.

I declare my servo like so:

Servo oLeftMotor;

and to initialize it, I just do this:

  oLeftMotor.attach(7);

I tried arming it by using write() with various values and waiting several seconds. I tried 0, 90 and 180 first and a few others somewhat randomly. No beep. I tried using writeMicroseconds() instead, with various values between 0 and 2000. Again, no joy. I hear no tone.
Logged

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

You could look at the data sheet for the ESC you are using, and quit guessing at how to use it.

If you can't understand the data sheet, post a link to it. You are more likely to get help if supply critical information.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 186
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't have the data sheet and could not find a link. But the guy I am working with has controlled these and other with the same "servo tester" device and says they are all pretty similar:

Quote
To my knowledge all ESCs will have the same control protocol.  A 1 amp ESC uses the same control signal that a 240 amp one does.  The control plug requires 5 to 6 volts on the center pin, ground on the black(sometimes brown) pin and  the control pulses on the white(sometimes yellow) pin.  The ESC will need to receive a series  of 1 millisec pulses (low throttle) before it will trigger  - this is to prevent a dangerous full throttle startup.  The amount of low throttle pulses an ESC needs before it will trigger does vary, my guess is somewhere between 5 and 10 seconds worth.  Most ESC produce a tone when they trigger,  and I am certain that the ones you have do.

The one I have now is just for testing, but I want to get it activating before I mess around  with the real device. I will probably get the real device late next week and the expectation is that I will be able to fire it up almost right away (I expect that, not just the people I am doing the work for).
Logged

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

Quote
I will probably get the real device late next week and the expectation is that I will be able to fire it up almost right away (I expect that, not just the people I am doing the work for).
Without a data sheet for the real device, that is not an expectation that I would have. But, good luck.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 186
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why is that? Here is a servo tester:
http://www.toysonics.com/esky-servo-tester-adjuster-ek2-0907.html
I don't know if that is a particularly good or bad one, but there are tons of them all over the net and they are generic - they work with almost any R/C ESC. What makes it so hard for the Arduino to do that?
Logged

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

I've got an inexpensive servo tester and it will operate a servo +-45 deg from the 90 deg position. I suggest you try sending 45 deg and 135 deg positions to the ESC and see if it will arm on one of these two settings. I think normal RC equipment will only position a servo +-45 deg from the neutral 90 deg position.
Logged

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

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6633
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

From the description, you should do something like:
Code:
Servo oLeftMotor;

oLeftMotor.attach(7);
oLeftMotor.writeMicroseconds(950);  // (less than 1ms)
delay(10000);
Is that about what you were doing?
Have you tried driving regular servos to see if the setup in general is working?
Logged

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

Quote
I declare my servo like so:
Servo oLeftMotor;
and to initialize it, I just do this:
 oLeftMotor.attach(7);

So where is your code? Bad code is often the reason why things don't work as expected.
Logged

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

0
Offline Offline
Full Member
***
Karma: 0
Posts: 186
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Quote
So where is your code? Bad code is often the reason why things don't work as expected.

GPS is one tab in a larger sketch; that's why I posted the snippets of code. But if you want small, here is one. i just coded westfw's suggestions into a standalone sketch:
Quote
#include <Servo.h>

Servo oLeftMotor;

void setup()
{

oLeftMotor.attach(7);
oLeftMotor.writeMicroseconds(950);  // (less than 1ms)
delay(10000);

}

void loop()
{
}

I hear no tone from the ESC...
Logged

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

You may want to try the below where you can send different position values via the serial monitor (change the servo pin to the one you are using). The delay in your code may be causing problems by stopping the required servo position updating as required.

Code:
// zoomkat 10-4-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// for 0019 and later

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

void setup() {
  Serial.begin(9600);
  myservo.attach(9);
}

void loop() {

  while (Serial.available()) {
    delay(10);  
    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c;  //makes the string readString
    }
  }

  if (readString.length() >0) {
    Serial.println(readString);
    int n;
    char carray[6];
    readString.toCharArray(carray, sizeof(carray));
    n = atoi(carray);
    myservo.writeMicroseconds(n);
    //myservo.write(n);
    readString="";
  }
}
« Last Edit: October 31, 2010, 01:12:49 am by zoomkat » Logged

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

Central Europe
Offline Offline
Edison Member
*
Karma: 7
Posts: 1220
Use the Source, Luke.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Arbarnhart,

your code doesn't look to be the problem, you simply don't know what to do. As long as you don't figure this out, it won't work. So go back to your friend who can initialise your ESC and investigate what this magic box of his is doing. You will need timing. An easy way to do this is to attach a regular servo and look how it moves. You also can attach an oscilloscope to the control line to measure the time or write a simple Arduino program who plays servo with the pulseIn() function and sends out the results on the serial line. After you have that information, my estimate is that the rest will be easy.

Some ESC have following manual calibration routine:
  • Disconnect receiver power.
  • Move to full throttle.
  • Connect receiver power - thus feeding the ESC
  • Wait for first beep.
  • Move to full stop (for planes that's minimum, for car that's middle position)
  • Wait for other beeps.
  • Optional for cars: Move to full reverse.
  • Wait for last beeps.
Assuming you just want to go control the speed in one direction, your test program should look roughly like this:
Code:
#include <Servo.h>

Servo oLeftMotor;

void setup()
{

// Set first the position to prevent the servo to move to the middle
// position at initialisation
oLeftMotor.writeMicroseconds(2000);  // Full power

// Only now attach the servo. When passing the proper
// minimum and maximum, you will be able to use the degrees
// for write. I assumed the standard range from 1000 to 2000
// microseconds.
oLeftMotor.attach(7, 1000, 2000);

// Wait for beep from ESC
delay(10000);

oLeftMotor.writeMicroseconds(1000);  // Power off

// Wait for beep from ESC
delay(10000);
}

void loop()
{
}

Perhaps this helps.

Korman
« Last Edit: October 31, 2010, 04:20:10 am by Korman » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 186
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Zoom - I actually have something similar, but substantially more complex, which is one reason I didn't post my whole sketch. I have a terminal interface that switches between USB or Bluetooth depending on which connects and sends the keys to enable it. That was one of the first things I got up and running because it makes adding in all the other pieces so much easier. I can connect up and send a command to read the compass, GPS or RF device, set or read pins, etc. I can turn on levels of diagnostic output, so I can leave status updates all over the place that only show if I turn verbose mode on.  I even had it turning and moving using 2 little motors and a shield, just so I could go ahead and work on that functionality without the real motors. In short, I am having a lot of success with the Arduino in general. There is something specific about this interface that I don't get.

That diagnostic interface works fine, so that is what I use when I plug in something new. But if I posted that (can't post all my code as it is work for hire), I would probably spend as much or more time explaining it as discussing whatever it is that is wrong.

Korman - Awesome suggestion about PulseIn() - I can add that to my diagnostics. A poor man's scope, if you will. I am asking for a magic box and motor before the prototype is ready. Had I been able to easily make the ESC beep, I would be less worried about it.

Speed will be one direction only, 3 phase brushless DC motors. Big, powerful motors - one of the reasons I haven't been messing with the real ones is that they require substantial power and need to be mounted properly to be operated safely.

By "receiver power", do you mean switching the 5V from the Arduino? That is something I have not tried

Logged

Central Europe
Offline Offline
Edison Member
*
Karma: 7
Posts: 1220
Use the Source, Luke.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
By "receiver power", do you mean switching the 5V from the Arduino?

Not at all, I was talking about the manual calibration routine you do with a RC-controller. There you don't have the option of not sending data on the control line, so the procedure is turn off the RC-receiver, set the transmitter to the correct position and only then turn the receiver on again so that it will never see anything but the correct position. With the Arduino, it usually is enough to set the position before calling the attach() function.

Korman
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

my ESC got a set key feature and i dont know how to make it work with arduino.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I had the same problem and I made a processing and arduino code for it.
Right now I am not at home so I dont have the codes.

As soon as I get home I will post it.
Logged


Pages: [1] 2   Go Up
Jump to: