<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Converting CANbus to Decimal from signed 2's complement</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1c7192b6c6/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1c7192b6c6/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/1c7192b6c6/</id><updated>2024-08-16T13:46:17.867000Z</updated><subtitle>Recent posts to Converting CANbus to Decimal from signed 2's complement</subtitle><entry><title>Converting CANbus to Decimal from signed 2's complement</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1c7192b6c6/?limit=25#1f4b" rel="alternate"/><published>2024-08-16T13:46:17.867000Z</published><updated>2024-08-16T13:46:17.867000Z</updated><author><name>liamb</name><uri>https://forge.codesys.com/u/liamb/</uri></author><id>https://forge.codesys.com4ec85ed9106780d6239d4ca90a6addae0e5c667e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I need to combine two 8 bit CANbus messages to 16 bits signed int then convert to decimal Decimal from signed 2's complement.&lt;br/&gt;
I've been using the below code to read for new messages, combine them then assign them to a variable&lt;/p&gt;
&lt;p&gt;What is the best way to do this for from signed 2's complement?&lt;/p&gt;
&lt;p&gt;fbRxMessage351(Data := RxMessage351Data);&lt;br/&gt;
IF fbRxMessage351.NewMessage THEN&lt;br/&gt;
    ChargeVoltage := (WORD_TO_REAL((RxMessage351Data&lt;span&gt;[0]&lt;/span&gt;) + ((RxMessage351Data&lt;a class="alink" href="/forge/talk-ru/1/"&gt;[1]&lt;/a&gt;) * 256))) * 0.1;&lt;br/&gt;
END_IF&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>