RoboDurden / Hoverboard-Firmware-Hack-Gen2.x

with different defines_2-x.h for different board layouts :-) Compiles with Keil version 6
GNU General Public License v3.0
85 stars 28 forks source link

Gen2.1.8 (ex2.10) (I seem to have found a new board) #25

Open Tommyboi2001 opened 1 year ago

Tommyboi2001 commented 1 year ago

20230919_083325 20230919_083256

RoboDurden commented 11 months ago

from the latest/current defines_2-10.h

// LED defines
#define LED_GREEN   PA12    // thanks to pacraf, transistors are on led module !
#define LED_ORANGE  PA15    // thanks to pacraf, transistors are on led module !
#define LED_RED         PB3     // thanks to pacraf, transistors are on led module !

#define UPPER_LED PF6   // pacraf: "two line "panel leds goes from PF6. of course via transistor and 1k
//#define UPPER_LED PB4 // pacraf: additional outputs on black dupont female header
#define LOWER_LED PB5   // pacraf: pulldown, additional outputs on black dupont female header

// Mosfet output, little onboard led
#define MOSFET_OUT PF1
RoboDurden commented 11 months ago

I could add different defines for SLAVE like:

#ifdef SLAVE
    #define LED_GREEN   P??
    #define LED_ORANGE  P??
    #define LED_RED         P??
#else
    #define LED_GREEN   PA12    
    #define LED_ORANGE  PA15    
    #define LED_RED         PB3     
#endif

#define UPPER_LED PF6   
#define LOWER_LED PB5   
pacraf commented 11 months ago
#ifdef SLAVE
    #define LED_GREEN   PA12
    #define LED_ORANGE  PA15
    #define LED_RED         PB3
#else
    #define LED_GREEN   PB3 
    #define LED_ORANGE  ? what in case there is nothing ?   
    #define LED_RED         PA15        
#endif

#define UPPER_LED PF6   
#define LOWER_LED PB5

look on below comparison Master board is right side , Slave left. originally master is with 4 led. image

RoboDurden commented 11 months ago

new binaries online with

// LED defines  - thanks to pacraf, transistors are on led module !
#ifdef SLAVE
    #define LED_GREEN   PA12    
    #define LED_ORANGE  PA15
    #define LED_RED         PB3
#else
    #define LED_GREEN   PB3 
    #define LED_ORANGE  PA12    // only two led on the cross-like led panel but users may attach other stuff
    #define LED_RED         PA15        
#endif

#define UPPER_LED PF6   // pacraf: "two line "panel leds goes from PF6. of course via transistor and 1k
//#define UPPER_LED PB4 // pacraf: additional outputs on black dupont female header
#define LOWER_LED PB5   // pacraf: pulldown, additional outputs on black dupont female header
Tommyboi2001 commented 11 months ago

I'm having trouble with uart control and esp 32, i have the tx of esp connected to rx Pb7 and esp rx connected to tx Pb6.

Tommyboi2001 commented 11 months ago

just getting gibberish on serial monitor and no attempt at motor spin

RoboDurden commented 11 months ago

Which esp32 ? The TestSpeed example is for the lolin S2 Mini: HoverSetupEsp32(oSerialHover,19200,39,37); // baud, rx, tx

pacraf commented 11 months ago

Robo - works - both green leds on 4 and 6 panels are OK now. Tommy - you have ESP S2?

pacraf commented 11 months ago

I have it as simple as here: image Lolin itself is powered by USB

pacraf commented 11 months ago

ensure beginning of sketch is like:

#define ESP32
#define _DEBUG      // debug output to first hardware serial port
//#define DEBUG_RX    // additional hoverboard-rx debug output
//#define REMOTE_UARTBUS

or:

#define ESP32
#define _DEBUG      // debug output to first hardware serial port
#define DEBUG_RX    // additional hoverboard-rx debug output
//#define REMOTE_UARTBUS
Tommyboi2001 commented 11 months ago

Which esp32 ? The TestSpeed example is for the lolin S2 Mini: HoverSetupEsp32(oSerialHover,19200,39,37); // baud, rx, tx

Ah that's my problem, I have an esp 8266

Tommyboi2001 commented 11 months ago

Would i be able to modify the sketch to work with this

RoboDurden commented 11 months ago

Sure, you need SoftwareSerial as ESP8266 only has one hardware serial. You could user the one hardware serial but then you must disable any debug output:

//#define _DEBUG // debug output to first hardware serial port

And you will see the esp-hover communical on your serial monitor strg+M.

But the softwareserial can handle 19200 baud so you should go that way

RoboDurden commented 11 months ago

If you do not have an ESP32, then automatically this code should be active:


  #include <SoftwareSerial.h>    // not compatible with RCReceiver because of interrupt conflicts.
  SoftwareSerial oSerialHover(9,8); // RX, TX 
  #define oSerialHover Serial    // Arduino

pin 9 and 8 are meant for some Arduino Mini/Nano. find some free io pins on your ESP8266 = D1 Mini ?

pacraf commented 11 months ago

Robo, compiled , loaded my first keil made version. it is UARTBUS with id 0. what suprised my that slave is doing the same what this UARTBUS recieves... (both boards connected with their original link)

RoboDurden commented 11 months ago

So you have single_uartbus or master_uartbus on the master ? and slave still the slave firmware ? With single_uartbus, the masterSlave communication should be disabled. With master_uartbus, it indeed might work but you can for now only send a speed value and not a steer value via uartBus, so the slave gets the same speed as the master, which is not really useful.

RoboDurden commented 11 months ago

