ich möchte gerne mein ABB Wechselrichter Trio 27.6 per RS485 abrufen. Den Solarmax habe ich schon per ASCII hinbekommen.
Beide liegen auf einer 485 Extension.
Das Problem in Loxone ist, das ich laut Script aus dem Netz für die Power in W das Vorzeichen Bit 31 um 1 kürzen muss.
Ich stell hier das Script aus dem Netz hinein. Vielleicht geht es auch mit Pico C.
Wenn ich also die Anfrag für :
GridPower
0x3B03
\x02\x3b\x03\x00\x00\x00\x00\x00\xa9\x24
sende. bekomme ich diese Antwort zurück:
Hex
00,06,46,1E,13,D3,5B,5F
Egal wie ich es drehe komme ich nicht weiter.
Das wichtigste ist für mich die Leistung und am besten eine Störmeldung.
Sollte es mehr sein ist dies (Nice to Have).
Ein Link vom Hersteller des Protokolls findet ihr hier:
Ich würde mich freuen wenn einer von Euch mir helfen könntet.!!!!
Danke im Voraus.
Aurora PVI communication ------------------------ Checks via RS485 Interface the availability of a Power one Aurora Photovoltaic Inverter PVI-3.0-TL-OUTD The RS485 Interface is driven by SoftwareSerial Routines pin 2 = Rx, Pin 3 = TX pin 5 = RTS, for HDX operation, High = Transmit, Low = Receive PVI parameters: Baudrate 19200, 8 Data, no parity, 1 stop RS485 PVI-ID address = 2 (default) Command Packet structure is a 10 Byte command 1 address 2 operation type 3 data1 4 data2 5 data3 6 data4 7 data5 8 data6 9 crc low 10 crc high Example: Get total amount of produced energy 02 4E 05 00 00 00 00 00 BC DD ----- crc = 0xDDBC -- Accumulated data type 5 = total -- Get accumulated data command = 78 (0x4E) -- PVI address = 2 PVI response 8 byte data packet: 1 State 2 MState 3 Param1 4 Param2 5 Param3 6 Param4 7 crc low 8 crc high Example: Response to above request 00 06 00 00 36 34 5A 62 ----- crc = 0x625A ----------- power in kwh (32Bit) = 0x3634 = 13876 Wh -- MState = 6 ? -- State = 0 ? */ // Aurora PVI commands definitions #define pviadr 2 #define cmdGridVoltage 0x3B01 //grid voltage //#define cmdGridVoltage 0x3B20 //average grid voltage #define cmdGridPower 0x3B03 #define cmdTempInv 0x3B15 #define cmdTempBst 0x3B16 #define cmdDc1Voltage 0x3B17 #define cmdDc1Current 0x3B19 #define cmdDc2Voltage 0x3B1A #define cmdDc2Current 0x3B1B #define cmdRiso 0x3B1E #define cmdGridPowerPeak 0x3B23 #define cmdTime 0x4600 #define cmdsetTime 0x4700 #define cmdEnergyDay 0x4E00 #define cmdEnergyTotal 0x4E05 #define logMessageFlushPVIRecBuf "*E4:FlushPVIRB x=" #define logMessagePVIRecChkSumErr "*E5:PVIChkSumErr" #define logMessagePVIRecTimeout "*E6:PVIRecTimeout" //#define cmdResetEnergyValue 0x0052 //reset energy total command for ArdaSol Energy Monitor #define cmdSize 10 // 10 Bytes command Packet static byte CmdBuf[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // 10 elements #define rspSize 8 // 8 Bytes response Packet static byte RspBuf[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // 8 elements // Aurora Data definitions unsigned long invDateAndTime = 0; //absolute format of date and time in seconds from aurora //unsigned long GridVoltage = 0; //grid tension in Volts //unsigned long GridPower = 0; //power fed to grid in W //unsigned long TempBst = 0; //Inverter operating temperature //unsigned long TempInv = 0; //Inverter operating temperature //unsigned long InvRiso = 0; //Isolation resistance // unsigned long GridPowerPeakDay = 0; //peak value of power fed to grid in W // unsigned long EnergyDay = 0; // energy produced in day in Wh //unsigned long EnergyTotal = 0; // total energy produced in inverters lifetime in Wh //unsigned long EnergyTotalkWh = 0; //unsigned long EnergyAverageDay = 0; // average a day calculated from start of operation of the PVI boolean resetEnergyDayUsed = false; unsigned long receiveTimeoutStart; // const unsigned int receiveMaxWait = 3000; //three second max for the answer of the PVI unsigned long sequenceCounter; unsigned int crc16Checksum; boolean respTimeout; //----------------------------------------------------------------------- //----------------------------------------------------------------------- /* CRC16 checksum calculation * Copyright (C) 2006-2012 Curtis J. Blank curt@curtronics.com 16 12 5 this is the CCITT CRC 16 polynomial X + X + X + 1. This is 0x1021 when x is 2, but the way the algorithm works we use 0x8408 (the reverse of the bit pattern). The high bit is always assumed to be set, thus we only use 16 bits to represent the 17 bit value. */ #define POLY 0x8408 /* 1021H bit reversed */ unsigned int uiCrc16Cal (byte * buf, byte length) { byte i; unsigned int data; unsigned int crc = 0xffff; if (length == 0) return (~crc); do { for (i=0, data=(unsigned int)0xff & *buf++; i < 8; i++, data >>= 1) { if ((crc & 0x0001) ^ (data & 0x0001)) crc = (crc >> 1) ^ POLY; else crc >>= 1; } } while (--length); crc = ~crc; return (crc); } //----------------------------------------------------------------------- // Sends the command get current power feeding to grid float getGridVoltage() { CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdGridVoltage); CmdBuf[2] = lowByte(cmdGridVoltage); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); actTension = 0.0; SendCommandPacketToPVI(); if (ResponsePacketReceived()) { actTension = *getReceivedValueAsFloat(); // Serial.print(F("gridtension in ArdaSolComm: ")); // Serial.println(gridtension); } } //----------------------------------------------------------------------- // Sends the command get the grid power peak current day void getGridPowerPeakDay() { CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdGridPowerPeak); CmdBuf[2] = lowByte(cmdGridPowerPeak); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); SendCommandPacketToPVI(); if (ResponsePacketReceived()) { float GPPD; GPPD = *getReceivedValueAsFloat(); if ((int(GPPD) >= 0) && (int(GPPD) < 4200)) { pwrPeak = int(GPPD); if (int((GPPD-pwrPeak)*10) >= 5) ++pwrPeak; } } } //----------------------------------------------------------------------- // Sends the command get current power feeding to grid void getGridPower() { CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdGridPower); CmdBuf[2] = lowByte(cmdGridPower); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); SendCommandPacketToPVI(); GridPower = 0; if (ResponsePacketReceived()) { float grdPpvi; grdPpvi = *getReceivedValueAsFloat(); unsigned int tempPpvi = int(grdPpvi); if ((tempPpvi >= 0) && (tempPpvi < 4200)) // && (tempPpvi <= pwrPeak) ) { GridPower = int(grdPpvi); if (int((grdPpvi-GridPower)*10) >= 5) ++GridPower; //round up // lastGridPower=GridPower; // sensors[1]->Actual = GridPower; } } } //----------------------------------------------------------------------- // Sends the command get current booster temperature void getTempBst() { CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdTempBst); CmdBuf[2] = lowByte(cmdTempBst); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); SendCommandPacketToPVI(); // float BstTemp = 0.0; if (ResponsePacketReceived()) { actBstTemp = *getReceivedValueAsFloat(); } } //----------------------------------------------------------------------- // Sends the command get actual inverter temperature void getTempInv() { CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdTempInv); CmdBuf[2] = lowByte(cmdTempInv); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); SendCommandPacketToPVI(); if (ResponsePacketReceived()) { float InvTemp = *getReceivedValueAsFloat(); float tempTemp = InvTemp - actInvTemp; tempTemp = abs(tempTemp); if( (InvTemp < 80.0 && tempTemp < 7.0) || (InvTemp > 10 && InvTemp < 56) ) { actInvTemp = InvTemp; } } // check if we have a temperature within the expected wide range otherwaise we have a mis read. return old value // the max deviation is 30 degrees // float tempHelper = InvTemp - actInvTemp; } //----------------------------------------------------------------------- // Sends the command get actual DC voltage string 1 void getDc1Voltage() { CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdDc1Voltage); CmdBuf[2] = lowByte(cmdDc1Voltage); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); SendCommandPacketToPVI(); if (ResponsePacketReceived()) { actDc1Voltage = *getReceivedValueAsFloat(); } } //----------------------------------------------------------------------- // Sends the command get actual DC voltage string 1 void getDc1Current() { CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdDc1Current); CmdBuf[2] = lowByte(cmdDc1Current); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); if( actTension == 0.0 ) actDc1Current = 0.0; SendCommandPacketToPVI(); if (ResponsePacketReceived()) { actDc1Current = *getReceivedValueAsFloat(); } } //----------------------------------------------------------------------- // Sends the command get actual DC voltage string 1 void getDc2Voltage() { CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdDc2Voltage); CmdBuf[2] = lowByte(cmdDc2Voltage); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); SendCommandPacketToPVI(); if (ResponsePacketReceived()) { actDc2Voltage = *getReceivedValueAsFloat(); } } //----------------------------------------------------------------------- // Sends the command get actual DC voltage string 1 void getDc2Current() { CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdDc2Current); CmdBuf[2] = lowByte(cmdDc2Current); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); SendCommandPacketToPVI(); if (ResponsePacketReceived()) { actDc2Current = *getReceivedValueAsFloat(); } } //----------------------------------------------------------------------- // Sends the command get the measuresed value of Riso at wake-up void getRiso() { CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdRiso); CmdBuf[2] = lowByte(cmdRiso); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); SendCommandPacketToPVI(); if (ResponsePacketReceived()) { Riso = *getReceivedValueAsFloat(); } } //----------------------------------------------------------------------- // Sends the command get current date and time void getTime() { long timeDiff; unsigned long at; // current time CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdTime); CmdBuf[2] = lowByte(cmdTime); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); SendCommandPacketToPVI(); if (ResponsePacketReceived()) { invDateAndTime = getReceivedValueAsInt(); } at = invDateAndTime + 946684800; timeDiff = at - now(); timeDiff = abs(timeDiff); if (timeDiff > 59) { SendTimeMail(timeDiff); Serial.println(F("Time difference between Inverter and real time to large (>59 sec)")); } } //----------------------------------------------------------------------- // Sends the command get current date and time void setinvTime() { long timeDiff; unsigned long at; // current time CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdTime); CmdBuf[2] = lowByte(cmdTime); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); SendCommandPacketToPVI(); if (ResponsePacketReceived()) { invDateAndTime = getReceivedValueAsInt(); } else { Serial.println(F("Failed to read invertertime in setTime")); return; } at = invDateAndTime + 946684800; timeDiff = at - now(); timeDiff = abs(timeDiff); delay(1000); if (timeDiff > 59) { /* adjust time to Aurora's time base if skew >= 1 minute */ invDateAndTime = now() - 946684800; /* adjust by 1 due to latency in setting the time */ invDateAndTime++; CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdsetTime); CmdBuf[2] = (invDateAndTime >> 24) & 0xff; CmdBuf[3] = (invDateAndTime >> 16) & 0xff; CmdBuf[4] = (invDateAndTime >> 8) & 0xff; CmdBuf[5] = (invDateAndTime) & 0xff; CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); SendCommandPacketToPVI(); // We have set the new time if (ResponsePacketReceived()) { // invDateAndTime = getReceivedValueAsInt(); delay(2000); // query and report new time in mail CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdTime); CmdBuf[2] = lowByte(cmdTime); CmdBuf[3] = 0; CmdBuf[4] = 0; CmdBuf[5] = 0; CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); SendCommandPacketToPVI(); if (ResponsePacketReceived()) { invDateAndTime = getReceivedValueAsInt(); } else { Serial.println(F("Failed to read inverter time in setTime")); } at = invDateAndTime + 946684800; SendsetTimeMail(at); Serial.print(F("Inverter time successful changed to: ")); Serial.println(DateTime(at)); } } } //----------------------------------------------------------------------- // Sends the command get the cumulated energy current day void getEnergyDay() { CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdEnergyDay); CmdBuf[2] = lowByte(cmdEnergyDay); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); unsigned int EnergyDay = 0; SendCommandPacketToPVI(); if (ResponsePacketReceived()) { totalToday = getReceivedValueAsInt(); // if (Epvi < 30000) EnergyDay=Epvi; //validate <30kWh in a day } } //----------------------------------------------------------------------- // Sends the command get the total cumulated void getEnergyTotal() { CmdBuf[0] = pviadr; //RS485 chain address of PVI CmdBuf[1] = highByte(cmdEnergyTotal); CmdBuf[2] = lowByte(cmdEnergyTotal); CmdBuf[6] = 0; CmdBuf[7] = 0; crc16Checksum = uiCrc16Cal (CmdBuf, 8) ; CmdBuf[8] = lowByte(crc16Checksum); CmdBuf[9] = highByte(crc16Checksum); SendCommandPacketToPVI(); if (ResponsePacketReceived()) { unsigned long EnergyTotal = getReceivedValueAsInt(); EnergyTotal = EnergyTotal % 100000000; // due to problem with PVI RAM failed cmltvPwr = EnergyTotal / 1000; if ((EnergyTotal % 1000) > 499) ++cmltvPwr; // round up } } //----------------------------------------------------------------------- static unsigned long getReceivedValueAsInt() { unsigned long value; value = RspBuf[2]; value = value << 8; value = value | RspBuf[3]; value = value << 8; value = value | RspBuf[4]; value = value << 8; value = value | RspBuf[5]; return (value); } //----------------------------------------------------------------------- static float *getReceivedValueAsFloat() { byte cValue[4]; float *value; // char waarde[10]; cValue[0] = RspBuf[5]; cValue[1] = RspBuf[4]; cValue[2] = RspBuf[3]; cValue[3] = RspBuf[2]; value = (float *)cValue; //Serial.print(F("in getReceivedValueAsFloat: ")); //Serial.println(*value); delay(1); return(value); } //----------------------------------------------------------------------- void clearRS485SerialInput() { while (Serial2.available() > 0) { Serial2.read(); } } //----------------------------------------------------------------------- // sends a valid PVI Command to RS485 void SendCommandPacketToPVI() { byte i; Serial2.flush(); clearRS485SerialInput(); digitalWrite(rts485Pin, HIGH); //Turns RTS On for transmisson for (i = 0; i < cmdSize ; ++i ) { Serial2.write(CmdBuf[i]); } Serial2.flush(); receiveTimeoutStart = millis(); delayMicroseconds(204); // was 52, 76, 90, 110, (0,75promille), 136 (1 en 0 error), 156 (1 error), 172 (2 error) wait 3 bittime, longer leads to CRCerrors due to the fast response of the pvi digitalWrite(rts485Pin, LOW); //Turns RTS Off } //----------------------------------------------------------------------- // waits for a valid PVI Response from RS485 (Aurora) boolean ResponsePacketReceived() { boolean respOk; unsigned int respCRC; byte i; unsigned long rxComplete; unsigned long rxTime; respOk = false; i=0; respTimeout = false; // receiveTimeoutStart = millis(); // Serial.println("enter ResponsePacketReceived"); do // the receive loop with timeout function { if (Serial2.available()) { RspBuf[i] = Serial2.read(); i++; } rxComplete= millis(); if ((rxComplete - receiveTimeoutStart) > receiveMaxRS485Wait) { respTimeout = true; if (receiveMaxRS485Wait == 3000) { // only count if the pvi is awake cntrespTimeout++; // rxReadCnt=i; } } } while ((i < rspSize) && !respTimeout); rxTime=rxComplete - receiveTimeoutStart; if (!respTimeout) { if (rxTime < minRxTime) minRxTime=rxTime; if (rxTime > maxRxTime) maxRxTime=rxTime; } if ((!respTimeout) && (i == rspSize)) { respCRC = RspBuf[6] + (RspBuf[7] << 8); if (respCRC == uiCrc16Cal (RspBuf, 6)) { respOk = true ; } else { ChkSumErrCnt++; } } return (respOk); }
Kommentar