I'm trying to use a servo and my datasshet says that, to get 180 degrees, I need as period 20 ms, but the Minnowboard Turbot only is capable to give 1.3 ms as maximun.
I have use same servo with Raspberry Pi, and I reached 180 degrees.
int main(int argc, char *argv[]){
mraa_result_t status = MRAA_SUCCESS;
float value = 0.0f;
float output;
/* initialize mraa for the platform (not needed most of the times) */
mraa_init();
mraa_pwm_close(pwm);
pwm = mraa_pwm_init(22);
if (pwm == NULL) {
fprintf(stderr, "Failed to initialize PWM\n");
mraa_deinit();
return EXIT_FAILURE;
}
/* set PWM period */
status = mraa_pwm_period_us(pwm, 20000);
if (status != MRAA_SUCCESS) {
fprintf(stderr, "Error PWM period_ms\n");
return EXIT_FAILURE;
}
/ enable PWM /
status = mraa_pwm_enable(pwm, 1);
if (status != MRAA_SUCCESS) {
fprintf(stderr, "Error PWM enable\n");
return EXIT_FAILURE;
}
while (flag) {
value = value + 0.01f;
mraa_pwm_write(pwm, value);
usleep(50000);
if (value >= 1.0f) {
value = 0.0f;
}
/* read PWM duty cyle */
output = mraa_pwm_read(pwm);
fprintf(stdout, "PWM value is %f\n", output);
I'm trying to use a servo and my datasshet says that, to get 180 degrees, I need as period 20 ms, but the Minnowboard Turbot only is capable to give 1.3 ms as maximun.
I have use same servo with Raspberry Pi, and I reached 180 degrees.
This is the datasheet: https://www.electronicoscaldas.com/datasheet/MG996R_Tower-Pro.pdf And this is my example:
include "mraa.h"
include "mraa/gpio.h"
include "mraa/pwm.h"
include
include
include
include
include
static volatile mraa_pwm_context pwm = NULL;
volatile sig_atomic_t flag = 1;
int main(int argc, char *argv[]){ mraa_result_t status = MRAA_SUCCESS; float value = 0.0f; float output;
/ enable PWM /
} / close PWM / mraa_pwm_close(pwm); }
How I can reach 20ms as period?
Regards