Giter Club home page Giter Club logo

simplefocstudio's Introduction

SimpleFOCStudio

Graphical user interface for the SimpleFOClibrary. This application allows to tune and configure any BLDC/Stepper SimpleFOClibrary controlled device, using serial port communications and the Commander interface.

The main features are:

  • Plug and play with the SimpleFOClibrary version 2.1
  • Real-time tuning and configuration of the motors
  • Real-time plotting and monitoring of motor variables
  • Code generation for easier integration of the tuned parameters in your code
  • Built on PyQt5 and a standardized SimpleFOCConnector interface that can be used as a gateway form python to the SimpleFOClibrary device.

Installation

Don't worry, SimpleFOCStudio is easy to install even if you have never used the terminal before! 😃 There are just couple of steps to take:

  1. Install Python if you don't have it installed yet
    • We suggest to use Anaconda. Here is how to install it.
    • Once you have your Anaconda running open your terminal (on windows anaconda prompt) and run:
    conda create -n simplefoc python=3.9.0
    • Once this is done you will never have to run that command again, from now on you will just need:
    conda activate simplefoc
  2. Clone this repository or download the zip file
  3. Enter the folder containing the repository using the terminal
    • the command will be something like this:
    cd  some_path_on_disk/SimpleFOCStudio
  4. Final step of the installation is installing all the necessary libraries for the SimpleFOCStudio :
    pip install -r "requirements.txt"

Once you have done all the steps above you do not need to repeat them any more. All you need to do the next time is open your terminal in the SimpleFOCStudio directory and run the command:

python simpleFOCStudio.py

Or if using Anaconda:

conda activate simplefoc
python simpleFOCStudio.py

Usage

SimpleFOCStudio has several useful features:

  • A simple approach to tuning your motor setup
    • Form view for fast motion control PID/LPF tuning
    • TreeView for more in depth tunning and experimenting
  • Code generation for transferring the found parameters into your arduino code
  • Serial terminal integrated with various commander features

Motion control tunning windows

Once you have your application running add a device by clicking the motor button in the toolbar. You can choose either the TreeView or the FormView.

  • To connect to your device first configure the serial port by clicking on Configure button
  • Add your com port info and click OK
  • Then add the device command ID that you've added to the commander usually its M
    • Command M , Arduino code : command.add('M',doMotor,"my motor")
    • Command A , Arduino code : command.add('A',doMotor,"my motor")
  • Then click to the Connect button and you should be ready to go!

Code generation

SimpleFOCStudio helps you to easier transfer your carefully tuned parameters to the Arduino code. Once you are happy with the performance of your system you can automatically generate the arduino code of the parameters you have tuned. To generate the code :

  • Click on the Arudino button in the toolbar.
  • Choose which sets of parameters you wish to generate the code for and click OK
  • In the new tab you will have a code of your tuned parameters.

The generated code you can just copy/paste in your setup() function, just before calling the motor.init()

Custom Commands

You can create your own custom commands if you extend the Commnader interface in your sketch. This can be used for example to do things like change register settings for SPI devicesor any oyher functionality. Each custom command has a name and a value as you can see at the below image.

Once you have added each custom command in order to execute it you just need to select it and once selected press the space key (⎵) or right arrow key (→).

Jogging panel

This panel is used to actuate with yor motor without having to write comands, is like using a joystick but pressing buttons. Each buton performas an action:
  • Fast Reverse button: reduces the current target by 2 times the specified increment.
  • Reverse button: reduces the current target by the specified increment.
  • Fordward button: Increase the current target by the specified increment.
  • Fast Fordward button: Increase the current target by 2 times the specified increment.
  • Stop button: in angle control mode, sets the current angle as target angle and in velocity control sets the target to zero.

Integrated serial terminal

SimpleFOCStudio also has integrated serial terminal for easier debugging and monitoring.

Arduino code

Basically there are two things you need to do:

  1. Use the commander interface and add the motor to the commander
  2. Use the monitoring and add the motor.monitor() in the loop

Here is a mockup of the code:

#include <SimpleFOC.h>

....

// include commander interface
Commander command = Commander(Serial);
void doMotor(char* cmd) { command.motor(&motor, cmd); }

void setup(){
  ....
  // add the motor to the commander interface
  // The letter (here 'M') you will provide to the SimpleFOCStudio
  command.add('M',doMotor,'motor');
  // tell the motor to use the monitoring
  motor.useMonitoring(Serial);
  motor.monitor_downsample = 0; // disable monitor at first - optional
  ...

}
void loop(){
  ....

  ....
  // real-time monitoring calls
  motor.monitor();
  // real-time commander calls
  command.run();
}

simplefocstudio's People

Contributors

arcticlampyrid avatar askuric avatar b3au avatar jorgemaker avatar nanoparticle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simplefocstudio's Issues

Supporting 2.1?

Any thoughts on supporting version 2.1 of SimpleFOC? I'm using the new Dagor board and would love to use this utility to manage that board. Thanks!

Jogging control not work

my c++ code is from the examples.

void loop() {
motor.loopFOC();
motor.move(target_velocity);
motor.monitor();
command.run();
}

everything seems fine, I can use command line send Target, but when I use Jogging control, the Command line interface show: Target: 3.14, but nothing happen.

is there something wrong or just a misunderstanding in jogging control?
thx.

the precision of the PID parameter is not enough

the precision of the PID parameters is not enough, I need to adjust the D parameter to about 0.0005 to get the system stable, but it can only show the three place decimal, and will round up the parameter. It made some problem, could it be improved?

Install instructions on main git page

Greetings! The installation instructions on the main git page are currently:

Clone the repo or download the zip
cd to the folder
run: pip -install -r "requirements.txt"
run: python simpleFOCStudio.py

I believe the third instruction should read: run: pip install -r "requirements.txt" (no dash in front of the "install" word)

TypeError: setValue(self, int): argument 1 has unexpected type 'numpy.float64'

pyqt5 5.15.6
pyqtgraph 0.11.1
pyserial 3.5
numpy 1.21.5

Traceback (most recent call last):
  File "/tmp/SimpleFOCStudio/src/gui/workAreaTabbedWidget.py", line 60, in addDeviceTree
    self.configDeviceTool = TreeViewConfigTool()
  File "/tmp/SimpleFOCStudio/src/gui/configtool/treeViewConfigTool.py", line 22, in __init__
    self.leftWidget = DeviceInteractionFrame(self)
  File "/tmp/SimpleFOCStudio/src/gui/configtool/deviceInteractionFrame.py", line 19, in __init__
    self.graphicWidget = SimpleFOCGraphicWidget(self)
  File "/tmp/SimpleFOCStudio/src/gui/configtool/graphicWidget.py", line 38, in __init__
    self.plotWidget.showGrid(x=True, y=True, alpha=0.5)
  File "/usr/lib/python3.10/site-packages/pyqtgraph/graphicsItems/PlotItem/PlotItem.py", line 382, in showGrid
    self.ctrl.gridAlphaSlider.setValue(v)
TypeError: setValue(self, int): argument 1 has unexpected type 'numpy.float64'
Traceback (most recent call last):
  File "/tmp/SimpleFOCStudio/src/gui/configtool/deviceTreeview.py", line 395, in commandResponseReceived
    self.setModCenter(self.device.modulationCentered)
  File "/tmp/SimpleFOCStudio/src/gui/configtool/deviceTreeview.py", line 470, in setModCenter
    self.selectModCenter.setCurrentIndex(value)
TypeError: setCurrentIndex(self, int): argument 1 has unexpected type 'float'

similar with this biolab/orange3#1896

Readme/setup tweak for less confusion

This is a powerful tool, and quite easy to set up - however one part of the process is particularly confusing.

The "mock-up" sketch at the end of the guide has two omitted lines that are necessary for functionality.

motor.move();
motor.loopFOC();

Without an in depth understanding of how the inner workings of the SimpleFOC and the SimpleFOCStudio operate, it ambiguous if these lines should be included in a user's sketch. (when I was setting up for the first time I assumed this meant these lines should NOT be included, which was eventually discovered to be wrong)

TypeError: setCurrentIndex(self, index: int): argument 1 has unexpected type 'float'

Tree view mode crashes on connect with the following stack trace:

Traceback (most recent call last): File "/<...>/SimpleFOCStudio/src/gui/configtool/deviceTreeview.py", line 395, in commandResponseReceived self.setModCenter(self.device.modulationCentered) File "/<...>/SimpleFOCStudio/src/gui/configtool/deviceTreeview.py", line 470, in setModCenter self.selectModCenter.setCurrentIndex(value) TypeError: setCurrentIndex(self, index: int): argument 1 has unexpected type 'float' Traceback (most recent call last): File "/<...>/SimpleFOCStudio/src/gui/configtool/deviceTreeview.py", line 395, in commandResponseReceived self.setModCenter(self.device.modulationCentered) File "/<...>/SimpleFOCStudio/src/gui/configtool/deviceTreeview.py", line 470, in setModCenter self.selectModCenter.setCurrentIndex(value) TypeError: setCurrentIndex(self, index: int): argument 1 has unexpected type 'float'

SimpleFOCStudio: commit 0e4306f
PyQt5 5.15.9
pyqtgraph 0.13.1
pyserial 3.5
numpy 1.22.0

Form View works without crashes
Upgrading pyqtgraph to 0.13.2 doesn't fix the crash

PID Tuning values

Hi Jorge!
I tried to use your GUI for SimpleFOC v2.0 but I was not able to change the PID parameters.

My loop function on the Arduino side looks like this:

void loop() {

    // iterative setting FOC phase voltage
    motor.loopFOC();

    // iterative function setting the outer loop target
    motor.move(target_angle*3.14/180);

    motor.monitor();

    // user communication
    serialReceiveUserCommand();
}

image

In the C code, for example, I set P gain = 10 but, as shown in the image above, the value is set to zero. Even though I set some value from the GUI, nothing really changes on the motor controller side.

Do I need to integrate something else on the Arduino side? Thanks in advance for your help.

SimpleFOCStudio does not start, does not show up

I have followed the installation instructions step by step. After trying to start the app this way:

(simplefoc) D:\Projects _repository\simplefoc>python simpleFOCStudio.py

...it shows nothing. Nothing starts. It "thinks" for a second and shows the prompt line again:

(simplefoc) D:\Projects _repository\simplefoc>

Am I doing something wrong? No log is created to figure out what is wrong.

Error Connecting on Mac os bigsur

I cannot connect properly to my device, commands seems to work sometimes, but I got no plotting at all.

this is one of the error I got from the terminal.

self.handle_received_data(reading.decode())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 2: invalid start byte

Error when starting SimpleFOC Studio after installation

After installing Python (3.9), PIP, and SimpleFOC Studio, I try to run SimpleFOC Studio with the following command:
python simpleFOCStudio.py

I then get the following error:
C:\SimpleFOCStudio>python simpleFOCStudio.py
Traceback (most recent call last):
File "C:\SimpleFOCStudio\simpleFOCStudio.py", line 8, in
from gui.mainWindow import UserInteractionMainWindow
ModuleNotFoundError: No module named 'gui'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.