diff options
-rw-r--r-- | Arduino/main.c/main.c.ino | 43 | ||||
-rw-r--r-- | build/default/debug/main.o | bin | 9044 -> 9380 bytes | |||
-rw-r--r-- | build/default/debug/mcc_generated_files/mssp2_i2c.o | bin | 19500 -> 19896 bytes | |||
-rw-r--r-- | build/default/production/main.o | bin | 8920 -> 0 bytes | |||
-rw-r--r-- | build/default/production/main.o.d | 6 | ||||
-rw-r--r-- | dist/default/production/memoryfile.xml | 4 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | mcc_generated_files/mssp2_i2c.c | 52 | ||||
-rw-r--r-- | mcc_generated_files/mssp2_i2c.h | 3 | ||||
-rw-r--r-- | nbproject/Makefile-genesis.properties | 2 |
10 files changed, 51 insertions, 63 deletions
diff --git a/Arduino/main.c/main.c.ino b/Arduino/main.c/main.c.ino index c527c33..8f651b9 100644 --- a/Arduino/main.c/main.c.ino +++ b/Arduino/main.c/main.c.ino @@ -1,7 +1,8 @@ #include <Wire.h> -double VOLTAGE, P68, P150; -double temp, load = 0; +bool percentageLoad = false; +double VOLTAGE, P68, P150, PTotal; +double temp, currentLoad, load = 0; uint8_t Q68, Q150; bool new_message = false; @@ -16,14 +17,36 @@ void setup() Serial.println(VOLTAGE, DEC); P150 = (VOLTAGE * VOLTAGE) / 150; P68 = (VOLTAGE * VOLTAGE) / 68; - Serial.println("Enter Load in kW:"); + PTotal = P150+P68; + + String input = "null"; + Serial.println("Express load as a percentage? (y/n)"); + while ((Serial.available() == 0)||(input!="y")||(input!="n")) + { + input = Serial.readString(); + input.trim(); + } + if(input=="y") + { + percentageLoad=true; + Serial.print("Enter Load as a percentage of "); + Serial.println(PTotal, DEC); + } + else + { + percentageLoad=false; + Serial.println("Enter Load in kW:"); + } } void loop() { - new_message = false; Serial.flush(); - if (Serial.available())temp = Serial.parseFloat(SKIP_ALL) * 1000; + if (Serial.available()) + { + if(percentageLoad) temp = Serial.parseFloat(SKIP_ALL) * 1000; + else temp = Serial.parseFloat(SKIP_ALL) * (PTotal/100.0); + } if ((temp != load) && (temp > 0)) { @@ -59,13 +82,21 @@ void loop() if (new_message == true) { delay(25); - Wire.requestFrom(0x30, 1); + Wire.requestFrom(0x30, 2); while (!Wire.available()) {;} int c = Wire.read(); + currentLoad = ((c & 0b00001111)*P150)+(((c & 0b01110000)>>4)*P68); + if(currentLoad==load) + { + new_message=false; + Serial.println("***Load Matched***"); + } + /* Serial.print("Quantity of 150Ohm: "); Serial.print(c & 0b00001111); //Print Q150 Serial.print(" Quantity of 68Ohm: "); Serial.print((c & 0b01110000)>>4); Serial.println(" was recieved."); + */ } } diff --git a/build/default/debug/main.o b/build/default/debug/main.o Binary files differindex 9d9cf16..dcd26f0 100644 --- a/build/default/debug/main.o +++ b/build/default/debug/main.o diff --git a/build/default/debug/mcc_generated_files/mssp2_i2c.o b/build/default/debug/mcc_generated_files/mssp2_i2c.o Binary files differindex ffcfcef..5be0913 100644 --- a/build/default/debug/mcc_generated_files/mssp2_i2c.o +++ b/build/default/debug/mcc_generated_files/mssp2_i2c.o diff --git a/build/default/production/main.o b/build/default/production/main.o Binary files differdeleted file mode 100644 index 2ab8071..0000000 --- a/build/default/production/main.o +++ /dev/null diff --git a/build/default/production/main.o.d b/build/default/production/main.o.d deleted file mode 100644 index b3bbd41..0000000 --- a/build/default/production/main.o.d +++ /dev/null @@ -1,6 +0,0 @@ -build/default/production/main.o: main.c mcc_generated_files/system.h \ - SPI.h - -mcc_generated_files/system.h: - -SPI.h: diff --git a/dist/default/production/memoryfile.xml b/dist/default/production/memoryfile.xml index ad07adc..79b3d32 100644 --- a/dist/default/production/memoryfile.xml +++ b/dist/default/production/memoryfile.xml @@ -11,8 +11,8 @@ <memory name="program"> <units>bytes</units> <length>16128</length> - <used>4353</used> - <free>11775</free> + <used>4386</used> + <free>11742</free> </memory> </executable> </project> @@ -58,6 +58,7 @@ int main(void) if (relay_delay)
{
active(activeResistors);
+ setI2CArray(2,activeResistors[0] | (activeResistors[0]<<4));
if (*timeoutcounter < 2)
{
_LATB8 = 1;
@@ -79,7 +80,8 @@ int main(void) }
else //Open contactors if I2C communication is broken.
{
- if (relay_delay) Message_OUT(activeResistors[0] - 1, activeResistors[1] - 1, 0);
+ if ((activeResistors[0] > 0) || (activeResistors[1] > 0)) Message_OUT(activeResistors[0] - 1, activeResistors[1] - 1, 0);
+ else Message_OUT(0, 0, 0);
_LATB7 = 1; //Make sure activity light is off
_LATB8 = 0;
//Message_HWCROCL();
diff --git a/mcc_generated_files/mssp2_i2c.c b/mcc_generated_files/mssp2_i2c.c index 6a7e51e..8985153 100644 --- a/mcc_generated_files/mssp2_i2c.c +++ b/mcc_generated_files/mssp2_i2c.c @@ -1,47 +1,3 @@ -/**
- MSSP2_I2C Generated Driver File
-
- @Company
- Microchip Technology Inc.
-
- @File Name
- mssp2_i2c.c
-
- @Summary
- This is the generated source file for the MSSP2_I2C driver using PIC24 / dsPIC33 / PIC32MM MCUs
-
- @Description
- This source file provides APIs for driver for MSSP2_I2C.
- Generation Information :
- Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.171.4
- Device : PIC24FV16KM202
- The generated drivers are tested against the following:
- Compiler : XC16 v2.10
- MPLAB : MPLAB X v6.05
-*/
-
-/*
- (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this
- software and any derivatives exclusively with Microchip products.
-
- THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
- EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
- WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
- PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
- WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
-
- IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
- INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
- WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
- BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
- FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
- ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
- THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
-
- MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
- TERMS.
-*/
-
#include "mssp2_i2c.h"
/**
@@ -239,9 +195,13 @@ void resetTimeoutCounter() {
I2C_timeout = 0x00;
}
-uint8_t getI2CArray(int index)
+void setI2CArray(uint8_t index, uint8_t value)
+{
+ if(index < ARRAY_CNT) i2cArray[index] = value;
+}
+uint8_t getI2CArray(uint8_t index)
{
- if(index < 5)return i2cArray[index];
+ if(index < ARRAY_CNT)return i2cArray[index];
else return 0;
}
diff --git a/mcc_generated_files/mssp2_i2c.h b/mcc_generated_files/mssp2_i2c.h index 329983a..d6df347 100644 --- a/mcc_generated_files/mssp2_i2c.h +++ b/mcc_generated_files/mssp2_i2c.h @@ -346,7 +346,8 @@ uint8_t *MSSP2_I2C_ReadPointerGet(void); </code>
*/
-uint8_t getI2CArray(int);
+uint8_t getI2CArray(uint8_t);
+void setI2CArray(uint8_t index, uint8_t value);
uint8_t *MSSP2_I2C_WritePointerGet(void);
diff --git a/nbproject/Makefile-genesis.properties b/nbproject/Makefile-genesis.properties index 23d9a04..7f7f620 100644 --- a/nbproject/Makefile-genesis.properties +++ b/nbproject/Makefile-genesis.properties @@ -1,5 +1,5 @@ # -#Thu Jun 06 16:11:03 CDT 2024 +#Thu Jun 13 21:15:57 CDT 2024 default.languagetoolchain.version=2.10 default.Pack.dfplocation=/opt/microchip/mplabx/v6.15/packs/Microchip/PIC24F-KA-KL-KM_DFP/1.4.83 default.com-microchip-mplab-mdbcore-PK5Tool-PK5ToolImpl.md5=723771b957e0f1e0ec1761a42d8bb5e8 |