Well I have been making a plane from quite a while .2 days ago I bought a new esc cause my earlier one was burnt due to some connection problem.
Now after the last one burnt I was using a friend ones and it worked fine for controlling the speed of bldc within the range of esc.write(0-2000) using servo library.
The problem is that I just bought a new one but it doesn't work with the previous code and only turns the motor in the range esc.write(55-160) and on other ranges it doesn't move the motor and I think the motor isn't giving it's best in this range . Please help me asap
And that's all we have to go on, is it?
Please help me asap
What motor ?
What ESC ?
Powered how ?
Program ?
Your choices are:
esc.writeMicroseconds() Values of roughly 1000 to 2000.
esc.write() Values of roughly 0 to 180.
Sounds like there is some confusion over which range you should be using.
Well I agree with johnwasser . There was some confusion and now it works in the range 1000-2000 with esc.writeMicroseconds
The motor starts spining at around 1030-1050 but after 1500 range is received I doubt the speed is constant till 2000.
I can't visually see or hear any change in speed.
I am really sorry if that is a stupid question it was just my doubt so I asked but I still can't understand why motor stops at esc.write(170-180) though it should be having full speed at that time
Some ESCs will stop when you send them a signal outside their normal range. Since you won't tell us what ESC you're using I'll just guess that your new one is is one of them and your old one wasn't.
Steve
Sometimes an ESC needs to be calibrated so it adjusts to the desired pulse width range. Read the owner's manual for your ESC to see how to calibrate. If you have a generic ESC running some common firmware (BLHeli or SimonK) you can probably find calibration instructions with a Google search.
well so i am sorry but my esc is generic and so i don't know which one it is, though i think it should be simonk since my earlier was bought from the same shop. but the problem with this esc still persists
I found this code on git
#include <Servo.h>
// ---------------------------------------------------------------------------
// Customize here pulse lengths as needed
#define MIN_PULSE_LENGTH 1000 // Minimum pulse length in µs
#define MAX_PULSE_LENGTH 2000 // Maximum pulse length in µs
// ---------------------------------------------------------------------------
Servo motA, motB, motC, motD;
char data;
// ---------------------------------------------------------------------------
/**
* Initialisation routine
*/
void setup() {
Serial.begin(9600);
motA.attach(4, MIN_PULSE_LENGTH, MAX_PULSE_LENGTH);
motB.attach(5, MIN_PULSE_LENGTH, MAX_PULSE_LENGTH);
motC.attach(6, MIN_PULSE_LENGTH, MAX_PULSE_LENGTH);
motD.attach(7, MIN_PULSE_LENGTH, MAX_PULSE_LENGTH);
displayInstructions();
}
/**
* Main function
*/
void loop() {
if (Serial.available()) {
data = Serial.read();
switch (data) {
// 0
case 48 : Serial.println("Sending minimum throttle");
motA.writeMicroseconds(MIN_PULSE_LENGTH);
motB.writeMicroseconds(MIN_PULSE_LENGTH);
motC.writeMicroseconds(MIN_PULSE_LENGTH);
motD.writeMicroseconds(MIN_PULSE_LENGTH);
break;
// 1
case 49 : Serial.println("Sending maximum throttle");
motA.writeMicroseconds(MAX_PULSE_LENGTH);
motB.writeMicroseconds(MAX_PULSE_LENGTH);
motC.writeMicroseconds(MAX_PULSE_LENGTH);
motD.writeMicroseconds(MAX_PULSE_LENGTH);
break;
// 2
case 50 : Serial.print("Running test in 3");
delay(1000);
Serial.print(" 2");
delay(1000);
Serial.println(" 1...");
delay(1000);
test();
break;
}
}
}
/**
* Test function: send min throttle to max throttle to each ESC.
*/
void test()
{
for (int i = MIN_PULSE_LENGTH; i <= MAX_PULSE_LENGTH; i += 5) {
Serial.print("Pulse length = ");
Serial.println(i);
motA.writeMicroseconds(i);
motB.writeMicroseconds(i);
motC.writeMicroseconds(i);
motD.writeMicroseconds(i);
delay(200);
}
Serial.println("STOP");
motA.writeMicroseconds(MIN_PULSE_LENGTH);
motB.writeMicroseconds(MIN_PULSE_LENGTH);
motC.writeMicroseconds(MIN_PULSE_LENGTH);
motD.writeMicroseconds(MIN_PULSE_LENGTH);
}
/**
* Displays instructions to user
*/
void displayInstructions()
{
Serial.println("READY - PLEASE SEND INSTRUCTIONS AS FOLLOWING :");
Serial.println("\t0 : Send min throttle");
Serial.println("\t1 : Send max throttle");
Serial.println("\t2 : Run test function\n");
}
with this my earlier used to work perfectly but this esc doesn't since
its starts rotating the motor when the pulse length is 1500 and doesn't gives max speed at 2000 in run test function since i could attain that with send max throttle
my airplane code transmitter simply sends
State.posr = map(analogRead(A3), 0, 1023, 55, 160);
which makes it spin but not to the max so i replaced it with 1000 and 2000
and on receiver side
esc.writeMicroseconds(State.posr) ;
but it won't work
i then did vice versa and replaced map function on receiver and left transmitter without mapping its value and that did work but not correctly
it first moves the motor until 1/4 speed(i assume) then stops it and then again move it as i move the throttle
and yes on transmitter value are given via a springless joystick module a.k.a potentiometer
What data type is State.posr?
It is Struct byte
'byte' can't contain the value 1000 or 2000. No wonder that failed.
So what should I use instead ? And will mapping the received value be alright? (I.e int n=map(posr, 0,1023,1000,2000);
esc.write(n)![]()
int n=map(posr, 0,1023,1000,2000);Won't work unless posr can hold a value of 1023, which a byte can't
Well thanks I'll make necessary changes and try it but can you please tell that what instead of byte should I use which can handle value of 1000-2000
Archut:
Well thanks I'll make necessary changes and try it but can you please tell that what instead of byte should I use which can handle value of 1000-2000
int.
Well int didn't work for me so I just transmitted (0,180) and remapped it on receiver for (1000,2000) hence it worked but I don't know whether it is working to its full or not .
Anyway thanks everyone
Well int didn't work for me
It works for me, always.