From 46c5b49b1838ad2aaa34ac21704075a6c9bb549d Mon Sep 17 00:00:00 2001 From: boo25263 Date: Thu, 25 Feb 2021 00:33:59 -0600 Subject: [PATCH 01/10] header file and pin initialization --- PowerBoardSoftware/PowerBoardSoftware.ino | 430 ---------------------- powerboardcode/powerboard.cpp | 42 +++ powerboardcode/powerboard.h | 50 +++ 3 files changed, 92 insertions(+), 430 deletions(-) delete mode 100644 PowerBoardSoftware/PowerBoardSoftware.ino create mode 100644 powerboardcode/powerboard.cpp create mode 100644 powerboardcode/powerboard.h diff --git a/PowerBoardSoftware/PowerBoardSoftware.ino b/PowerBoardSoftware/PowerBoardSoftware.ino deleted file mode 100644 index 3daf712..0000000 --- a/PowerBoardSoftware/PowerBoardSoftware.ino +++ /dev/null @@ -1,430 +0,0 @@ -/* -* POWERBOARD SOFTWARE -* Patrick Sanchez -* Missouri University of Science and Technology -* Mars Rover Design Team -* 2020, Revision 1 -*/ - -//C types -#include -#include -#include -#include "Energia.h" - -//RoveComm -#include - -RoveCommEthernet RoveComm; -rovecomm_packet packet; - -const uint16_t ROVECOMM_TELEM_RATE = 1000; -const uint16_t NO_ROVECOMM_MESSAGE = 0; - -//Current readings -const uint16_t MOTOR_CURRENT_READING = 3105; //M1,M2,M3,M4,M5,M6,M7,Spare (last 2 unused atm) -const uint16_t ACT_LOG_CURRENT_READING = 3106; //Actuation, Logic -const uint16_t MISC_30V_CURRENT_READING = 3107; //12V Board, Rockets, Auxiliary -const uint16_t VAC_CURRENT_READING = 3108; //Vacuum - -//Bus control -//Disable = 0, Enable = 1 -const uint16_t MOTOR_ENABLE = 3100; //M1,M2,M3,M4,M5,M6,M7,Spare (last 2 unused atm) -const uint16_t ACT_LOG_ENABLE = 3101; //Actuation,Logic -const uint16_t MISC_30V_ENABLE = 3102; //12V Board, Rockets, Auxiliary -const uint16_t VAC_ENABLE = 3103; //Vacuum -const uint16_t PATCH_ENABLE = 3104; //PB1,PB2,PB3,PB4,PB5,PB6,PB7,PB8 - - -//TIVA PIN MAPPINGS -//ANALOG PINS -//30V -#define RKT_ISENSE PE_4 -#define TWV_ISENSE PE_5 -#define AUX_ISENSE PD_3 -#define VAC_ISENSE PE_2 -#define M1_ISENSE PD_4 -#define M2_ISENSE PK_1 -#define M3_ISENSE PK_3 -#define M4_ISENSE PD_2 -#define M5_ISENSE PB_4 -#define M6_ISENSE PE_1 -//12V -#define LOG_ISENSE PD_7 -#define ACT_ISENSE PE_3 - -//TEMPORARY MAPPINGS BECAUSE I DID BAD -#define LOG_EN PA_6 -#define ACT_EN PD_7 -//end temp stuff - -//DIGITAL PINS -//Error LED -#define ERROR PB_3 -//30V -#define RKT_EN PB_2 -#define TWV_EN PC_6 -#define AUX_EN PC_7 -#define VAC_EN PC_5 -#define M1_EN PP_1 -#define M2_EN PD_5 -#define M3_EN PQ_0 -#define M4_EN PN_5 -#define M5_EN PP_0 -#define M6_EN PE_0 -//12V -//#define LOG_EN PM_4 -//#define ACT_EN PA_6 -#define VOUT_EN PM_5 -//Patch Panel -#define PB1_EN PL_3 -#define PB2_EN PF_3 -#define PB3_EN PL_2 -#define PB4_EN PG_0 -#define PB5_EN PL_1 -#define PB6_EN PL_4 -#define PB7_EN PL_0 -#define PB8_EN PL_5 - -//Current sense mapping values -const uint16_t ADCMin = 330; -const uint16_t ADCMax = 4095; -const uint16_t ISENSEMin = 0; -const uint16_t ISENSEMax = 40000; -const float CURR_SCALER = 1.15; - -//Overcurrent constants (amps) -const uint8_t OCP_MOTOR = 180; //temp fix due to inaccurate current readings on Motor busses -const uint8_t OCP_12V = 18; -const uint8_t OCP_30V = 18; -const uint8_t OCP_RKT = 4; -const uint8_t OCP_VAC = 13; -const uint16_t RESET_TIME = 5000; //ms between tripping OCP and turn on - - -struct Bus -{ - int EN_PIN; - int ISENSE_PIN = -1;//default for busses without ISENSE pins - bool enabled = false; - - Bus(const int en, const int isense) - { - EN_PIN = en; - ISENSE_PIN = isense; - pinMode(ISENSE_PIN,INPUT); - pinMode(EN_PIN,OUTPUT); - } - - Bus(const int en) - { - EN_PIN = en; - pinMode(EN_PIN,OUTPUT); - } - -}; - -Bus busses_Motor[6] = {Bus(M1_EN,M1_ISENSE),Bus(M2_EN,M2_ISENSE),Bus(M3_EN,M3_ISENSE),Bus(M4_EN,M4_ISENSE),Bus(M5_EN,M5_ISENSE),Bus(M6_EN,M6_ISENSE)}; -Bus busses_12V[3] = {Bus(ACT_EN,ACT_ISENSE),Bus(LOG_EN,LOG_ISENSE),Bus(VOUT_EN)}; -Bus busses_30V[3] = {Bus(TWV_EN,TWV_ISENSE),Bus(RKT_EN,RKT_ISENSE),Bus(AUX_EN,AUX_ISENSE)}; -Bus vac = Bus(VAC_EN,VAC_ISENSE); -//the last time in millis() when telemetry was sent -unsigned long lastTelemTime = 0; - - -void setup() { - Serial.begin(9600); - RoveComm.begin(RC_POWERBOARD_FOURTHOCTET, RC_ROVECOMM_ETHERNET_POWERBOARD_PORT); - delay(100); - Serial.println("Started"); - - //turning on all 30V busses - for(int i = 0; i < 3; i++) - { - digitalWrite(busses_30V[i].EN_PIN,HIGH); - busses_30V[i].enabled = true; - } - - //turning on all 12V busses - for(int i = 0; i < 3; i++) - { - digitalWrite(busses_12V[i].EN_PIN,HIGH); - busses_12V[i].enabled = true; - } - - //turning on the ACT bus as well - pinMode(PD_7, OUTPUT); - digitalWrite(PD_7, HIGH); - - delay(3000); - - //turning on all motor busses - for(int i = 0; i < 6; i++) - { - digitalWrite(busses_Motor[i].EN_PIN,HIGH); - busses_Motor[i].enabled = true; - } - delay(500); -} - -void loop() -{ - //read - packet = RoveComm.read(); - //Serial.println(packet.data_id); - - //Motor bus switches - switch(packet.data_id) - { - case RC_POWERBOARD_MOTOR_BUSENABLE_DATAID: - { - //expects data to be an array with a single uint8 - //checks each bit. Bit 0 is M1, bit 1 is M2, etc. - for(int i = 0; i < 6; i++) - { - if(packet.data[0] & 1<= OCP_MOTOR) - { - //disable bus - digitalWrite(busses_Motor[i].EN_PIN,LOW); - busses_Motor[i].enabled = false; - //save error - error_motor |= 1<= OCP_MOTOR) - { - //disable bus - digitalWrite(busses_12V[i].EN_PIN,LOW); - busses_12V[i].enabled = false; - //save error - error_12V |= 1<= OCP_MOTOR || (i==1 && curr_30V[i] >= OCP_RKT)) - { - //disable bus - digitalWrite(busses_30V[i].EN_PIN,LOW); - busses_30V[i].enabled = false; - //save error - error_30V |= 1<= OCP_VAC) - { - //disable bus - digitalWrite(vac.EN_PIN,LOW); - vac.enabled = false; - //save error - error_vac = true; - } - - - if(error_motor /*|| error_12V*/ || error_30V || error_vac) - { - //NEED ERROR LED ACTIVATION ONCE THE LED WORKS - if(error_motor) - { - RoveComm.write(RC_POWERBOARD_MOTOR_BUS_OVERCURRENT_DATAID, RC_POWERBOARD_MOTOR_BUS_OVERCURRENT_DATACOUNT, error_motor); - } - /* - if(error_12V) - { - RoveComm.write(RC_POWERBOARD_12V_BUS_OVERCURRENT_DATAID, RC_POWERBOARD_12V_BUS_OVERCURRENT_DATACOUNT, error_12V); - } - */ - if(error_30V) - { - RoveComm.write(RC_POWERBOARD_30V_BUS_OVERCURRENT_DATAID, RC_POWERBOARD_30V_BUS_OVERCURRENT_DATACOUNT, error_30V); - //check if the error is on Rockets - if(error_30V & 1<<1) - { - //wait, then reenable - delay(RESET_TIME); - digitalWrite(busses_30V[1].EN_PIN,HIGH); - busses_30V[1].enabled = true; - } - } - if(error_vac) - { - RoveComm.write(RC_POWERBOARD_VACUUM_OVERCURRENT_DATAID, RC_POWERBOARD_VACUUM_OVERCURRENT_DATACOUNT, error_motor); - } - } - - //send the telemetry at the specified rate - if((millis() - lastTelemTime) >= ROVECOMM_TELEM_RATE) - { - //write the telemetry as a batch - Serial.println("Sending telemetry"); - RoveComm.write(RC_POWERBOARD_MOTOR_BUS_CURRENT_DATAID, RC_POWERBOARD_MOTOR_BUS_CURRENT_DATACOUNT, curr_motor); - RoveComm.write(RC_POWERBOARD_MOTOR_BUSENABLED_DATAID, RC_POWERBOARD_MOTOR_BUSENABLED_DATACOUNT, en_motor); - RoveComm.write(RC_POWERBOARD_VACUUM_CURRENT_DATAID, RC_POWERBOARD_VACUUM_CURRENT_DATACOUNT, curr_vac); - RoveComm.write(RC_POWERBOARD_VACUUM_ENABLED_DATAID, RC_POWERBOARD_VACUUM_ENABLED_DATACOUNT, en_vac); - lastTelemTime = millis(); - } -} \ No newline at end of file diff --git a/powerboardcode/powerboard.cpp b/powerboardcode/powerboard.cpp new file mode 100644 index 0000000..19e4745 --- /dev/null +++ b/powerboardcode/powerboard.cpp @@ -0,0 +1,42 @@ +#include "powerboard.h" +void setup() { + + Serial.begin(9600); + setPins(); + setPinStates(); +} + +void loop() +{ + // put your main code here, to run repeatedly: + +} + +void setPins() +{ + + for (int i = 0 ; i < 4 ; i++) + { + pinMode(currentSense[i], OUTPUT); + } + + for (int i = 0 ; i < 10 ; i++) + { + pinMode(busses[i], INPUT); + pinMode(P_CurrentSense[i], OUTPUT); + } + + for (int i = 0 ; i < 9 ; i++) + { + pinMode(P_busses[i], OUTPUT); + } +} + +void setPinStates() +{ + // ONLY THESE FOR NOW BECAUSE THEY ARE THE ONLY FUNCTIONING ONES :) + for (int i = 3 ; i < 9 ; i++) + { + digitalWrite(busses[i], LOW); + } +} diff --git a/powerboardcode/powerboard.h b/powerboardcode/powerboard.h new file mode 100644 index 0000000..077e1d3 --- /dev/null +++ b/powerboardcode/powerboard.h @@ -0,0 +1,50 @@ + +#include "Energia.h" +//12V Current Sensing +#define AUX_MOUNT_SENSE PK3 +#define MULTIMEDIA_SENSE PK2 +#define LOW_CURRENT_SENSE PK1 +#define GIMBAL_SENSE PK0 + +//12V CTL +#define BUCKCTL PG_1 +#define MULTIMEDIA_LOG_CTL PK_5 +#define MULTIMEDIA_ACT_CTL PM_0 +#define AUX_LOG_CTL PM_1 +#define AUX_ACT_CTL PM_2 +#define GIMBAL_LOG_CTL PH_0 +#define GIMBAL_ACT_CTL PH_1 +#define NAV_BOARD_CTL PK_7 +#define CAM_CTL PP_3 +#define EXTRA_CTL PQ_1 +#define DRIVE_CTL PM_6 + +//PACK CURRENT +#define P_MOTOR1_SENSE PD_5 +#define P_MOTOR2_SENSE PD_4 +#define P_MOTOR3_SENSE PD_2 +#define P_MOTOR4_SENSE PD_3 +#define P_SPARE_SENSE PE_4 +#define P_ROCKET_SENSE PD_0 +#define P_TWELVE_SENSE PD_1 +#define P_VACUUM_SENSE PE_1 +#define P_DRIVE_SENSE PE_5 +#define P_AUX_SENSE PE_2 + +//PACK BUSSES +#define P_MOTOR1_CTL PQ_0 +#define P_MOTOR2_CTL PP_1 +#define P_MOTOR3_CTL PP_0 +#define P_MOTOR4_CTL PC_7 +#define P_SPARE_CTL PC_4 +#define P_ROCKET_CTL PN_2 +#define P_TWELVE_CTL PH_3 +#define P_VACUUM_CTL PE_0 +#define P_DRIVE_CTL PC_6 +#define P_AUX_CTL PE_3 + + +list currentSense = [ AUX_MOUNT_SENSE, MULTIMEDIA_SENSE, GIMBAL_SENSE, LOW_CURRENT_SENSE]; +list busses = [AUX_ACT_CTL, MULTIMEDIA_ACT_CTL, GIMBAL_ACT_CTL, BUCKCTL, AUX_LOG_CTL, MULTIMEDIA_LOG_CTL, GIMBAL_LOG_CTL, NAV_BOARD_CTL, CAM_CTL, EXTRA_CTL, DRIVE_CTL]; +list P_CurrentSense = [ P_MOTOR1_SENSE, P_MOTOR2_SENSE, P_MOTOR3_SENSE, P_MOTOR4_SENSE, P_SPARE_SENSE, P_ROCKET_SENSE, P_TWELVE_SENSE, P_VACUUM_SENSE, P_DRIVE_SENSE, P_AUX_SENSE]; +list P_busses = [P_MOTOR1_CTL, P_MOTOR2_CTL, P_MOTOR3_CTL, P_MOTOR4_CTL, P_SPARE_CTL, P_ROCKET_CTL, P_TWELVE_CTL, P_VACUUM_CTL, P_DRIVE_CTL, P_AUX_CTL]; \ No newline at end of file From 0f20f5162595007795d59c5924a908e53bb2976d Mon Sep 17 00:00:00 2001 From: boo25263 Date: Thu, 25 Feb 2021 00:47:33 -0600 Subject: [PATCH 02/10] fixed the header file fun fact: lists in c++ are not like python. don't do that :) --- powerboardcode/{ => powerboard}/powerboard.h | 16 ++++++++-------- .../powerboard.ino} | 7 ++++--- 2 files changed, 12 insertions(+), 11 deletions(-) rename powerboardcode/{ => powerboard}/powerboard.h (60%) rename powerboardcode/{powerboard.cpp => powerboard/powerboard.ino} (89%) diff --git a/powerboardcode/powerboard.h b/powerboardcode/powerboard/powerboard.h similarity index 60% rename from powerboardcode/powerboard.h rename to powerboardcode/powerboard/powerboard.h index 077e1d3..af5703d 100644 --- a/powerboardcode/powerboard.h +++ b/powerboardcode/powerboard/powerboard.h @@ -1,10 +1,10 @@ #include "Energia.h" //12V Current Sensing -#define AUX_MOUNT_SENSE PK3 -#define MULTIMEDIA_SENSE PK2 -#define LOW_CURRENT_SENSE PK1 -#define GIMBAL_SENSE PK0 +#define AUX_MOUNT_SENSE PK_3 +#define MULTIMEDIA_SENSE PK_2 +#define LOW_CURRENT_SENSE PK_1 +#define GIMBAL_SENSE PK_0 //12V CTL #define BUCKCTL PG_1 @@ -44,7 +44,7 @@ #define P_AUX_CTL PE_3 -list currentSense = [ AUX_MOUNT_SENSE, MULTIMEDIA_SENSE, GIMBAL_SENSE, LOW_CURRENT_SENSE]; -list busses = [AUX_ACT_CTL, MULTIMEDIA_ACT_CTL, GIMBAL_ACT_CTL, BUCKCTL, AUX_LOG_CTL, MULTIMEDIA_LOG_CTL, GIMBAL_LOG_CTL, NAV_BOARD_CTL, CAM_CTL, EXTRA_CTL, DRIVE_CTL]; -list P_CurrentSense = [ P_MOTOR1_SENSE, P_MOTOR2_SENSE, P_MOTOR3_SENSE, P_MOTOR4_SENSE, P_SPARE_SENSE, P_ROCKET_SENSE, P_TWELVE_SENSE, P_VACUUM_SENSE, P_DRIVE_SENSE, P_AUX_SENSE]; -list P_busses = [P_MOTOR1_CTL, P_MOTOR2_CTL, P_MOTOR3_CTL, P_MOTOR4_CTL, P_SPARE_CTL, P_ROCKET_CTL, P_TWELVE_CTL, P_VACUUM_CTL, P_DRIVE_CTL, P_AUX_CTL]; \ No newline at end of file +uint8_t currentSense[4] = { AUX_MOUNT_SENSE, MULTIMEDIA_SENSE, GIMBAL_SENSE, LOW_CURRENT_SENSE}; +uint8_t busses[11] = { AUX_ACT_CTL, MULTIMEDIA_ACT_CTL, GIMBAL_ACT_CTL, BUCKCTL, AUX_LOG_CTL, MULTIMEDIA_LOG_CTL, GIMBAL_LOG_CTL, NAV_BOARD_CTL, CAM_CTL, EXTRA_CTL, DRIVE_CTL}; +uint8_t P_CurrentSense[11] = { P_MOTOR1_SENSE, P_MOTOR2_SENSE, P_MOTOR3_SENSE, P_MOTOR4_SENSE, P_SPARE_SENSE, P_ROCKET_SENSE, P_TWELVE_SENSE, P_VACUUM_SENSE, P_DRIVE_SENSE, P_AUX_SENSE}; +uint8_t P_busses[10] = { P_MOTOR1_CTL, P_MOTOR2_CTL, P_MOTOR3_CTL, P_MOTOR4_CTL, P_SPARE_CTL, P_ROCKET_CTL, P_TWELVE_CTL, P_VACUUM_CTL, P_DRIVE_CTL, P_AUX_CTL}; \ No newline at end of file diff --git a/powerboardcode/powerboard.cpp b/powerboardcode/powerboard/powerboard.ino similarity index 89% rename from powerboardcode/powerboard.cpp rename to powerboardcode/powerboard/powerboard.ino index 19e4745..9584700 100644 --- a/powerboardcode/powerboard.cpp +++ b/powerboardcode/powerboard/powerboard.ino @@ -20,13 +20,13 @@ void setPins() pinMode(currentSense[i], OUTPUT); } - for (int i = 0 ; i < 10 ; i++) + for (int i = 0 ; i < 11 ; i++) { pinMode(busses[i], INPUT); pinMode(P_CurrentSense[i], OUTPUT); } - for (int i = 0 ; i < 9 ; i++) + for (int i = 0 ; i < 10 ; i++) { pinMode(P_busses[i], OUTPUT); } @@ -35,8 +35,9 @@ void setPins() void setPinStates() { // ONLY THESE FOR NOW BECAUSE THEY ARE THE ONLY FUNCTIONING ONES :) - for (int i = 3 ; i < 9 ; i++) + for (int i = 3 ; i < 10 ; i++) { digitalWrite(busses[i], LOW); } + } From 00fd87059c076bc97cc077db276d6843ee3ab3e7 Mon Sep 17 00:00:00 2001 From: amwcandy Date: Sat, 13 Mar 2021 20:20:48 -0600 Subject: [PATCH 03/10] started power board code --- powerboardcode/powerboard/powerboard.h | 18 ++++- powerboardcode/powerboard/powerboard.ino | 99 +++++++++++++++++------- 2 files changed, 84 insertions(+), 33 deletions(-) diff --git a/powerboardcode/powerboard/powerboard.h b/powerboardcode/powerboard/powerboard.h index af5703d..a05d066 100644 --- a/powerboardcode/powerboard/powerboard.h +++ b/powerboardcode/powerboard/powerboard.h @@ -1,5 +1,6 @@ #include "Energia.h" +#include "RoveComm.h" //12V Current Sensing #define AUX_MOUNT_SENSE PK_3 #define MULTIMEDIA_SENSE PK_2 @@ -43,8 +44,17 @@ #define P_DRIVE_CTL PC_6 #define P_AUX_CTL PE_3 +#define MOTOR_DELAY 30000 +#define DRIVE_DELAY 5000 + +uint8_t currentSense12V[4] = { AUX_MOUNT_SENSE, MULTIMEDIA_SENSE, GIMBAL_SENSE, LOW_CURRENT_SENSE}; +uint8_t busses12V[11] = { AUX_ACT_CTL, DRIVE_CTL, MULTIMEDIA_ACT_CTL, GIMBAL_ACT_CTL, BUCKCTL, AUX_LOG_CTL, MULTIMEDIA_LOG_CTL, GIMBAL_LOG_CTL, NAV_BOARD_CTL, CAM_CTL, EXTRA_CTL}; +uint8_t drivePack = P_DRIVE_CTL; +uint8_t currentSensePack[11] = { P_MOTOR1_SENSE, P_MOTOR2_SENSE, P_MOTOR3_SENSE, P_MOTOR4_SENSE, P_SPARE_SENSE, P_ROCKET_SENSE, P_TWELVE_SENSE, P_VACUUM_SENSE, P_DRIVE_SENSE, P_AUX_SENSE}; +uint8_t bussesPack[4] = { P_ROCKET_CTL, P_TWELVE_CTL, P_VACUUM_CTL, P_AUX_CTL}; +uint8_t bussesMotor[5] = {P_MOTOR1_CTL, P_MOTOR2_CTL, P_MOTOR3_CTL, P_MOTOR4_CTL, P_SPARE_CTL}; + +RoveCommEthernet RoveComm; +rovecomm_packet packet; +EthernetServer TCPServer(RC_ROVECOMM_POWERBOARD_PORT); -uint8_t currentSense[4] = { AUX_MOUNT_SENSE, MULTIMEDIA_SENSE, GIMBAL_SENSE, LOW_CURRENT_SENSE}; -uint8_t busses[11] = { AUX_ACT_CTL, MULTIMEDIA_ACT_CTL, GIMBAL_ACT_CTL, BUCKCTL, AUX_LOG_CTL, MULTIMEDIA_LOG_CTL, GIMBAL_LOG_CTL, NAV_BOARD_CTL, CAM_CTL, EXTRA_CTL, DRIVE_CTL}; -uint8_t P_CurrentSense[11] = { P_MOTOR1_SENSE, P_MOTOR2_SENSE, P_MOTOR3_SENSE, P_MOTOR4_SENSE, P_SPARE_SENSE, P_ROCKET_SENSE, P_TWELVE_SENSE, P_VACUUM_SENSE, P_DRIVE_SENSE, P_AUX_SENSE}; -uint8_t P_busses[10] = { P_MOTOR1_CTL, P_MOTOR2_CTL, P_MOTOR3_CTL, P_MOTOR4_CTL, P_SPARE_CTL, P_ROCKET_CTL, P_TWELVE_CTL, P_VACUUM_CTL, P_DRIVE_CTL, P_AUX_CTL}; \ No newline at end of file diff --git a/powerboardcode/powerboard/powerboard.ino b/powerboardcode/powerboard/powerboard.ino index 9584700..b6d56db 100644 --- a/powerboardcode/powerboard/powerboard.ino +++ b/powerboardcode/powerboard/powerboard.ino @@ -1,43 +1,84 @@ #include "powerboard.h" -void setup() { - - Serial.begin(9600); - setPins(); - setPinStates(); +void setup() +{ + Serial.begin(9600); + setPins(); + setPinStates(); + Serial.begin(9600); + RoveComm.begin(RC_POWERBOARD_FOURTHOCTET, &TCPServer); + delay(100); } void loop() { - // put your main code here, to run repeatedly: - + packet = RoveComm.read(); + if(packet.data_id != 0) + { + switch(packet.data_id) + { + case RC_POWERBOARD_MOTORBUSENABLE_DATA_ID: + break; + case RC_POWERBOARD_12VACTBUSENABLE_DATA_ID: + break; + case RC_POWERBOARD_12VLOGICBUSENABLE_DATA_ID: + break; + case RC_POWERBOARD_30VBUSENABLE_DATA_ID: + break; + case RC_POWERBOARD_VACUUMENABLE_DATA_ID: + break; + } + } + } void setPins() { - - for (int i = 0 ; i < 4 ; i++) - { - pinMode(currentSense[i], OUTPUT); - } - - for (int i = 0 ; i < 11 ; i++) - { - pinMode(busses[i], INPUT); - pinMode(P_CurrentSense[i], OUTPUT); - } - - for (int i = 0 ; i < 10 ; i++) - { - pinMode(P_busses[i], OUTPUT); - } + // sets input/output of pack busses and 12V current sense + for (int i = 0 ; i < 4 ; i++) + { + pinMode(currentSense12V[i], INPUT); + pinMode(bussesPack[i], OUTPUT); + } + // sets input/output of pack current sense and 12V busses + for (int i = 0 ; i < 11 ; i++) + { + pinMode(currentSensePack[i], INPUT); + pinMode(busses12V[i], OUTPUT); + } + // sets output of motor busses + for (int i = 0 ; i < 5 ; i++) + { + pinMode(bussesMotor[i], OUTPUT); + } + pinMode(drivePack, OUTPUT); } void setPinStates() { - // ONLY THESE FOR NOW BECAUSE THEY ARE THE ONLY FUNCTIONING ONES :) - for (int i = 3 ; i < 10 ; i++) - { - digitalWrite(busses[i], LOW); - } - + // turn on 12 volt busses + for (int i = 0 ; i < 11 ; i++) + { + digitalWrite(busses12V[i], HIGH); + } + // turns off motor busses + for (int i = 0 ; i < 5 ; i++) + { + digitalWrite(bussesMotor[i], LOW); + } + // turns on Pack busses + for (int i = 0 ; i < 4 ; i++) + { + digitalWrite(bussesPack[i], HIGH); + } + //turns off pack drive board bus + digitalWrite(drivePack, LOW); + delay(MOTOR_DELAY); + // turns on motor busses after a delay + for (int i = 0 ; i < 5 ; i++) + { + digitalWrite(bussesMotor[i], HIGH); + } + delay(DRIVE_DELAY); + // turns on pack drive bus + digitalWrite(drivePack, HIGH); } From 187d2cf2dc913cfcec7889bfe1dea64118c1ec8c Mon Sep 17 00:00:00 2001 From: amwcandy <70861002+amwcandy@users.noreply.github.com> Date: Tue, 6 Apr 2021 00:38:30 -0500 Subject: [PATCH 04/10] Started things 12V logic should be able to turn on and off --- powerboardcode/powerboard/powerboard.h | 8 +++--- powerboardcode/powerboard/powerboard.ino | 35 +++++++++++++++++++++--- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/powerboardcode/powerboard/powerboard.h b/powerboardcode/powerboard/powerboard.h index a05d066..022d8fc 100644 --- a/powerboardcode/powerboard/powerboard.h +++ b/powerboardcode/powerboard/powerboard.h @@ -8,7 +8,6 @@ #define GIMBAL_SENSE PK_0 //12V CTL -#define BUCKCTL PG_1 #define MULTIMEDIA_LOG_CTL PK_5 #define MULTIMEDIA_ACT_CTL PM_0 #define AUX_LOG_CTL PM_1 @@ -44,13 +43,14 @@ #define P_DRIVE_CTL PC_6 #define P_AUX_CTL PE_3 -#define MOTOR_DELAY 30000 +#define MOTOR_DELAY 5000 #define DRIVE_DELAY 5000 uint8_t currentSense12V[4] = { AUX_MOUNT_SENSE, MULTIMEDIA_SENSE, GIMBAL_SENSE, LOW_CURRENT_SENSE}; -uint8_t busses12V[11] = { AUX_ACT_CTL, DRIVE_CTL, MULTIMEDIA_ACT_CTL, GIMBAL_ACT_CTL, BUCKCTL, AUX_LOG_CTL, MULTIMEDIA_LOG_CTL, GIMBAL_LOG_CTL, NAV_BOARD_CTL, CAM_CTL, EXTRA_CTL}; +uint8_t actuation12V[3] = { AUX_ACT_CTL, MULTIMEDIA_ACT_CTL, GIMBAL_ACT_CTL}; +uint8_t logic12V[7] = {DRIVE_CTL, AUX_LOG_CTL, MULTIMEDIA_LOG_CTL, GIMBAL_LOG_CTL, NAV_BOARD_CTL, CAM_CTL, EXTRA_CTL}; uint8_t drivePack = P_DRIVE_CTL; -uint8_t currentSensePack[11] = { P_MOTOR1_SENSE, P_MOTOR2_SENSE, P_MOTOR3_SENSE, P_MOTOR4_SENSE, P_SPARE_SENSE, P_ROCKET_SENSE, P_TWELVE_SENSE, P_VACUUM_SENSE, P_DRIVE_SENSE, P_AUX_SENSE}; +uint8_t currentSensePack[10] = { P_MOTOR1_SENSE, P_MOTOR2_SENSE, P_MOTOR3_SENSE, P_MOTOR4_SENSE, P_SPARE_SENSE, P_ROCKET_SENSE, P_TWELVE_SENSE, P_VACUUM_SENSE, P_DRIVE_SENSE, P_AUX_SENSE}; uint8_t bussesPack[4] = { P_ROCKET_CTL, P_TWELVE_CTL, P_VACUUM_CTL, P_AUX_CTL}; uint8_t bussesMotor[5] = {P_MOTOR1_CTL, P_MOTOR2_CTL, P_MOTOR3_CTL, P_MOTOR4_CTL, P_SPARE_CTL}; diff --git a/powerboardcode/powerboard/powerboard.ino b/powerboardcode/powerboard/powerboard.ino index b6d56db..f70c79a 100644 --- a/powerboardcode/powerboard/powerboard.ino +++ b/powerboardcode/powerboard/powerboard.ino @@ -21,6 +21,25 @@ void loop() case RC_POWERBOARD_12VACTBUSENABLE_DATA_ID: break; case RC_POWERBOARD_12VLOGICBUSENABLE_DATA_ID: + // Bit 0 is Drive control, Bit 1 is Auxilary logic control, Bit 2 is Multimedia logic control + // Bit 3 is Gimbal logic control, Bit 4 is Navigation control, Bit 5 is Camera control + // Bit 6 is Extra control + Serial.printIn("Enable/Disable 12V Logic Busses"); + for(int i = 0; i < 7; i++) + { + if (packet.data[0] & 1< Date: Sat, 10 Apr 2021 17:02:25 -0500 Subject: [PATCH 05/10] Update powerboard.ino --- powerboardcode/powerboard/powerboard.ino | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/powerboardcode/powerboard/powerboard.ino b/powerboardcode/powerboard/powerboard.ino index f70c79a..7c77183 100644 --- a/powerboardcode/powerboard/powerboard.ino +++ b/powerboardcode/powerboard/powerboard.ino @@ -24,19 +24,19 @@ void loop() // Bit 0 is Drive control, Bit 1 is Auxilary logic control, Bit 2 is Multimedia logic control // Bit 3 is Gimbal logic control, Bit 4 is Navigation control, Bit 5 is Camera control // Bit 6 is Extra control - Serial.printIn("Enable/Disable 12V Logic Busses"); + Serial.println("Enable/Disable 12V Logic Busses"); for(int i = 0; i < 7; i++) { if (packet.data[0] & 1< Date: Fri, 30 Apr 2021 22:50:42 -0500 Subject: [PATCH 06/10] Enabled toggling of busses --- powerboardcode/powerboard/powerboard.h | 8 +- powerboardcode/powerboard/powerboard.ino | 108 +++++++++++++++++++++-- 2 files changed, 106 insertions(+), 10 deletions(-) diff --git a/powerboardcode/powerboard/powerboard.h b/powerboardcode/powerboard/powerboard.h index 022d8fc..056bbb3 100644 --- a/powerboardcode/powerboard/powerboard.h +++ b/powerboardcode/powerboard/powerboard.h @@ -47,11 +47,13 @@ #define DRIVE_DELAY 5000 uint8_t currentSense12V[4] = { AUX_MOUNT_SENSE, MULTIMEDIA_SENSE, GIMBAL_SENSE, LOW_CURRENT_SENSE}; -uint8_t actuation12V[3] = { AUX_ACT_CTL, MULTIMEDIA_ACT_CTL, GIMBAL_ACT_CTL}; -uint8_t logic12V[7] = {DRIVE_CTL, AUX_LOG_CTL, MULTIMEDIA_LOG_CTL, GIMBAL_LOG_CTL, NAV_BOARD_CTL, CAM_CTL, EXTRA_CTL}; +uint8_t actuation12V[3] = { GIMBAL_ACT_CTL, MULTIMEDIA_ACT_CTL, AUX_ACT_CTL}; +uint8_t logic12V[7] = {GIMBAL_LOG_CTL, MULTIMEDIA_LOG_CTL, AUX_LOG_CTL, DRIVE_CTL, NAV_BOARD_CTL, CAM_CTL, EXTRA_CTL}; uint8_t drivePack = P_DRIVE_CTL; uint8_t currentSensePack[10] = { P_MOTOR1_SENSE, P_MOTOR2_SENSE, P_MOTOR3_SENSE, P_MOTOR4_SENSE, P_SPARE_SENSE, P_ROCKET_SENSE, P_TWELVE_SENSE, P_VACUUM_SENSE, P_DRIVE_SENSE, P_AUX_SENSE}; -uint8_t bussesPack[4] = { P_ROCKET_CTL, P_TWELVE_CTL, P_VACUUM_CTL, P_AUX_CTL}; +uint8_t bussesPackStart[3] = { P_ROCKET_CTL, P_TWELVE_CTL, P_AUX_CTL}; +uint8_t bussesPack[4] = { P_TWELVE_CTL, P_ROCKET_CTL, P_AUX_CTL, P_DRIVE_CTL}; +uint8_t vacuumCtrl = P_VACUUM_CTL; uint8_t bussesMotor[5] = {P_MOTOR1_CTL, P_MOTOR2_CTL, P_MOTOR3_CTL, P_MOTOR4_CTL, P_SPARE_CTL}; RoveCommEthernet RoveComm; diff --git a/powerboardcode/powerboard/powerboard.ino b/powerboardcode/powerboard/powerboard.ino index 7c77183..2ae0252 100644 --- a/powerboardcode/powerboard/powerboard.ino +++ b/powerboardcode/powerboard/powerboard.ino @@ -17,13 +17,42 @@ void loop() switch(packet.data_id) { case RC_POWERBOARD_MOTORBUSENABLE_DATA_ID: + Serial.println("Enable/Disable Motor Busses"); + for(int i = 0; i < 5; i++) + { + if (packet.data[0] & 1< Date: Fri, 30 Apr 2021 23:10:50 -0500 Subject: [PATCH 07/10] Fixed compile errors that I forgot to check for last push --- powerboardcode/powerboard/powerboard.h | 2 +- powerboardcode/powerboard/powerboard.ino | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/powerboardcode/powerboard/powerboard.h b/powerboardcode/powerboard/powerboard.h index 056bbb3..4829e4f 100644 --- a/powerboardcode/powerboard/powerboard.h +++ b/powerboardcode/powerboard/powerboard.h @@ -53,7 +53,7 @@ uint8_t drivePack = P_DRIVE_CTL; uint8_t currentSensePack[10] = { P_MOTOR1_SENSE, P_MOTOR2_SENSE, P_MOTOR3_SENSE, P_MOTOR4_SENSE, P_SPARE_SENSE, P_ROCKET_SENSE, P_TWELVE_SENSE, P_VACUUM_SENSE, P_DRIVE_SENSE, P_AUX_SENSE}; uint8_t bussesPackStart[3] = { P_ROCKET_CTL, P_TWELVE_CTL, P_AUX_CTL}; uint8_t bussesPack[4] = { P_TWELVE_CTL, P_ROCKET_CTL, P_AUX_CTL, P_DRIVE_CTL}; -uint8_t vacuumCtrl = P_VACUUM_CTL; +uint8_t vacuumCtrl[1] = {P_VACUUM_CTL}; uint8_t bussesMotor[5] = {P_MOTOR1_CTL, P_MOTOR2_CTL, P_MOTOR3_CTL, P_MOTOR4_CTL, P_SPARE_CTL}; RoveCommEthernet RoveComm; diff --git a/powerboardcode/powerboard/powerboard.ino b/powerboardcode/powerboard/powerboard.ino index 2ae0252..88d70ea 100644 --- a/powerboardcode/powerboard/powerboard.ino +++ b/powerboardcode/powerboard/powerboard.ino @@ -90,17 +90,17 @@ void loop() break; case RC_POWERBOARD_VACUUMENABLE_DATA_ID: Serial.println("Enable/Disable Vacuum Busses"); - if (packet.data == 1) + if (packet.data[0] == 1) { Serial.println("Enabling Bus:"); - Serial.println(i); - digitalWrite(logic12V[i], HIGH); + Serial.println(0); + digitalWrite(vacuumCtrl[0], HIGH); } else { Serial.println("Disabling Bus:"); - Serial.println(i); - digitalWrite(logic12V[i], LOW); + Serial.println(0); + digitalWrite(vacuumCtrl[0], LOW); } break; } @@ -157,7 +157,7 @@ void setPinStates() } //turns off pack drive board bus digitalWrite(drivePack, LOW); - digitalWrite(vacuumCtrl, LOW); + digitalWrite(vacuumCtrl[0], LOW); delay(MOTOR_DELAY); // turns on motor busses after a delay for (int i = 0 ; i < 5 ; i++) From 39d0115f85a15c6660ec59a05e8ecc7686b495b5 Mon Sep 17 00:00:00 2001 From: amwcandy Date: Fri, 14 May 2021 16:44:17 -0500 Subject: [PATCH 08/10] corrected an error in pin defines --- powerboardcode/powerboard/powerboard.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerboardcode/powerboard/powerboard.h b/powerboardcode/powerboard/powerboard.h index 4829e4f..5e15ccd 100644 --- a/powerboardcode/powerboard/powerboard.h +++ b/powerboardcode/powerboard/powerboard.h @@ -29,7 +29,7 @@ #define P_TWELVE_SENSE PD_1 #define P_VACUUM_SENSE PE_1 #define P_DRIVE_SENSE PE_5 -#define P_AUX_SENSE PE_2 +#define P_AUX_SENSE PE_3 //PACK BUSSES #define P_MOTOR1_CTL PQ_0 @@ -41,7 +41,7 @@ #define P_TWELVE_CTL PH_3 #define P_VACUUM_CTL PE_0 #define P_DRIVE_CTL PC_6 -#define P_AUX_CTL PE_3 +#define P_AUX_CTL PE_2 #define MOTOR_DELAY 5000 #define DRIVE_DELAY 5000 From f36167548e4f2387448fdfd34849ff1a60fcb2e1 Mon Sep 17 00:00:00 2001 From: Max Ryan <70597225+MaxR-mrdt@users.noreply.github.com> Date: Sat, 15 May 2021 18:11:18 -0500 Subject: [PATCH 09/10] alex changed code, I am pushing. Vacuum pinstate function added? --- powerboardcode/powerboard/powerboard.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/powerboardcode/powerboard/powerboard.ino b/powerboardcode/powerboard/powerboard.ino index 88d70ea..5d7f420 100644 --- a/powerboardcode/powerboard/powerboard.ino +++ b/powerboardcode/powerboard/powerboard.ino @@ -136,6 +136,7 @@ void setPins() pinMode(logic12V[i], OUTPUT); } pinMode(drivePack, OUTPUT); + pinMode(vacuumCtrl[0], OUTPUT) } void setPinStates() From 5aedbf4d99e59cefebe9fc8ad709ce885a7527a5 Mon Sep 17 00:00:00 2001 From: boo25263 Date: Sat, 15 May 2021 21:04:46 -0500 Subject: [PATCH 10/10] added a semicolon --- powerboardcode/powerboard/powerboard.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerboardcode/powerboard/powerboard.ino b/powerboardcode/powerboard/powerboard.ino index 5d7f420..b7721ef 100644 --- a/powerboardcode/powerboard/powerboard.ino +++ b/powerboardcode/powerboard/powerboard.ino @@ -136,7 +136,7 @@ void setPins() pinMode(logic12V[i], OUTPUT); } pinMode(drivePack, OUTPUT); - pinMode(vacuumCtrl[0], OUTPUT) + pinMode(vacuumCtrl[0], OUTPUT); } void setPinStates()