nkmakes / SMARS-esp32

Esp32 webserver robot tank control. Uses only one Jostick to control the movement. Based on TB6612FNG motor driver and smars project robot, uses async HTML protocol.
https://nkmakes.github.io/2020/09/02/esp32-tank-robot-joystick-http-web-control/
GNU General Public License v3.0
13 stars 7 forks source link

Joystick readings are encoded #1

Open Phli1 opened 2 years ago

Phli1 commented 2 years ago

Hi, I tried to connect it, changed the pins etc. and connected to the IP-adress from the serial monitor. The motors didn't move, so I printed out the readings of the joystick, when I move it: ...�␡?���Slp␜',��␔ô@��Cw␙�]��[I�:�ǖ␓ؖ�?I~�#�{癛�$�΋Λ�9��_ ��␚.��$�␋�o-#�Jy&�* ␙ x"X"��U␔��␟�e␔��␚85R�D"�q?␏h����5�"g���w.�␡?���Slp␜',��␔ô@��Cw␙�]�[I��␚.��$�␋�o-#�Jy&�* Λ�9�x"X"��U␔��␟�e␔��␚85R�D"�q?␏h����5�"g���w.. The dots printed [programmed by me], when the joystick stayed in the centre, so apparently it notices, when I do something... In the gibberish you can also see "X"... Did someone else have this problem? How can I fix it? My hardware: TTGO T-Display, TB6612FNG.

Phli1 commented 2 years ago

Update: I still get this encoded value, also the T-Display crashes after a while - maybe because it can't handle the encoded blurr?

BUT: I managed to get one motor working - it's very responsive, thank you for this code! What irritates me is that this motor only works when A1 and B1/B2 are connected to the motor... Shouldn't just B1 or B2 work? And to start with, motor 1 should be connected to A1 and A2, right? This could be a hardware issue though, I will continue testing.

nkmakes commented 2 years ago

Hi Phil, i would need to know more info about the problem to try to reproduce it, specially the wiring scheme and the library you are using for the screen, the values from the web page come as a "###,###" string format value, there should be no encoding, you can see the simple parsing on main file:

void handle_message(WebsocketsMessage msg) {
  commaIndex = msg.data().indexOf(',');
  LValue = msg.data().substring(0, commaIndex).toInt();
  RValue = msg.data().substring(commaIndex + 1).toInt();
  motor1.drive(LValue);
  motor2.drive(RValue);
}

Guessing for what i understand about the problem i would say you have:

  1. A CPU internal resource problem probably because of using both the tft screen library and the motor driver at the same time, maybe they use same internal component in the board (timer, pin?)
  2. A problem with your hardware setup (wiring, power supply, ground... )
  3. A problem related to configuration of serial speed between the screen and the CPU