SimpleFOCStudio 2.0 a tunning and configuration tool

Just added support to save custom commands and motorID. Hope did not brake anything. If you can, please let me know if everything works fine.

Regards !!

1 Like

Thanks Jorge! Now I can open SimpleFOC Studio, Load, and it remembers everything.

1 Like

First of all, thank you very much Jorge for this fantastic tool, very useful!

I have seen a bug, when changing the low pass filter of ‘d’, edit the ‘q’ wrongly.
This happens in device tree mode, in form view mode it works correctly

1 Like

Hi @Jorgefer88

Thank you for advising :slight_smile: I will try to reproduce the described behavior to solve it.

Regards

EDIT: I hope i have just solved the minor bug in my last commit to the repository without breaking anything else :slight_smile:

It seems that now it works great! :smiley:

Thanks!

1 Like

I have been using SimpleFOCStudio for a few weeks with the STM32F446RE without any problems

Now I have switched to ESP32 (the same configuration, but I have it seems that I have to tune the parameters again) but I find that it does not connect correctly with the application.

From the Arduino IDE and with the CoolTermWin it works without problems, but with the Studio it does not connect from the main screen (Three or Form View)

I have come to connect by doing the following:
Connect from “Cmd Line”, (from there it always connects me correctly) with the sequence:
MOT: Monitor enabled!
MOT: Init
MOT: Enable driver.
MOT: Align sensor.
MOT: Index search …

And then go to the main screen.
If I try to connect directly from the main screen 90% of the time it doesn’t succeed.

Always with the same configuration and testing 115200.

In any case, even though I connect, after a few minutes the change of parameters starts to go very slowly until I see similar data (but wrong) to those of the “motor.monitor ();” and it crashes

Traceback (most recent call last):
  File "C: \ Users \ Jorge-PC \ Desktop \ SimpleFOCStudio \ src \ gui \ configtool \ graphicWidget.py", line 116, in upDateGraphic
    signals = np.array (signalList, dtype = float)
ValueError: could not convert string to float: '.'
Traceback (most recent call last):
  File "C: \ Users \ Jorge-PC \ Desktop \ SimpleFOCStudio \ src \ gui \ configtool \ graphicWidget.py", line 116, in upDateGraphic
    signals = np.array (signalList, dtype = float)
ValueError: could not convert string to float: '\ r2.35695452340005.00'
Traceback (most recent call last):
  File "C: \ Users \ Jorge-PC \ Desktop \ SimpleFOCStudio \ src \ gui \ configtool \ graphicWidget.py", line 116, in upDateGraphic
    signals = np.array (signalList, dtype = float)
ValueError: could not convert string to float: ''

Has anyone had these problems or been able to prove that it is not just my thing?

These types of errors are not easy to correct as they are difficult to reproduce.

My guess about what is happening is that for some reason that I am not aware of, the MCU is sending unparsable values in a float [ '\ r2.35695452340005.00' ] and the application starts throwing exceptions until it crashes.

One thing that could be done to see where the error comes from is to analyze if the strings sent by the MCU that later are parsed to floats.

I will try to investigate the problem, because apart from this problem, I have others in control.
Even adjusting the parameters a bit (as little as I could), from 20rad/s it destabilizes, when with the STM32F4 I get 120rad/s without problems. Exactly the same configuration (motor, driver, and encoder).

Just so you see, I just skipped this in the window:
Error

How many decimal digits are you using in your floats? You can play with decimal_places variable to see if it makes any difference

I did not have that configuration defined.

If I put command.decimal_places = 3; in setup () it ignores me, since when I run # I always get 0

When it is running I can change it, but the same 4 decimal places still appear in the terminal. It’s pretty weird

Data taken with CoolTermWin:

0.0000 -0.5371 0.0000 7.0780
0.0000 -0.5371 0.0000 7.0780
0.0000 -0.5371 0.0000 7.0780
0.0000 -0.5533 0.0000 7.0780

Changing the decimals to 2 in Arduino IDE, it ignores:

22: 00: 17.612 → 0.0000 -1.0867 -0.0039 6.5110
22: 00: 17.658 → 0.0000 -1.1367 -0.0042 6.5110
22: 00: 17.658 → 0.0000 -1.1631 -0.0042 6.5110
22: 00: 17.658 → Decimal: 2
22: 00: 17.705 → 0.0000 -1.1787 -0.0042 6.5110
22: 00: 17.705 → 0.0000 -1.1344 -0.0005 6.5110
22: 00: 17.751 → 0.0000 -1.1310 -0.0000 6.5110

How many decimal places can SimpleFOCStudio handle?

It can handle as much as Python can handle … there is not any limitation at SimpleFOCStudio level. Maybe @Antun_Skuric can clarify the behaviour of the Commander when limiting the number of decimal places.

Now that I think about it, the problem I’m having has nothing to do with “decimal_places”. Those are the decimals for the commander, not the monitor.