First try hoverboard 2.10 master Dummy.bin and when the motor of the master spins nicely, go for hoverboard 2.10 master Uart.bin

Voltage of your cc power supply should be something like 26 Volt.

pacraf commented 11 months ago

hey Robo, 4 boards (Two 2.0 and two 2.10 - loaded with "SINGLE UARTBUS" id 0,1,2,3 - dictated by lolin. it works! https://youtu.be/cZYQoIplPDc

why buzzer of 2_0 masterboard (loaded with single uartbus) makes sounds (beeps) on one direction rotation... edit = buzzers of both masters are doing this. there is problem with arduino - feedback : -when all 4 drives work - feedback is visible only from id2,id3

> iSpeed: -30   iSlave: 2   iOdom: 1931     iSpeed: -0.49       iAmp: 0.02      iVolt: 34.61
> iSpeed: -15   iSlave: 3   iOdom: 2012     iSpeed: 0.00        iAmp: 0.16      iVolt: 31.11
> iSpeed: -15   iSlave: 2   iOdom: 1935     iSpeed: 0.00        iAmp: 0.02      iVolt: 34.83
> iSpeed: 0 iSlave: 3   iOdom: 2012     iSpeed: 0.00        iAmp: 0.10      iVolt: 31.11

if I turn off 2 drives (these id2 and 3) then I see in arduino console feedback from id 0 and 1. Instantly, arduino is working all the time without reset

iSpeed: 240 iSlave: 0   iOdom: 5389     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.17
iSpeed: 255 iSlave: 1   iOdom: 3772     iSpeed: -1.04       iAmp: 0.40      iVolt: 29.19
iSpeed: 255 iSlave: 0   iOdom: 5383     iSpeed: 0.00        iAmp: 0.40      iVolt: 29.17
iSpeed: 270 iSlave: 1   iOdom: 3793     iSpeed: -1.14       iAmp: 0.40      iVolt: 29.19

when I turn ON back these ID2 and 3 , console displays again only their feedback.

tried to increase response delay to 20ms, nothing changed.

anyway all drives work as lolin sends messages... feedback is somehow limited to two highest ID's.

my changes in TestSpeed.ino are like here

 HoverSend(oSerialHover,0,iSpeedL,wState);  // hoverboard will answer immediatly on having received this message ...
      delay(20);
      HoverSend(oSerialHover,1,iSpeedR,wState);  // but wait 10 ms for the RX line to be clear again
      delay(20);
      HoverSend(oSerialHover,2,iSpeedL,wState);  // hoverboard will answer immediatly on having received this message ...
      delay(20);
      HoverSend(oSerialHover,3,iSpeedR,wState);  // but wait 10 ms for the RX line to be clear again
      delay(20);
RoboDurden commented 11 months ago

Great, you are the first to connect 4 motors via my new uartBus :-)

With all sends one after another, the

boolean bReceived = Receive(oSerialHover,oHoverFeedback); will always only read one feedback from the serial stack, while 4 more get triggered in one loop.

Try

int iSendId = 0;

