PosSensor Module

This module provides position sensor interfaces.

Driver Classes

The Driver class is used to define the programmer to be used with the sensor.

class qmh_pyclient.PosSensor.SD4Yv01(REF: str, Baudrate: int = 9600)

Bases: PosSensorDriver

Driver class for the SD4Yv01 programmer.

Variables:
  • REF (str) – Com port assigned to the SD4Yv01 programmer.

  • Baudrate (int) – Baudrate between PC and the programmer, default is 9600.

class qmh_pyclient.PosSensor.SD4Yv02(REF: str, Baudrate: int = 115200, V_PSI5_h: float = 11, V_PSI5_l: float = 5.5, Sensor_Baud_Rate: int = 39000)

Bases: PosSensorDriver

Driver class for the SD4Yv02 position sensor.

Variables:
  • REF (str) – Com port assigned to the SD4Yv02 programmer.

  • Baudrate (int) – Baudrate between PC and the programmer, default is 115200.

  • V_PSI5_h (float) – PSI5 sync Pulse Voltage/ UARToverPSI5 high voltage, default is 11.

  • V_PSI5_l (float) – PSI5 Idle voltage/ UARToverPSI5 low voltage, default is 5.5.

  • Sensor_Baud_Rate (int) – Sensor-specific baud rate setting, default is 39000.

class qmh_pyclient.PosSensor.PSI5_PCBv01(REF: str, Baudrate: int = 38400)

Bases: PosSensorDriver

Driver Class for PSI5_PCBv01.

Parameters:
  • REF (str) – Com port assigned to the PSI5_PCBv01 programmer.

  • Baudrate (int) – Baudrate between PSI5_PCBv01 and the Sensor (defaults to 38400).

class qmh_pyclient.PosSensor.UART_PCB(REF: str, Baudrate: int = 9600, Connection: str = 'Top')

Bases: PosSensorDriver

Driver Class for UART_PCB.

Variables:
  • REF (str) – Com port assigned to the PSI5_PCBv01 programmer.

  • Baudrate (int) – Baudrate between UART_PCB and the Sensor (defaults to 9600).

  • Connection (str) – Where is the sensor connected to the board, options are Top or Bot (defaults to Top).

class qmh_pyclient.PosSensor.Sim

Bases: PosSensorDriver

Driver Class for simulated driver. It is used without any hardware.

Position Sensor Classes

The PosSen class is used to define the sensor aka device to be used.

class qmh_pyclient.PosSensor.PosSen(Sensor: str, Driver: PosSensorDriver)

Bases: object

Base Class for position sensors.

init(Sensor, Driver, Name='')

Initiates a Sensor/Programmer combination based on inputs.

Parameters:
  • Sensor (str) – Sensor name.

  • Driver (Driver Classes) – A compatible programer for the sensor.

Write(Reg, Data)

Writes Data to a register address.

Parameters:
  • Reg (int) – The address of the register.

  • Data (int) – The data to be written to the register.

Return type:

None

Read(Reg)

Reads a register address.

Parameters:

Reg (int) – The address of the register.

Returns:

A list of Address’s value, Address+1’s value:

Return type:

list

Close()

Closes all opened connections to the programmers.

Return type:

None

CloseDev()

Closes the opened connection to the programmer.

Return type:

None

Pass2Func()

Execute the pass2function command

Return type:

None

Fuse() bool

Start the fusing process β€œBurn Command”

Returns:

True if the burn command was executed correctly.

Return type:

boolean

REG_Read_OTP(CheckContent=False)

Reads the OTP Content. Optionally it can check if the acquired data matches what was written. Sensor.OTP{i:02x} will be also available i.e Sensor.OTP02 with contents of 0x02 or Sensor.OTP1e for address 0x1E.

Returns:

If CheckContent=False:

  • A tuple of:
    • A list containing the OTP values and

    • None.

If CheckContent=True:

  • A tuple of:
    • A tuple of the OTP values

    • Boolean result of CheckContent.

Return type:

tuple

REG_Write_OTP()

Writes and returns OTP Content.

Returns:

A list containing the OTP values.

Return type:

list

REG_Write_Array(Array)

Writes an array to the OTP