EDIT:
I have discovered because from the main screen (Tree or Form View) it does not connect me from the beginning.

With ESP32 it serializes the following string every time it reboots:

rst: 0x1 (POWERON_RESET), boot: 0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP: 0xee
clk_drv: 0x00, q_drv: 0x00, d_drv: 0x00, cs0_drv: 0x00, hd_drv: 0x00, wp_drv: 0x00
mode: DIO, clock div: 1
load: 0x3fff0018, len: 4
load: 0x3fff001c, len: 1216
ho 0 tail 12 room 4
load: 0x40078000, len: 10944
load: 0x40080400, len: 6388
entry 0x400806b4
MOT: Monitor enabled!
MOT: Init
MOT: Enable driver.
MOT: Align sensor.

That is why the application does not finish connecting, because it does not understand that first part. So when I start it from the “Cmd Line” and then go to “Form View” if it works.

I’m going to see if it is possible to disable that initial string … (EDIT: connect GPIO15 to GND)

On the other hand, I still have slowdowns after I have been a few minutes. Then the characters that the program cannot recognize appear.

I think it happens when I change some parameters of D and Q that it causes the motor to become very unstable, causing everything to crash.

EDIT2:
I was trying to connect to the Studio without the monitor() data being displayed. When I do a reset (PCB button) from Studio it does not enter the initialization function and therefore does not show the monitor().

If I turn on the motor and initialize it before connecting to Studio, it runs smoothly for a while. (Until it slows down and crash, I’m looking into it …)

Hi, how to use this?Is there a step by step tutorial for this? Thank you.

Hi @ponz_17

A brief explanation of how to use the tool can be found on the GitHub page where the repository is published. Repository → Usage section

Thanks a lot @JorgeMaker, I tried reading through it, was able to run the app using python, was able to connect my ESP32 to the app but I don’t see anything in the logs. Is this hardware specific? I’ve been using this hardware from Aliexpress: https://vi.aliexpress.com/item/3256804900642588.html?spm=a2g0o.order_list.order_list_main.147.68be1802Kz9Fj4&gatewayAdapt=glo2vnm

It is not HW specific . Did you added the “M” as is explained in the documentation?

Hi @JorgeMaker here is my code. I was able to connect to SimpleFOC Studio but have not seen any movement or reading in the graph. Can you help check why?

#include <Arduino.h>
#include <SimpleFOC.h>
// Define the hardware connections of motor 0
#define Pin_Phase_A0 32
#define Pin_Phase_B0 33
#define Pin_Phase_C0 25
#define Pin_Enable_0 22
#define Pin_SCL_0 19
#define Pin_SDA_0 18
#define Pin_CurrentA_0 39
#define Pin_CurrentB_0 36
#define PolePair_0 7
// Variables
float target_position =0;
// Instantiate classes for motor A
BLDCMotor motor = BLDCMotor(PolePair_0);
BLDCDriver3PWM driver = BLDCDriver3PWM(Pin_Phase_A0,Pin_Phase_B0,Pin_Phase_C0,Pin_Enable_0);
MagneticSensorI2C sensor = MagneticSensorI2C(AS5600_I2C);
TwoWire I2Cone = TwoWire(0);
Commander command = Commander(Serial);
// Functions
void doMotor(char* cmd) { command.motor(&motor, cmd); }
// Setup
void setup() {
  I2Cone.begin(Pin_SCL_0,Pin_SDA_0,400000);
  sensor.init(&I2Cone);
  motor.linkSensor(&sensor);
  driver.voltage_power_supply = 12;
  driver.init();
  motor.linkDriver(&driver);
  motor.foc_modulation = FOCModulationType::SpaceVectorPWM;
  motor.controller = MotionControlType::angle;
  motor.voltage_limit = 4;
  motor.voltage_sensor_align = 1;
  motor.PID_velocity.P = 0.05;
  motor.PID_velocity.I = 1;
  motor.PID_velocity.D = 0;
  motor.P_angle.P = 20;
  motor.LPF_velocity.Tf = 0.01;
  Serial.begin(115200);
  motor.useMonitoring(Serial);
  motor.monitor_downsample = 20;
  delay(2000);
  motor.init(); 
  motor.initFOC();
  command.add('M',doMotor,"motor");
  Serial.println(F("Motor ready."));
  Serial.println(F("Set the target position using serial terminal:"));
}

void loop() {
  // put your main code here, to run repeatedly:
  motor.loopFOC();
  motor.move(target_position);
  // real time monitoring calls
  motor.monitor();
  // real-time commander calls
  command.run();
}

Here is the photo:

Thank you.

i found the issue, now it can communicate.

1 Like

Just 8 minutes ago, I opened your message to try and understand what was happening. :wink: Glad to hear you found a solution! Out of curiosity, what was the issue?