void loop()
{
...
 iNext = iNow + 25;
 HoverSend(oSerialHover,iSendId,iSpeedL,wState);  
 iSendId = (iSendId+1) % 4;
RoboDurden commented 11 months ago

@pacraf , i have uploaded a new arduino example that might work for you: https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/blob/main/Arduino%20Examples/Test_4Wheeler/Test_4Wheeler.ino

pacraf commented 11 months ago

I modified according first suggestion so this is how it looked (below) but behaved identically like before changes.

#ifdef REMOTE_UARTBUS
    if (iNow > iNext)
    {
      iNext = iNow + 25;
      //DEBUGLN("time",iNow)
      int iSpeedL = CLAMP(iSpeed + iSteer,-1000,1000);
      int iSpeedR = -CLAMP(iSpeed - iSteer,-1000,1000);

      HoverSend(oSerialHover,iSendId,iSpeedL,wState);  // hoverboard will answer immediatly on having received this message ...
      iSendId = (iSendId+1) % 4;
      delay(10);

    }

trying Test4Wheeler.ino gives identical behaviour

observation that may help. if on the setup only ID0 works and ID2 (so ID1 not switched ON board, and ID3 not switched board) the response is ONLY from ID2 anyway. I would expect ID0 will also appear.

RoboDurden commented 11 months ago

Are you sure you flashed the four different ids to the for boards ? When you flash two boards with the same id, both will read the command and both will answer at the same time :-(

This now is a true problem for a programmer. Unfortunately i do not have a 4wheeler test setup :-/

if on the setup only ID0 works and ID2 (so ID1 not switched ON board, and ID3 not switched board) the response is ONLY from ID2 anyway. I would expect ID0 will also appear.

I agree. I would test the reverse order

  iSendId--;
  if (iSendId <0) iSendId = 3;

and see if still only id2 appears.

What happens if you only power id0 ? Then still no answer from id0 ?

pacraf commented 11 months ago

I am pretty sure I programmed it corretly (ID's into boeards) I see their reply with correct ID's. with your 4wheeler.ino I see that:

All drives started: , All rotate OK, but answers are only from ID2,3

Speed: -183 iSlave: 2   iOdom: -70      iSpeed: -0.53       iAmp: 0.04      iVolt: 34.53
iSpeed: -174    iSlave: 3   iOdom: -571     iSpeed: 0.99        iAmp: 0.14      iVolt: 31.16
iSpeed: -168    iSlave: 2   iOdom: -61      iSpeed: -0.49       iAmp: 0.06      iVolt: 34.49
iSpeed: -159    iSlave: 3   iOdom: -589     iSpeed: 0.92        iAmp: 0.06      iVolt: 31.16

I remove serial cable from board ID3, 3 drives rotate, response output below:

iSpeed: 210 iSlave: 2   iOdom: 2273     iSpeed: 0.49        iAmp: 0.04      iVolt: 36.46
iSpeed: 225 iSlave: 2   iOdom: 2255     iSpeed: 0.50        iAmp: 0.08      iVolt: 36.76
iSpeed: 240 iSlave: 2   iOdom: 2245     iSpeed: 0.53        iAmp: 0.08      iVolt: 36.76
iSpeed: 255 iSlave: 2   iOdom: 2232     iSpeed: 0.62        iAmp: 0.08      iVolt: 36.63

Iremove additionally ID2 cable , only drive ID0 and ID1 rotate , i start to see feedback from them

iSpeed: -27 iSlave: 1   iOdom: 2786     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.16
iSpeed: -21 iSlave: 0   iOdom: 3463     iSpeed: 0.00        iAmp: 0.00      iVolt: 29.15
iSpeed: -12 iSlave: 1   iOdom: 2786     iSpeed: 0.00        iAmp: 0.00      iVolt: 29.16

What suprises me, that now I remove let's say ID0 and add back ID3 (So ID1 and ID3 stay online) , both rotate ,but feedback is only from ID3

iSpeed: -264    iSlave: 3   iOdom: 2364     iSpeed: 0.52        iAmp: 0.22      iVolt: 31.14
iSpeed: -279    iSlave: 3   iOdom: 2352     iSpeed: 0.59        iAmp: 0.18      iVolt: 31.14
iSpeed: -294    iSlave: 3   iOdom: 2340     iSpeed: 0.65        iAmp: 0.28      iVolt: 31.14
iSpeed: -291    iSlave: 3   iOdom: 2326     iSpeed: 0.70        iAmp: 0.30      iVolt: 31.14
RoboDurden commented 11 months ago

This is so confusing.

Add more log output:

  DEBUGT("time",iNow)  DEBUGLN("HoverSend",iSendId);
  HoverSend(oSerialHover,iSendId,aiSpeed[iSendId],wState);  // hoverboard will answer immediatly on having received this message ...

And increase the send difference time to half a second:

iNext = iNow + 500;

Then you should see in the Arduino log which and when data is sent and received. Full changes:

 boolean bReceived = Receive(oSerialHover,oHoverFeedback);   
  if (bReceived)
  {
    //DEBUGT("millis",iNow-iLast);
    DEBUGT("time",iNow);
    DEBUGT("iSpeed",iSpeed);
    //DEBUGT("iSteer",iSteer);
    HoverLog(oHoverFeedback);
    iLast = iNow;
   }

  if (iNow < iNext)
    return;

  iNext = iNow + 500;
  //DEBUGLN("time",iNow)
  int iSpeedL = CLAMP(iSpeed + iSteer,-1000,1000);
  int iSpeedR = -CLAMP(iSpeed - iSteer,-1000,1000);

  aiSpeed[0] = iSpeedL; // front left
  aiSpeed[1] = iSpeedR; // front right
  aiSpeed[2] = iSpeedL; // back left
  aiSpeed[3] = iSpeedR; // back right

  DEBUGT("time",iNow)  DEBUGLN("HoverSend",iSendId);
  HoverSend(oSerialHover,iSendId,aiSpeed[iSendId],wState);  // hoverboard will answer immediatly on having received this message ...
  iSendId++;
  if (iSendId == 4) iSendId = 0;
}

Sorry, i still do not have a clue on what is going on :-(

pacraf commented 11 months ago

I just checked , and if you have two boards, I think you can replicate it. program one as ID0 second as ID2 and into lolin upload like you would have 4 boards (4wheeler.ino)

Then you will see that in console feedback from ID0 will appear only if ID2 will not be powered... if only ID2 will start sending feedback - in console there will be messages from only ID2

pacraf commented 11 months ago

will try your suggestion

RoboDurden commented 11 months ago

Okay, will build another 2.0 test setup tomorrow.

pacraf commented 11 months ago

it was not compiling with DEBUGLN, so changed it to

DEBUGT("time",iNow); 
DEBUGT("HoverSend",iSendId);
HoverSend(oSerialHover,iSendId,aiSpeed[iSendId],wState);

output here

time: 58554 HoverSend: 0    time: 59054 HoverSend: 1    time: 59554 HoverSend: 2    time: 59560 iSpeed: -66 iSlave: 3   iOdom: 3337     iSpeed: 0.00        iAmp: 0.02      iVolt: 31.13
time: 60054 HoverSend: 3    time: 60060 iSpeed: 9   iSlave: 2   iOdom: 264      iSpeed: 0.00        iAmp: 0.00      iVolt: 36.55
time: 60554 HoverSend: 0    time: 61054 HoverSend: 1    time: 61554 HoverSend: 2    time: 61560 iSpeed: 234 iSlave: 3   iOdom: 3256     iSpeed: 0.00        iAmp: 0.38      iVolt: 31.14
time: 62054 HoverSend: 3    time: 62060 iSpeed: 291 iSlave: 2   iOdom: 293      iSpeed: 0.00        iAmp: 0.00      iVolt: 36.65
time: 62554 HoverSend: 0    time: 63054 HoverSend: 1    time: 63554 HoverSend: 2    time: 63560 iSpeed: 66  iSlave: 3   iOdom: 3258     iSpeed: 0.00        iAmp: 0.12      iVolt: 31.14
time: 64054 HoverSend: 3    time: 64060 iSpeed: -9  iSlave: 2   iOdom: 235      iSpeed: 0.00        iAmp: 0.00      iVolt: 35.99
time: 64554 HoverSend: 0    time: 65054 HoverSend: 1    time: 65554 HoverSend: 2    time: 65560 iSpeed: -234    iSlave: 3   iOdom: 3382     iSpeed: 0.00        iAmp: 0.46      iVolt: 31.13
time: 66054 HoverSend: 3    time: 66060 iSpeed: -291    iSlave: 2   iOdom: 235      iSpeed: 0.00        iAmp: 0.00      iVolt: 35.77
time: 66554 HoverSend: 0    time: 67054 HoverSend: 1    time: 67554 HoverSend: 2    time: 67560 iSpeed: -66 iSlave: 3   iOdom: 3382     iSpeed: 0.00        iAmp: 0.02      iVolt: 31.13
time: 68054 HoverSend: 3    time: 68060 iSpeed: 9   iSlave: 2   iOdom: 330      iSpeed: 0.00        iAmp: 0.02      iVolt: 35.69
time: 68554 HoverSend: 0    time: 69054 HoverSend: 1    time: 69554 HoverSend: 2    time: 69560 iSpeed: 234 iSlave: 3   iOdom: 3289     iSpeed: 0.00        iAmp: 0.06      iVolt: 31.13
time: 70054 HoverSend: 3    time: 70060 iSpeed: 291 iSlave: 2   iOdom: 350      iSpeed: 0.00        iAmp: 0.02      iVolt: 36.47
time: 70554 HoverSend: 0    time: 71054 HoverSend: 1    time: 71554 HoverSend: 2    time: 72054 HoverSend: 3    time: 72060 iSpeed: -9  iSlave: 3   iOdom: 3289     iSpeed: 0.00        iAmp: 0.14      iVolt: 31.13
time: 72554 HoverSend: 0    time: 73054 HoverSend: 1    time: 73554 HoverSend: 2    time: 73560 iSpeed: -234    iSlave: 3   iOdom: 3406     iSpeed: 0.00        iAmp: 0.02      iVolt: 31.13
time: 74054 HoverSend: 3    time: 74060 iSpeed: -291    iSlave: 2   iOdom: 282      iSpeed: 0.00        iAmp: 0.00      iVolt: 36.18
time: 74554 HoverSend: 0    time: 75054 HoverSend: 1    time: 75554 HoverSend: 2    time: 75560 iSpeed: -66 iSlave: 3   iOdom: 3406     iSpeed: 0.00        iAmp: 0.04      iVolt: 31.13
pacraf commented 11 months ago

and here output, when I start to disconnect ID3 , then disconnect ID 2 , at the end only ID1 and 0 works

time: 18552 HoverSend: 0    time: 19052 HoverSend: 1    time: 19552 HoverSend: 2    time: 19558 iSpeed: -69 iSlave: 3   iOdom: 3453     iSpeed: 0.00        iAmp: 0.00      iVolt: 31.13
time: 20052 HoverSend: 3    time: 20058 iSpeed: 6   iSlave: 2   iOdom: 350      iSpeed: 0.00        iAmp: 0.00      iVolt: 35.19
time: 20552 HoverSend: 0    time: 21052 HoverSend: 1    time: 21552 HoverSend: 2    time: 21558 iSpeed: 231 iSlave: 3   iOdom: 3360     iSpeed: 0.00        iAmp: 0.16      iVolt: 31.13
time: 22052 HoverSend: 3    time: 22058 iSpeed: 294 iSlave: 2   iOdom: 377      iSpeed: 0.00        iAmp: 0.00      iVolt: 35.35
time: 22552 HoverSend: 0    time: 23052 HoverSend: 1    time: 23552 HoverSend: 2    time: 23558 iSpeed: 69  iSlave: 3   iOdom: 3362     iSpeed: 0.00        iAmp: 0.16      iVolt: 31.13
time: 24052 HoverSend: 3    time: 24552 HoverSend: 0    time: 25052 HoverSend: 1    time: 25552 HoverSend: 2    time: 25558 iSpeed: -231    iSlave: 2   iOdom: 319      iSpeed: 0.00        iAmp: 0.00      iVolt: 35.97
time: 26052 HoverSend: 3    time: 26552 HoverSend: 0    time: 27052 HoverSend: 1    time: 27552 HoverSend: 2    time: 27558 iSpeed: -69 iSlave: 2   iOdom: 319      iSpeed: 0.00        iAmp: 0.00      iVolt: 35.45
time: 28052 HoverSend: 3    time: 28552 HoverSend: 0    time: 29052 HoverSend: 1    time: 29552 HoverSend: 2    time: 29558 iSpeed: 231 iSlave: 2   iOdom: 430      iSpeed: 0.00        iAmp: 0.00      iVolt: 36.20
time: 30052 HoverSend: 3    time: 30552 HoverSend: 0    time: 31052 HoverSend: 1    time: 31552 HoverSend: 2    time: 31558 iSpeed: 69  iSlave: 2   iOdom: 469      iSpeed: 0.00        iAmp: 0.00      iVolt: 37.97
time: 32052 HoverSend: 3    time: 32552 HoverSend: 0    time: 32558 iSpeed: -81 iSlave: 2   iOdom: 419      iSpeed: 0.00        iAmp: 0.00      iVolt: 36.95
time: 33052 HoverSend: 1    time: 33058 iSpeed: -156    iSlave: 0   iOdom: 267      iSpeed: 0.00        iAmp: 0.00      iVolt: 29.17
time: 33552 HoverSend: 2    time: 34052 HoverSend: 3    time: 34552 HoverSend: 0    time: 34558 iSpeed: -219    iSlave: 1   iOdom: 1284     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.19
time: 35052 HoverSend: 1    time: 35058 iSpeed: -144    iSlave: 0   iOdom: 315      iSpeed: 0.00        iAmp: 0.00      iVolt: 29.17
time: 35552 HoverSend: 2    time: 36052 HoverSend: 3    time: 36552 HoverSend: 0    time: 37052 HoverSend: 1    time: 37058 iSpeed: 156 iSlave: 1   iOdom: 1279     iSpeed: 0.00        iAmp: 0.00      iVolt: 29.18
time: 37552 HoverSend: 2    time: 38052 HoverSend: 3    time: 38552 HoverSend: 0    time: 38558 iSpeed: 219 iSlave: 1   iOdom: 1279     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.19
time: 39052 HoverSend: 1    time: 39058 iSpeed: 144 iSlave: 0   iOdom: 432      iSpeed: 0.00        iAmp: 0.20      iVolt: 29.17
time: 39552 HoverSend: 2    time: 40052 HoverSend: 3    time: 40552 HoverSend: 0    time: 40558 iSpeed: -81 iSlave: 1   iOdom: 1373     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.19
time: 41052 HoverSend: 1    time: 41058 iSpeed: -156    iSlave: 0   iOdom: 401      iSpeed: 0.00        iAmp: 0.20      iVolt: 29.17
time: 41552 HoverSend: 2    time: 42052 HoverSend: 3    time: 42552 HoverSend: 0    time: 42558 iSpeed: -219    iSlave: 1   iOdom: 1467     iSpeed: 0.00        iAmp: 0.00      iVolt: 29.19
time: 43052 HoverSend: 1    time: 43058 iSpeed: -144    iSlave: 0   iOdom: 465      iSpeed: 0.00        iAmp: 0.20      iVolt: 29.17
time: 43552 HoverSend: 2    time: 44052 HoverSend: 3    time: 44552 HoverSend: 0    time: 44558 iSpeed: 81  iSlave: 1   iOdom: 1466     iSpeed: 0.00        iAmp: 0.00      iVolt: 29.19
time: 45052 HoverSend: 1    time: 45058 iSpeed: 156 iSlave: 0   iOdom: 578      iSpeed: 0.00        iAmp: 0.20      iVolt: 29.17
pacraf commented 11 months ago

For today I finish... wife will file for divorce if I continue... good night.

RoboDurden commented 11 months ago

Sorry for my bad code :'( You last log does not make any sense to me:

time: 18552 HoverSend: 0    
time: 19052 HoverSend: 1    
time: 19552 HoverSend: 2    
time: 19558 iSpeed: -69 iSlave: 3   iOdom: 3453     iSpeed: 0.00        iAmp: 0.00      iVolt: 31.13

time: 20052 HoverSend: 3    
time: 20058 iSpeed: 6   iSlave: 2   iOdom: 350      iSpeed: 0.00        iAmp: 0.00      iVolt: 35.19

About 6 ms after a send, the slave should answer. But no answer from 0, 1, 2 but then 6ms after the send to 2, id3 answers whish had received its command 1.5 seconds eariler (i guess at 18052).

So i feel that my Receive(...) function is faulty and lots of incoming data gets skiped. And those complete messages that get detected seem in some random order.

You could/should activate

#define DEBUG_RX // additional hoverboard-rx debug output

And connect and power all 4 boards. Then we can see all incoming bytes.

Sorry, it is not DEBUGLN("HoverSend",iSendId); but DEBUGN("HoverSend",iSendId);

  DEBUGT("time",iNow)  DEBUGN("HoverSend",iSendId);
  HoverSend(oSerialHover,iSendId,aiSpeed[iSendId],wState);  // hoverboard will answer immediatly on having received this message ...
  iSendId++;
RoboDurden commented 11 months ago

test setup slave 2 0 or not slave 2 0 or not

I am not sure if this is a 2.0 layout :-/ The second serial port does not work and it's tx is shorted with the Rx :-( So I needed to use the masterSlave UART for the remoteUartBus.

Motor is also not spinning but hissing an ugly noise.

That is why I have iSteer=iSpeed=0 in the 4wheeler.ino

Led seem to work.

RoboDurden commented 11 months ago

@pacraf , i have uploaded new code. The firmware is set to layout 2.0 !

DEBUG_LED is activated in config.h

#define DEBUG_LED // uncomment to activate DEBUG_LedSet(bSet,iColor) macro. iCol: 0=green, 1=organge, 2=red

I let the green led flash when the board has received data for its id and sends back its log data.

It seems that indeed the problem is with my Receive function on the Arduino side:

time: 1204114   HoverSend to: 0
 CD AB :-)
time: 1204120   rx left: 5  iSlave: 2   iOdom: 0        iSpeed: 0.00        iAmp: 0.20      iVolt: 24.71
time: 1205114   HoverSend to: 1
time: 1206115   HoverSend to: 2
 CD AB :-)
time: 1206122   rx left: 7  iSlave: 0   iOdom: -1       iSpeed: 0.00        iAmp: 0.20      iVolt: 24.50
time: 1207115   HoverSend to: 3
time: 1208116   HoverSend to: 0
 CD AB :-)
time: 1208122   rx left: 6  iSlave: 2   iOdom: 0        iSpeed: 0.00        iAmp: 0.00      iVolt: 24.71
time: 1209116   HoverSend to: 1
time: 1210117   HoverSend to: 2
 CD AB :-)
time: 1210124   rx left: 7  iSlave: 0   iOdom: -1       iSpeed: 0.00        iAmp: 0.20      iVolt: 24.50

After a complete log is read (15 bytes) from the rx data buffer, there are still "rx left" bytes in the buffer. I do not know (yet) why this is so. But that could explain why a log from id0 is read when a new command is sent to id2.

Very frustrating. But thank you for showing me that my UartBus protocol does not really work.

RoboDurden commented 11 months ago

Okay, it seems i fixed the bug in the hoverserial.h Receive() function:


time: 135703    HoverSend to: 0
 CD AB :-)
time: 135715    rx left: 0  iSlave: 0   iOdom: -1       iSpeed: 0.00        iAmp: 0.00      iVolt: 24.52
time: 136703    HoverSend to: 1
time: 137704    HoverSend to: 2
 CD AB :-)
time: 137716    rx left: 0  iSlave: 2   iOdom: 0        iSpeed: 0.00        iAmp: 0.20      iVolt: 24.72
time: 138704    HoverSend to: 3
time: 139705    HoverSend to: 0
 CD AB :-)
