liamb - 2024-08-16

I need to combine two 8 bit CANbus messages to 16 bits signed int then convert to decimal Decimal from signed 2's complement.
I've been using the below code to read for new messages, combine them then assign them to a variable

What is the best way to do this for from signed 2's complement?

fbRxMessage351(Data := RxMessage351Data);
IF fbRxMessage351.NewMessage THEN
ChargeVoltage := (WORD_TO_REAL((RxMessage351Data[0]) + ((RxMessage351Data[1]) * 256))) * 0.1;
END_IF

 

Related

Talk.ru: 1


Last edit: liamb 2024-08-16