Support Portal

How to read out and interpret the MPB temperature value

How to get the MPB10 temperature by using the correct data format.
Related Products
MPB10-VS00VSIQ00 MULTIPHYSICSBOX
Multi Physics Box
Attachments
MPB process data 32bit float to dec.py
signed 8bit bin to int.py

Table of Contents

You have two possibilities to read out the current temperature of the MPB10:

 

1. via process data if index 17 (17 to 20 possible) is configured to value 29:

 

You receive the temperature value in the process data as 32 bit (4byte) float number:

To convert this 32bit float number to a decimal value you can use eg. the Python script below:

import struct

def binary_to_float(binary_str):
    # Convert the binary string to an integer
    int_rep = int(binary_str, 2)
   
    # Pack the integer as a 32-bit binary and unpack it as a float
    float_rep = struct.unpack('!f', struct.pack('!I', int_rep))[0]
   
    return float_rep

# Query the binary number from input eg. 01000001111100000000000000000000 for 30.0 or 01000001010010000000000000000000 for 12.5
binary_str = input("Enter a 32-bit binary number (avoid blank spaces): ")

# Convert the binary number to a decimal number
decimal_number = binary_to_float(binary_str)

# Print the result
print(f"The decimal representation of the 32-bit binary number {binary_str} is {decimal_number}.")

2. the second possibility to get the MPB temperatures (current, max, min, max & min since last reset) is by reading out the needed subindex of index 4352:

The format of the temperature values is 8bit signed integer.
To convert the binary value to an integer value you can use the Python script below:

def signed_binary_to_integer(binary_str):
    # Ensure the binary string is 8 bits long
    if len(binary_str) != 8:
        raise ValueError("The binary number must be 8 bits long.")
   
    # Check if the binary number is negative (if the most significant bit is 1)
    if binary_str[0] == '1':
        # Convert to integer and subtract 256 to get the negative value
        integer_number = int(binary_str, 2) - 256
    else:
        # Convert to integer directly
        integer_number = int(binary_str, 2)
   
    return integer_number

# Query the binary number from input
binary_str = input("Enter an 8-bit signed binary number: ")

# Convert the binary number to an integer
integer_number = signed_binary_to_integer(binary_str)

# Print the result
print(f"The integer representation of the signed 8-bit binary number {binary_str} is {integer_number}.")
Keywords:
mpb temperature value, mpb10, float number