time: 139718    rx left: 0  iSlave: 0   iOdom: -1       iSpeed: 0.00        iAmp: 0.00      iVolt: 24.52
time: 140705    HoverSend to: 1
time: 141706    HoverSend to: 2
 CD AB :-)
time: 141719    rx left: 0  iSlave: 2   iOdom: 0        iSpeed: 0.00        iAmp: 0.20      iVolt: 24.72
time: 142706    HoverSend to: 3

Now the received log data matches to the HoverSend :-)

bug fixed in the 4wheeler hoverserial.h. Will now test RemoteUart and then update the TestSpeed::hoverserial.h

RoboDurden commented 11 months ago

Yes, Remote_Uart also still works. So @pacraf please test the 4wheeler.ino with your great 4wheeler-setup again :-)

pacraf commented 11 months ago

Hey Robo. I got you right - only Arduino reload with 4Wheeler.ino code. Drives stays as they are since yesterday trials?

RoboDurden commented 11 months ago

@pacraf , @Tommyboi2001 , please update the sourecode or flash new binaries (orange and red led were not onOff correctly) binaries are now in BinariesToFlash :-)

@parcraf, better eload both Arduino and firmware.

pacraf commented 11 months ago

to test is from BinariesToTest or ReadyToFlash , you need to compile for me: for 2_0 board UartBus version , ID0 and ID1 for 2_10 boear UartBus version ID2 and ID 3 right? or you mean differetn test?

