RoboRemo Users' Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

ESP32 board and four Servo motors

2 posters

Go down

ESP32 board and four Servo motors Empty ESP32 board and four Servo motors

Post by rpnogue Thu Feb 06, 2020 4:25 pm

Hi, I need some help.
I´m trying to control a Robot with 4 servo motors controlled by a ESP32 DevKit V1 board.
I set up an Interface with 4 buttons to command the raising and decreasing servo signals for each motor, set with repeat option. There is a Connect button, too, connecting through BT MAC address.
The Arduino code is OK, tested with another application. But RoboRemo App controls 3 motors. The fourth of them gets mad after the first command. It starts repeat one of the command (always the same), regardless of which command is sent from any other button.

The first question is: is there anyone that could help me in analysing the problem? That is, that have faced the same problem?
If so, I can print my code, or give more details of the Interface, if necessary..

Another question: is it some kind of incompatibility with that ESP32 board? I dont think so, because the communication with the board is OK and stable, the receiving strings are well read and handled by Arduino code. The problem is repetition.

Thanks all for any support, in advance.

rpnogue

Posts : 4
Join date : 2020-02-01

Back to top Go down

ESP32 board and four Servo motors Empty Re: ESP32 board and four Servo motors

Post by rpnogue Sat Feb 08, 2020 5:28 pm

Well, some News.
Part of the problems were solved by disassembling and reassembling the kit. In fact, there where some assembling erros, like setting the zero positions of the mechanical pieces according with the relative positions of the Motors axes.  After corrections, the movements became soft.

I couldn´t find where the Arduino code would be impacting the sequencial commands, causing the repetitions mentioned in the main msg, above. But, beyond revising the Code, I changed the logic. And the repetitions disapeared.
But, some spurious commands remain occurring. The connection is broken from time to time, revealing some instabilities.

I´m not sure if this is happening because the ESP32board or because some Roboremo App incompatibility. I´ll keep analysing.

As it is a child's toy, I think it can be used. But, I will keep trying to give more stability to the connection and the movements.

If I have any News, I´ll send to all.

Tks

rpnogue

Posts : 4
Join date : 2020-02-01

Back to top Go down

ESP32 board and four Servo motors Empty Re: ESP32 board and four Servo motors

Post by Admin Wed Feb 12, 2020 7:38 am

Hi,
If you want you can send us the ESP code and the exported RoboRemo interface file and we will take a look.

All the best,
Victor

Admin
Admin

Posts : 150
Join date : 2016-03-08

https://roboremo.forumotion.com

Back to top Go down

ESP32 board and four Servo motors Empty Re: ESP32 board and four Servo motors

Post by rpnogue Sat Feb 15, 2020 12:59 am

Hi, Victor. Glad to see you.
The system became more stable. I guess the lost of connections is not caused by Roberemo App, but is inherent to the system. The devices are not professionals, and I guees the accuracity is not so good.
But I´m printing the Arduino code just below. I couldn't pass up the opportunity to count on your help and advice.

The App Interface is going well, the commands are sent and received fine by the board. But (there´s always a "but"), I can´t set one virtual led to light up when any command is received and executed by the board. I thought this led would monitor if the connection is up.
If you help me, I will appreciate so much.

The code:
(I appologize the comments are in portuguese. If you need, I can translate. And, I forgot to say, the board is a ESP32 DevKit V1. Even though it´s nor listed as tested boards, It´s doing right until, now. Works fine)

//*****************************
#include <ESP32Servo.h>
#include <BluetoothSerial.h>

BluetoothSerial ESP_BT; //Objeto Bluetooth
Servo garra; // Objeto Garra ==> "mão" que pega os objetos
Servo base; // Objeto Base ==> gira a base à esquerda ou direita
Servo ombro; // Objeto Ombro ==> avança ou recua a garra
Servo cotovelo; // Objeto Cotovelo ==> eleva e abaixa a Garra

/*------------DEFINIÇÕES DOS GPIO DE SAÍDA----------*/
int pinGarra = 14;
int pinOmbro = 27;
int pinCotovelo = 26;
int pinBase = 25;

