Package: emachinery
emachineryA package for analysis of electric machinery.[A]. Functions1. Machine Quantities Calculations & Conversion2. PI Regulator Tuner based on Texas Instruments' InstaSPIN3. Run C-based Numerical Integration Simulation4. Sweep Frequency Analysis5. Run Python- and Numba-based Realtime Numerical Integration Simulation6. FEA based Machine Design and Multi-Objective Optimization (develop)7. PC User GUI for Serial Communication to DSP (develop)[B]. Installation and RequirementsThe package can be installed via pip.pipinstallemachineryTo make it work, one needs to take care of the dependencies, which will be detailed below.The package requires the following free softwares to work as expected:gcc (comes withMinimalist GNU for Windows---See thisawesome pagefor info)gmake.exe (I use the one fromTI's CCS, it is located at somewhere like:D:\ti\ccs930\ccs\utils\bin\gmake.exe. Anyway, I decided to just copy-paste gmake.exe to/emachinery/acmsimc/c/gmake.exe. So no need to install CCS anymore.)It also works with CMake with some minor modification.pip installcontrolPySide2qtconsolenumpy, matplotlib, rich, and numba.[Optional, to view .ui file]Qt DesignerA list of python dependency is as follows (tested with Python 3.9.5):backcall==0.2.0colorama==0.4.4commonmark==0.9.1control==0.9.0cycler==0.10.0decorator==5.0.9ipykernel==5.5.5ipython==7.24.1ipython-genutils==0.2.0jedi==0.18.0jupyter-client==6.1.12jupyter-core==4.7.1kiwisolver==1.3.1llvmlite==0.36.0matplotlib==3.4.2matplotlib-inline==0.1.2numba==0.53.1numpy==1.20.3pandas==1.2.4parso==0.8.2pickleshare==0.7.5Pillow==8.2.0prompt-toolkit==3.0.18pycairo==1.20.1Pygments==2.9.0pyparsing==2.4.7PySide2==5.15.2python-dateutil==2.8.1pytz==2021.1pywin32==301pyzmq==22.1.0qtconsole==5.1.0QtPy==1.9.0rich==10.2.2scipy==1.6.3shiboken2==5.15.2six==1.16.0tornado==6.1traitlets==5.0.5typing-extensions==3.10.0.0wcwidth==0.2.5Save the above list as a file named, e.g.,req.txt.I recommend to use virtual env, e.g., on Windows prompt:pipinstallvirtualenv
virtualenv.my_venvcd.my_venv/Scripts&&activate
pipinstall-rreq.txt
pipinstall--upgradeemachinery
emyCommandemyis an entry point for starting the main program of this package, which is equivalent topython guiv2/main.py[C]. Simulation TipsField oriented control is an asymptotic input-output linearizing (IOL) control. This means the IOL is achieved only when flux modulus is regulated to its reference. So before motor starts, we must wait for the motor to build up its magnetic air gap field or else the starting transient would be disturbed. Refer to the figure below.The inductance of the motor matters. For a small "DC" servo PM motor, the inductance is relatively designed to be low because the DC source is usually only 24 V or 48 V. However, an induction motor usually has higher inductance, which limits the bandwidth of the current loop, I think. For example, this is what happens to d-axis current regulation when I set desired velocity loop bandwidth from 50 Hz up to 100 Hz. Refer to the figure below.[D]. Known IssuesGNU Make failed to create processAfter adding installing CCS and MinGW, you might need to restart the PC.gcc -o main pmsm_comm.c im_controller.c ... -I. -L.
process_begin: CreateProcess(NULL, gcc -o main pmsm_comm.c im_controller.c... -I. -L., ...) failed.
make (e=2): The system cannot find the file specified.
makefile:11: recipe for target 'main' failed
gmake: *** [main] Error 2See thisquestionAnaconda3 Python VersionAnaconda3 (Python 3.8) comes with qtconsole now, but it will causeproblems. My code was developed with Anaconda3 (Python 3.7).One silly fix is to revert back to Python 3.7 for now:conda install python=3.7 anaconda=customHowever, it seems upgrade jupyterlab would fix this issue:pip install --upgrade jupyterlabJupyterlab/Qtconsole VersionAfter I upgrade my jupyterlab to version 3, qtconsole (version 4.6.0) starts to not work well. Below is some error message.Traceback (most recent call last):
  File "D:\DrH\Codes\emachineryTestPYPI\emachinery\gui\main.py", line 947, in <module>
    main()
  ...
  ...
  ...
  File "D:\DrH\Codes\emachineryTestPYPI\emachinery\gui\consolewidget.py", line 31, in __init__
    self.kernel_client = kernel_client = self._kernel_manager.client()
  File "D:\Users\horyc\Anaconda3\lib\site-packages\qtconsole\base_frontend_mixin.py", line 63, in kernel_client
    if kernel_client.channels_running:
  File "D:\Users\horyc\Anaconda3\lib\site-packages\jupyter_client\client.py", line 141, in channels_running
    self.control_channel.is_alive())
  File "D:\Users\horyc\Anaconda3\lib\site-packages\jupyter_client\client.py", line 200, in control_channel
    socket, self.session, self.ioloop