pacraf commented 11 months ago

I can update source code now and compile with Keil, but maybe before we sortout problem we stay on your compilation?

RoboDurden commented 11 months ago

have uploaded 2.0 and 2.10 binaires. But as you now can F7 and F8 in Keil, you better download my repo again. Then you know for sure what you are flashing...

RoboDurden commented 11 months ago

But only updating the 4wheeler.ino should already get you log data from all four motors.

pacraf commented 11 months ago

no good news. Ok, so first trial - drives flash as yesterday. 4wheeler.ino and hooverserial.h as now in repo. as yesterday - started with all drives ID0,1,2,3 , responsen only from 2,3

time: 9945  rx left: 0  iSlave: 3   iOdom: -47      iSpeed: 0.80        iAmp: 0.12      iVolt: 31.12
time: 10021 rx left: 0  iSlave: 2   iOdom: 211      iSpeed: -1.02       iAmp: 0.08      iVolt: 34.51
time: 10046 rx left: 0  iSlave: 3   iOdom: -64      iSpeed: 0.87        iAmp: 0.08      iVolt: 31.12
time: 10121 rx left: 0  iSlave: 2   iOdom: 232      iSpeed: -1.07       iAmp: 0.16      iVolt: 34.49
time: 10146 rx left: 0  iSlave: 3   iOdom: -81      iSpeed: 0.93        iAmp: 0.22      iVolt: 31.11

then I start to physicaly remove cable from socket if drive ID 3

time: 36134 rx left: 0  iSlave: 2   iOdom: 2370     iSpeed: -0.49       iAmp: 0.02      iVolt: 35.69
time: 36234 rx left: 0  iSlave: 2   iOdom: 2374     iSpeed: 0.00        iAmp: 0.00      iVolt: 35.75
time: 36334 rx left: 0  iSlave: 2   iOdom: 2377     iSpeed: 0.00        iAmp: 0.00      iVolt: 35.76
time: 36434 rx left: 0  iSlave: 2   iOdom: 2378     iSpeed: 0.00        iAmp: 0.02      iVolt: 35.75
time: 36534 rx left: 0  iSlave: 2   iOdom: 2378     iSpeed: 0.00        iAmp: 0.00      iVolt: 35.83

I remove cable from ID2

time: 68800 rx left: 0  iSlave: 0   iOdom: 4174     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.12
time: 68825 rx left: 0  iSlave: 1   iOdom: 3310     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.14
time: 68900 rx left: 0  iSlave: 0   iOdom: 4172     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.12
time: 68925 rx left: 0  iSlave: 1   iOdom: 3317     iSpeed: -0.49       iAmp: 0.20      iVolt: 29.14
time: 69000 rx left: 0  iSlave: 0   iOdom: 4169     iSpeed: 0.49        iAmp: 0.00      iVolt: 29.12
time: 69025 rx left: 0  iSlave: 1   iOdom: 3326     iSpeed: -0.49       iAmp: 0.20      iVolt: 29.14

finally only ID 1 has cable