Read_Cordic(NoOfReads=10)

Reads the CORDIC value.

Parameters:

NoOfReads (int) – The number of readings.

Returns:

A list containing CORDIC value in lsb.

Return type:

list

Read_Mag_AGC(NoOfReads=10)

Reads the Magnitude and the AGC registers.

Parameters:

NoOfReads (int) – The number of readings.

Returns:

A list containing:

  • Mag (list int): list of Mag readings.

  • AGC (list int): list of AGC readings.

Return type:

list

Sim_ChangeAngleRel(Target)

For a simulated device, the angle can changed to relative to the current position.

Parameters:

Target (float) – Relative position.

Return type:

None

Sim_ChangeAngleAbs(Target)

For a simulated device, the angle can changed to an absolute position.

Parameters:

Target (float) – Absolute position.

Return type:

None

param_calc(T1, T2, Direction, No_Q, CLH, CLL)

Calculates the values of Gain, BP, Offset, NoQ, RedAngle, CLH, CLL. Works for AS5171, AS5172, AS5270

Parameters:
  • T1 (int) – Angle 1.

  • T2 (int) – Angle 2.

  • Direction (str) – Sets rising or falling ramp output. Valid inputs are: β€˜cw’, β€˜ccw’

  • No_Q (int) – No of quadrants

  • CLH (int) – Clamping level high.

  • CLL (int) – Clamping level high.

Returns:

A tuple containing:

  • Gain (int): Output gain factor.

  • BP (int): Output Breakpoint.

  • Offset (int): Output offset value.

  • NoQ (int): Number of quadrants.

  • RedAngle (float): Reduced angle enabled.

  • CLH (float): clamping limit high.

  • CLL (float): clamping limit low.

Return type:

tuple

AS5171 Class

The AS5171 class is the base class used to define the sensor as AS5171.

class qmh_pyclient.PosSensor.AS5171(Driver, **kwargs)

Bases: PosSen

OTP_1st_Addr = 2

Uses the methods from the base class PosSen

Write(Reg, Data, Data_1=0)

Writes Data to a register address β€œReg” and Data_1 to address+1.

Parameters:
  • Reg (int) – The address of the register for Data.

  • Data (int) – The data to be written to the register.

  • Data_1 (int) – The data to be written to the register with address+1.

Return type:

None

RampCalc(T1, T2, No_Q, Direction, CLH, CLL)

Calculates the values of Gain, BP, Offset, NoQ, RedAngle, CLH, and CLL.

This function shows the output preview on the GUI. It uses qmh_pyclient.PosSensor.PosSen.param_calc().

Parameters:
  • T1 (int) – Angle 1.

  • T2 (int) – Angle 2.

  • No_Q (int) – No of quadrants.

  • Direction (str) – Sets rising or falling ramp output. Valid inputs are: β€˜cw’, β€˜ccw’.

  • CLH (int) – The desired high clamping level.

  • CLL (int) – The desired low clamping level.

Returns:

A tuple containing:

  • Gain (int): Output gain factor.

  • BP (int): Output Breakpoint.

  • Offset (int): Output offset value.

  • NoQ (int): Number of quadrants.

  • RedAngle (float): Reduced angle enabled.

  • CLH (float): Clamping limit high.

  • CLL (float): Clamping limit low.

Return type:

tuple

class qmh_pyclient.PosSensor.AS5171A(Driver, **kwargs)

Bases: AS5171

class qmh_pyclient.PosSensor.AS5171B(Driver, **kwargs)

Bases: AS5171

AS5270 Class

The AS5270 class is the base class used to define the sensor as AS5270.

class qmh_pyclient.PosSensor.AS5270(Driver, **kwargs)

Bases: PosSen

OTP_1st_Addr = 2

Uses the methods from the base class PosSen, besides to the following methods:

REG_Read_OTP(*cls)

Reads the OTP Content. Optionally it can check if the acquired data matches what was written. TBD:Sensor.OTP{i:02x} will be also available i.e AS5270.Top.OTP02 with contents of 0x02 or Axxx.Top.OTP1e.

Returns:

If CheckContent=False:

  • A tuple of:
    • A list containing the OTP values and

    • None.

