HallSensor+BLDCget.value problem

Hi everyone I tried to get value step by step in the simplefoc tuning video on YouTube and the problem with it is I can’t get the value of get.Angle() but I can get the value of getSensorAngle(); I didn’t what’s different between these two but it’s as I see the library is used a lot of getAngle() what do I miss in this condition. my motor is this link:motor it’s have 4 magnetic stator and on 6 rotor so pole pair should be 3 pp.

#include <SimpleFOC.h>

HallSensor sensor = HallSensor(3 ,2 ,4 ,3);
const int hallSensorPin1 = 2;
const int hallSensorPin2 = 3;
const int hallSensorPin3 = 4;
//const int8_t electric_sector[8] = { -1,  0,  4,  5,  2,  1,  3 , -1 };
//float getangle = ((electric_rotations * 6 + electric_sector) / cpr) * _2PI ;
void doA(){sensor.handleA();}
void doB(){sensor.handleB();}
void doC(){sensor.handleC();}

float target = 0.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() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  sensor.pullup = Pullup::USE_EXTERN ;
//  pinMode(2, INPUT_PULLUP);
//  pinMode(3, INPUT_PULLUP);
//  pinMode(4, INPUT_PULLUP);
  sensor.init();
  sensor.enableInterrupts(doA,doB,doC);
  
  delay(1000);

}

void loop() {
  // put your main code here, to run repeatedly:
//  int hallState1 = digitalRead(hallSensorPin1);
//  int hallState2 = digitalRead(hallSensorPin2);
//  int hallState3 = digitalRead(hallSensorPin3);
//  String stateStr = String(hallState3) + String(hallState2) + String(hallState1);
//  Serial.println(stateStr);
  serialLoop();
  Serial.print(sensor.getAngle());
  Serial.print("\t");
  Serial.print(sensor.getMechanicalAngle());
  Serial.print("\t");
  Serial.print(sensor.getSensorAngle());
  Serial.print("\t");
  Serial.println(sensor.getVelocity());
//  Serial.print();

}

You are never running sensor.update() ?

This is required if you are not yet using motor.loopfoc()

Oh, my bad now it’s work .if i asking for the pole pair is this motor have 3 pp because it’s have 6 magnetic on rotor?

Yes that’s correct, pp is number of magnets divided by 2.

Thanks for answering a lot :blush: