electrical-pro / ESP32_Robot

ESP32 Balancing Robot
22 stars 10 forks source link

scketch usage #2

Open FrancescoMontedori opened 2 years ago

FrancescoMontedori commented 2 years ago

Hi, I am Francesco Montedori. First of all thanks a lot for sharing your code. I followed both your and Wouter Klop tutorial and i managed to reproduce the circuit with the changes that you made (remove potentiometer and solder the wire to the integrated circuit).

I also achieved to upload the scketch on my esp32 board and when the device boot it shows this output on the serial monitor:

image

Now I am a bit stucked. I understood that for IMU calibration you used the web interface. Anyway, when i run the ws.htm file you provided, i get this message:

image

should i change the wifi_mode in this line of the sketch?

image

Can you give me hint to make it work please? it would be very kind and appreciated.

Sorry if my question looks silly, but i'm not an advanced programmer (basically i only write code in python and arduino) and even an electronics engeneer.

Tomasonx commented 2 years ago

Francesco, maybe you can detail issue #3 [Details on removing the potentiometer and soldering the wire].

electrical-pro commented 2 years ago

@FrancescoMontedori, hello, you don't need that ws.htm file, it is just for debugging :) After uploading the sketch, ESP32 should create a Wi-Fi network: balancingRobot with password: turboturbo After you connect to the robot, PID tuning should be available at adress 192.168.4.1 and control at 192.168.4.1/control.htm image image

If for some reason you want to connect the robot to a router it is possible to do here (it's not necessary): image

if robot can't connect to the router then Wi-Fi network: balancingRobot with password: turboturbo will appear

electrical-pro commented 2 years ago

If you go to 192.168.4.1 or 192.168.4.1/control.htm and it says FileNotFound, it means you need to upload files from the data folder to ESP32. Just press "ESP32 Sketch Data Upload" to upload everything from the data folder to ESP32: image

data folder should be next to the sketch: image

If you don't have the option "ESP32 Sketch Data Upload" then read this: https://github.com/me-no-dev/arduino-esp32fs-plugin

FrancescoMontedori commented 2 years ago

Thank you very much, awesome!! I can finally connect to the robot and change the values ​​in real time from the web interface. However, I have a further problem. When the robot tilt on back side, the stepper motors move coordinated (same direction), but when the robot tilts on the other side, the steppers start to turn in opposite directions, making the robot turn on itself. I don't think the problem is related to these lines of code, as the motors turn to the correct side when the robot leans backwards:

image

Any suggestions?

electrical-pro commented 2 years ago

@FrancescoMontedori is one of the motors only able to rotate in one direction? if so, maybe ESP32 can't control the direction input of DVR8825, maybe the wiring is wrong. The change in voltage from 0V to 3.3V on this input should change the direction. Make sure that ESP32 can fully control DVR8825. (try to measure the voltage on that pin, to see if it changes) InkedDRV8825-Pinout-2_LI

FrancescoMontedori commented 2 years ago

Ho ricontrollato tutti i collegamenti del circuito e sembrano corretti. Potrebbe essere un errore nella definizione dei pin per step e dir dei DRV8825

Are this pin defined in this line of code?

20220506_130738

Looking at your circuit diagram, you used: 1° DRV8825: Step = D5 Dir = D2 2° DRV8825: Step = D18 Dir = D15

Should i change the pin definition in the code? Thanks again

electrical-pro commented 2 years ago

@FrancescoMontedori, I found a mistake in my circuit, that is probably what caused the issue. Yes you can change these pins in the code (but better don't do this). Please build everything according to the code. I changed the circuit instead, because that is how it is soldered in my robot, I want to be consistent.

My code: https://github.com/electrical-pro/ESP32_Robot/blob/cd4acb83d7e442c3fcf9e00e34b1fa1c7aaa4642/BalancingRobot.ino#L85 https://github.com/electrical-pro/ESP32_Robot/blob/cd4acb83d7e442c3fcf9e00e34b1fa1c7aaa4642/BalancingRobot.ino#L86

My robor in real life (Now it corresponds to the code, I checked): image

Here is an updated circuit: https://raw.githubusercontent.com/electrical-pro/ESP32_Robot/master/circuit_01.jpg

I drew this circuit after I've built the robot, so I did not notice the mistake... Sorry

electrical-pro commented 2 years ago

@FrancescoMontedori, Please use the pins from my code, because D2 is used by the built-in LED on the ESP32 board, and is used to indicate the discharged battery, so don't use it for the stepper. https://github.com/electrical-pro/ESP32_Robot/blob/cd4acb83d7e442c3fcf9e00e34b1fa1c7aaa4642/BalancingRobot.ino#L85 https://github.com/electrical-pro/ESP32_Robot/blob/cd4acb83d7e442c3fcf9e00e34b1fa1c7aaa4642/BalancingRobot.ino#L86

Is it working now? tell me your result

FrancescoMontedori commented 2 years ago

@FrancescoMontedori, Please use the pins from my code, because D2 is used by the built-in LED on the ESP32 board, and is used to indicate the discharged battery, so don't use it for the stepper.

https://github.com/electrical-pro/ESP32_Robot/blob/cd4acb83d7e442c3fcf9e00e34b1fa1c7aaa4642/BalancingRobot.ino#L85

https://github.com/electrical-pro/ESP32_Robot/blob/cd4acb83d7e442c3fcf9e00e34b1fa1c7aaa4642/BalancingRobot.ino#L86

Is it working now? tell me your result

Hi @electrical-pro, and thanks again for your help. Sorry for the late reply. The problem is solved and the robot is stable on its wheels. Now i'm trying to tune the PID value for "Go", as the robot falls when i increase to much the speed from the control web page. I've just another question, i would like to control the robot using a glove with another Esp32 (The mini D1 module in this case) and an MPU6050 sensor (Gyroscope and Accelerometer), connected via bluetooth to the robot. Can you help me showing the part of the code (BalancingRobot.ino) where the control.htm file sends its value, in order to change that part with the value coming from bluetooth communication?

Thanks again for your help!!