/*---------PARAMETROS BASE-------------*/
//#define BASE 25
int posBaseInicial = 90; //angulo posição inicial do eixo do motor
int BaseInicial = 10; //angulo de posição inicial do eixo do motor
int BaseFinal = 170; //angulo de posição final do eixo do motor
int posBase = posBaseInicial; //angulo posição do eixo do servo da BASE

/*---------PARAMETROS GARRA-------------*/
//#define GARRA 14
int posGarraInicial = 135; //angulo posição inicial do eixo do motor
int GarraInicial = 90; //30 angulo de posição inicial do eixo do motor. Garra aberta
int GarraFinal = 180; // 130 angulo de posição final do eixo do motor. garra fechada
int posGarra = posGarraInicial; //angulo posição do eixo do servo da GARRA

/*---------PARAMETROS OMBRO-------------*/
//#define OMBRO 27
int posOmbroInicial = 90; //angulo posição inicial do eixo do motor
int OmbroInicial = 0; //40 angulo de posição inicial do eixo do motor
int OmbroFinal = 80; //130 angulo de posição final do eixo do motor
int posOmbro = posOmbroInicial; //angulo posição do eixo do servo da OMBRO

/*---------PARAMETROS COTOVELO-------------*/
//#define COTOVELO 26
int posCotoveloInicial = 150; //angulo posição inicial do eixo do motor
int CotoveloInicial = 80; //angulo de posição inicial do eixo do motor
int CotoveloFinal = 180; //70 angulo de posição final do eixo do motor
int posCotovelo = posCotoveloInicial; //angulo posição do eixo do servo da COTOVELO

String comando; //String com o comando recebido do App, via BT
char b; //guarda cada byte recebido do App
int I =101;

int pg; //posição da garra no ciclo anterior
int pb; //posição da base no ciclo anterior
int po; //posição do ombro no ciclo anterior
int pc; //posição do cotovelo no ciclo anterior

void setup() {
Serial.begin(115200);
ESP_BT.begin("Robot"); //Nome de link BT
Serial.println("ESP32 pronto para conectar ");

pinMode(pinGarra,OUTPUT);
pinMode(pinCotovelo,OUTPUT);
pinMode(pinOmbro,OUTPUT);
pinMode(pinBase,OUTPUT);

//Associa os servos aos pinos do Arduino
garra.attach(pinGarra);
base.attach(pinBase);
ombro.attach(pinOmbro);
cotovelo.attach(pinCotovelo);

//Posições iniciais
garra.write(posGarraInicial);
base.write(posBaseInicial);
ombro.write(posOmbroInicial);
cotovelo.write(posCotoveloInicial);

pg = posGarraInicial;
pb = posBaseInicial;
po = posOmbroInicial;
pc = posCotoveloInicial;
}

