Revision 4:c16866ed9508, committed 2011-05-04
- Comitter:
- Wimpie
- Date:
- Wed May 04 20:15:25 2011 +0000
- Parent:
- 3:5ae3c983f241
- Commit message:
- added HeatQuantity
Changed in this revision
diff -r 5ae3c983f241 -r c16866ed9508 VBus.cpp
--- a/VBus.cpp Sun Apr 17 17:25:56 2011 +0000
+++ b/VBus.cpp Wed May 04 20:15:25 2011 +0000
@@ -1,5 +1,12 @@
/*
- Copyright (c) 2010 Wim De Roeve
+ Copyright (c) 2010 Wimpie
+
+ Based on the VBus� Protocol Specification see http://goo.gl/HP6ZY
+ and http://hobbyelektronik.org/w/index.php/VBus-Decoder
+
+ VBus� en Resol� are registrated trademarks see http://www.resol.de
+
+ Debugtrace.h -> http://mbed.org/users/snatch59/programs/DebugTrace/gpdz54
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -21,12 +28,11 @@
*/
#include "VBus.h"
-#include "DebugTrace.h"
-
#define DEBUG 0
#if DEBUG
-DebugTrace pc_VBus(OFF, TO_SERIAL);
+#include "DebugTrace.h"
+DebugTrace pc_VBus(ON, TO_SERIAL);
#endif
static uint8_t CalcCrc(const unsigned char *Buffer, int Offset, int Length);
@@ -150,8 +156,31 @@
if ((Command==0x0100) and (Bufferlength==10+Framecnt*6)) {
- // Frame info for the Resol ConergyDT5 used by IZEN
+ // Frame info for the Resol ConergyDT5
// check VBusprotocol specification for other products
+
+ // This library is made for the ConergyDT5 (0x3271)
+
+ //Offset Size Mask Name Factor Unit
+ //0 2 Temperature sensor 1 0.1 �C
+ //2 2 Temperature sensor 2 0.1 �C
+ //4 2 Temperature sensor 3 0.1 �C
+ //6 2 Temperature sensor 4 0.1 �C
+ //8 1 Pump speed pump 1 1
+ //9 1 Pump speed pump 2 1
+ //10 1 Relay mask 1
+ //11 1 Error mask 1
+ //12 2 System time 1
+ //14 1 Scheme 1
+ //15 1 1 Option PostPulse 1
+ //15 1 2 Option thermostat 1
+ //15 1 4 Option HQM 1
+ //16 2 Operating hours relay 1 1
+ //18 2 Operating hours relay 2 1
+ //20 2 Heat quantity 1 Wh
+ //22 2 Heat quantity 1000 Wh
+ //24 2 Heat quantity 1000000 Wh
+ //26 2 Version 0.01
//
// Each frame has 6 bytes
// byte 1 to 4 are data bytes -> MSB of each bytes
@@ -195,23 +224,48 @@
Septet=Buffer[F+FSeptet];
InjectSeptet(Buffer,F,4);
-
+#if DEBUG
+ pc_VBus.traceOut("\r\nFrame 4 %i %i %i %i ",Buffer[F],Buffer[F+1],Buffer[F+2],Buffer[F+3]);
+#endif
SystemTime = Buffer[F+1] << 8 | Buffer[F];
- System = Buffer[F+2];
+ Scheme = Buffer[F+2];
OptionPostPulse = (Buffer[F+3] & 0x01);
OptionThermostat = ((Buffer[F+3] & 0x02) >> 1);
- OptionWMZ = ((Buffer[F+3] & 0x04) >> 2);
+ OptionHQM = ((Buffer[F+3] & 0x04) >> 2);
//******************* Frame 5 *******************
F=FOffset+FLength*4;
Septet=Buffer[F+FSeptet];
InjectSeptet(Buffer,F,4);
-
+#if DEBUG
+ pc_VBus.traceOut("\r\nFrame 5 %i %i %i %i ",Buffer[F],Buffer[F+1],Buffer[F+2],Buffer[F+3]);
+#endif
OperatingHoursRelais1=Buffer[F+1] << 8 | Buffer[F];
OperatingHoursRelais2=Buffer[F+3] << 8| Buffer[F+2];
+ //******************* Frame 6 *******************
+ F=FOffset+FLength*5;
+
+ Septet=Buffer[F+FSeptet];
+ InjectSeptet(Buffer,F,4);
+#if DEBUG
+ pc_VBus.traceOut("\r\nFrame 6 %i %i %i %i ",Buffer[F],Buffer[F+1],Buffer[F+2],Buffer[F+3]);
+#endif
+ HeatQuantity=(Buffer[F+1] << 8 | Buffer[F])+(Buffer[F+3] << 8| Buffer[F+2])*1000;
+
+ //******************* Frame 7 *******************
+ F=FOffset+FLength*6;
+
+ Septet=Buffer[F+FSeptet];
+ InjectSeptet(Buffer,F,4);
+#if DEBUG
+ pc_VBus.traceOut("\r\nFrame 7 %i %i %i %i ",Buffer[F],Buffer[F+1],Buffer[F+2],Buffer[F+3]);
+#endif
+ HeatQuantity=HeatQuantity+(Buffer[F+1] << 8 | Buffer[F])*1000000;
+ Version=Buffer[F+3] << 8| Buffer[F+2];
+
///******************* End of frames ****************
if (Sensor1_temp>Sensor1_temp_max)
@@ -225,21 +279,22 @@
#if DEBUG
- pc_VBus.traceOut("\r\nSensor 1 %f", Sensor1_temp);
- pc_VBus.traceOut("\r\nSensor 2 %f", Sensor2_temp);
- pc_VBus.traceOut("\r\nSensor 3 %f", Sensor3_temp);
- pc_VBus.traceOut("\r\nSensor 4 %f", Sensor4_temp);
- pc_VBus.traceOut("\r\nPumpSpeed1 %i", PumpSpeed1);
- pc_VBus.traceOut("\r\nPumpSpeed2 %i", PumpSpeed2);
- pc_VBus.traceOut("\r\nRelaismask %i", RelaisMask);
- pc_VBus.traceOut("\r\nErrorMask %i", ErrorMask);
- pc_VBus.traceOut("\r\nSystemTime %i", SystemTime);
- pc_VBus.traceOut("\r\nSystem %i", System);
- pc_VBus.traceOut("\r\nOptionPostPulse %i", OptionPostPulse);
- pc_VBus.traceOut("\r\nOptionThermostat %i", OptionThermostat);
- pc_VBus.traceOut("\r\nOptionWMZ %i", OptionWMZ);
- pc_VBus.traceOut("\r\nOperatingHoursRelais1 %i", OperatingHoursRelais1);
- pc_VBus.traceOut("\r\nOperatingHoursRelais2 %i", OperatingHoursRelais2);
+ /* pc_VBus.traceOut("\r\nSensor 1 %f", Sensor1_temp);
+ pc_VBus.traceOut("\r\nSensor 2 %f", Sensor2_temp);
+ pc_VBus.traceOut("\r\nSensor 3 %f", Sensor3_temp);
+ pc_VBus.traceOut("\r\nSensor 4 %f", Sensor4_temp);
+ pc_VBus.traceOut("\r\nPumpSpeed1 %i", PumpSpeed1);
+ pc_VBus.traceOut("\r\nPumpSpeed2 %i", PumpSpeed2);
+ pc_VBus.traceOut("\r\nRelaismask %i", RelaisMask);
+ pc_VBus.traceOut("\r\nErrorMask %i", ErrorMask);
+ pc_VBus.traceOut("\r\nSystemTime %i", SystemTime);
+ pc_VBus.traceOut("\r\nSystem %i", Scheme);
+ pc_VBus.traceOut("\r\nOptionPostPulse %i", OptionPostPulse);
+ pc_VBus.traceOut("\r\nOptionThermostat %i", OptionThermostat);
+ pc_VBus.traceOut("\r\nOptionHQM %i", OptionHQM);
+ pc_VBus.traceOut("\r\nOperatingHoursRelais1 %i", OperatingHoursRelais1);
+ pc_VBus.traceOut("\r\nOperatingHoursRelais2 %i", OperatingHoursRelais2);*/
+ pc_VBus.traceOut("\r\nHeatQuantity %i", HeatQuantity);
#endif
}
@@ -249,41 +304,37 @@
}
void VBus::SaveToSDcard(char* datetime, char* date,char* dayfn) {
-#if DEBUG
- pc_VBus.traceOut("save ULX code=%i\r\n",code);
-#endif
-
- char fn[16];
+ char fn[17];
strcpy(fn,"/sd/vb");
strcat(fn,dayfn);
- strcat(fn,".js");
+ strcat(fn,".csv");
//****************
- // vbyymmdd.js
+ // filename vbyymmdd.csv
//
- // detailed dayinfo , each 5 minutes
+ // detailed dayinfo, each 5 minutes
//
- // vb[i++]="dd.mm.yy hh:mm:ss|v1;v2;v3;v4;v5;v6;v7;...
+ // dd.mm.yy hh:mm:ss;v1;v2;v3;v4;v5;v6;v7;...
//
//****************
-
- fprintf(stderr,"vb[i++]=%c%s|%4.1f;%4.1f;%4.1f;%4.1f;%i;%i;%i;%i;%i;%i;%i;%i;%i;%i;%i%c\r\n", 34,datetime,
- Sensor1_temp, Sensor2_temp,Sensor3_temp, Sensor4_temp,
- PumpSpeed1,PumpSpeed2,
- RelaisMask,ErrorMask,SystemTime,System,OptionPostPulse,
- OptionThermostat, OptionWMZ, OperatingHoursRelais1,OperatingHoursRelais2,
- 34);
+#if DEBUG
+ pc_VBus.traceOut("%s;%4.1f;%4.1f;%4.1f;%4.1f;%i;%i;%i;%i;%i;%i;%i;%i;%i;%i;%i%;%i;%i\r\n",datetime,
+ Sensor1_temp, Sensor2_temp,Sensor3_temp, Sensor4_temp,
+ PumpSpeed1,PumpSpeed2,
+ RelaisMask,ErrorMask,SystemTime,Scheme,OptionPostPulse,
+ OptionThermostat, OptionHQM, OperatingHoursRelais1,OperatingHoursRelais2,HeatQuantity,Version
+ );
+#endif
if (_sdcard) {
FILE *fp = fopen(fn, "a");
if (fp) {
- fprintf(fp,"vb[i++]=%c%s|%4.1f;%4.1f;%4.1f;%4.1f;%i;%i;%i;%i;%i;%i;%i;%i;%i;%i;%i%c\r\n", 34,datetime,
+ fprintf(fp,"%s;%4.1f;%4.1f;%4.1f;%4.1f;%i;%i;%i;%i;%i;%i;%i;%i;%i;%i;%i%;%i;%i\r\n",datetime,
Sensor1_temp, Sensor2_temp,Sensor3_temp, Sensor4_temp,
PumpSpeed1,PumpSpeed2,
- RelaisMask,ErrorMask,SystemTime,System,OptionPostPulse,
- OptionThermostat, OptionWMZ, OperatingHoursRelais1,OperatingHoursRelais2,
- 34);
-
+ RelaisMask,ErrorMask,SystemTime,Scheme,OptionPostPulse,
+ OptionThermostat, OptionHQM, OperatingHoursRelais1,OperatingHoursRelais2,HeatQuantity,Version
+ );
fclose(fp);
}
}
@@ -299,11 +350,9 @@
void VBus::make_Header (unsigned int DAdr,unsigned int SAdr,unsigned char Ver,unsigned int Cmd,unsigned char AFrames) {
unsigned char Buffer[10]={Sync,(uint8_t)DAdr,DAdr>>8,(uint8_t)SAdr,SAdr>>8,Ver,(uint8_t)Cmd,Cmd>>8,AFrames};
Buffer[9]=CalcCrc(Buffer,1,8);
-// pc_VBus.traceOut("\r\nmake_Header\r\n");
for (unsigned bo=0;bo<=9;bo++) {
_Serial.putc(Buffer[bo]);
}
-// pc_VBus.traceOut("\r\n");
}
static uint8_t CalcCrc(const unsigned char *Buffer, int Offset, int Length) {
@@ -319,7 +368,7 @@
int v;
v = Byte1 << 8 | Byte2;
- if (Byte1 == 0xFF) // negatief value
+ if (Byte1 == 0xFF)
v = v - 0x10000;
if (v==SENSORNOTCONNECTED)
diff -r 5ae3c983f241 -r c16866ed9508 VBus.h
--- a/VBus.h Sun Apr 17 17:25:56 2011 +0000
+++ b/VBus.h Wed May 04 20:15:25 2011 +0000
@@ -1,5 +1,10 @@
/*
- Copyright (c) 2010 Wim De Roeve
+ Copyright (c) 2010 Wimpie
+
+ Based on the VBus® Protocol Specification see http://goo.gl/HP6ZY
+ and http://hobbyelektronik.org/w/index.php/VBus-Decoder
+
+ VBus® en Resol® are registrated trademarks see http://www.resol.de
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -27,7 +32,7 @@
#define FLength 6 // Framelength
#define FOffset 10 // Offset start of Frames
#define FSeptet 4 // Septet byte in Frame
-#define ResolAddress 0x3271 // Address of the controller
+#define ResolAddress 0x3271 // ConergyDT5 (0x3271) Address of the controller
#define SENSORNOTCONNECTED 8888
#include "mbed.h"
@@ -35,7 +40,6 @@
/** @defgroup API The VBus API */
/** VBus module
- * @author Wim De Roeve
*
* Example:
* @code
@@ -43,7 +47,7 @@
* #include "VBus.h"
*
* Serial pc(USBTX, USBRX);
- * VBus ResolBS(p9, p10);
+ * VBus ResolBS(NC, p10);
*
* int main() {
*
@@ -66,13 +70,35 @@
/**
* The VBus constructor is used to initialise the VBus object.
*
- * @param tx The TX pin the VBus is connected to p9, p13, p28
- * @param rx The RX pin the GPS is connected to p10, p14, p27.
+ * @param tx The TX pin is NOT connected
+ * @param rx The RX pin is connected to p10 or p14 or p27.
*/
VBus(PinName tx, PinName rx);
+ /**
+ * The VBus destructor
+ */
+ // virtual ~VBus();
- uint16_t networkaddress;
+
+ /**
+ * Read
+ * Reads all the device parameters (Sensors, Pumpspeed, RelaisMask)
+ **/
+ bool Read();
+ /**
+ * SaveToSDcard
+ * Saves the device parameters to a textfile /sd/vb20110101.txt
+ **/
+ void SaveToSDcard(char* datetime, char* date,char* dayfn);
+ void SDcardAvailable(bool status);
+ /**
+ * ClearMax
+ * Clears the maximum values
+ **/
+ void ClearMax();
+
+ uint16_t networkaddress;
float Sensor1_temp;
float Sensor2_temp;
float Sensor3_temp;
@@ -88,19 +114,15 @@
char RelaisMask;
char ErrorMask;
uint16_t SystemTime;
- char System;
+ char Scheme;
char OptionPostPulse;
char OptionThermostat;
- char OptionWMZ;
+ char OptionHQM;
uint16_t OperatingHoursRelais1;
uint16_t OperatingHoursRelais2;
+ uint32_t HeatQuantity;
+ uint16_t Version;
uint16_t OperatingHoursRelais1Today;
-
- void Init(int addr);
- bool Read();
- void SaveToSDcard(char* datetime, char* date,char* dayfn);
- void SDcardAvailable(bool status);
- void ClearMax();
protected:
Serial _Serial;
@@ -124,6 +146,7 @@
bool _sdcard;
bool _all;
+ void Init(int addr);
void InjectSeptet(unsigned char *Buffer, int Offset, int Length);
void FrameOutput (void);
void make_Header (unsigned int DAdr,unsigned int SAdr,unsigned char Ver,unsigned int Cmd,unsigned char AFrames);