time: 78430 rx left: 0  iSlave: 1   iOdom: 3655     iSpeed: -0.97       iAmp: 0.20      iVolt: 29.16
time: 78530 rx left: 0  iSlave: 1   iOdom: 3673     iSpeed: -0.92       iAmp: 0.40      iVolt: 29.16
time: 78630 rx left: 0  iSlave: 1   iOdom: 3690     iSpeed: -0.84       iAmp: 0.00      iVolt: 29.16
time: 78730 rx left: 0  iSlave: 1   iOdom: 3705     iSpeed: -0.79       iAmp: 0.20      iVolt: 29.16
time: 78830 rx left: 0  iSlave: 1   iOdom: 3719     iSpeed: -0.70       iAmp: 0.00      iVolt: 29.16
time: 78930 rx left: 0  iSlave: 1   iOdom: 3731     iSpeed: -0.63       iAmp: 0.00      iVolt: 29.16

should I reprogram drives now with new binaries?

RoboDurden commented 11 months ago

You mean "finally only ID 0 has cable" i guess. Try to find something wrong with only two boards, than i can test with my new 2.13 setup Yes you should flash all 4 motors again anyway to get the orange and red led working

RoboDurden commented 11 months ago

activate #define DEBUG_RX // additional hoverboard-rx debug output and increase time delay to iNext = iNow + 1000; Then give me some logs again with all motors connected, etc.

RoboDurden commented 11 months ago

And also activate the Send Debug:

  DEBUGT("time",iNow)  DEBUGN("HoverSend to",iSendId);
  HoverSend(oSerialHover,iSendId,aiSpeed[iSendId],wState);  // hoverboard will answer immediatly on having received this message ...
pacraf commented 11 months ago

regarding test before one - finally left drive was as I wrote - ID1 - but it does not matter I suppose.

next output like last time - start with all ID's, then remove cables from 3 then from 2, then from 0 (so at the and stays only ID1)

time: 1559  HoverSend to: 1
time: 2559  HoverSend to: 2
 CD AB :-)
time: 2571  rx left: 0  iSlave: 2   iOdom: 5086     iSpeed: 0.00        iAmp: 0.00      iVolt: 36.29
time: 3559  HoverSend to: 3
 CD AB :-)
time: 3571  rx left: 0  iSlave: 3   iOdom: 5725     iSpeed: 0.00        iAmp: 0.12      iVolt: 31.11
time: 4559  HoverSend to: 0
time: 5559  HoverSend to: 1
time: 6559  HoverSend to: 2
 CD AB :-)
time: 6571  rx left: 0  iSlave: 2   iOdom: 5163     iSpeed: 0.00        iAmp: 0.02      iVolt: 36.19
time: 7559  HoverSend to: 3
 CD AB :-)
time: 7571  rx left: 0  iSlave: 3   iOdom: 5722     iSpeed: 0.00        iAmp: 0.14      iVolt: 31.11
time: 8559  HoverSend to: 0
time: 9559  HoverSend to: 1
time: 10559 HoverSend to: 2
 CD AB :-)
pacraf commented 11 months ago

this is now full output... sorry but copy paste is terrible from arduino console

time: 1559  HoverSend to: 1
time: 2559  HoverSend to: 2
 CD AB :-)
time: 2571  rx left: 0  iSlave: 2   iOdom: 5086     iSpeed: 0.00        iAmp: 0.00      iVolt: 36.29
time: 3559  HoverSend to: 3
 CD AB :-)
time: 3571  rx left: 0  iSlave: 3   iOdom: 5725     iSpeed: 0.00        iAmp: 0.12      iVolt: 31.11
time: 4559  HoverSend to: 0
time: 5559  HoverSend to: 1
time: 6559  HoverSend to: 2
 CD AB :-)
time: 6571  rx left: 0  iSlave: 2   iOdom: 5163     iSpeed: 0.00        iAmp: 0.02      iVolt: 36.19
time: 7559  HoverSend to: 3
 CD AB :-)
time: 7571  rx left: 0  iSlave: 3   iOdom: 5722     iSpeed: 0.00        iAmp: 0.14      iVolt: 31.11
time: 8559  HoverSend to: 0
time: 9559  HoverSend to: 1
time: 10559 HoverSend to: 2
 CD AB :-)
time: 10571 rx left: 0  iSlave: 2   iOdom: 5094     iSpeed: 0.00        iAmp: 0.00      iVolt: 36.14
time: 11559 HoverSend to: 3
 CD AB :-)
time: 11571 rx left: 0  iSlave: 3   iOdom: 5735     iSpeed: 0.00        iAmp: 0.30      iVolt: 31.11
time: 12559 HoverSend to: 0
time: 13559 HoverSend to: 1
time: 14559 HoverSend to: 2
 CD AB :-)
time: 14571 rx left: 0  iSlave: 2   iOdom: 5183     iSpeed: 0.00        iAmp: 0.00      iVolt: 36.41
time: 15559 HoverSend to: 3
 CD AB :-)
time: 15571 rx left: 0  iSlave: 3   iOdom: 5735     iSpeed: 0.00        iAmp: 0.18      iVolt: 31.11
time: 16559 HoverSend to: 0
time: 17559 HoverSend to: 1
time: 18559 HoverSend to: 2
 CD AB :-)
time: 18571 rx left: 0  iSlave: 2   iOdom: 5122     iSpeed: 0.00        iAmp: 0.00      iVolt: 35.71
time: 19559 HoverSend to: 3
 CD AB :-)