TypeError: ChannelABC() takes no argumentsI found a related discussion here:https://github.com/jupyter/jupyter_client/issues/523Reading the webpage, I fix this problem by first uninstalling ipykernel and install it back to a higher version.pip uninstall ipykernel
Found existing installation: ipykernel 5.1.4
Uninstalling ipykernel-5.1.4:

pip install ipykernel
Collecting ipykernel
  Downloading ipykernel-5.4.2-py3-none-any.whl (119 kB)[E] Other InformationThis package is published to PYPI followinghttps://www.youtube.com/watch?v=Qs91v2TofysChangelog1.3.1Attempt to distribute <gmake.exe> with the package.1.3.0Add button for revoking console (for Python based real-time simulation).New gui-v3 using Wanderson's  has issues with matplotlib stylesheet (which cannot be resolved and new gui is postponed).Sensorless operation with ACMSimPy is tested.1.2.6Use pycairo for faster plotting (as backend for matplotlib).1.2.5Python based Real-time simulation now supports more waveforms.1.2.4Python packaging issue. Update Manifest.in. Seethis post.1.2.3Fix bugs when calling acmsimpy from app_functions.py.1.2.2Fix bugs when setting the path to acmsimc.1.2.0Mordern GUI in dark theme by Wanderson.Top level global variable CTRL, which is a struct of pointers to other structs.1.1.5Recover last user selected MachineName and MachineType.1.1.4Anaconda3 (Python 3.8) comes with qtconsole now, but it will cause problems.My code was developed with Anaconda3 (Python 3.7). So one silly fix is to revert back to Python 3.7 for now:conda install python=3.7 anaconda=customBut before you try to revert, trypip install --upgrade jupyterlabfirst.1.1.3No use of LoadUi when published.1.1.2Support parametric analysis.1.1.1User is now able to select from different plot settings.Support sinusoidal flux modulus command for induction motor.Remember user's last selected plot setting considering machine types, i.e., IM or PMSM.Marino05 is tuned.1.1.0Induction motor simulation.Marino05 is added.Harnefors06 is tuned for a different motor.Fix the bug "cannot file .dat file" when "Plot Here" is clicked upon start.1.0.9(Video@Bilibili) Demonstrate the effectiveness of the current loop decoupling (PMSM).Allow velocity-open-loop and current-closed-loop for sweep frequency analysis.Automatically add path2acmsimc if the user-specified path does not exist.Remember last user input for C-based simulation.1.0.8I was stupid. Version 1.0.7 did not do its job.1.0.7Add the resource "makefile" to the package.1.0.6Remember last user input for path2acmsimcv5 and add config.json to gui/Publish acmsimcv5 along with the package.1.0.5Add sweep-frequency and bode-plot feature.gmake compile .c program, execute .exe, collect .dat, and ggplot.