Skip to content

Commit

Permalink
Use digital pin for IMU powering on off
Browse files Browse the repository at this point in the history
  • Loading branch information
jerabaul29 committed Sep 9, 2024
1 parent b3a99b5 commit 69d259b
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 173 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# About this branch
This is the version to use for JARE deployments

This is the version to use for JARE deployments.
This is updated to work without the qwiic switch. Instead of using the qwiic switch to power the IMU on and off, we use a digital pin with 12mA sourcing strength that we turn on and off. Note that the "qwiic" name still appears in the code (for example, turn_qwiic_switch_on), but this is only for historical reasons: the corresponding code just turns the pin HIGH and LOW.

# Getting the code to compile and upload

Expand Down Expand Up @@ -60,9 +62,7 @@ Switched to a new branch 'fix/SPI_with_Artemis'
- Artemis Global Tracker
- Iridium and GNSS passive antenna
- SMA extension cable
- Qwiic switch
- Adafruit 9-dof (Adafruit ISM330DHCX + LIS3MDL FeatherWing - High Precision 9-DoF IMU, PRODUCT ID: 4569)
- 2 Qwiic cables
- LSH20 cells, 3 in parallel
- pololu 3.3V step up step down regulator

Expand All @@ -74,9 +74,9 @@ Switched to a new branch 'fix/SPI_with_Artemis'
## Assembly

- connect AGT - SMA extender - antenna
- connect AGT Qwiic - Qwiic switch in - Qwiic switch out - Adafruit 9 dof
- connect IMUPwr pin (see definition in the code) to the 3.3V Vin of the IMU, and SCL / SDA from the IMU to the corresponding pins for the I2C port chosen on the AGT
- solder battery - 3.3V regulator - 3.3V pin
- cut the LED enable traces on the AGT (```PWR_LED```) and Qwiich switch (```LED_IN``` and ```LED_OUT```)
- cut the LED enable traces on the AGT (```PWR_LED```)

# Operating notes

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "board_control.h"

TwoWire ArtemisWire(i2c_port_number);
QWIIC_POWER qwiic_switch;

void blink_LED_n_times(unsigned int number_of_blinks, float frequency_hz){
wdt.restart(); // we choose to restart at the start and end, but not in loop as a way to make sure not so much blinking that we freeze.
Expand All @@ -23,6 +22,9 @@ void blink_LED_n_times(unsigned int number_of_blinks, float frequency_hz){
void setup_pins(void){
pinMode(LED, OUTPUT); // Make the LED pin an output

// make the IMUPwr pin an output
pinMode(IMUPwr, g_AM_HAL_GPIO_OUTPUT_12); // enable 12mA output

turn_gnss_off(); // Disable power for the GNSS
pinMode(geofencePin, INPUT); // Configure the geofence pin as an input

Expand Down Expand Up @@ -80,19 +82,17 @@ void turn_iridium_off(void){

void turn_qwiic_switch_off(void){
Serial.println(F("turn qwiic switch off"));
qwiic_switch.pinMode(1, INPUT);
qwiic_switch.pinMode(2, INPUT);
delay(50);
qwiic_switch.powerOff();
pinMode(IMUPwr, g_AM_HAL_GPIO_OUTPUT_12); // enable 12mA output
digitalWrite(IMUPwr, LOW);
// NOTE: maybe we also need to put the I2C SCL SDA to INPUT to avoid crosstalks and power wasting?
delay(100);
}

void turn_qwiic_switch_on(void){
Serial.println(F("turn qwiic switch on"));
qwiic_switch.powerOn();
pinMode(IMUPwr, g_AM_HAL_GPIO_OUTPUT_12); // enable 12mA output
digitalWrite(IMUPwr, HIGH);
delay(50);
qwiic_switch.pinMode(1, INPUT);
qwiic_switch.pinMode(2, INPUT);
}

void turn_thermistors_on(void){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include "params.h"
#include "watchdog_manager.h"
#include "sleep_manager.h"
#include "params.h"

#include "Wire.h"
#include <SparkFun_Qwiic_Power_Switch_Arduino_Library.h>

//--------------------------------------------------------------------------------
// Artemis Tracker pin definitions
Expand Down Expand Up @@ -57,6 +57,7 @@ void blink_LED_n_times(unsigned int number_of_blinks, float frequency_hz=1.0);

//--------------------------------------------------------------------------------
// functions to save power on the Qwiic switch
// we do not rename these, but in practice this is now using the pinmode, not qwiic

void turn_qwiic_switch_on(void);

Expand All @@ -73,6 +74,5 @@ void turn_thermistors_off(void);
//making the ArtemisWire Qwiic port and Qwiic switch available to all

extern TwoWire ArtemisWire;
extern QWIIC_POWER qwiic_switch;

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,13 @@ bool IMU_Manager::start_IMU(){
wdt.restart();
Serial.println(F("started ArtemisWire"));

Serial.println(F("start qwiic switch"));
if (qwiic_switch.begin(ArtemisWire) == false){
Serial.println(F("Qwiic Power Switch not detected at default I2C address. Please check wiring. Freezing."));
while (true){;}
}
turn_qwiic_switch_off();
delay(500);
wdt.restart();

// TODO: instead of hang, return false...
turn_qwiic_switch_on();

// configure the power switch
turn_qwiic_switch_on();
qwiic_switch.isolationOff();
delay(500);
wdt.restart();

Serial.println("Adafruit ISM330DHCX start!");
while (true){
if (!ism330dhcx.begin_I2C(LSM6DS_I2CADDR_DEFAULT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class IMU_Manager{
int counter_nbr_cycles_LED_off {0};
};

extern QWIIC_POWER mySwitch;
extern Adafruit_ISM330DHCX ism330dhcx;
//extern Adafruit_LIS3MDL lis3mdl;
extern Adafruit_NXPSensorFusion Kalman_filter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
void print_params(void){
Serial.print(F("baudrate_debug_serial : ")); Serial.println(baudrate_debug_serial );
Serial.print(F("i2c_port_number: ")); Serial.println(i2c_port_number );
Serial.print(F("IMU power pin: ")); Serial.println(IMUPwr);

Serial.println(F("----- TEST_MODE -----"));
Serial.print(F("DEPLOYMENT_MODE: ")); Serial.println(DEPLOYMENT_MODE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ constexpr int i2c_port_number {1};
// for using the I2C port corresponding to the Qwiic connector
// constexpr int i2c_port_number {4};

#define IMUPwr 42

// TODO: use some form of constexpr if instead
// first declare the variables and document
// then use if constexpr to set the values
Expand Down

0 comments on commit 69d259b

Please sign in to comment.