Issues with calculation data is there but result is 0

Hi,

I’m running RC with OBD data generated from a Stannum Embedded analogue to OBD converter. I get all signals I need to work but oil pressure, which is on a custom PID (01 AD) with a generic sensor. Data is recorded (in this case 53, which corresponds to 208 kPa with the sender I have) - see image - but the calculation for some reason returns 0. Where did I do wrong?


Comments

  • a and 255 are both integers, so division is calculated as integer operation, and it will return zero. Make one of them floating point so the division is done in floats. Either

    a / 255.0
    float(a) / 255
    float(a) / float(255)

    will work

  • Brilliant, thanks!

Sign In or Register to comment.