0

How to get LSB from 16bit unsigned value?

Jürgen Jürgenson 4 years ago in Devices / Modbus updated 4 years ago 3

Hey,

I'm wondering if there is a better way - Komfovent AHU sends its time and date values in 8x2int where MSB is hour value and LSB is the minute value.
I couldnt get the correct values with the options bOS has, so i turned to math... but i feel like the programs i made may be incorrect.

Image 2879

First i divided the 16bit unsigned value with 256 to get the MSB first. Then i basically subtracted the MSB value i got from the MSB Int value and multiply that again with 256. 

Image 2880

As i need to make a visu for the scheduler then it feels like a lot of trouble separating the values. Any better solutions?

Best regards,

Jürgen



Hey,

I got it working. I needed to make separate integer values for the users visualization, where they can input the time(hour and minute). As the calculation value itself is read only. 

Maybe i will release its template when im done with it.

+1

I used BitConverter

For minutes: 

  • Start bit: 0
  • Stop bit: 7

For hours:

  • Start bit: 8
  • Stop bit: 16

Same approach for Month-Day. I have not tried it for scheduling but I believe it should work too.

Thanks for the tip! This seems to be a much better solution - I didn't even know this option existed.