Saudações Garagistas!
Estou tentando enviar o sinal de um potênciometro via RF (433 MHz) entre dois Arduinos Nano, utilizando a biblioteca RCSwitch, para um dispositivo de controle de velocidade (ESC) de um motor sem escova (brushless).
Consigo enviar o sinal e o motor funciona, porém parece que o sinal chega atrasado e muitas vezes "se perde no caminho”!
O potênciometro está no zero (0) e o sinal da ESC está alto (~20%) e não vai para zero. Preciso ficar subindo e descendo o potênciometro até o conseguir que sinal de 0% seja transmitido e/ou recebido!
Ou seja, não consigo parar o motor quando quero.
Não entendo se o problema é a biblioteca (RCSwitch) ou o código (abaixo).
Obrigado pela ajuda.
Emissor:
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
int potpin = 0;
void setup() {
Serial.begin(9600);
mySwitch.enableTransmit(10);
}
void loop() {
int val = analogRead(potpin);
val = map(val, 0, 1023, 0, 179);
val = val;
mySwitch.send(val, 24);
}
Receptor:
#include <RCSwitch.h>
#include <PWMServo.h>
PWMServo myservo;
RCSwitch mySwitch = RCSwitch();
void setup() {
myservo.attach(9);
Serial.begin(9600);
mySwitch.enableReceive(0);
}
void loop() {
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();
if (value == 0){
Serial.println("Unknown enconding");
}
else {
Serial.println(mySwitch.getReceivedValue());
myservo.write(mySwitch.getReceivedValue());
mySwitch.resetAvailable();
}
}
}
Tags:
Será que o problema não esta na falta de calibração dos ESCs ?
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por