Hey Guys,
I am seeing some inconsistencies with a calculated expression. I am using the following equation to convert the bits of the stage registers to a decimal number for use by my HMI. My design is such that only one state/stage is enabled at a time. For most cases, this calculation appears to work fine. However, when S15 is enabled (S0_15 = 0x8000), the execution of the calculation returns a decimal value of 14. I am stumped as to why it would be fine for some cases but not others. For example S5 is converted properly to a decimal value of 5. Any thoughts?
IF(TestPlatform.S0_15 > 0, ((LN(TestPlatform.S0_15) / LN(2)) + 0), 0)
+ IF(TestPlatform.S16_31 > 0, ((LN(TestPlatform.S16_31) / LN(2)) + 16), 0)
+ IF(TestPlatform.S32_47 > 0, ((LN(TestPlatform.S32_47) / LN(2)) + 32), 0)
+ IF(TestPlatform.S48_63 > 0, ((LN(TestPlatform.S48_63) / LN(2)) + 48), 0)
+ IF(TestPlatform.S64_79 > 0, ((LN(TestPlatform.S64_79) / LN(2)) + 64), 0)
+ IF(TestPlatform.S80_95 > 0, ((LN(TestPlatform.S80_95) / LN(2)) + 80), 0)
+ IF(TestPlatform.S96_111 > 0, ((LN(TestPlatform.S96_111) / LN(2)) + 96), 0)
+ IF(TestPlatform.S112_127 > 0, ((LN(TestPlatform.S112_127) / LN(2)) + 112), 0)