If CheckContent=True:

  • A tuple of:
    • A tuple of the OTP values

    • Boolean result of CheckContent.

Return type:

tuple

Read_Cordic(*cls)

Reads the CORDIC value for AS5270.

Parameters:

NoOfReads (int) – The number of readings.

Returns:

A list of two lists containing CORDIC value for Top/Bottom in lsb.

Return type:

list of two list

Read_Mag_AGC(*cls)

Reads the Magnitude and the AGC registers.

Parameters:

NoOfReads (int) – The number of readings.

Returns:

A list containing two lists:

  • Top Die List contains:
    • Mag (list int): list of Mag readings.

    • AGC (list of int): list of AGC readings.

  • Bottom Die List contains:
    • Mag (list int): list of Mag readings.

    • AGC (list of int): list of AGC readings.

Return type:

list

class qmh_pyclient.PosSensor.AS5270A(Driver, **kwargs)

Bases: AS5270

class qmh_pyclient.PosSensor.AS5270B(Driver, **kwargs)

Bases: AS5270

AS5172 Class

The AS5172 class is used to define the sensor as AS5172.

class qmh_pyclient.PosSensor.AS5172(Driver, **kwargs)

Bases: PosSen

OTP_1st_Addr = 1

**kwargs: Name > An ID to be assigned to the sensor that will appear in the Device GUI

RampCalc(T1, T2, No_Q, Direction, PSI5_mode)

Calculates the values of Gain, BP, Offset, NoQ, RedAngle, CLH, and CLL.

This function shows the output preview on the GUI. It uses qmh_pyclient.PosSensor.PosSen.param_calc().

Parameters:
  • T1 (int) – Angle 1.

  • T2 (int) – Angle 2.

  • No_Q (int) – No of quadrants

  • Direction (str) – Sets rising or falling ramp output. Valid inputs are: β€˜cw’, β€˜ccw’

  • PSI5_mode (int) – the PSI5 output resolution. Valid inputs are 12, 14

Returns:

A tuple containing:

  • Gain (int): Output gain factor.

  • BP (int): Output Breakpoint.

  • Offset (int): Output offset value.

  • NoQ (int): Number of quadrants.

  • RedAngle (float): Reduced angle enabled.

  • CLH (float): Clamping limit high.

  • CLL (float): Clamping limit low.

Return type:

tuple

Write(Reg, Data, Data_1=0)

Writes Data to a register address β€œReg” and Data_1 to address+1.

Parameters:
  • Reg (int) – The address of the register for Data.

  • Data (int) – The data to be written to the register.

  • Data_1 (int) – The data to be written to the register with address+1.

Return type:

None

SetCustomerParam(Direction=0, PSI5_14bit_angle=0, PSI5_quad_info=0, PSI5_16bit_frame=0, Extended_init_phase=0, Day=0, Month=0, Year=0, SensorType=0, SensorParameter=0, SensorCodeManufacturer=0, SensorCodeVehicle=0, PSI5Mode=0, Sync_discharge=0, Init_phase_repetition=0, PSI5_timeslot=0, Init_phase_disable=0, Extended_range_disable=0, Customer_lock=0, VendorID=0)

Configure customer-specific parameters for the AS5172 device.

Each parameter corresponds to specific configuration bits or registers as defined in the datasheet, allowing detailed customization of sensor behavior and PSI5 protocol options.

