Hi,
When i am decoding PF value with the C libraray its giving wrong value, but the same response if I am decoding in the DLMS translator its showing correct there. Can you pls tell me why its happening below is the data.
cmd: 7e a0 1a 02 a1 21 32 a2 cb e6 e6 00 c0 01 81 00 03 01 01 49 07 00 ff 02 00 97 73 7e
Response: 7e a0 13 21 02 a1 52 21 3f e6 e7 00 c4 01 81 00 0f aa 7d 5e 7e
Received data 1.1.73.7.0.255 , 2:
Value : 170 (actual data is -86)
Value in HEX: aa
cmd:7e a0 1a 02 a1 21 54 92 cd e6 e6 00 c0 01 81 00 03 01 01 49 07 00 ff 03 00 4f 6a 7e
Response: 7e a0 17 21 02 a1 74 05 56 e6 e7 00 c4 01 81 00 02 02 0f fe 16 ff 38 db 7e
Scaler : -2
You are reading different attributes. In the first command, you are reading attribute #2 (Value) and in the second you are reading attribute #3 (Scaler and unit).
Read the same attribute index and the values are the same.
BR,
Mikko
Hi,
Thanks for your reply. If you see the below data its coming proper for other PF. As per my observation whenever PF is in -ve value that time only this wrong conversion is happening from the resp.
cmd : 7e a0 1a 02 a1 21 fe c2 c7 e6 e6 00 c0 01 81 00 03 01 01 35 07 00 ff 02 00 62 87 7e
Resp: 7e a0 13 21 02 a1 1e 49 b7 e6 e7 00 c4 01 81 00 11 26 98 1f 7e
Value : 38
Value in HEX: 26
cmd: 7e a0 1a 02 a1 21 10 b2 c9 e6 e6 00 c0 01 81 00 03 01 01 35 07 00 ff 03 00 ba 9e 7e
resp: 7E A0 17 21 02 A1 30 25 52 E6 E7 00 C4 01 81 00 02 02 0F FE 16 FF 38 DB 7E
Scaler : -2
Hi,
I think we are getting confused with the topic of conversation. I will start once again from the top to clarify my doubt.
cmd: 7e a0 1a 02 a1 21 32 a2 cb e6 e6 00 c0 01 81 00 03 01 01 49 07 00 ff 02 00 97 73 7e
Response: 7e a0 13 21 02 a1 52 21 3f e6 e7 00 c4 01 81 00 0f aa 7d 5e 7e
Above are the command and responses to collect one of the Power factor from the meter with OBIS 1.1.73.7.0.255.
In the meter display power factor for this particular OBIS is coming as "-0.86", but from the DLMS library after converting the response command (7e a0 13 21 02 a1 52 21 3f e6 e7 00 c4 01 81 00 0f aa 7d 5e 7e) the value is coming as "170" instead of "-86" in reg.value.lVal.
This is happening only when there is a negative power factor.
We are using the same DLMS library which has been purchased from Gurux.
Please clarify where this conversion is happening in DLMS library and how can we make it convert properly.
below is the code snippet for your reference.
if (requestType == DLMS_OBJECT_TYPE_REGISTER)
{
delay_us(100);
queryStatus = com_read(&con, ®.base, 2);
if(queryStatus == 0)
{
debug_print("\r\nReceived data %s , 2: ",dlmsDevice->oidList.oid[oididx]);
debug_print("\r\nValue : %d\r\n",reg.value.lVal); // Here its coming 170 instead of -86
for(pIdx=0;pIdx<con.data.size;pIdx++)
{
debug_print("%02X ",con.data.data[pIdx]);
}
debug_puts("\n");
}
Hi can you please update on
Hi can you please update on this please.
Hi,
Hi,
You are reading different attributes. In the first command, you are reading attribute #2 (Value) and in the second you are reading attribute #3 (Scaler and unit).
Read the same attribute index and the values are the same.
BR,
Mikko
Hi,
Hi,
Thanks for your reply. If you see the below data its coming proper for other PF. As per my observation whenever PF is in -ve value that time only this wrong conversion is happening from the resp.
cmd : 7e a0 1a 02 a1 21 fe c2 c7 e6 e6 00 c0 01 81 00 03 01 01 35 07 00 ff 02 00 62 87 7e
Resp: 7e a0 13 21 02 a1 1e 49 b7 e6 e7 00 c4 01 81 00 11 26 98 1f 7e
Value : 38
Value in HEX: 26
cmd: 7e a0 1a 02 a1 21 10 b2 c9 e6 e6 00 c0 01 81 00 03 01 01 35 07 00 ff 03 00 ba 9e 7e
resp: 7E A0 17 21 02 A1 30 25 52 E6 E7 00 C4 01 81 00 02 02 0F FE 16 FF 38 DB 7E
Scaler : -2
Converted Value : o.38
Hi,
Hi,
ANSI C doesn't multiply the value with scaler for you. You must do it by yourself. The reason is that memory footprint is kept as small as possible.
BR,
Mikko
Hi,
Hi,
I think we are getting confused with the topic of conversation. I will start once again from the top to clarify my doubt.
cmd: 7e a0 1a 02 a1 21 32 a2 cb e6 e6 00 c0 01 81 00 03 01 01 49 07 00 ff 02 00 97 73 7e
Response: 7e a0 13 21 02 a1 52 21 3f e6 e7 00 c4 01 81 00 0f aa 7d 5e 7e
Above are the command and responses to collect one of the Power factor from the meter with OBIS 1.1.73.7.0.255.
In the meter display power factor for this particular OBIS is coming as "-0.86", but from the DLMS library after converting the response command (7e a0 13 21 02 a1 52 21 3f e6 e7 00 c4 01 81 00 0f aa 7d 5e 7e) the value is coming as "170" instead of "-86" in reg.value.lVal.
This is happening only when there is a negative power factor.
We are using the same DLMS library which has been purchased from Gurux.
Please clarify where this conversion is happening in DLMS library and how can we make it convert properly.
below is the code snippet for your reference.
if (requestType == DLMS_OBJECT_TYPE_REGISTER)
{
delay_us(100);
queryStatus = com_read(&con, ®.base, 2);
if(queryStatus == 0)
{
debug_print("\r\nReceived data %s , 2: ",dlmsDevice->oidList.oid[oididx]);
debug_print("\r\nValue : %d\r\n",reg.value.lVal); // Here its coming 170 instead of -86
for(pIdx=0;pIdx<con.data.size;pIdx++)
{
debug_print("%02X ",con.data.data[pIdx]);
}
debug_puts("\n");
}
if(queryStatus == 0)
{
queryStatus1 = com_read(&con, ®.base, 3);
if(queryStatus1 == 0)
{
debug_print("\r\nReceived data %s , 3: ",dlmsDevice->oidList.oid[oididx]);
debug_print("\r\nScaler : %d\r\n",reg.scaler);
for(pIdx=0;pIdx<con.data.size;pIdx++)
{
debug_print("%02X ",con.data.data[pIdx]);
}
debug_puts("\n");
}
}
}
Hi,
Hi,
Please create a ticket, If you have purchased the stack. You get an answer faster.
I tested this and I get value -86 like below.
Index: 3 Value: Scaler: 0.010000 Unit: NoUnit
Index: 2 Value: -86
How you try to convert it?
BR,
Mikko
Hi,
Hi,
Please, don't update the existing question. It's hard to find the updated questions.
Your value is a signed byte and you can get it from .cVal, not lVal.
You can get value as an integer using var_toInteger -method.
Something like this:
debug_print("\r\nValue : %d\r\n", var_toInteger(®.value));
BR,
Mikko