canmatrix icon indicating copy to clipboard operation
canmatrix copied to clipboard

Wrong min/max scaling when signal has slope or offset

Open lbeuster opened this issue 2 years ago • 1 comments

I try to convert arxml to dbc/kcd. Seems like the min/max values are scaled twice with the slope value. This happens when converting to dbc and kdc. And with all signals with a slope.

slope=0.0625 phys-max=1023.8125 internal-max=16383 (phys-max * slope)

but the converted max-value in kcd = 63.98828125 (16383 * 0.0625 * 0.0625), should be 1023.8125

In Xlsx the max value is missing.

It's the same for the offset. It is applied twice to min and max.

May be I miss something because I'm not very familiar with these CAN things?

ARXML

        <DATA-CONSTR UUID="626a0205-0000-0000-b658-00000004ec2a">
          <SHORT-NAME>DC_DC_IstSpannung_HV</SHORT-NAME>
          <DATA-CONSTR-RULES>
            <DATA-CONSTR-RULE>
              <PHYS-CONSTRS>
                <LOWER-LIMIT INTERVAL-TYPE="CLOSED">0.0000</LOWER-LIMIT>
                <UPPER-LIMIT INTERVAL-TYPE="CLOSED">1023.8125</UPPER-LIMIT>
                <UNIT-REF DEST="UNIT">/Unit/Unit_Unit_Volt</UNIT-REF>
              </PHYS-CONSTRS>
              <INTERNAL-CONSTRS>
                <LOWER-LIMIT INTERVAL-TYPE="CLOSED">0</LOWER-LIMIT>
                <UPPER-LIMIT INTERVAL-TYPE="CLOSED">16383</UPPER-LIMIT>
              </INTERNAL-CONSTRS>
            </DATA-CONSTR-RULE>
          </DATA-CONSTR-RULES>
        </DATA-CONSTR>

        <!-- hopefully this is the correct part ;) -->
        <COMPU-METHOD UUID="626a0202-0000-0000-b658-00000004ec2a">
          <SHORT-NAME>CM_DC_IstSpannung_HV</SHORT-NAME>
          <CATEGORY>SCALE_LINEAR_AND_TEXTTABLE</CATEGORY>
          <UNIT-REF DEST="UNIT">/Unit/Unit_Unit_Volt</UNIT-REF>
          <COMPU-INTERNAL-TO-PHYS>
            <COMPU-SCALES>
              <COMPU-SCALE>
                <LOWER-LIMIT INTERVAL-TYPE="CLOSED">0</LOWER-LIMIT>
                <UPPER-LIMIT INTERVAL-TYPE="CLOSED">16381</UPPER-LIMIT>
                <COMPU-RATIONAL-COEFFS>
                  <COMPU-NUMERATOR>
                    <V>0</V>
                    <V>0.0625</V>
                  </COMPU-NUMERATOR>
                  <COMPU-DENOMINATOR>
                    <V>1</V>
                  </COMPU-DENOMINATOR>
                </COMPU-RATIONAL-COEFFS>
              </COMPU-SCALE>
            </COMPU-SCALES>
          </COMPU-INTERNAL-TO-PHYS>
        </COMPU-METHOD>

KCD

    <Message id="0x2AE" name="DCDC_01_XIX_VCP_CANFD07" length="8" triggered="true" interval="10">
      <Notes></Notes>
      <Signal name="DC_IstSpannung_HV_XIX_DCDC_01_XIX_VCP_CANFD07" offset="12" length="14">
        <Value slope="0.0625" max="63.98828125" unit="Unit_Volt"/>
      </Signal>
    </Message>

lbeuster avatar Dec 01 '23 16:12 lbeuster

Hi @lbeuster

I think you have found a bug.

The arxml-parser does not take care of PHYS-CONSTRS and INTERNAL-CONSTRS. It's more or less random which one the parser uses. But it alwas calculates if it were INTERNAL-CONSTRS.

This is what I think happens: The parser takes the PHYS-CONSTRS --> 1023.8125 but it thinks it's the internal val and so scales it ...

ebroecker avatar Dec 06 '23 13:12 ebroecker

should be merged

ebroecker avatar Jul 18 '24 09:07 ebroecker