hoverboard-firmware-hack icon indicating copy to clipboard operation
hoverboard-firmware-hack copied to clipboard

Automatic Motor Configuration

Open TomTinkering opened this issue 6 years ago • 6 comments

This should be a pull request, but I can't figure out how to make one when I already have a heavily modified fork of the base repo (NiklasFauth). Guess I should make a branch?

Anyway: I am using some old unknown motors with the new YST AT32 mainboard. The cabling colors and hall connectors don't match. In order to find the right configuration for the motors without having to change the wiring, I added CONTROL_DETECT_HALL and CONTROL_MOTOR_TEST control modes to the code (see this patch)

The way it works:

  1. Enable only the CONTROL_DETECT_HALL control mode definition in config.h
  2. Build/Flash/Run on the board. The board will step through all 6 possible hall configurations. You will hear a number of beeps, then the motors will spin or stall (see this video).
  3. For each motor, listen to the number of beeps (1-6), if after the beeps one or both of the motors start spinning smoothly (no noise), write down the number of beeps for this motor.
  4. Set the HALL_IDX_LEFT and HALL_IDX_RIGHT definitions in config.h to the number of beeps that showed smooth operation for the respective motor.
  5. Enable the CONTROL_MOTOR_TEST control mode definition in config.h
  6. Build/Flash/Run on the board. The board will spin the motors at a slow constant speed, as shown in this video.
  7. If motors are spinning in the wrong direction for your liking, set the respective INVERT_L_DIRECTION and INVERT_R_DIRECTION to get the motors to spin in the direction you want for positive control values. This video shows both motors spinning in the same direction.
  8. Build/Flash/Run on the board. The motors should now spin slowly in the desired directions.

Congratulations! You now know that your board works and that the motors are configured properly. From here you can start to implement/enable your control methods.

TomTinkering avatar Jun 26 '19 12:06 TomTinkering

I think there are not so many files and code that it is possible to manually merge them and continue from the same repo.

cloidnerux avatar Jun 27 '19 13:06 cloidnerux

Nice work!

EFeru avatar Jun 28 '19 06:06 EFeru

Hi Tom,

I am trying to use CONTROL_DETECT_HALL to test my motor connections but I hear no beeps and no motors are turning. I have setup the #define CONTROL_DETECT_HALL in config.h

An I supposed to setup some non-zero values here to get this going?

motor_test_admin tst_admin = {0,0,1000/DELAY_IN_MAIN_LOOP,5,0,0};

thanks

sjamthe avatar Jul 02 '19 07:07 sjamthe

Hey sjamte, you should not have to change the tst_admin settings. Are you hearing beeps when you start the board? This should happen whenever you power on, regardless of what control method you are using.

Two things that gave me some issues:

  • Power button was not wired -> this causes the board to shutdown immediately
  • DC current measurement was not on my board -> this overrides the PWM outputs

TomTinkering avatar Jul 02 '19 21:07 TomTinkering

Thanks for your response. I was missing the following from your code patch #ifndef CONTROL_DETECT_HALL else { // do not beep buzzerFreq = 0; buzzerPattern = 0; } #endif

Now I do hear the beeps but still no motors turn. I seem to be getting no power to the motors. I see #ifndef AT32F403Rx_HD in the code but not sure where to debug for difference between AT32 code and ST32

Thx

On Tue, Jul 2, 2019, 2:06 PM Tom Vocke [email protected] wrote:

Hey sjamte, you should not have to change the tst_admin settings. Are you hearing beeps when you start the board? This should happen whenever you power on, regardless of what control method you are using.

Two things that gave me some issues:

  • Power button was not wired -> this causes the board to shutdown immediately
  • DC current measurement was not on my board -> this overrides the PWM outputs

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cloidnerux/hoverboard-firmware-hack/issues/1?email_source=notifications&email_token=AAXUAJ3RRR36HDW5U5AYA7TP5O7NZA5CNFSM4H3R2HV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZCRQEA#issuecomment-507844624, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXUAJ4A3MZR4M6GKCCVQ2DP5O7NZANCNFSM4H3R2HVQ .

sjamthe avatar Jul 02 '19 21:07 sjamthe

Ignore above, My motors are moving with ADC control. So the above may just be some error I did while patching.

I was able to get AT32 chip working by patching openocd so it recognize the chip just like ST32. I didn't have J-link but it worked with ST-link by simply writing the hover.hex file.

Thanks all. Will post my code to my fork soon.

sjamthe avatar Jul 03 '19 03:07 sjamthe