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:
PosSensorDriverDriver 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:
PosSensorDriverDriver 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:
PosSensorDriverDriver 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:
PosSensorDriverDriver 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:
PosSensorDriverDriver 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:
objectBase 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- 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
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- 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
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