Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Revision 1:bc3509459a27, committed 2022-12-06
- Comitter:
- Slord2142
- Date:
- Tue Dec 06 18:47:01 2022 +0000
- Parent:
- 0:b3410a1e9843
- Commit message:
- Helix commit 1
Changed in this revision
--- a/inc/adc_defs.h Thu Jan 27 21:58:14 2022 +0000 +++ b/inc/adc_defs.h Tue Dec 06 18:47:01 2022 +0000 @@ -34,9 +34,9 @@ const unsigned int ADC_SCALE_FACTOR = ADC_MAX_VALUE/2; #define VOLTAGE_TARG_VALUE 1.65 -#define VOLTAGE_48_ACTUAL_VALUE 1.51 +#define VOLTAGE_48_ACTUAL_VALUE 1.65 #define VOLTAGE_24_ACTUAL_VALUE 1.55 -#define VOLTAGE_12_ACTUAL_VALUE 1.53 +#define VOLTAGE_12_ACTUAL_VALUE 1.6668 const double VOLTAGE_48_CORRECTION = VOLTAGE_TARG_VALUE/VOLTAGE_48_ACTUAL_VALUE/ADC_SCALE_FACTOR; const double VOLTAGE_24_CORRECTION = VOLTAGE_TARG_VALUE/VOLTAGE_24_ACTUAL_VALUE/ADC_SCALE_FACTOR; const double VOLTAGE_12_CORRECTION = VOLTAGE_TARG_VALUE/VOLTAGE_12_ACTUAL_VALUE/ADC_SCALE_FACTOR; @@ -82,12 +82,12 @@ //#define CURRENT_12_DIV_FACTOR1 -440 //#define CURRENT_12_DIV_FACTOR0 -535 -#define CURRENT_12_DIV_FACTOR5 -188 -#define CURRENT_12_DIV_FACTOR4 -186 -#define CURRENT_12_DIV_FACTOR3 -182 -#define CURRENT_12_DIV_FACTOR2 -177 -#define CURRENT_12_DIV_FACTOR1 -179 -#define CURRENT_12_DIV_FACTOR0 -175 +#define CURRENT_12_DIV_FACTOR5 121.81 +#define CURRENT_12_DIV_FACTOR4 120.53 +#define CURRENT_12_DIV_FACTOR3 117.94 +#define CURRENT_12_DIV_FACTOR2 114.7 +#define CURRENT_12_DIV_FACTOR1 116 +#define CURRENT_12_DIV_FACTOR0 113.4 #define CURRENT_12_DIV_THRESH5 1600 #define CURRENT_12_DIV_THRESH4 800
--- a/inc/clocks.h Thu Jan 27 21:58:14 2022 +0000 +++ b/inc/clocks.h Tue Dec 06 18:47:01 2022 +0000 @@ -40,12 +40,13 @@ void initOut(void); //void flipSlow(void); //void flipFast(void); -//void checkFlip(void); +void checkFlip(void); //void slowFlip(); //void fastFlip(); //void progress(); void ILR(); void setClocks(int num); +unsigned int numOn; extern volatile bool dosFlip; extern volatile bool dofFlip;
--- a/inc/globals.h Thu Jan 27 21:58:14 2022 +0000
+++ b/inc/globals.h Tue Dec 06 18:47:01 2022 +0000
@@ -71,10 +71,10 @@
#define LEVEL_MAIN 0
struct adcValues{
- unsigned short v48;
- unsigned short v12;
- unsigned short i12;
- unsigned short test_v;
+ double v48;
+ double v12;
+ double i12;
+ double test_v;
};
struct statusValues{
--- a/src/adc.cpp Thu Jan 27 21:58:14 2022 +0000
+++ b/src/adc.cpp Tue Dec 06 18:47:01 2022 +0000
@@ -45,10 +45,10 @@
*******************************************************************************/
struct adcValues getADCresults(void){
- unsigned int v48x = 0;
- unsigned int v12x = 0;
- unsigned int i12x = 0;
- unsigned int test_vx = 0;
+ double v48x = 0;
+ double v12x = 0;
+ double i12x = 0;
+ double test_vx = 0;
struct adcValues avals;
unsigned int loopCounter = LOOP_COUNTER;
--- a/src/clocks.cpp Thu Jan 27 21:58:14 2022 +0000
+++ b/src/clocks.cpp Tue Dec 06 18:47:01 2022 +0000
@@ -30,6 +30,7 @@
#include "all_io.h"
//#include "menu.h"
unsigned short i;
+unsigned int numOn;
int enkey[6] = {2, 1, 1, 1, 1, 1};
@@ -54,9 +55,10 @@
en8 = 1;
en16 = 1;
en32 = 1;*/
- for(i = 0; i < 6; i++){
+ for(i = 0; i < 5; i++){
en[i] = 1;
}
+ en[5] = 0;
}
/*
void flipSlow(void){
@@ -142,9 +144,11 @@
}
void setClocks(int num){
+ numOn = num;
if (num == 32 or enable == TRUE){
en[5] = 1;
} else {
+ en[5] = 0;
if (num >= 16) {
en[4] = 1;
num = num - 16;
@@ -175,4 +179,7 @@
en[0] = 0;
}
}
+ WR = 1;
+ wait_us(250);
+ WR = 0;
}
--- a/src/command.cpp Thu Jan 27 21:58:14 2022 +0000
+++ b/src/command.cpp Tue Dec 06 18:47:01 2022 +0000
@@ -34,6 +34,7 @@
#include "math.h"
#include "parameters.h"
#include "all_io.h"
+#include "adc.h"
//#include "calibrate.h"
#include "boards.h"
#include "menu.h"
@@ -554,6 +555,19 @@
max_boards = commandData;
}
}
+ else if (!strcmp(commandString, "ZERO"))
+ // Used to zero out the board amperage measurements
+ {
+ if (running == 1)
+ {
+ sprintf(strbuf, " Parameters may not be updated while running!");
+ sendSerial(strbuf);
+ }
+ else
+ {
+ initADC();
+ }
+ }
else if (!strcmp(commandString, "BRDS"))
// BRDS is used to get/set the wr_out value.
// The integer value of boardsActive is used to change wr_out via setBoardEnables(boardsActive).
--- a/src/main.cpp Thu Jan 27 21:58:14 2022 +0000
+++ b/src/main.cpp Tue Dec 06 18:47:01 2022 +0000
@@ -74,7 +74,7 @@
double CURRENT_48_OFFSET = 33940;
double CURRENT_24_OFFSET = 33580;
-double CURRENT_12_OFFSET = 33256;
+double CURRENT_12_OFFSET = 57700;
float temperatureVal;
@@ -97,7 +97,7 @@
int main() {
- if(MS){ //New for 1U5
+ /*if(MS){ //New for 1U5
#ifdef IS_MASTER
master = TRUE;
#endif
@@ -110,12 +110,13 @@
slave1 = FALSE;
slave2 = TRUE;
#endif
- }
+ }*/
//Slave_Init();
initOut();
- //Serial dcm2(PC_10, PC_11);
+ //Serial dcm2(PC_10, PC_11, 9600);
+ //char storage;
fan_pwm.period(1.0f);
//slowClk.attach_us(&slowFlip, CLK_SLOW);
@@ -156,6 +157,9 @@
menuRedraw(WITH_PROMPT);
initBoards(adcVals);
+
+ en_out_code = 2;
+ setClocks(en_out_code);
while (1)
{
@@ -174,12 +178,24 @@
processCommand();
+ //dcm2.printf("Hello?");
/*if(dcm2.readable()) {
- char storage = dcm2.getc();
+ storage = dcm2.getc();
storage += 1;
dcm2.putc(storage);
}*/
+ /*char men = 'm';
+ char bor = 'b';
+ if (dcm2.readable()) {
+ storage = dcm2.getc();
+ if (storage == men) {
+ dcm2.printf("This is the demo menu.\n");
+ } else if (storage == bor) {
+ dcm2.printf(" %d\n", boardsActive);
+ }
+ }*/
+
// Select RUN from menu to activate running mode.
// BRDS, MULT activate testing mode. MY12 emulates running mode wthout being in running mode.
// CAL and UNCAL do not change state of running or testing.
@@ -191,40 +207,41 @@
buck = FALSE;
}
row_test = abs((int)(row-old_row));
-
- if(updateReady && pcConnected){
+ //updateTerminal(adcVals, statVals);
+ if(updateReady){
updateReady = FALSE;
updateTerminal(adcVals, statVals); // May want to gate this call when we run a headless system.
}
#endif
- //checkFlip();
- //if(running && master){ //New for 1U5
+ /*checkFlip();
+ if(running && master){ //New for 1U5
//The current sensors results are single-ended. Results below the midpoint are for buck mode, above is for boost mode.
- //if(row_test>ROW_HYSTERESIS){
- //old_row = row;
- //if(row<=1023){
- //slave_code = updateMasterControls(row); //New for 1U5
- //sendSlaveCommands(slave_code); //New for 1U5
- //}
+ if(row_test>ROW_HYSTERESIS){
+ old_row = row;
+ if(row<=1023){
+ slave_code = updateMasterControls(row); //New for 1U5
+ sendSlaveCommands(slave_code); //New for 1U5
+ }
+ }
+ }
+ else if(running && !master){ //New for 1U5
+ new_slave_code = getMasterCommands(); //New for 1U5
+ if(new_slave_code != slave_code){
+ slave_code = new_slave_code;
+ updateSlaveControls(slave_code); //New for 1U5
//}
- //else if(running && !master){ //New for 1U5
- //new_slave_code = getMasterCommands(); //New for 1U5
- //if(new_slave_code != slave_code){
- //slave_code = new_slave_code;
- //updateSlaveControls(slave_code); //New for 1U5
- //}
- //}
- //}else if(!testing){
- //row_test = abs((int)(my12-old_row));
- //if(row_test>ROW_HYSTERESIS){
- //old_row = my12;
- //if(row<=1023){
- //updateMasterControls(my12);
- //}
- //}
- //numFast = 36;
- //}
+ }
+ }else if(!testing){
+ row_test = abs((int)(my12-old_row));
+ if(row_test>ROW_HYSTERESIS){
+ old_row = my12;
+ if(row<=1023){
+ updateMasterControls(my12);
+ }
+ }
+ numFast = 36;
+ }*/
}//end while(1)
}//end void main(void)
\ No newline at end of file
--- a/src/menu.cpp Thu Jan 27 21:58:14 2022 +0000
+++ b/src/menu.cpp Tue Dec 06 18:47:01 2022 +0000
@@ -32,6 +32,7 @@
#include "stdlib.h"
#include "lut.h"
#include "temp.h"
+#include "clocks.h"
Ticker drt;
unsigned int oldTime=0;
@@ -133,7 +134,7 @@
struct displayValues dvals = calcDisplayValues(adcVals);
- double pwr_out=dvals.v12f*dvals.i12f;
+ //double pwr_out=dvals.v12f*dvals.i12f;
//double pwr_in=dvals.v48f*(dvals.i48f);
//double pwr_eff=100*pwr_out/pwr_in;
@@ -146,6 +147,8 @@
sprintf(strbuf, "V48=%2.1f | V12=%2.1f, I12=%3.2f | Temp=%f | Test=%2.1f \r\n", dvals.v48f, dvals.v12f, dvals.i12f, temp_reading, dvals.test_v);
//sprintf(strbuf, "V48=%2.1f, I48=%2.2f | V24=%2.1f, I24=%2.2f | V12=%2.1f, I12=%2.2f || loop=%d \r\n", v48f, i48f, v24f, i24f, v12f, i12f, loopTime);
sendSerial(strbuf);
+ sprintf(strbuf, "NumOn=%d \r\n", numOn);
+ sendSerial(strbuf);
//sprintf(strbuf, "adcVals.i12 = %d \r\n", adcVals.i12);
//sendSerial(strbuf);
//sprintf(strbuf, "Power Out = %4.1f W, Power In = %4.1f W \r\n", pwr_out, pwr_in);
--- a/src/serial.cpp Thu Jan 27 21:58:14 2022 +0000 +++ b/src/serial.cpp Tue Dec 06 18:47:01 2022 +0000 @@ -16,9 +16,9 @@ // set up serial port for 115200 baud -//Serial dcm1(USBTX, USBRX, 115200); +Serial dcm1(USBTX, USBRX, 115200); //Serial dcm1(USBTX, USBRX, 921600); -Serial dcm1(PC_10, PC_11, 115200); +//Serial dcm1(PA_2, PA_3, 921600); // initialize the serial port variables