From e4f031cafb4384b0d82a01ad74a2cb5ed8e60a27 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Fri, 11 Aug 2023 13:46:53 +0200 Subject: [PATCH 1/3] Add I2C address setting for Ext mag --- data/initialize_files/components/rm3100_external.ini | 3 +++ src/simulation/spacecraft/aocs_module_components.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/data/initialize_files/components/rm3100_external.ini b/data/initialize_files/components/rm3100_external.ini index fef4930..f430a3d 100644 --- a/data/initialize_files/components/rm3100_external.ini +++ b/data/initialize_files/components/rm3100_external.ini @@ -45,6 +45,9 @@ normal_random_standard_deviation_c_nT(2) = 15.0 range_to_constant_nT = 1.0e6 // smaller than Range_to_zero range_to_zero_nT = 1.5e6 +[I2C_PORT_2] +i2c_address = 0x23 + [POWER_PORT] minimum_voltage_V = 3.3 // V assumed_power_consumption_W = 0.03 //W diff --git a/src/simulation/spacecraft/aocs_module_components.cpp b/src/simulation/spacecraft/aocs_module_components.cpp index e682d63..5d09dac 100644 --- a/src/simulation/spacecraft/aocs_module_components.cpp +++ b/src/simulation/spacecraft/aocs_module_components.cpp @@ -75,9 +75,11 @@ AocsModuleComponents::AocsModuleComponents(const Dynamics *dynamics, Structure * 0, rm3100_aobc_hils_port_id, 0x20, aobc_, hils_port_manager_); const std::string rm3100_ext_ini_path = iniAccess.ReadString("COMPONENTS_FILE", "magsensor_h_ext_file"); const unsigned int rm3100_ext_hils_port_id = iniAccess.ReadInt("COM_PORT", "rm3100_ext_hils_port_id"); + IniAccess rm3100_ext_ini_access = IniAccess(rm3100_ext_ini_path); + const uint8_t rm3100_ext_i2c_address = (uint8_t)rm3100_ext_ini_access.ReadInt("I2C_PORT_2", "i2c_address"); rm3100_ext_ = new RM3100(Magnetometer(InitMagnetometer(clock_generator, power_controller_->GetPowerPort((int)PowerPortIdx::RM), 2, rm3100_ext_ini_path, compo_step_sec, &local_environment_->GetGeomagneticField())), - 0, rm3100_ext_hils_port_id, 0x23, aobc_, hils_port_manager_); + 0, rm3100_ext_hils_port_id, rm3100_ext_i2c_address, aobc_, hils_port_manager_); const std::string nanoSSOC_D60_ini_path = iniAccess.ReadString("COMPONENTS_FILE", "ss_file"); const unsigned int nanoSSOC_D60_pz_hils_port_id = iniAccess.ReadInt("COM_PORT", "nanoSSOC_D60_pz_hils_port_id"); From 7957e269c4ca0c42bd34f4d3cc27a02d292e344a Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Fri, 11 Aug 2023 13:47:32 +0200 Subject: [PATCH 2/3] Update example for Ext Mag I2C address settings --- example/data/initialize_files/components/rm3100_external.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/example/data/initialize_files/components/rm3100_external.ini b/example/data/initialize_files/components/rm3100_external.ini index fef4930..f430a3d 100644 --- a/example/data/initialize_files/components/rm3100_external.ini +++ b/example/data/initialize_files/components/rm3100_external.ini @@ -45,6 +45,9 @@ normal_random_standard_deviation_c_nT(2) = 15.0 range_to_constant_nT = 1.0e6 // smaller than Range_to_zero range_to_zero_nT = 1.5e6 +[I2C_PORT_2] +i2c_address = 0x23 + [POWER_PORT] minimum_voltage_V = 3.3 // V assumed_power_consumption_W = 0.03 //W From 452df623b362b8b675288a0b9030a706d10ed920 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Fri, 11 Aug 2023 13:48:10 +0200 Subject: [PATCH 3/3] Fix format --- src/simulation/spacecraft/aocs_module_components.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/simulation/spacecraft/aocs_module_components.cpp b/src/simulation/spacecraft/aocs_module_components.cpp index 5d09dac..48318b0 100644 --- a/src/simulation/spacecraft/aocs_module_components.cpp +++ b/src/simulation/spacecraft/aocs_module_components.cpp @@ -65,20 +65,20 @@ AocsModuleComponents::AocsModuleComponents(const Dynamics *dynamics, Structure * const std::string mpu9250_mag_ini_path = iniAccess.ReadString("COMPONENTS_FILE", "magsensor_l_file"); const unsigned int mpu9250_mag_hils_port_id = iniAccess.ReadInt("COM_PORT", "mpu9250_mag_hils_port_id"); mpu9250_mag_ = new MPU9250_MAG(InitMagnetometer(clock_generator, power_controller_->GetPowerPort((int)PowerPortIdx::MPU), 2, mpu9250_mag_ini_path, - compo_step_sec, &(local_environment_->GetGeomagneticField())), + compo_step_sec, &(local_environment_->GetGeomagneticField())), 0, mpu9250_mag_hils_port_id, 0x0c, aobc_, hils_port_manager_, mpu9250_gyro_->GetIsMagOn()); const std::string rm3100_aobc_ini_path = iniAccess.ReadString("COMPONENTS_FILE", "magsensor_h_aobc_file"); const unsigned int rm3100_aobc_hils_port_id = iniAccess.ReadInt("COM_PORT", "rm3100_aobc_hils_port_id"); rm3100_aobc_ = new RM3100(Magnetometer(InitMagnetometer(clock_generator, power_controller_->GetPowerPort((int)PowerPortIdx::RM), 1, - rm3100_aobc_ini_path, compo_step_sec, &local_environment_->GetGeomagneticField())), + rm3100_aobc_ini_path, compo_step_sec, &local_environment_->GetGeomagneticField())), 0, rm3100_aobc_hils_port_id, 0x20, aobc_, hils_port_manager_); const std::string rm3100_ext_ini_path = iniAccess.ReadString("COMPONENTS_FILE", "magsensor_h_ext_file"); const unsigned int rm3100_ext_hils_port_id = iniAccess.ReadInt("COM_PORT", "rm3100_ext_hils_port_id"); IniAccess rm3100_ext_ini_access = IniAccess(rm3100_ext_ini_path); const uint8_t rm3100_ext_i2c_address = (uint8_t)rm3100_ext_ini_access.ReadInt("I2C_PORT_2", "i2c_address"); rm3100_ext_ = new RM3100(Magnetometer(InitMagnetometer(clock_generator, power_controller_->GetPowerPort((int)PowerPortIdx::RM), 2, - rm3100_ext_ini_path, compo_step_sec, &local_environment_->GetGeomagneticField())), + rm3100_ext_ini_path, compo_step_sec, &local_environment_->GetGeomagneticField())), 0, rm3100_ext_hils_port_id, rm3100_ext_i2c_address, aobc_, hils_port_manager_); const std::string nanoSSOC_D60_ini_path = iniAccess.ReadString("COMPONENTS_FILE", "ss_file");