Sign in to follow this  
Followers 0
electric101

Getting UDT to work with physical IO

10 posts in this topic

Greetings,

I'm here in my home lab trying to acquire a working knowledge of UDT's.  I've had to work with them in the past in large existing programs and they were a pain to track down and find out what IO they were really controlling.  I have a decent understanding of what they are and I've created several to play with here using my softlogix processor and a digital flex IO rack.

My issue starts when i'm trying connect my UDT's to the physical IO.  it looks like I cant use a simple move instruction (which would be way too easy and exactly what I need)  I have a flex IO 8 point output.  Local:1:O.Data[0]

I have a UDT consisting of (see attachment)

Valve001

 Valve001.Out

    Valve001.Out.OPEN

    Valve001.Out.CLOSE

  Valve001.In

    Valve001.In.OPEN

    Valve001.In.CLOSED

I have a copy instruction set to copy Valve001    to Local:1:O.Data[0]     Length 2

that allows the Out.Open and Out.Close UDT's to control bits 0 and 1 of the 8 bit output . .... great.

Now I have another UDT setup to control lighting...

Door

  Door.Out.OPEN

  Door.Out.CLOSE

I want to control bits 2 and 3

I make another copy instruction in a line before the original copy instruction that states Copy Door to Local:1:O.Data[0] Length 4

but i'm really just fighting for the same 2 bits that the valve controls.... how can I control bits 2 and 3 for the door/lighting logic using these UDT's?

 

and that's not yet getting into having physical inputs moved/copied to the UDT input bits.

thanks!!

 

 

UDT1.PNG

UDT2.PNG

Share this post


Link to post
Share on other sites


For your basic example, the easiest mapping method would be to use simple XIC--OTE rungs.

Keep the mapping logic in separate routines from the functional logic. Order execution to be :

  1. map inputs
  2. perform function logic
  3. map outputs

There may be little benefit from use of UDT's in your example. Where they are most useful is in bringing order to devices such as VFD's scanned on devicenet or profibus.

 

 

 

Share this post


Link to post
Share on other sites

Now I have another UDT setup to control lighting...

Door

  Door.Out.OPEN

  Door.Out.CLOSE

I want to control bits 2 and 3

I make another copy instruction in a line before the original copy instruction that states Copy Door to Local:1:O.Data[0] Length 4

but i'm really just fighting for the same 2 bits that the valve controls.... how can I control bits 2 and 3 for the door/lighting logic using these UDT's?

********************************************************************************************************

Change "Copy Door to Local:1:O.Data[0] Length 4" to " Copy Door to Local:1:O.Data[2] Length 2

 

The [2] is your starting bit point, and since you only need bits 2 and 3, your length is 2 bits.  I do agree with Gerry, where mapping can be done using rungs with xic-ote instructions, however, I have worked some very large IO projects, and this can become quite cumbersome as well as difficult to troubleshoot.  I built a couple of AOIs that map directly to the discrete input and output type cards, and all you have to do then is drag in your tag to the appropriate channel and you are good to go.  If anyone is interested I can share, just send me a msg.

Share this post


Link to post
Share on other sites

First:  Local:1:O.Data[0] is not a bit address! If the 8-point flex module is correctly entered in the I/O tree, it is a SINT address.

Second: The amount of data copied by a COP instruction is determined by the length parameter and the size of the destination type.

Third: COP & CPS do not operate on bit addresses.

The COP instructions in the OP's  screenshot are attempting to copy 4 and 2 Sint's (bytes) from his UDT into a single SINT. In this case, since the length is too big, each instruction will only copy one SINT (byte).

Share this post


Link to post
Share on other sites

Gerry, 

the 8 point flex module is connected to the softlogix processor using a 1784 PCIDS (PCI devicenet scanner card in the PC)  I used rsnetworks for devicenet to add the modules to the 1794 devicenet adapter and then added it to the scanlist of the 1784 scanner.  I then added the devicenet scanner to my rslogix 5000 project and it automatically mapped an array of DINTS [123]

I say all of that so that you know exactly what I have and know that a lot of what you say may seem like common knowledge to you guys but I've not had 1 day of actual training on PLC's or had anyone around me that knew them that I could learn from.  everything I know has been from reading online, playing with the 2 that I have in my lab and 8 months of work experience with them.

 

so,

are you saying that with the copy instruction I had on the valve with a length of 2  I was actually copying   2 bytes or 16 bits of the Valve001 UDT (even though it isn't that big) ?

is there anyway to stagger where the data is copied to in a DINT.   like if I wanted to copy 1 byte (8bits) from some other DINT into Local:1:O.Data[1]  but I didn't want it to start on the first byte of the Local:1:O.Data[1]  .... say I wanted it to copy it to the 2nd byte so that I could map the first byte using XIC.

 

thanks!

Share this post


Link to post
Share on other sites

OK. So Local:1 is the Dnet scanner and the O:Data array is 123 DINT's.

Quote

The amount of data copied by a COP instruction is determined by the length parameter and the size of the destination type.

With a length of 2 and destination of type DINT, you are copying 8 bytes. If the source is less than 8 bytes, the COP will get whatever follows the source tag in memory until satisfied.

There is an instruction BTD (bit distribute) that will copy bits into different positions.

Kudos for making the effort!

 

Share this post


Link to post
Share on other sites

Why not just alias the bits? Get rid of the copy statements.

Share this post


Link to post
Share on other sites
7 hours ago, Armadillo852 said:

Why not just alias the bits? Get rid of the copy statements.

Aliasing would be a substitute for using a UDT.

Elements in a UDT can't be aliased to elements external to the UDT.

 

Share this post


Link to post
Share on other sites
1 hour ago, Gerry said:

Aliasing would be a substitute for using a UDT.

Elements in a UDT can't be aliased to elements external to the UDT.

 

Holy Crap, you are correct. Wasn't even thinking about that. (Face Palms Self...)

Ignore my previous post.

Share this post


Link to post
Share on other sites

I would simply create an AOI and use Input Parameters for ZSO, ZSC, and Output Parameters for ZYO and ZYC.
Maybe also include Input Parameters for Max. Time to Open, Max. Time to Close, Valve Fault Reset. An Output Parameter to show Fault (Max. time exceeded)

In effect it is like creating a UDT however it's actually an Add-On-Defined Data Type and can be reused as many times as needed.

 

ValveAOI.jpg

Edited by Filthy McNasty

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0