Hey guys.
Since STM32duino is really a fat ass and eatting all the flash(64k is not enough for i2c using), I am working on some transplant to keil project.
I copy some snippets from the souce code and try to make it work without arduino lib. The main purpose is cheaper design, high performance and less flash using. Though Im not a pro programmer and I will always need your help. So this is the thread where I leave my question and log my progress.
Again, thanks to everyone and this awesome project!
The very first question is about setPWM()
The dc_a/dc_b/dc_c here is the duty cycle in decimal from 0 to 1 right?
That way i just need to rewrite _writeDutyCycle3PWM(), multiply dc_x with ARR and get the CCRx.
if the HardwareTimer class isn’t part of the KEIL toolchain, then you’ll have to rewrite the hardware driver for the STM32. That includes the _writeDutyCycle3PWM and configure3PWM parts.
Also you’ll have to look at the timer functions (_micros()) and the SPI / I2C code.
The algorithm itself should be fairly portable.
@ngalin has alread done a great job of porting the simplefoc to the keil toolchain. It is specific to her her boards but it is a great place to start. Here is the git repo:
_micros() wont be matter. Im going to call the loopFOC funciton at regular frequent.
That way something is easier.
So far I do made some progress. Now PWM, current sensor, position sensor are available. Once the loopFOC ,LPF and PID are done I am able to test something! The source code is really readable. Thats supreme helpful.
You can use this to move the zero-position to a different location. This has no real effect on anything, it is just like adding an offset to the set-point.
It can be helpful in real-world setups, where you want zero to be in a certain place, and don’t always want to do offset calculations in other code (or your head).
If you just set a static voltage to the motor. When the motor stabilizes you’ll have a current in d direction not in q direction.
Q axis of current is responsible for generating torque and if you have any q current your motor will try to move to cancel it. Once when it stops you’ll have any the current in d direction which does not generate any torque, but a lot of heat
So I’d say that you still have a problem in the code.
Are you sure that electrical zero angle is well aligned?