Parameters:
  • Direction (int) – Direction setting (bit 2 at register 0x01).

  • PSI5_14bit_angle (int) – Enable/disable 14-bit PSI5 angle mode (bit 3 at 0x01).

  • PSI5_quad_info (int) – Quadrants info flag for PSI5 (bit 4 at 0x01).

  • PSI5_16bit_frame (int) – Enable 16-bit PSI5 frame mode (bit 5 at 0x01).

  • Extended_init_phase (int) – Extended initialization phase flag (bit 7 at 0x01).

  • Day (int) – Day value (bits 0:4 at 0x0D).

  • Month (int) – Month value (bits 5:7 at 0x0D plus bit 0 at 0x0C).

  • Year (int) – Year value (bits 1:7 at 0x0C).

  • SensorType (int) – Sensor type identifier (bits 0:3 at 0x0E).

  • SensorParameter (int) – Sensor parameter bits (bits 0:3 at 0x0F plus bits 4:7 at 0x0E).

  • SensorCodeManufacturer (int) – Manufacturer code (bits 0:3 at 0x10 plus bits 4:7 at 0x0F).

  • SensorCodeVehicle (int) – Vehicle code (bits 4:7 at 0x10).

  • PSI5Mode (int) – PSI5 protocol mode setting (bits 0:7 at 0x11).

  • Sync_discharge (int) – Synchronization discharge flag (bit 0 at 0x12).

  • Init_phase_repetition (int) – Initialization phase repetition count (bits 1:2 at 0x12).

  • PSI5_timeslot (int) – PSI5 timeslot setting (bits 3:4 at 0x12).

  • Init_phase_disable (int) – Disable initialization phase flag (bit 5 at 0x12).

  • Extended_range_disable (int) – Disable extended range flag (bit 3 at 0x1D).

  • Customer_lock (int) – Customer lock flag (bit 7 at 0x1D).

  • VendorID (int) – Vendor identifier (bits 0:7 at 0x1E).

Returns:

None

class qmh_pyclient.PosSensor.AS5172A(Driver, **kwargs)

Bases: AS5172

P10P_5003L_Timeslot1 = 0
P10P_5003L_Timeslot2 = 1
P10P_5003L_Timeslot3 = 2
P10P_5003L_Discharge_Timeslot2 = 3
P10P_5003L_Discharge_Timeslot3 = 4
P10P_5003L_HighResMode_Timeslot1_2 = 5
P10P_5003L_HighResMode_Timeslot2_3 = 6
P10P_5003L_Discharge_HighResMode_Timeslot2_3 = 7
A10P_5001L = 8
A10P_2501L = 9
A10P_5001L_HighResMode = 10
A10P_2501L_HighResMode = 11
P20CRC_5001L_Timeslot1 = 12
P20CRC_5002L_Timeslot2 = 13
P20CRC_5002H_Timeslot1 = 14
P20CRC_5002H_Timeslot2 = 15
P20CRC_5003H_Timeslot1 = 16
P20CRC_5003H_Timeslot2 = 17
P20CRC_5003H_Timeslot3 = 18
P16CRC_5003H_Timeslot1 = 19
P16CRC_5003H_Timeslot2 = 20
P16CRC_5003H_Timeslot3 = 21
A20CRC_2001H = 22
A20CRC_5001H = 23
A20CRC_2002H = 24
A20CRC_3001L = 25
SetPSI5Mode(PSI5Mode, LowPower, K_times=0, RollingCounter=0)

Configure the PSI5 communication mode related parameters for AS5172EA/B.

Parameters:
  • PSI5Mode (int) – PSI5 mode setting value.

  • LowPower (int) – Low power mode enable flag.

  • ErrBit (int) – Error bit enable flag (default is 1).

  • K_times (int) – K-times configuration parameter (default is 0).

  • P16_new_init (int) – P16 new initialization flag (default is 0).

  • RollingCounter (int) – Rolling counter enable flag (default is 0).

Returns:

None

Read_PSI5(PSI5Mode, LowPower=0, Mode_14bit=0, NoSamples=1) tuple

Read PSI5 sensor data according to the specified mode and options.

Parameters:
  • PSI5Mode (int) – PSI5 communication mode setting.

  • LowPower (int) – Enable low power mode if set to 1 (default is 0).

  • Mode_14bit (int) – Enable 14-bit mode if set to 1 (default is 0).

  • NoSamples (int) – Number of samples to read (default is 1).

Returns:

A tuple containing the PSI5 sensor data samples read.

Return type:

tuple

class qmh_pyclient.PosSensor.AS5172E(Driver, **kwargs)

Bases: AS5172

