Copy byte to UDT of same Length Siemens

JDCROCKETT724

Member
Join Date
Jun 2010
Location
Michigan
Posts
249
How do I move one byte of data in an array to a UDT that is one byte in length. AB would be a slam dunk on this with a simple Copy instruction, but this is a head scratcher. Everything I have tried has not worked or is an error at compiling. How do I do this? You can see from my attached screen shot everything I have done.

I have accomplished what I am looking for by moving my byte to another byte in my static variables. Then I create a tag with my UDT below it with the AT datatype, but I feel this is hokey. I should be able to do this with a simple instruction.

Thoughts????? 🤾

1500 PLC with V16 of portal

Capture.PNG
 
Thanks for the reply. I didn't think to look into the Legacy instructions. However, this is inside of an FB that we plan to use throughout our line. When I put it into the FB then both my UDT variable and the Byte that is in the array are red. Also shown is me trying to get the move block variant to work without success.

Capture.PNG
 
Thanks for the reply. I didn't think to look into the Legacy instructions. However, this is inside of an FB that we plan to use throughout our line. When I put it into the FB then both my UDT variable and the Byte that is in the array are red. Also shown is me trying to get the move block variant to work without success.


Can you explain what the variables are in the FB?
i.e. input/output/inout/stat/temp


(Previous post deleted as I realised your UDT is not just 8 bools :( )
 
Last edited:
The "Status" variable is a Static variable and the "RawInputs.RawInputs[1]" is an input variable. I have an array of bytes from my device that I need to break down to what they mean. I tried to use a UDT for the PLC tag, but thank to the vendor and them breaking up the bytes in uneven numbers it throws the mapping off. So I thought if I just brought them into the FB as an array of bytes that I could easily copy them to a static variable.
 
That is certainly another way to do it, but I was looking for a nice clean way to do it. In the AB world a simple copy instruction would handle this with no problem. Copy byte to UDT with a length of 1. I was just hoping there was a clean way to do it in Siemens. I might just stick with my other way of doing it by using the AT function in the tags. Although that is not very intuitive to others who are not familiar with some of the higher functions of Siemens like maintenance personel.
 
Do you actually NEED the data as an array of bits anywhere? How does it get into that form in the first place?



If the data comes in as PLC inputs, you can assign the whole structure to a UDT. Obviously, you'd need to make sure you include reserve/spare/blanks whereever things are uneven.

Also, on a related question, the commands Serialize and Deserialize can be used to move an array of bytes to a UDT or vice versa. Doesn't help for array of bits though.


Technically, you can also declare your data as unoptimized and do things with absolute addressing, but that usually complicates things.



If you can't map the data type directly at the input, I'd recommend LDs strategy of making an FC to do the mapping for you.
 
Well spotted......tested and yes, this will work with my data blocks. Will have to check using STATs in FB.
 
Last edited:

Similar Topics

I have 2 7cp476 plcs. How can I copy one of them and install it somewhere else?
Replies
0
Views
73
Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
135
Hi everyone I'm in a bit of a conundrum, I've been trying to get this HMI on our machine and I am unable to retrieve it. Device Delta Model...
Replies
10
Views
891
Hi I have a Melsec FX1S-20MR, which has been programmed. I would like to copy the program to a new FX1S-20MR? What are the possible ways to do...
Replies
4
Views
620
Project involves updating a ~23 year old controller (C200HX CPU64). The HMI is a windows NT machine with the gui done with Delphi 5 (Pascal)...
Replies
1
Views
1,098
Back
Top Bottom