void loop() {

if((posGarra != pg)||(posBase!=pb)||(posOmbro!=po)||(posCotovelo!=pc)){ //só vai guardar valores anteriores se as posições mudaram
// Serial.println("posGarra: " + String(posGarra,DEC));
http://Serial.println("posBase: " + String(posBase,DEC));
http://Serial.println("posOmbro: " + String(posOmbro,DEC));
http://Serial.println("posCotovelo: " + String(posCotovelo,DEC));
http://Serial.println(" ");
pg = posGarra;
pb = posBase;
po = posOmbro;
pc = posCotovelo;
}

if (ESP_BT.available()) //Check if we receive anything from Bluetooth
{
comando = "";
b = 0;

do{
b = ESP_BT.read();
http://Serial.println(comando + " " + char(b));
if(b == 35){ //char # - indica fim de string
break; //sai do laço do...while
}
comando = comando + char(b);
}while(true); //somente sai do laço se alcançar o fim do String

if ((comando == "abre")&&(posGarra>GarraInicial)){ //garra abrindo
posGarra = posGarra - 5;
garra.write(posGarra);
Serial.print("led1 1#"); //liga led1 virtual
http://Serial.println("abrindo ==> " + String(posGarra,DEC));
}else

if ((comando == "fecha")&&(posGarra<GarraFinal)){ //garra fechando
posGarra = posGarra + 5;
garra.write(posGarra);
Serial.print("led1 1#"); //liga led1 virtual
http://Serial.println("fechando ==> " + String(posGarra,DEC));
}else

if ((comando == "esquerda")&&(posBase<BaseFinal)){ //base girando para esquerda
posBase = posBase + 5;
base.write(posBase);
http://Serial.println("esquerda ==> " + String(posBase,DEC));
}else

if ((comando == "direita") && (posBase > BaseInicial)){ //base girando para direita
posBase = posBase - 5;
base.write(posBase);
http://Serial.println("direita ==> " + String(posBase,DEC));
} else

if ((comando == "desce")&&(posCotovelo>CotoveloInicial)){ //Garra subindo - cotovelo
posCotovelo = posCotovelo - 5;
cotovelo.write(posCotovelo);
http://Serial.println("subindo ==> " + String(posCotovelo,DEC));
}else

if ((comando == "sobe")&&(posCotovelo<CotoveloFinal)){ //Garra descendo - cotovelo
posCotovelo = posCotovelo + 5;
cotovelo.write(posCotovelo);
http://Serial.println("descendo ==> " + String(posCotovelo,DEC));
}else

if ((comando == "avanca")&&(posOmbro<OmbroFinal)){ //Garra avancando - ombro
posOmbro = posOmbro + 5;
ombro.write(posOmbro);
http://Serial.println("avancando ==> " + String(posOmbro,DEC));
}else

if ((comando == "recua") && (posOmbro > OmbroInicial)){ //Garra recuando - ombro
posOmbro = posOmbro - 5;
ombro.write(posOmbro);
http://Serial.println("recuando ==> " + String(posOmbro,DEC));
}
}

Serial.print("led1 0#"); //desliga led1 virtual
delay(20);
}

rpnogue

Posts : 4
Join date : 2020-02-01

Back to top Go down

ESP32 board and four Servo motors Empty Re: ESP32 board and four Servo motors

Post by Admin Wed Feb 19, 2020 3:02 pm

how do you get the ESP32Servo library?
I get this error:
error: ESP32Servo.h: No such file or directory

Admin
Admin

Posts : 150
Join date : 2016-03-08

https://roboremo.forumotion.com

Back to top Go down

ESP32 board and four Servo motors Empty Re: ESP32 board and four Servo motors

Post by Admin Wed Feb 19, 2020 3:07 pm

is it this one?
ESP32 board and four Servo motors Esp32_10

Admin
Admin

Posts : 150
Join date : 2016-03-08

https://roboremo.forumotion.com

Back to top Go down

ESP32 board and four Servo motors Empty Re: ESP32 board and four Servo motors

Post by Admin Wed Feb 19, 2020 4:04 pm

The code looks OK.
Well, it can be improved but unfortunately I don't have time for that.

But I think the problem is from power supply. Check on the pins where you provide power to the ESP board to see if you have voltage dropping when the motors move, and try to add a capacitor like 1000uF to that pins.

Admin
Admin

Posts : 150
Join date : 2016-03-08

https://roboremo.forumotion.com

Back to top Go down

ESP32 board and four Servo motors Empty Re: ESP32 board and four Servo motors

Post by rpnogue Sun Mar 01, 2020 5:10 pm

Updating posts,

a)- Yes. ESP32Servo library is that you listed, by John K. Bennet and Kevin Harrington. It can be found In Github site.

b)-I reassembled both the hardware and the robot and redid the tests thoroughly. The system is working well now, considering, of course, that the components are unprofessional. Now, it seems that it is obvious that the corrections were just a matter of care in the assembly. But his guidance was essential for everything goes well.
The goal now is to adapt the robotic hand in a small truck, so that my son can drive it via smartphone.

At last, as I didn´t find any Robocore compatibility issues with ESP32 boards, I have to say that I did not have any problems in using the "ESP32 Devkit V1" model. I can not say about other versions, but I can´t see any reasons to Robocore doesn´t work with them.

Thanks by the support. If I can help anyone in this forum, pls, just contact.

rpnogue

Posts : 4
Join date : 2020-02-01

Back to top Go down

ESP32 board and four Servo motors Empty Re: ESP32 board and four Servo motors

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum