Give me a hint, please. There is a board from a Segway minirobot, a Chinese version. The board is very similar to the board of a hoverboard, but I can’t understand some things.
Mcu GD32F103RCT6
There are two operational amplifiers LMW324I, apparently for measuring current, but I don’t understand how to set shunt_resistor and gain for LowsideCurrentSense.
The hall sensors are connected via a microcircuit similar to an operational amplifier, unfortunately I can’t make out the markings.
I didn’t find if there is a voltage measurement like on the board of a hoverboard, because there are only 2 operational amplifiers.
I tried to run it on SimpleFOS. I flashed it like STM32 and checked it on the motor of hoverboard (15pp).
Hall sensors work fine, checked manually by turning the motor, one revolution shows correctly.
Then I started the velocity openloop, the motor rotated if I set the target to 3, if I set more than 5 the motor only vibrates, if less than 3 it does not rotate.
Then I tested with the torque control mode, the motor starts to rotate if I set 2v, it sets a maximum of 500 rpm at 10v, does not accelerate more.
I could not check with the current sensor, the processor is flashed, but at the moment current_sense.init() everything freezes, these are apparently artifacts where GD32?
I wanted to check on the firmware GitHub - EFeru/hoverboard-firmware-hack-FOC: With Field Oriented Control (FOC) but I did not find a voltage sensor on the board.
Please give me some hints where to dig, maybe someone has encountered such boards?
Hi,
I might not be able to answer all questions but here are few comments:
the hoverboard FOC firmware uses same exact code for ST32F103 and GD32F103 chips and it works because the GD32 is a really close clone. But there are still difference, I am not sure if SimpleFOC would need some adjustments
keep in mind SimpleFOC doesn’t support Dual FOC on STM32 at the moment, so initializing 2 current sense won’t work
I would first make sure torque/voltage mode works well, we can help if you share your code.
You should also use the smoothing sensor, it will reduce noise and is needed later for FOC.
Then you will be able to try FOC but on a single motor for now.
Thanks for the reply
Yes, I’m trying to run with only one motor
Tried the smoothing sensor, but it seems nothing changed.
Currently the status is as follows
1v motor does not move
2-8v spins, picks up speed, but there is noise, the noise is like a bearing has fallen apart
9v noise increases greatly
My code
Trapezoidal will sure be noisy, and the smoothing sensor will not help in this case.
You need to use SinePWM or SpaceVectorPWM with the smoothing sensor.
With hall sensors, smoothing sensor needs a specific setting:
smooth.phase_correction = -_PI_6;
I wouldn’t do this for now, it will do a current estimation and the value looks wrong:
Thanks, that helped
Now the motor sound is almost perfect up to about 340 rpm, if the revs are higher, the bad sound returns. At the same time, there is still high-frequency vibration at all revs.
Let me ask a few more questions
Is there any experience with the gyro scooter motor on velocity_openloop, according to the instructions, we need to check the pp? but pp we know for sure that it is 15. I could not run it on velocity_openloop, only two mosfets burned out (the other one did not have a limiting power supply)
For higher speed, the inductance needs to be compensated:
this is achieved with lag compensation in voltage mode if you know the correct phase resistance, phase inductance and KV
or with FOC when current sense works, without any motor parameters
About your questions:
PP check in SimpleFOC won’t work with hall sensors, it needs an encoder. But 15 is correct for a hoverboard motor. It’s important to set up a much lower voltage for velocity_openloop than the one used for close loop.
What SmoothingSensor does is interpolation of the angle, it’s needed because Hall Sensors provides and update only every 4 mechanical degrees. The hoverboard FOC firmware starts without interpolation when speed is low or direction change, and then uses the interpolation when speed is high enough.
It’s hard to help here without details. Please share exactly where it hangs if you can use a debugger. Using the SIMPLEFOC_STM32_DEBUG build flag could also help get more details from the serial output. From your code we cannot see what parameters you are using to initialize current sense.
And one more general question. Were you able to configure SimpleFoс so that it would work on the hoverboard board no worse than EFeru/hoverboard-firmware-hack-FOC?
The hoverboard FOC firmware works very well because the implementation is fast ( FOC control loop runs at 16khz with 2 motors thanks to fix-point math) and because it’s tuned for hoverboard motors already.
But it’s not easy to adapt and is not maintained anymore. So it won’t get things like:
encoder support
position control
sensorless
…
With good tuning, it should run well with SimpleFOC also.
My only doubt is that SimpleFOC is much slower on STM32F1, but I am not sure if it can be an issue on those motors.
Hi. I tried it on another hoverboard board, which is fully tested on the EFeru/hoverboard-firmware-hack-FOC firmware and works well, has the same Mcu GD32F103RCT6. I haven’t managed to achieve good engine performance yet, but at least it spins in voltage mode.
Regarding current sense, if you select the left side, the firmware does not start with current sense, the error is the same as on the first board, something TIM8
If you start the right side (TIM1), the firmware starts and gives an error
15:12:49.304 -> MOT: sensor_direction==CW
15:12:49.337 -> MOT: PP check: OK!
15:12:50.024 -> MOT: Zero elec. angle: 0.00
15:12:50.254 -> MOT: Align current sense.
15:12:51.323 -> CS: Switch A-(C)NC
15:12:52.423 -> CS: Err B - all currents same magnitude!
15:12:52.464 -> MOT: Align error!
15:12:52.464 -> MOT: Init FOC failed.
15:12:52.499 -> Motor initFoc failed!
I tried playing with shunt_resistor and gain did not give any results.
Please give me some tips?
I reread the documentation, moved the current_sense.init() code below motor.init() and it worked, apparently this is important for automatic alignment. Not at all obvious behavior, you can easily miss this moment.
And how to choose the right shunt_resistor, gain?
There is no shunt resistor for phase current on hoverboard controllers, the Mosfet RDSON is used as shunt. So you have to check the datasheet of your mosfets.
The gain has to be derived from the schematics, but I am really not an expert here:
Thank you very much for the tips
The most important thing is that the motor works in voltage mode without vibration and sounds.
What else can you pay attention to besides smooth.phase_correction = -_PI_6; to get rid of vibration and noise?
I also noticed at the moment that if I turn on the MotionControlType::angle mode, the motor immediately starts to rotate and does not stop even if I specify a target other than 0.