// Overall Current Function Definition void Currentfunct(void) { // The binary representation of the frame for // displaying a "A" on the CPLD. uint8_t CurrentFrame = 0b11001011; // Send the "A" frame for 1 second. setTimerDelay(1); PORTB |= (1<<5); while(1) { // If the overflow is raised, then the 1 second // count must be over, so break out of the loop. if(TIFR1 & (1<<TOV1)) { TIFR1 |= (1<<TOV1); break; } // If the overflow isn't raised then keep transmitting UART_Transmit(CurrentFrame); } // Checking if the signal on pin 3 is above a certain // value. If it is below that value, then we will change // to reading from the higher gain circuit. uint8_t adcPin = CurrentPinSelect(PC3_IsenLG); float currentPk = CurrentMax(adcPin); //float currentRMS = RMSval(adcPin,2); // Current in mA currentPk = currentPk * 1000; // setTimerDelay(2); PORTB &= ~(1<<5); while(1) { if(TIFR1 & (1<<TOV1)) { TIFR1 |= (1<<TOV1); break; } MakeArray_Trans(currentPk); } }
// Energy Calculation, Transmission and Storage function void Energyfunct(void) { // The binary representation of the frame for // displaying a "E" on the CPLD. uint8_t EnergyFrame = 0b11101010; // Send the "E" frame for 1 second. setTimerDelay(1); PORTB |= (1<<5); while(1) { // If the overflow is raised, then the 1 second // count must be over, so break out of the loop. if(TIFR1 & (1<<TOV1)) { TIFR1 |= (1<<TOV1); break; } // If the overflow isn't raised then keep transmitting UART_Transmit(EnergyFrame); } // Storing the energy value into eeprom. eeprom_add(energy); // EnergyVal is new energy value uint16_t EngyVal = energy; // This energy value is then given to the MakeArray_Trans // function to be transmitted for 2 seconds. setTimerDelay(2); PORTB &= ~(1<<5); while(1) { // If the overflow is raised, then the 2 second // count must be over, so break out of the loop. if(TIFR1 & (1<<TOV1)) { TIFR1 |= (1<<TOV1); break; } // If the overflow isn't raised then keep transmitting MakeArray_Trans(EngyVal); } }
// Overall Voltage Function Definition void Voltagefunct(void) { // The binary representation of the frame for // displaying a "V" on the CPLD. uint8_t VoltageFrame = 0b11001010; // Send the "V" frame for 1 second. setTimerDelay(1); PORTB |= (1<<5); while(1) { // If the overflow is raised, then the 1 second // count must be over, so break out of the loop. if(TIFR1 & (1<<TOV1)) { TIFR1 |= (1<<TOV1); break; } // If the overflow isn't raised then keep transmitting UART_Transmit(VoltageFrame); } // Telling the function to calculate the Vload // RMS value using PIN C1 float VLoad = RMSval(PC1_Vsen, 1); // This RMS value is then given to the MakeArray_Trans // function to be transmitted for 2 seconds. setTimerDelay(2); PORTB &= ~(1<<5); while(1) { // If the overflow is raised, then the 2 second // count must be over, so break out of the loop. if(TIFR1 & (1<<TOV1)) { TIFR1 |= (1<<TOV1); break; } // If the overflow isn't raised then keep transmitting MakeArray_Trans(VLoad); } }
NMEAGPS::NMEAGPS(): ui(new Ui::NMEAGPS) { CreateGUI(); setTimerDelay(boat.updateDelay); this->pluginName = "NMEA Simulator"; this->produceIDs = "RMC"; this->parseIDs = "RMC;HDG;MWD"; plugin_widget->setWindowTitle(pluginName); }
NMEA_Anemometer::NMEA_Anemometer(): ui(new Ui::AnemometerWidget), windSpeedValue(0.0) { CreateGUI(); setTimerDelay(updateDelay); this->pluginName = "NMEA Windmeter"; this->produceIDs = "MWD"; this->parseIDs = "MWD"; plugin_widget->setWindowTitle(pluginName); }
// Overall Power Function Definition void Powerfunct(void) { // The binary representation of the frame for // displaying a "P" on the CPLD. uint8_t PowerFrame = 0b11101000; // Send the "P" frame for 1 second. setTimerDelay(1); PORTB |= (1<<5); while(1) { // If the overflow is raised, then the 1 second // count must be over, so break out of the loop. if(TIFR1 & (1<<TOV1)) { TIFR1 |= (1<<TOV1); break; } // If the overflow isn't raised then keep transmitting UART_Transmit(PowerFrame); } // Checking if the signal on pin 3 is above a certain // value. If it is below that value, then we will change // to reading from the higher gain circuit. uint8_t currentPin = CurrentPinSelect(PC3_IsenLG); // Calculate current and voltage RMS float currentRMS = RMSval(currentPin,2); float voltageRMS = RMSval(PC1_Vsen,1); // //for(int i=0; i< 10; i++){ //} float powerFactor = cos(SamplePhaseShift()); // Calculating the power value using all the above values // and then converting it into W. float power = (currentRMS * voltageRMS * powerFactor); // Take this power value, and then give it to the energy // calculate function to then set the value globally, // where then the value is written into eeprom. energy = EnergyCalc(power); // Send the calculated power for 2 seconds. setTimerDelay(2); PORTB &= ~(1<<5); while(1) { // If the overflow is raised, then the 2 seconds // count must be over, so break out of the loop. if(TIFR1 & (1<<TOV1)) { TIFR1 |= (1<<TOV1); break; } // Keep transmitting if 2 seconds aren't over yet MakeArray_Trans(power); } }