Go Down

Topic: Servo library and BLDC motor (Read 341 times) previous topic - next topic

marcinmrag

Hello,

I have problem. I would like to know frequancy and duty ratio of servo function. Im using arduino to running motor with this code :

#include <Servo.h>//Using servo library to control ESC

Servo esc; //Creating a servo class with name as esc

void setup()

{

esc.attach(8); //Specify the esc signal pin,Here as D8

esc.writeMicroseconds(1000); //initialize the signal to 1000

Serial.begin(9600);

}

void loop()

{

int val; //Creating a variable val

val= analogRead(A0); //Read input from analog pin a0 and store in val

val= map(val, 0, 1023,1000,2000); //mapping val to minimum and maximum(Change if needed)

esc.writeMicroseconds(val); //using val as the signal to esc

}



But I would like to control this motor using PLC controler nad PWM output from PLC. Can someone help me and tell me what a value i should use for calibration and full speed ( frequency and duty ratio )

Robin2

But I would like to control this motor using PLC controler nad PWM output from PLC.
Are you saying that you are able to control the motor using an Electronic Speed Control and the Servo library but you would like to use some PLC controller (whatever that is)?

If so, please post a link to the datasheet for the PLC controller so that we can see all the details.


The PWM output produced by analogWrite() is very different from the signal produced by the Servo library. I suspect the Servo library will not be appropriate for your new controller.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

daysleeper

FIY: Servo-like pulses is only one of the several control options that escs can use nowadays: oneshot, dshot, multishot, proshot... For a PLC based system maybe you'd rather use more advanced control protocols, the PWM is only easy to implement.

Anyway, the standard calibration is done powering the esc while the input signal is kept high for 2ms every 20ms (50Hz). After few beeps (this signals the max range is recorded by the esc) you need to provide 1ms high signal at 50Hz as before.

Then your control signal should be [1-2ms] <-> 0-100%. (50Hz as usual)

Se è stupido ma funziona allora non è stupido.

slipstick

A standard servo signal, also used by RC ESCs, has a frequency of approximately 50Hz. The high pulse within that is usually between 0.6ms and 2.4ms. If you're used to thinking in terms of duty cycle that's approximately 3% to 12%.

Steve

marcinmrag

Im using this ecs hobbywing skywalker 80a ubec. Is controlled by PWM signal and I would like to use PLC instead of Arduino uno. With code from my first post and arduino is everything running. I just need this values to prepare PLC code. In plc i have function for pwm signal. This function requied frequency and duty ratio.

daysleeper

I just need this values to prepare PLC code. This function requied frequency and duty ratio.
Slipstick just gave you these specific values, frequency and duty cycle. What else do you need?
Se è stupido ma funziona allora non è stupido.

marcinmrag

OK im trying but is not working :( . What about the voltage? It should be 5V supply for the PWM output, right?

slipstick

Yes the PWM signal should be approx 5V high, 0V low. But I can't help you with PLC programming. I've never used the things.

Steve

daysleeper

Which PLC?
Do you have an oscilloscope, or anything else, to analyze the signal?
Se è stupido ma funziona allora non è stupido.

vinceherman

OK im trying but is not working
One of the things that many people miss about ESCs is that they often require an arming sequence.

1000 microsecond signal for 2 seconds. 
Then 2000 microsecond signal for 2 seconds. 
Then 1000 microsecond signal for 2 seconds.
The the ESC beeps and is armed.

The actual numbers and general behavior may vary from model to model of ESC.  But this generally describes the arming sequence.

Does your ESC have an arming sequence requirement?
Are you implementing this arming sequence in your PLC code?


Go Up