EFeru / hoverboard-firmware-hack-FOC

With Field Oriented Control (FOC)
GNU General Public License v3.0
1.09k stars 915 forks source link

Reset Button #112

Closed farev closed 3 years ago

farev commented 3 years ago

Hello, is there a way of programming a reset button into the board? Like pressing the on button for 10 sec and the code runs from the beggining again. My project only works one time after I flash the motherboard, each time I want it to work properly I need to connect it to my computer again and flash the firmware. I think a reset button might fix this problem.

NickLD commented 3 years ago

Sounds like you have a more serious problem at hand, having a 'reset button' isn't a very good patch.. Are you saying you have to re-flash the hoverboard mainboard firmware again, or your external microcontroller?

farev commented 3 years ago

The hoverboard mainboard firmware. The problem I have is that after I turn off and on again the hoverboard after reflashing it the motors don't stay still anymore. But the first time I try it after reflashing the mainboard it does work fine.

EFeru commented 3 years ago

I never heard about such an issue. What kind of chip do you have? Try to full erase your chip, flash and recheck? Try another main board to see if that one is OK and rule out a programming issue.

Also, when you get unexplainable issues is good to lock the chip and unlock it one more time. Sometimes the unlocking procedure did not fully succeeded. I encountered it once with the sideboard.

farev commented 3 years ago

I am using the normal hoverboard chip, and how do I fully erase my chip? I think I accidentally did that one time when I was flashing it and that might have started the problem. I don't have another board to test, I had one but it burned because of a bad battery.

Candas1 commented 3 years ago

In same menu as for unlocking the chip, you have the option to erase it. https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/wiki/How-to-Unlock-MCU-Flash

As chip will be empty you will have to keep on/off button pressed while flashing.

farev commented 3 years ago

I will try it, and is it better to flash it from terminal or the stm32 platform?

EFeru commented 3 years ago

Most of us flash it directly from Platformio.

farev commented 3 years ago

I don't know how to do it from there, but is it ok if I flash it from the stm32 platform or from terminal?

EFeru commented 3 years ago

I don't know how to do it from there, but is it ok if I flash it from the stm32 platform or from terminal?

I only flashed with Platformio and Keil uVision, so I cannot comment. But I know a lot of people are also flashing using STM Link Utility which works as well.

farev commented 3 years ago

Ok I will try with both, to see if it affects.

farev commented 3 years ago

Sorry it took me a while but I tested both ways and I still have the problem. I tried doing a complete chip erase and then reflashing it and it didn't change anything.

EFeru commented 3 years ago

When you can make a video with the behavior you have. It will help understanding the issue.

farev commented 3 years ago

The arduino code was causing the problem, so I decided to use a nunchuk instead and it works correctly using this variant. The motors do stay still at 0. To which cables should I connect the nunchuk, to the right side or the left side cables? And is there a way of using the buttons of the nunchuk?

farev commented 3 years ago

And I feel it is a bit slow, it doesn't reach max speed.

Candas1 commented 3 years ago

Nunchuk can only connect to right side. Speed_coefficient in config.h is lower for nunchuk variant, you can increase it if needed. The buttons are not used, but you can implement it if needed.

farev commented 3 years ago

How can I implement the buttons, I don't know how. And to which number should I change the speed coefficient if I want it to reach max speed, right now it is at 8192.

Candas1 commented 3 years ago

32767 is the maximum but it would be too fast. Check the other variants there are examples

farev commented 3 years ago

About how many km/h would that be?

farev commented 3 years ago

I tried it and seems like there is interferance but I that is normal at that speed right?

farev commented 3 years ago

Also is there a way to add like a deadband for the nunchuk joystick, or is that the filter?

Candas1 commented 3 years ago

You can adjust the deadband parameter in config.h. Doing the auto calibration can also help center the joystick. Please also check the wiki. If you don't use pull up resistors and the cable is disconnected, the board will go full speed.

farev commented 3 years ago

I couldn’t find where to change the deadband parameter is it the filter value that is with the speed and steer coefficients, and I couldn’t find the wiki if you could please share the link.

Candas1 commented 3 years ago

You have to do little efforts. Please use the search

farev commented 3 years ago

I alredy cheked out the wiki but I am still not able to find the deadban parameter in config.h. I found it but not for the variant nunchuk, I found it for the PPM and PWM.

Candas1 commented 3 years ago

Then it means you are not using the latest version of the firmware

farev commented 3 years ago

Yes I am not using the latest version of the firmware, I will update it. And how can I make the buttons work like a throttle and smooth brake?

Candas1 commented 3 years ago

Hi, it's not something you can just activate with a parameter.

farev commented 3 years ago

I know but can you like direct me to where I can do it, or atleast help me activate the inputs from the buttons.

farev commented 3 years ago

So I was able to control it with a nunchuk but then I updated to the newest frimware and it doesn't read the nunchuk.