Hi,
I am using a MagAlpha sensor in a BLDC application, the motor has 4 poles and due to size constraints I have a 2 pole target magnet from which I am sensing the angle from, and i am using the UVW outputs to a motor controller.
From my understanding because of my pole count, I need to change the NPP register value to 001 to get 2 pulses per revolution for each output. My problem is that this doesn’t happen when i change the register. I am programing the sensor with an Arduino using the official MagAlpha Arduino library, and the when I write to and read the registers I get the expected values, but I still only end up with 1 pulse per revolution on each UVW output.
What am I doing wrong? happens on both MA3xx sensors
Here is my Arduino code below.
/*
*/
#include <SPI.h>
#include <MagAlphaGen3.h>
#include <MagAlphaPartProperties.h>//Setup SPI for the magnetic sensor
#define SPI_CS_PIN (7) //Using Digital Pin 7 since its right next to the other SPI pins on the MKR1000 WIFI
#define SPI_SCLK_FREQUENCY (1000000)MagAlphaGen3 magalpha;
double angle_real;
uint16_t zero, bct, angle_raw;
uint8_t register_value[9];
bool crc_error;void setup() {
magalpha.begin(SPI_SCLK_FREQUENCY, MagAlphaSPIMode::MODE_0, SPI_CS_PIN, &SPI);
Serial.begin(115200);
while(!Serial);register_value[6] = magalpha.writeRegister(0x7, B001);//write number of pole pairs to NPP default is 000
//magalpha.setBct(57);
//delay(50);
}void loop() {
register_value[6] = magalpha.readRegister(0x7);
Serial.println(register_value[6], BIN);
//delay(2000);}