Saturday, February 9, 2019

How to model a BLDC (PMSM) motors Kv (velocity constant) and Kt (torque constant) in FEMM

In a previous post, the velocity constant (Kv) and torque constant (Kt) was estimated for a number of different 'hobbyist level' BLDC (PMSM) out-runner motors. In this post, I will be using FEMM to model one of these motors as accurately as possible. In the process, you will see how to use FEMM to model such a motor and how accurately its results compare to the real thing.

Measuring key parameters prior to modelling

Before the motor can be simulated in FEMM we first need to determine its key parameters. The motor to be simulated is an Odrive Robotics N5065 motor which has previously been characterised in this post. Note that this motor is a pre-production unit that was sent to me for testing by Oskar of Odrive Robotics and differs slightly (5mm shorter stator, different winding number) from that offered in his shop today.

The key motor parameters are:
  • The number of slots in the stator and the number of poles in the rotor
In order to make this, and the following steps, easier the motor was first disassembled. Disassembly was achieved by the removal of a single circlip from the shaft and pulling the rotor bell away from the stator. Some force is required due to the attraction of the magnets to the stator iron. 


With the rotor bell removed it was simply a matter of counting the number of slots/teeth on the stator and the number of magnets on the rotor. This motor has 12 slots and 14 poles (12n14p). The likely reason that the manufacturer chose this number of slots and poles is explored in detail here.
  • The stator lamination dimensions and tooth profile
The stator lamination dimensions and tooth profile can be difficult to measure directly. If you don't mind destroying your motor then you can remove all the windings and separate a single stator lamination (or just section the entire motor with a slow speed saw) and use a flatbed scanner to capture the dimensions of the lamination without any perspective errors. Including a ruler when scanning will allow you to set a correct scale. Then you could use a software package with edge detection (such as Inkscape, which is free) to produce a DXF file without the need for any other CAD software.

In my case, I didn't want to destroy or unwind the motor and so I instead opted to model it as best I could in F360 (free for hobby/student use) and then export the sketch as a DXF file for FEMM. By doing this in with parametric design software like F360 it also allows me to play around with motor parameters in future without the need to start from scratch.

The sketch was started with the inner and outer diameters and then a single tooth and its windings were added. This tooth was then copied using the 'circular pattern tool' to make a full stator. 

F360 sketch of the stator
While this method is far from ideal it does give a good approximation as we shall see.
  • The rotor magnet dimensions and grade
The magnets are glued to the rotor bell with epoxy and are also held at the correct separation by segments machined into the end cap and also into an aluminium retaining ring at the open end of the rotor bell.

The silver magnets are retained in the black rotor bell with the grey epoxy and the silver coloured aluminium ring in the open end
This approach gives good retention of the magnets but does make it difficult to estimate the actual thickness of these magnets. I made my best approximation by taking the outer bell diameter and the inner flat-to-flat measurement of the magnets and assuming the rotor bell thickness (the black walled region in the image above) is constant. Using this data, and the assumption that the magnets are flat and not curved the rotor was also modelled in F360.

F360 sketch of the rotor
Since the magnets are assumed to be perfectly flat and are glued to the inside of a cylinder there is a small 'air space' (actually filled with epoxy) below the magnets. When I imported this sketch as a DXF into FEMM later these small gaps were removed by FEMM. If you wish to maintain them for accuracy then you can force FEMM to recognise them by including a small line segment between the rotor bell and the magnet that crosses the thin air gap region.

 The magnet grade specified by the motor manufactures is N42. If you don't know the magnet grade of your motor then you can make a fairly safe guess by assuming N35 if its a cheaper model or N42 if its a higher end model. As there was in no material option in FEMM for N42, I went with N40 instead. In my case, FEMM suggests that using over N40 over N35 grade magnets leads to a ~7% increase in torque.

The rotor and stator sketches were exported as DXF files ready for importing into FEMM. You can find a copy of DXF files here. Note that FEMM doesn't know the difference between 'construction' geometry generated by F360 and normal sketch lines and so you may want to remove them before exporting as a DXF file.
  • The diameter of the wire used, the turn number per tooth and the number of parallel strands
Since I didn't want to unwind the motor it was difficult to determine the number of strands and turns per tooth used. Isolating a single strand and measuring it with a calliper suggested the diameter to be around 0.35 mm and so the diameter of the wire without copper insulation was assumed to be 0.34 mm.

The number of parallel strands was estimated by isolating a segment of wire running from tooth to tooth and poking it with a pen until most of the individual strands were visible. 


I count a total of 8 strands. Luckily for me, the number of turns per tooth (ten) was written right on the side of the stator stack.


However, it should be possible to estimate the number of turns with a reasonable margin of error from the winding resistance of the motor and the wire diameter if needed.
  • The method of winding (i.e. star or delta)
In my previous post, I had assumed that this motor is star wound. This turns out not to be the case. As can be seen in the image above one of the leads coming from the motor has 16 parallel strands. This suggests that the motor is delta wound, with the ends of each phase winding (8 parallel strands) grouped together with the next phase for termination to give a total of 16 strands. This was further supported by the fact that that I can't see any region in the motor where a required join would be made for the natural point of a start wound motor. It is likely that all of the motors I previously look at are delta and not star wound.

Other motor parameters include the lamination thickness, the lamination hysteresis loss, skin and proximity effect of the windings, friction of the bearings etc. can be ignored here as we are only considering the motor under static conditions.

Modelling a motor in FEMM

Getting started with FEMM is fairly straight forward if you can look past its outdated interface. Before starting the motor simulation below I would highly recommend following this quick tutorial so that you are familiar with the interface first.

When ready to model your motor, start a new magnetics problem. From the menu bar select 'problem' and check that you are using the correct units with respect to your DXF file and that have set up a planar simulation. You will also want to check that the 'depth' of your simulation matches the length of your rotor. In this case, my rotor was 30 mm long.



The next step is to import your DXF file(s) using the file -> import DXF option. This can take some time depending on the amount of geometry. If you have any 'construction' lines left over from your CAD model now is also time to remove those. Note that it is also important that the centre of your model be located at point (0,0) for torque estimation to be conducted later.



With your geometry imported its now time to assign material properties. In my case, the rotor bell was assumed to be M-22 Fe-Si steel which is inaccurate. I should have used hot rolled low carbon steel or similar. However, this is unlikely to have had a large impact on the results. The shaft was selected as hot rolled low-carbon steel. The laminations were chosen as M-22 Fe-Si steel which is a common grade used for electric motors.

Magnet placement was done using the Lua scripting language, which is natively supported by FEMM. You can find a copy of the script I used here. Simply enter the number of poles, the radius at which the magnets can be found and the angle (0 degrees being horizontal) that the first magnet can be found. The script will then place each material assignment at the correct orientation. If you wish to change the magnet grade just change the name of the block property in the script (i.e. "NdFeB 40 MGOe")  to that of the magnet you wish to use from the list in FEMM.

The windings were then assigned based on the number of turns and the number of strands. In my case, I created a new 'block property' using the property definition dialogue box. In this case, I selected plain stranded wire with a 0.34 mm diameter and 8 strands and then assigned the same properties used by the other copper conductors.


The actual order which the windings were placed was determined using this handy winding layout tool. By selecting 12 slots, 14 poles, two-layer winding (single winding per tooth as opposed to a single winding for every second tooth) the following is seen.



Using this as a template the winding phase and direction (either into or out of the page) was assigned. This was the most tedious process of creating the motor in FEMM. With all the materials properties assigned we see the following.
The regions filled by air were assigned (one for the air gap region inside the rotor bell and one for outside the motor) and the open boundary builder (circle within a circle button) was used to set the boundary conditions and default settings are fine here.


Finally, we need to set how much current is supplied to each winding. Since this motor is driven using field oriented control (FOC) we need only supply a current to one phase and a current opposite in sign, and twice as small, for the other two phases as per the figure below.


In addition, this motor is delta wound and so the current supplied to the phase will be equal to square root(3) of the line current as described here. In my previous post a phase current of 40 A produced a torque of 1.2 N.m. However, this value of 40 A is the line current (or phase current for a star wound motor) and so we need to divide that value by sqrt(3) to get the phase current that our delta wound motor saw. This gives a value of + 23.1 A for phase A, and - 11.55 A for phase B and C. These values are set in the circuit dialogue box with a series connection.

With this, the motor is now ready for simulating. The complete FEMM file used can also be found here. Note that in order to run this script the minimum angle setting (Problem -> Min. Angle.) needs to be set to 20.

Torque constant estimation

The torque constant (Kt) of an electric motor can be estimated using FEMM with only a single simulation. However, you will want to make sure that your rotor is rotated so that it will produce its maximum torque per amp. In this case, peak motor torque is given when the rotors d-axis is 90 electrical degrees (360 electrical degrees is equal to 360 mechanical degrees divided by the number of pole pairs, which in this case is 7) ahead of the q-axis. A simpler 6n8p motor schematic below for illustration purposes.


