Controlling the speed of brushless DC motor WITHOUT potentiometer (2)

According to this topic:
https://forum.arduino.cc/index.php?topic=581300.0
beacause of that the code doesn't work for me,how can control BLDC only by code on arduino that connected to ESC?ThankYou

So post the code that you have tried which "doesn't work". Then explain what it does do and how that is different from what you want it to do.

Steve

Exactly what do you want the BLDC motor to do ?

Will it run at a fixed speed ?
Will the program change its speed at fixed times ?
Will the speed by changed based on user input from the Serial monitor, sensors, switches, something else ?

Details please

In addition to the code and description that Steve asked for, please provide information on what ESC you have, what motor, what power supply and how you have it wired up.
Pencil, paper and a camera are usually good enough for the siring diagram.
It is often helpful t see a pic of your project as well.

"how can control BLDC only by code on arduino that connected to ESC?"

I think in the RC world ESCs are pulse controlled the same as are servos. Have you tried any servo code to control the ESC?

slipstick:
So post the code that you have tried which "doesn't work". Then explain what it does do and how that is different from what you want it to do.

Steve

simple code such this:
#include <Servo.h>

Servo esc_signal;
int velocity = 0;

void setup() {
esc_signal.attach(9);
esc_signal.writeMicroseconds(velocity);
delay(2000);
}

void loop()
{
for (velocity = 0; velocity <= 2600; velocity += 100)
{
esc_signal.writeMicroseconds(velocity);
delay(100);
}

delay(5000);
}

It only tests maximum of brushless speed.
When I use a servo tester all things works well but tester has potentiometer and I want to change its speed just by simple code such as mentioned codes without any other tools so I remove tester and use this codes.It didn't work.

You still haven't said EXACTLY what you want the code to do. But for a start just change the 2600 to another number, try 500 or 1000 or 1500, and it will go up to a lower speed.

Or do you mean you want to be able to vary the speed? If that is so and you won't use a potentiometer how are you going to tell the system what speed you want?

Steve

slipstick:
You still haven't said EXACTLY what you want the code to do. But for a start just change the 2600 to another number, try 500 or 1000 or 1500, and it will go up to a lower speed.

Or do you mean you want to be able to vary the speed? If that is so and you won't use a potentiometer how are you going to tell the system what speed you want?

Steve

I tried your solution but did not work.
Yes I want to be able to vary the speed.
Datas receive to arduino from another device but before that I should test some speed with BLDC.
problem is when I use codes It's not work and just beeping.This beeping also happens when I use potentiometer while its state is not 0. I think I should use delay but where?

Use the forum Google search function in the upper right of this page to search for ESC and similar key words. You will probably find many previous project discussions and code using these devices.

mohsenhrt:
I tried your solution but did not work.
Yes I want to be able to vary the speed.
Datas receive to arduino from another device but before that I should test some speed with BLDC.
problem is when I use codes It's not work and just beeping.This beeping also happens when I use potentiometer while its state is not 0. I think I should use delay but where?

Make your mind up. You said that code makes the motor go to maximum speed. Are you now saying it doesn't move at all but just beeps. So what EXACTLY does that posted code do?

The thing is you can see what is happening. We can't. If you can't tell us accurately what the code is doing we can't really help.

Steve

My problem resolved using Controlling a brushless motor ESC - Project Guidance - Arduino Forum
thank you everybody but 2 questions:
1.why this code on end of this page " Arduino ESC brushless motor control through buttons?? - Project Guidance - Arduino Forum " ,works for someone but does not work for me?
That's what I mean:


include <Servo.h>

Servo m1;
int pushButton = 2;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
m1.attach(6);
delay(1);
m1.write(40);
pinMode(pushButton, INPUT);
}

void loop() {https://forum.arduino.cc/
// put your main code here, to run repeatedly:
if (digitalRead(pushButton) == HIGH > LOW) { //Opens the door when the 'open' button is pressed
m1.attach(6); //Gives the servo power
m1.write(90); //Tells servo to move to 0 degree mark
delay(1); // waits 1000ms for the servo to reach the position
} else {
m1.write(40);
delay(1);
}
}


2.According to my previous efforts I figured out that it is necessary to use the "map" function for BLDC,is this true?

Is it necessary to use some delay before running BLDC?I studied earlier that it's necessary!

You say your problem is resolved. So you have some working code. So you must already know what is and isn't necessary.

Steve