Hello all,
I am a newbie to SimpleFoc and coding and right now I’m exploring the functionalities. Currently I am watching the Tuning guide Part 1 from SimpleFOC on youtube (Not sure if I am allowed to post Links here; It’s at the time stamp 5:20 - 7:20) and I am trying to reproduce it.
In the video he sets up the Hall sensors and then he reads out the Angle and Velocity of the rotor. But unfortunately I always get a 0 on my Angle Read. The velocity works fine, when I turn the rotor by hand I get positive and negative values depending on in which direction I spin the rotor. Pretty sure the hardware is fine, because I already managed to turn the Motor in Velocity Control Mode with different set velocities.
Hardware used:
ESP32S3
DriverBoard with TMC6200 (Standalone, no SPI)
BLDC Motor (3 Phases, 8 Poles, 24V, 4.41±5% Back EMF, Hall Sensors)
Thank you in advance! I hope my Newbiness does not annoy you.
#include <SimpleFOC.h>
#define HALLU_PIN 6
#define HALLV_PIN 7
#define HALLW_PIN 15
#define POLE_PAIRS 8 // Number of poles divided by two
//hall sensor instance
HallSensor sensor = HallSensor(HALLU_PIN, HALLV_PIN, HALLW_PIN, POLE_PAIRS);
//Interrupt routune init
//Channel A and B callbacks
void doA(){sensor.handleA();}
void doB(){sensor.handleB();}
void doC(){sensor.handleC();}
float target = 1.0;
void serialLoop() {
static String received_chars;
while(Serial.available()) {
char inChar = (char) Serial.read();
received_chars += inChar;
if (inChar == '\n') {
target = received_chars.toFloat();
Serial.print("Target = "); Serial.println(target);
received_chars = "";
}
}
}
void setup() {
Serial.begin(115200);
delay(1000);
// initialize sensor sensor hardware
sensor.init();
sensor.enableInterrupts(doA, doB, doC);
Serial.println("setup");
}
void loop() {
serialLoop();
Serial.print(sensor.getAngle());
Serial.print("\t");
Serial.println(sensor.getVelocity());
}