<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Codesys v3.5 Sint to byte</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/47a3b05ef6/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/47a3b05ef6/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/47a3b05ef6/</id><updated>2024-04-24T14:15:00.352000Z</updated><subtitle>Recent posts to Codesys v3.5 Sint to byte</subtitle><entry><title>Codesys v3.5 Sint to byte</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/47a3b05ef6/?limit=25#e07c" rel="alternate"/><published>2024-04-24T14:15:00.352000Z</published><updated>2024-04-24T14:15:00.352000Z</updated><author><name>bjarne-pagaard</name><uri>https://forge.codesys.com/u/bjarne-pagaard/</uri></author><id>https://forge.codesys.com3b25279e29f6e1b66972498dd694081f91b31c43</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi&lt;br/&gt;
A SINT is a short (signed) integer. It is already only 1 byte - so you should have no problem casting it to a byte like so: bMyByte := TO_BYTE(sintMyShortInt);&lt;br/&gt;
If you have a regular INT you want to put in 2 bytes - there are a lot of ways you can do this. A Union is certainly one of them. You could have a union with 2 memebers: An array of 2 bytes as one member, and an integer value as another member.&lt;/p&gt;
&lt;p&gt;Another way would be to look at MEMCPY to put the value into your CAN-message.&lt;br/&gt;
.. or create a function to take your input value as input, and giving you 2 individual bytes as output. This could be handy if you need to change the byte-order.&lt;/p&gt;
&lt;p&gt;Integer data types:&lt;br/&gt;
&lt;a href="https://help.codesys.com/webapp/_cds_datatype_integer;product=codesys;version=3.5.17.0" rel="nofollow"&gt;https://help.codesys.com/webapp/_cds_datatype_integer;product=codesys;version=3.5.17.0&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;-Bjarne&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Codesys v3.5 Sint to byte</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/47a3b05ef6/?limit=25#3486" rel="alternate"/><published>2024-04-22T07:03:13.211000Z</published><updated>2024-04-22T07:03:13.211000Z</updated><author><name>abjha1998</name><uri>https://forge.codesys.com/u/abjha1998/</uri></author><id>https://forge.codesys.com665b1c51ca47e39e161160cacf93ab30e9f37310</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi everyone,&lt;br/&gt;
I have been doing a project where I have to send CAN messages from WAGO plc pf200 in BYtes. The signed integer needs to be unpacked into two bytes. so far I have tried Union but that has not worked with me&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>