Two Bytes One Int

rkukl

Lifetime Supporting Member
Join Date
May 2002
Location
USA MA
Posts
194
working on a project using Compact Logix I need to write data to a device that is looking for bytes but sent in an int. for instance Int 0 has Bytes 0 & 1 Int 1 has Bytes 2&3 etc. looking for suggestions how to make that happen. When i Read data from same device it outputs a 32 bit word (dint) use BTD instruction Bit Field Distribute strip out Bits 0-15 then 16-32. Now need to kind-of reverse that and send in 0-7 then 8-15 of integer to bytes.
 
Yup; examine how the COP instruction handles data byte-by-byte, and how the Length argument is the number of destination elements (not bits/bytes/words).

Like this:

COP MySINTArrray[0] MyINTValue Length 1

That puts the two bytes in MySINTArray[0] and [1] into the one 16-bit Word of MyINTValue.
 
Thanks Guys! I was making it more complicated that it needed to be. COPY does just what i need.
Have a Great Day!!!
 

Similar Topics

Hello, I have just started programming RS Logix 5000 for Compact logix. What is the proper way to split a DINT to 4 bytes?
Replies
3
Views
2,821
Hi. I have a new project, and it's in siemens S7. I can say that I'm having a hard time, because it's my first project with S7. In the...
Replies
5
Views
4,956
Hi everyone! I am working on a Siemens plc (1200/1500), and I have two instruction that i have to perform. A) data structure (40 bools, 40...
Replies
3
Views
2,433
I'm working on a project that involves updating messages on a Linx printer via ControlLogix. I'm sending and receiving data via sockets and can...
Replies
6
Views
2,116
Hello, I am new to Codesys 3.5 and I am trying to figure out how to convert a word into 2 bytes to send to another plc via ethernet/ip. Could...
Replies
5
Views
5,074
Back
Top Bottom