time: 19571 rx left: 0  iSlave: 3   iOdom: 5758     iSpeed: 0.00        iAmp: 0.20      iVolt: 31.11
time: 20559 HoverSend to: 0
time: 21559 HoverSend to: 1
time: 22559 HoverSend to: 2
 CD AB :-)
time: 22571 rx left: 0  iSlave: 2   iOdom: 5222     iSpeed: 0.00        iAmp: 0.00      iVolt: 36.29
time: 23559 HoverSend to: 3
time: 24559 HoverSend to: 0
time: 25559 HoverSend to: 1
time: 26559 HoverSend to: 2
 CD AB :-)
time: 26571 rx left: 0  iSlave: 2   iOdom: 5172     iSpeed: 0.00        iAmp: 0.00      iVolt: 36.65
time: 27559 HoverSend to: 3
time: 28559 HoverSend to: 0
time: 29559 HoverSend to: 1
time: 30559 HoverSend to: 2
 CD AB :-)
time: 30571 rx left: 0  iSlave: 2   iOdom: 5266     iSpeed: 0.00        iAmp: 0.00      iVolt: 36.69
time: 31559 HoverSend to: 3
time: 32559 HoverSend to: 0
time: 33559 HoverSend to: 1
time: 34559 HoverSend to: 2
 CD AB :-)
time: 34571 rx left: 0  iSlave: 2   iOdom: 5229     iSpeed: 0.00        iAmp: 0.02      iVolt: 36.79
time: 35559 HoverSend to: 3
time: 36559 HoverSend to: 0
time: 37559 HoverSend to: 1
 CD AB :-)
time: 37571 rx left: 0  iSlave: 1   iOdom: 6643     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.16
time: 38559 HoverSend to: 2
time: 39559 HoverSend to: 3
time: 40559 HoverSend to: 0
 CD AB :-)
time: 40571 rx left: 0  iSlave: 0   iOdom: 2843     iSpeed: 0.00        iAmp: 0.40      iVolt: 29.15
time: 41559 HoverSend to: 1
 CD AB :-)
time: 41571 rx left: 0  iSlave: 1   iOdom: 6766     iSpeed: 0.00        iAmp: 0.00      iVolt: 29.16
time: 42559 HoverSend to: 2
time: 43559 HoverSend to: 3
time: 44559 HoverSend to: 0
 CD AB :-)
time: 44571 rx left: 0  iSlave: 0   iOdom: 2901     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.16
time: 45559 HoverSend to: 1
 CD AB :-)
time: 45571 rx left: 0  iSlave: 1   iOdom: 6734     iSpeed: 0.00        iAmp: 0.00      iVolt: 29.17
time: 46559 HoverSend to: 2
time: 47559 HoverSend to: 3
time: 48559 HoverSend to: 0
 CD AB :-)
time: 48571 rx left: 0  iSlave: 0   iOdom: 2901     iSpeed: 0.00        iAmp: 0.40      iVolt: 29.15
time: 49559 HoverSend to: 1
 CD AB :-)
time: 49571 rx left: 0  iSlave: 1   iOdom: 6863     iSpeed: 0.00        iAmp: 0.00      iVolt: 29.16
time: 50559 HoverSend to: 2
time: 51559 HoverSend to: 3
time: 52559 HoverSend to: 0
 CD AB :-)
time: 52571 rx left: 0  iSlave: 0   iOdom: 2949     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.15
time: 53559 HoverSend to: 1
 CD AB :-)
time: 53571 rx left: 0  iSlave: 1   iOdom: 6820     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.16
time: 54559 HoverSend to: 2
time: 55559 HoverSend to: 3
time: 56559 HoverSend to: 0
time: 57559 HoverSend to: 1
 CD AB :-)
time: 57571 rx left: 0  iSlave: 1   iOdom: 6926     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.17
time: 58559 HoverSend to: 2
time: 59559 HoverSend to: 3
time: 60559 HoverSend to: 0
time: 61559 HoverSend to: 1
 CD AB :-)
time: 61571 rx left: 0  iSlave: 1   iOdom: 6875     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.18
time: 62559 HoverSend to: 2
time: 63559 HoverSend to: 3
time: 64559 HoverSend to: 0
time: 65559 HoverSend to: 1
 CD AB :-)
time: 65571 rx left: 0  iSlave: 1   iOdom: 6977     iSpeed: 0.00        iAmp: 0.00      iVolt: 29.18
time: 66559 HoverSend to: 2
time: 67559 HoverSend to: 3
time: 68559 HoverSend to: 0
time: 69559 HoverSend to: 1
 CD AB :-)
time: 69571 rx left: 0  iSlave: 1   iOdom: 6914     iSpeed: 0.00        iAmp: 0.20      iVolt: 29.18
time: 70559 HoverSend to: 2
RoboDurden commented 11 months ago

well i guess this now is only the end when you have pulled all rx/tx cable but those of slave id1. But it already looks way better then yesterday. you send to idX and idX immediately answers :-) Still strange, why not every board answers, depending on the number connected. Maybe too many pullup resistors on the many hoverboards.. .. :-/

RoboDurden commented 11 months ago

So when you have pulled id2 and id3 you only have both gen2.0 connected ? or only both gen2.10 ? And with only one type of board these two (later one) behave just as they should do. But if one or two of the other layout are also on the bus, then only this other layout succeeds in sending log data back to arduino ?

pacraf commented 11 months ago

yes , removal of cable like last time. hmm if it would be pullups - then if I force ID2and 3 with empty flash , their pullups will stay, but drives will not respond, so we will see if then , when all 4 (with 2 braindead) will be connected, if number 0 and 1 will answer