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
84 stars 28 forks source link

can not get steer data (always 0) #7

Open QGB opened 1 year ago

QGB commented 1 year ago

I modify HoverBoardGigaDevice\Src\main.c main function while 1 loop to print steer data, I did not modify other files

  while(1){
    steerCounter++; 
    if ((steerCounter % 2) == 0){   
        // Request steering data
        SendSteerDevice();
    }

        #ifdef TEST_SPEED
            speed = 3 * (ABS((  ((int32_t)steerCounter+100) % 400) - 200) - 100);
        //speed = 300;
        #endif

        // Calculate expo rate for less steering with higher speeds
        expo = MAP((float)ABS(speed), 0, 1000, 1, 0.5);

      // Each speedvalue or steervalue between 50 and -50 means absolutely no pwm
        // -> to get the device calm 'around zero speed'
        scaledSpeed = speed < 50 && speed > -50 ? 0 : CLAMP(speed, -1000, 1000) * SPEED_COEFFICIENT;
        scaledSteer = steer < 50 && steer > -50 ? 0 : CLAMP(steer, -1000, 1000) * STEER_COEFFICIENT * expo;

        // Map to an angle of 180 degress to 0 degrees for array access (means angle -90 to 90 degrees)
        steerAngle = MAP((float)scaledSteer, -1000, 1000, 180, 0);
        xScale = lookUpTableAngle[(uint16_t)steerAngle];

    printf("%04X %04X %04X %f\r\n",steerCounter,speed,steer,steerAngle);

    Delay(DELAY_IN_MAIN_LOOP);

    // Reload watchdog (watchdog fires after 1,6 seconds)
    fwdgt_counter_reload();
  }

define USART_STEER_COM USART0

use UART1 to prints:

0001 0000 0000 90.000000
0002 0000 0000 90.000000
0003 0000 0000 90.000000
0004 0000 0000 90.000000
0005 0000 0000 90.000000
0006 0000 0000 90.000000
0007 0000 0000 90.000000
0008 0000 0000 90.000000
0009 0000 0000 90.000000
000A 0000 0000 90.000000
000B 0000 0000 90.000000
000C 0000 0000 90.000000
000D 0000 0000 90.000000
000E 0000 0000 90.000000
000F 0000 0000 90.000000
0010 0000 0000 90.000000
0011 0000 0000 90.000000
0012 0000 0000 90.000000
0013 0000 0000 90.000000
0014 0000 0000 90.000000
0015 0000 0000 90.000000
0016 0000 0000 90.000000
0017 0000 0000 90.000000
0018 0000 0000 90.000000
........

Gyroscope chip: a432e3998e6c29fdfc71957dbcc90eb

my board layout: image

RoboDurden commented 1 year ago

Nice to see that printf works. You are not using the 2.0 layout. Only this layout has been successfully tested ? You are not controlling the board with an esp32 via second UART because you use this to get debug output. So you have flashed a test binary ? This only modifies speed, steer is always zero. So you have modified the test code to also vary steer. Sorry I am on the road and have not fully studied your code.