Using FOC Software
Synchronous motors have turned out only to be well drivable when their stator current is controlled by means of a feedback current loop. Due to this, the existing feed forward control used for induction motors could not be extended for use with synchronous motors. Therefor the well known field oriented control approach was implemented in a separate software.
Field oriented control is only implemented for permanent magnet motors. Moreover it is optimized for IPM motors (interior permanent magnet). So it will not drive PMSM or BLDC motors in an efficient manner. It will yield no movement at all with induction motors.
Since the absolute rotor position is a key factor with synchronous motors, said software requires an absolute position feedback device. This can be a resolver or a sin/cos chip on top of a small magnet. Resolvers will need a so-called excitation. That is a high frequency (4.4kHz in our case) sine wave. Only V3 main boards generate this excitation signal. sin/cos chips do not need excitation and can also be run with V2 main boards.
Most of Damiens Toyota Designs implement V3 main board circuitry.
So to sum up
- IPM (Interior Permanent Magnet Synchronous Motor)
- Resolver or sin/cos chip
- V3 Mainboard
First of all you need to flash your board with preferable the latest FOC version (stm32_foc.bin or hex). It will identify itself with the version value of "X.YY.R-foc".
If not using a pretuned kit (like Leaf dropin board) do the usual current and voltage calibration. Be aware that polarity is important. So if current flows from the IGBT to the motor the reading must be positive. Therefor it is possible to set negative gain. When setting negative gain ocurlim must be negative also.
Find out the number of stator pole pairs. Resolver polepairs are either the same as stator pole pairs or 1. sin/cos is always respolepairs=1. Set "encmode" to "Resolver" or "sin/cos", respectively. Set syncadv=10.
It is important that the PWM channels line up with the current sensors. So current sensor "il1" must sense the phase generated by "PWM1", same for il2. You don't need to hardware-swap anything since we have parameter "pinswap". For example on some inverters current sensors are on phases 1 and 3. (next software revision) has the entry "PWMOutput23" in pinswap. That will essentially make PWM channel 3 responsible for phase 2 and PWM channel 2 becomes phase 3.
Next step is to find out your motors "syncofs". That is the offset between what the resolver reports as 0° and what actually is 0° alignment between the stator and the rotor magnetic field. To do this, a test mode has been implemented. First start your inverter with the "start" input, then switch to manual mode with the corresponding button on the web interface. Warning: manual mode does not implement any rotor speed limit! When used carelessly you might overspeed your motor to the point were it looses structural integrity - it explodes. So have means to brake your motor externally e.g. by doing this tuning with an already mounted motor and jacked up wheels. Then you can use your cars friction brakes.
- Go into manual mode -> start input, then button on web interface. Select forward direction.
- Observe value "angle" and turn rotor by hand -> you should see angle changes between 0 to 360°. If not, check resolver connection and excitation signal.
- Start with syncofs=0
- enter a positive value for "manualid". Start low, with respect to motor rating. E.g. 5% of rated current
- Keep increasing the value until you notice that the motor starts to spin - make sure you hear PWM going
- If motor spins, change syncofs in 1000 digit increments until it stops spinning. If you need to go below 0, like -1000 enter 64536 (=65536-1000)
- If manualid is less than about max_motor_current/2 go back to 4. When approaching rated_motor_current/2 make your increments/decrements smaller, like down to 300 digits
- You have found 1 of 2 possible offsets. Now you can enter a small value for "manualiq" and set "manualid" to 0.1. The motor should spin clockwise.
- If its spins counter-clockwise, add 32768 to syncofs. If the resulting value is > 65535, subtract 32768 instead (or do modulo addition in the first place)
Congratulations, the most difficult step is done. The default values or curkp and curki can usually stay untouched, I don't know a good tuning procedure anyway. Higher curki means faster reaction but also tends to oscillate at low speed. Next set up the "throtcur" parameter. It defines how many motor amps are produced per % of throttle travel.
Internally, this is split into a so-called direct and a quadrature current by means of the "Most Torque Per Amp" algorithm (MTPA). MTPA usually needs setup for the motor that your working with. Right now some typical constants are hard coded in the software. This might be replaced by auto-tuning in the future. But the deviation from optimal should not be too large with most IPM motors out there.