Author | Rob Jansen, Copyright © 2024..2024, all rights reserved. |
Adapted-by | |
Compiler | 2.5r8 |
Library functions for the AS5600 and the AS5600L Magnetic Rotary Position Sensor. The main program has to setup the IIC communication using an IIC clock at most 1 MHz.
AS5600 AMS datasheet [v1-06] 2018-Jun-20 AS5600L AMS datasheet [v1-12] 2020-May-14
The library supports both the AS5600 as well as the AS5600L. In order to select the correct device the user must provide the the correct 7-bit IIC address in the init function. Adresses are: -) For AS5600 = 0x37. Default address and cannot be changed. -) For AS5600L = 0x40. Default address but this address can be changed.
No dependency found
const byte _AS5600_BURN_ANGLES = 0x80
const byte AS5600L_POWER_MODE_LOW_3 = 0b0000_0011
const byte AS5600L_FAST_FILTER_LSB_7 = 0b0000_1000
const byte AS5600L_HYSTERESIS_LSB_2 = 0b0000_1000
const byte _AS5600L_REG_CONF = 0x07 ; Plus 0x08.
const byte _AS5600_REG_BURN = 0xFF
const byte AS5600L_FAST_FILTER_LSB_18 = 0b0001_0000
const byte AS5600L_POWER_MODE_LOW_1 = 0b0000_0001
const byte AS5600L_HYSTERESIS_LSB_1 = 0b0000_0100
const byte AS5600L_HYSTERESIS_OFF = 0b0000_0000
var byte _as5600l_current_iic_address = 0
const byte AS5600L_SLOW_FILTER_2X = 0b0000_0011
const byte _AS5600L_CONF_WATCHDOG = 0b1000_0000
const byte AS5600L_FAST_FILTER_LSB_21 = 0b0001_0100
const byte _AS5600L_STATUS_MAGNET_DETECTED = 0b0010_0000
const byte AS5600L_SLOW_FILTER_8X = 0b0000_0001
const byte _AS5600L_STATUS_MAGNET_STRONG = 0b0000_1000
const byte _AS5600L_REG_STATUS = 0x0B
const byte _AS5600L_REG_ANGLE = 0x0E ; Plus 0x0F.
const byte _AS5600_BURN_SETTINGS = 0x40
const byte _AS5600L_REG_MAGNITUDE = 0x1B ; Plus 0x1C
const byte AS5600L_OUTPUT_STAGE_ANALOG_90 = 0b0001_0000
const word _AS5600L_MAX_ANGLE = 4096
const byte AS5600L_PWM_115_HZ = 0b0000_0000
const byte _AS5600L_REG_ZMCO = 0x00
const byte AS5600L_PWM_460_HZ = 0b1000_0000
const byte AS5600L_FAST_FILTER_NONE = 0b0000_0000
const byte AS5600L_OUTPUT_STAGE_PWM = 0b0010_0000
const byte AS5600L_OUTPUT_STAGE_ANALOG_100 = 0b0000_0000
const byte _AS5600L_STATUS_MAGNET_WEAK = 0b0001_0000
const byte _AS5600L_REG_ZPOS = 0x01 ; Plus 0x02.
const byte _AS5600L_REG_AGC = 0x1A
const byte AS5600L_FAST_FILTER_LSB_6 = 0b0000_0100
const byte AS5600L_HYSTERESIS_LSB_3 = 0b0000_1100
const byte _AS5600L_REG_I2C_UPDT = 0x21
const byte AS5600L_PWM_230_HZ = 0b0100_0000
const byte AS5600L_FAST_FILTER_LSB_9 = 0b0000_1100
const byte AS5600L_FAST_FILTER_LSB_10 = 0b0001_1100
const byte AS5600L_PWM_920_HZ = 0b1100_0000
const byte AS5600L_POWER_MODE_NOMINAL = 0b0000_0000
const byte AS5600L_FAST_FILTER_LSB_24 = 0b0001_1000
const byte AS5600L_SLOW_FILTER_16X = 0b0000_0000
const byte _AS5600L_REG_MPOS = 0x03 ; Plus 0x04.
const byte _AS5600L_REG_MANG = 0x05 ; Plus 0x06.
const byte _AS5600L_REG_I2C_ADDR = 0x20
const byte AS5600L_SLOW_FILTER_4X = 0b0000_0010
const byte AS5600L_POWER_MODE_LOW_2 = 0b0000_0010
const byte _AS5600L_REG_RAW_ANGLE = 0x0C ; Plus 0x0D.
as5600l_iic_address'put(byte in iic_address)
as5600l_slow_filter'put(byte in slow_filter)
as5600l_output_stage'put(byte in output_stage)
as5600l_init(byte in iic_address)
as5600l_pwm_frequency'put(byte in pwm_frequency)
as5600l_power_mode'put(byte in power_mode)
as5600l_maximum_angle'put(word in angle)
as5600l_maximum_position'put(word in position)
as5600l_fast_filter'put(byte in fast_filter)
as5600l_hysteresis'put(byte in hysteresis)
as5600l_zero_position'put(word in position)
as5600l_watchdog_on'put(bit in watchdog_on)
_as5600l_write_data_word(byte in register, word in data)
_as5600l_write_data_byte(byte in register, byte in data)
as5600l_hysteresis'get() return byte
as5600l_power_mode'get() return byte
as5600l_number_of_program_cycles'get() return byte
as5600l_maximum_angle'get() return word
as5600l_raw_position'get() return word
as5600l_magnitude'get() return word
as5600l_scaled_position'get() return word
as5600l_output_stage'get() return byte
as5600l_iic_address'get() return byte
as5600l_magnet_too_strong'get() return bit
as5600l_watchdog_on'get() return bit
as5600l_agc'get() return byte
as5600l_maximum_position'get() return word
as5600l_angle_to_degree(word in angle) return word
as5600l_pwm_frequency'get() return byte
as5600l_fast_filter'get() return byte
as5600l_magnet_detected'get() return bit
as5600l_magnet_too_weak'get() return bit
as5600l_slow_filter'get() return byte
as5600l_zero_position'get() return word
_as5600l_read_data_byte(byte in register) return byte
_as5600l_read_data_word(byte in register) return word
const byte _AS5600_BURN_ANGLES = 0x80
AS5600(L) burn commands.
const byte AS5600L_POWER_MODE_LOW_3 = 0b0000_0011
No documentation found
const byte AS5600L_FAST_FILTER_LSB_7 = 0b0000_1000
No documentation found
const byte AS5600L_HYSTERESIS_LSB_2 = 0b0000_1000
No documentation found
const byte _AS5600L_REG_CONF = 0x07 ; Plus 0x08.
No documentation found
const byte _AS5600_REG_BURN = 0xFF
AS5600(L) burn register.
const byte AS5600L_FAST_FILTER_LSB_18 = 0b0001_0000
No documentation found
const byte AS5600L_POWER_MODE_LOW_1 = 0b0000_0001
No documentation found
const byte AS5600L_HYSTERESIS_LSB_1 = 0b0000_0100
No documentation found
const byte AS5600L_HYSTERESIS_OFF = 0b0000_0000
Hysteresis.
var byte _as5600l_current_iic_address = 0
No documentation found
const byte AS5600L_SLOW_FILTER_2X = 0b0000_0011
No documentation found
const byte _AS5600L_CONF_WATCHDOG = 0b1000_0000
Masks for the configuration (CONF) register.
const byte AS5600L_FAST_FILTER_LSB_21 = 0b0001_0100
No documentation found
const byte _AS5600L_STATUS_MAGNET_DETECTED = 0b0010_0000
No documentation found
const byte AS5600L_SLOW_FILTER_8X = 0b0000_0001
No documentation found
const byte _AS5600L_STATUS_MAGNET_STRONG = 0b0000_1000
Masks for the status (STATUS) register.
const byte _AS5600L_REG_STATUS = 0x0B
AS5600(L) status registers. These are 8 bit addresses.
const byte _AS5600L_REG_ANGLE = 0x0E ; Plus 0x0F.
No documentation found
const byte _AS5600_BURN_SETTINGS = 0x40
No documentation found
const byte _AS5600L_REG_MAGNITUDE = 0x1B ; Plus 0x1C
No documentation found
const byte AS5600L_OUTPUT_STAGE_ANALOG_90 = 0b0001_0000
No documentation found
const word _AS5600L_MAX_ANGLE = 4096
Max raw angle values.
const byte AS5600L_PWM_115_HZ = 0b0000_0000
PWM frequency in Hz.
const byte _AS5600L_REG_ZMCO = 0x00
AS5600(L) configuraion registers. These are 8 bit addresses.
const byte AS5600L_PWM_460_HZ = 0b1000_0000
No documentation found
const byte AS5600L_FAST_FILTER_NONE = 0b0000_0000
Fast filter threshold.
const byte AS5600L_OUTPUT_STAGE_PWM = 0b0010_0000
No documentation found
const byte AS5600L_OUTPUT_STAGE_ANALOG_100 = 0b0000_0000
Output stage.
const byte _AS5600L_STATUS_MAGNET_WEAK = 0b0001_0000
No documentation found
const byte _AS5600L_REG_ZPOS = 0x01 ; Plus 0x02.
No documentation found
const byte _AS5600L_REG_AGC = 0x1A
No documentation found
const byte AS5600L_FAST_FILTER_LSB_6 = 0b0000_0100
No documentation found
const byte AS5600L_HYSTERESIS_LSB_3 = 0b0000_1100
No documentation found
const byte _AS5600L_REG_I2C_UPDT = 0x21
No documentation found
const byte AS5600L_PWM_230_HZ = 0b0100_0000
No documentation found
const byte AS5600L_FAST_FILTER_LSB_9 = 0b0000_1100
No documentation found
const byte AS5600L_FAST_FILTER_LSB_10 = 0b0001_1100
No documentation found
const byte AS5600L_PWM_920_HZ = 0b1100_0000
No documentation found
const byte AS5600L_POWER_MODE_NOMINAL = 0b0000_0000
Power modes.
const byte AS5600L_FAST_FILTER_LSB_24 = 0b0001_1000
No documentation found
const byte AS5600L_SLOW_FILTER_16X = 0b0000_0000
Slow filter.
const byte _AS5600L_REG_MPOS = 0x03 ; Plus 0x04.
No documentation found
const byte _AS5600L_REG_MANG = 0x05 ; Plus 0x06.
No documentation found
const byte _AS5600L_REG_I2C_ADDR = 0x20
AS5600L IIC registers (AS5600L only).
const byte AS5600L_SLOW_FILTER_4X = 0b0000_0010
No documentation found
const byte AS5600L_POWER_MODE_LOW_2 = 0b0000_0010
No documentation found
const byte _AS5600L_REG_RAW_ANGLE = 0x0C ; Plus 0x0D.
AS5600(L) output registers. These are 8 bit addresses.
as5600l_iic_address'put(byte in iic_address)
Pseudo variable to change the 7-bit IIC address (AS5600L only).
as5600l_slow_filter'put(byte in slow_filter)
Pseudo variable that sets the slow filter.
as5600l_output_stage'put(byte in output_stage)
Pseudo variable that sets the output stage.
as5600l_init(byte in iic_address)
Init the AS5600(L) library. This sets the 7-bit IIC address with determines which device (AS5600 or AS5600L) is selected.
as5600l_pwm_frequency'put(byte in pwm_frequency)
Pseudo variable that sets the PWM frequency.
as5600l_power_mode'put(byte in power_mode)
Pseudo variable that sets the power mode.
as5600l_maximum_angle'put(word in angle)
Pseudo variable that sets the maximum angle for the AS5600(L). Range is 0..4095.
as5600l_maximum_position'put(word in position)
Pseudo variable that sets the maximum position for the AS5600(L). Range is 0..4095.
as5600l_fast_filter'put(byte in fast_filter)
Pseudo variable that sets the fast filter.
as5600l_hysteresis'put(byte in hysteresis)
Pseudo variable that sets the hysteresis.
as5600l_zero_position'put(word in position)
Pseudo variable that sets the zero position for the AS5600(L). Range is 0..4095.
as5600l_watchdog_on'put(bit in watchdog_on)
Pseudo variable to switch the watchdog on or off.
_as5600l_write_data_word(byte in register, word in data)
Write a word to the given register of the AS5600(L) via the IIC interface. The AS5600 has data stored with Most Significant Byte (MSB) first.
_as5600l_write_data_byte(byte in register, byte in data)
Write a byte to the given register of the AS5600(L) via the IIC interface.
as5600l_hysteresis'get() return byte
Pseudo variable that returns the hysteresis.
as5600l_power_mode'get() return byte
Pseudo variable that returns the power mode.
as5600l_number_of_program_cycles'get() return byte
Pseudo variable that returns the number of times the zero position and maximum positions have been programmed. This is limited to at most 3 times.
as5600l_maximum_angle'get() return word
Pseudo variable that returns the maximum angle of the AS5600(L). Range is 0..4095.
as5600l_raw_position'get() return word
Pseudo variable that returns the raw position from the AS5600(L). Range is 0..4095.
as5600l_magnitude'get() return word
Pseudo variable returning the magnitude.
as5600l_scaled_position'get() return word
Pseudo variable that returns the scaled position from the AS5600(L). Range is 0..4095.
as5600l_output_stage'get() return byte
Pseudo variable that returns the output stage
as5600l_iic_address'get() return byte
Pseudo variable to get the current 7-bit IIC address (AS5600L only).
as5600l_magnet_too_strong'get() return bit
Pseudo variable returns TRUE when the magnet was too strong.
as5600l_watchdog_on'get() return bit
Pseudo variable returns TRUE when the watchdog is on.
as5600l_agc'get() return byte
Pseudo variable returning the AGC level.
as5600l_maximum_position'get() return word
Pseudo variable that returns the maximum position of the AS5600(L). Range is 0..4095.
as5600l_angle_to_degree(word in angle) return word
Convert the given angle to a degree.
as5600l_pwm_frequency'get() return byte
Pseudo variable that returns the PWM frequency.
as5600l_fast_filter'get() return byte
Pseudo variable that returns the fast filter.
as5600l_magnet_detected'get() return bit
Pseudo variable returns TRUE when the magnet was detected.
as5600l_magnet_too_weak'get() return bit
Pseudo variable returns TRUE when the magnet was too weak.
as5600l_slow_filter'get() return byte
Pseudo variable that returns the slow filter.
as5600l_zero_position'get() return word
Pseudo variable that returns the zero position of the AS5600(L). Range is 0..4095.
_as5600l_read_data_byte(byte in register) return byte
Read a byte from the given register of the AS5600(L) via the IIC interface.
_as5600l_read_data_word(byte in register) return word
Read a word from the given register of the AS5600(L) via the IIC interface. The AS5600 has data stored with Most Significant Byte (MSB) first.
16f1825 | 16f1825_as5600l.jal |