sparkfun / SparkFun_IoT_Brushless_Motor_Driver

The hardware repository for an IoT motor driver development board using the ESP32
https://docs.sparkfun.com/SparkFun_IoT_Brushless_Motor_Driver/
Other
6 stars 0 forks source link

Closed Loop Control - TMAG5273 to simpleFOC hallsensor.h & INA240 & MPC6021 to simpleFOC InlineCurrentSense.h #3

Open aiaaaa opened 8 months ago

aiaaaa commented 8 months ago

Greetings, happy new year, and hope all is well! I am really learning a lot from this board and my deep dive with it, it’s been a wonderful introduction into the world of motors and FOC control.

I have a beginner question, and basically was wondering are there any examples or hints you could give for closed loop controls for this board? It works very well as a wheel for IoT control, but I was hoping to implement it as a motor as opposed to a potentiometer. Hoping to implement very smooth rotation (as opposed to direct voltage open control), haptics, gimbal style motion and anything else. I am new to motor control and a bit new to coding. I could use some pointing in the right direction or som bread crumbs, as it seems.

Specifically can you help find the output of SparkFun_TMAG5273_Arduino_Library_Defs.h, that might “fit” in the HallSensor.h of simpleFOC, and can you help find the INA240/MPC6021 outputs that would match the InlineCurrentSense.h of simpleFOC, either of these would close the loop and get smooth motor operation:

(1) the output of the TMAG5273 chip is not the same as the simpleFOC hallsensor.h input.

class HallSensor: public Sensor{ public: /* HallSensor class constructor @param encA HallSensor A pin @param encB HallSensor B pin @param encC HallSensor C pin @param pp pole pairs (e.g hoverboard motor has 15pp and small gimbals often have 7pp) @param index index pin number (optional input) / HallSensor(int encA, int encB, int encC, int pp);

All enumerators from class: SparkFun_TMAG5273_Arduino_Library_Defs.h

(2) And the output of the INA240 & MPC6021 are not the same as the simpleFOC InlineCurrentSense.h input:

class InlineCurrentSense: public CurrentSense{ public: /* InlineCurrentSense class constructor @param shunt_resistor shunt resistor value @param gain current-sense op-amp gain @param phA A phase adc pin @param phB B phase adc pin @param phC C phase adc pin (optional) /

Subject of the issue

Using either of the two closed loop FOC control: TMAG5273 to simpleFOC hallsensor.h & INA240 & MPC6021 to simpleFOC InlineCurrentSense.h

Your workbench

Steps to reproduce

Issue here is in generating the code to begin with, see above description

Expected behavior

simpleFOC hallsensor.h should be populated with data from TMAG5273 hall sensor simpleFOC InlineCurrentSense.h should be populated with data from INA240 & MPC6021

Actual behavior

Currently TMAG5273 hall sensor provides angular data, and I dont see within the manual a description of all the the functions contained within SparkFun_TMAG5273_Arduino_Library_Defs.h, SparkFun_TMAG5273_Arduino_Library_Defs.h is not commented enough that a begginer like myself can convert the TMAG data to simpleFOC hallsensor.h logic.

Currently INA240 & MPC6021 data is only described (as far as my abilities and travels have thus led me, I may have missed a doc) in the online hardware overview MKdoc with INA240 (U) on GPIO 35, INA240 (V) on GPIO 36, INA240 (W) on GPIO 39, MCP6021 on GPIO 32. I am wondering how to rectify these pin inputs with the simpleFOC InlineCurrentSense.h logic.

Thank you for any help you may have, Waffle City, aiaaaa