Simulating the 12n14p N5065 motor with the rotor 90 elec. degrees ahead of the d-axis looks like the following.



To determine the torque produced the rotor needs to be selected using the area selection tool (green box inside four points) by clicking on each of the magnets and the back iron as shown below.


With rotor selected we can find the torque around point 0.0 using the integrate option and 'Torque via Weighted Stress Tensor' selection from the drop-down menu as recommended in the FEMM manual.


The result is a torque of 1.37 N.m.


For reference, the real motor measured 1.2 N.m. Therefore the FEMM value is an overestimation of about 15%. Considering the number of assumptions made with this model I was actually surprised that the FEMM estimation is as close as it is.

Kv, back EMF estimation

The back EMF constant (Kv) can be estimated using only the torque constant and the motor current as described in this post. In this case, our line current of 40 A and FEMM modelled torque of 1.37 N.m gives

$$K_{V} \approx \frac{8.3 \times 40 }{\tau } \approx 242$$

The listed Kv of this motor was 270 Kv and so once again we are only off around 15 %.

In order to estimate the shape of the back EMF we need to do a series of simulations at different rotor angles and plot the torque output. This torque output can then be converted to Kv in the same way as shown in the equation above. In order to automate the rotor incrementing process, I used a Lua script which can be found here.  In short, it rotates group one by x degrees around point 0,0 and solves. At the completion of solving it prints the torque around point 0,0 to the console and takes a screenshot of the resulting output. Thefeore the use of this script means that you need to assign each line segment and materials property of the rotor to group one as is shown in this video. Don't forget to copy the contents of the console output into another file and the completion of your simulation or otherwise modify the script to output data to a file. To use this script, place it in the same folder as your motor's .femm script so that your file is listed in line 8 "open(mydir .. "Your file name here.FEM")". You can also set how many steps you wish to make and how many degrees of rotation you desire.

Note that solving for each position may take up to 30 seconds and so running hundreds of steps will take many hours to complete. Doing this for the D5065 motor model we see the sinusoidal torque output with rotor angle below.

This sinusoidal torque with rotor angle, and therefore back EMF as they are the same thing, agree well with the back EMF seen for this motor.




Using the excellent, and free, OBS studio in 'slide show' mode was also able to stitch all the separate solutions .bmp files that my script outputted and create this clip of the flux distribution for different rotor angles.


Cogging torque estimation

The cogging torque (torque due to the attraction of the rotor magnets to the salient teeth of the stator) was estimated using the same method as the Kv estimation. The key difference being that the armature current was set to zero and a much finer step was used. The figure below shows the raw output data in black which is quite noisy and an FFT smoothed fit of the data in red.


As discussed in the last post, the number of cogging steps per rotation is given by the least common multiple (LCM) of the number of stator slots and rotor poles. The LCM of this 12n14p motor is therefore 84. A quick count of the peaks in the smoothed data above and extrapolated out to 1 rotation (360 mechanical degrees) and a cogging frequency of 84 is confirmed. As will be discussed in more detail in a future post, the cogging torque amplitude depends strongly on magnet placement, magnet shape, stator tooth shape etc. and so the magnitude and shape of your cogging torque estimated be FEMM will only be accurate if you have modelled your motor exactly.

Modelling motors with symmetry

While it is not shown here, it is important to point out that it is often not necessary to model an entire motor to determine its properties. For motors with symmetry you may only need to model a small segment of the motor and from that, you can extrapolate the results of a full-size motor. There are also a few different tools available in FEMM that may be worth exploring.

Alternatives to FEMM

As can be seen from the results above FEMM is capable of approximating some properties of an electric motor. However, there are many alternatives that are also worth considering. If you would like to use FEMM on platforms other than windows then take a look at the xFEMM project. While xFEMM does away with the user interface it is also considerably faster (up to 80x in some instances) and is still a free open source.

If you require simulations of 3D bodies or more complicated AC loss analysis etc. then you will need to move on to an expensive commercial FEA package such as the Maxwell from Ansys or Comsol Multiphysics

Conclusion

Modelling an electric motor in FEMM is no easy undertaking. However, by carefully replicating all of the required components it is possible to get a reasonably accurate estimation of a motors Kt, Kv, back EMF shape and cogging torque parameters. Kt and Kv was shown to be within about 15% of that measured for a real motor and so FEMM can act as a nice starting point for verifying ideas when designing an electric motor.