P10P_5003L_Timeslot1 = 0
P10P_5003L_Timeslot2 = 1
P10P_5003L_Timeslot3 = 2
P10P_5003L_Discharge_Timeslot2 = 3
P10P_5003L_Discharge_Timeslot3 = 4
P10P_5003L_HighResMode_Timeslot1_2 = 5
P10P_5003L_HighResMode_Timeslot2_3 = 6
P10P_5003L_Discharge_HighResMode_Timeslot2_3 = 7
A10P_5001L = 8
A10P_2501L = 9
A10P_5001L_HighResMode = 10
A10P_2501L_HighResMode = 11
P20CRC_5001L_Timeslot1 = 12
P20CRC_5002L_Timeslot2 = 13
P20CRC_5002L_AngleandVelocity = 14
P20CRC_5002H_Timeslot1 = 15
P20CRC_5002H_Timeslot2 = 16
P20CRC_5002H_AngleandVelocity = 17
P20CRC_5003H_Timeslot1 = 18
P20CRC_5003H_Timeslot2 = 19
P20CRC_5003H_Timeslot3 = 20
P20CRC_5003H_AngleandVelocity_Timeslot1and2 = 21
P20CRC_5003H_AngleandVelocity_Timeslot2and3 = 22
P20CRC_5003H_AngleandVelocity_Timeslot1and3 = 23
P16CRC_5003H_Timeslot1 = 24
P16CRC_5003H_Timeslot2 = 25
P16CRC_5003H_Timeslot3 = 26
P16CRC_5003H_AngleandVelocity_Timeslot1and2 = 27
P16CRC_5003H_AngleandVelocity_Timeslot2and3 = 28
P16CRC_5003H_AngleandVelocity_Timeslot1and3 = 29
P16CRC_10004H_AngleandVelocity_Timeslot1and2 = 30
P16CRC_10004H_AngleandVelocity_Timeslot3and4 = 31
A20CRC_2001H = 32
A20CRC_5001H = 33
A20CRC_2002H = 34
A20CRC_3001L = 35
SetPSI5Mode(PSI5Mode, LowPower, ErrBit=1, K_times=0, P16_new_init=0, RollingCounter=0)

Configure the PSI5 communication mode related parameters for AS5172E/F.

Parameters:
  • PSI5Mode (int) – PSI5 mode setting value.

  • LowPower (int) – Low power mode enable flag.

  • ErrBit (int) – Error bit enable flag (default is 1).

  • K_times (int) – K-times configuration parameter (default is 0).

  • P16_new_init (int) – P16 new initialization flag (default is 0).

  • RollingCounter (int) – Rolling counter enable flag (default is 0).

Returns:

None

Read_PSI5(PSI5Mode, LowPower=0, ErrBit=1, Mode_14bit=0, NoSamples=1, NoQ=1) tuple

Read PSI5 sensor data according to the specified configuration.

Parameters:
  • PSI5Mode (int) – PSI5 communication mode setting.

  • LowPower (int) – Enable low power mode if set to 1 (default is 0).

  • ErrBit (int) – Enable error bit handling if set to 1 (default is 1).

  • Mode_14bit (int) – Use 14-bit mode if set to 1 (default is 0).

  • NoSamples (int) – Number of samples to read (default is 1).

  • NoQ (int) – Number of Quadrants (default is 1).

Returns:

A tuple containing the PSI5 sensor data samples read.

Return type:

tuple

AS5173 Class

The AS5173 class is used to define the sensor as AS5173.

class qmh_pyclient.PosSensor.AS5173(Driver, **kwargs)

Bases: AS5172E

param_calc(T1, T2, Direction, No_Q, CLH, CLL, Mode)

Calculates the values of Gain, BP, Offset, NoQ, RedAngle, CLH, CLL. Works for AS5173.

Parameters:
  • T1 (int) – Angle 1.

  • T2 (int) – Angle 2.

  • Direction (int) – Input direction.

  • No_Q (int) – Number of quadrants.

  • CLH (int) – Clamping limit high.

  • CLL (int) – Clamping limit low.

  • Mode (int) – Sensor mode.

Returns:

A tuple containing:

  • Gain (int): Output gain factor.

  • BP (int): Output breakpoint.

  • Offset (int): Output offset value.

  • NoQ (int): Number of quadrants.

  • RedAngle (float): Reduced angle enabled.

  • CLH (float): Clamping limit high.

  • CLL (float): Clamping limit low.

  • Direction (int): Returned direction.

  • Mode (int): Returned mode.

Return type:

tuple