Jump to content
Sign in to follow this  
LPK

Run once in ladder logic

Recommended Posts

Hi all,

I've started using a UniStream product (USP-070-B10) having previously used a Vision V1210 and was wondering if there was a similar thing to the SB2 contact for the UniStream PLCs / UniLogic.
 
I used SB2 in ladder previously to do things that that needed to be done at startup, and only once, like initializing values, etc. I’d like to do something similar now, but to load up data tables, to make sure that they are present in memory before using them (as look-up tables for data/calculations). This would ensure that the data’s there in the tables if a power outage occurs, etc.

Any ideas for how to do this?

Share this post


Link to post
Share on other sites

Hello,

 

Thank you for using our Unitronics Forum.

 

The UniStream uses structs to organize information.  One of the standard system structs is the "General" struct, which hold general system information.  With in this struct, there is a bit called "Ladder Initial Cycle".  This is the same thing as SB2 in the Vision controllers.

 

Place a contact in the ladder, click on "<Empty>" (Not the blue pencil) to bring up the valid structs and data types for this contact.  Select "General" then "Ladder Initial Cycle" to use this bit.

 

Hope this helps.

  • Upvote 1

Share this post


Link to post
Share on other sites

Ah! There it is! Thank you very much. This data table thing has a pretty complex import/export/write/create/download thing going on, but I think I have it now.

Share this post


Link to post
Share on other sites
Oh, I thought I had it, but now I see (other) issues…

 

As I said, I’ve been trying to load up data tables on PLC start/restart, to make sure that they are present in memory before using them.

 

I had no issues with the first table (3 columns, 139 rows of values), but on adding a second “Load DTI from File” function after the first to load a second table (3 columns, 500 rows of values), the values don’t load and I get a status value of -35, which the help says means ”Too many requests”.

 

I’m not sure what this means is getting too many requests, though – is it that the second “Load DTI from File” function is being called before the first has started, or something? Might it need a pause or something after the first to ensure the first is finished or something to make sure the first is finished successfully before the second is done? Or does this mean something different to what I’m imagining?

 

Any ideas would be gratefully received!

Share this post


Link to post
Share on other sites

Hello,

 

Are you trying to load two data tables at once?  It appears the PLC may be getting to many Load DTI calls.

 

Have you tried loading the second data table on the next rung?  Try loading it off of a compare statement: If DTI Status message = 0, Then Load DTI from Table 2.

 

Let us know if this helps.

Share this post


Link to post
Share on other sites
Thank you for the tips.

 

Yes, I was loading them in separate rungs, and I tried to load a third table, with the same results (a -35 error code).

 

My concern was that if it hadn't completed the first load by the time it came to the second, and so it didn’t try and load the second, it would pass through and not try again, as I was triggering the loadings on start-up using the General.Ladder Initial Cycle bit.

 

So I was wondering if there was an easy way, if the loading hadn’t finished, to keep trying until it had. But that might be trying to force my PC programming experience (using a Do ... Until type thing) onto this issue in a way that’s not right for ladder logic.

 

Maybe it’d be better to set up some bits as flags and keep trying to load the data until it’s satisfactorily loaded, keeping those inside the code that _is_ run each cycle - I was just trying to avoid having something (a flag) that’s checked for the many millions of cycles that the PLC will run for after each start-up, when the table loading is something that only needs to be done once at the start?

Share this post


Link to post
Share on other sites

You cannot save or load more than 1 data table at the same time. Here is how I would do it:

 

Assuming I have 3 data tables I want to load from file on initial cycle (well, none of them will be loaded in the inicial cycle, but the progress would start on the initial cycle)

On the initial cycle, I would set 1 bit and reset an int8 which would be used for the status (the output of the load DTI utility).

 

Then I have the code for the first table:

 

When (Bit1 && Status != 1)

{

Reset Bit1

Load_DTI(table1)

Set Bit2

}

 

I will have a similar code for the rest of the tables:

When (Bit2 && Status != 1)

{

Reset Bit2

Load_DTI(table2)

Set Bit3

}

 

When (Bit3 && Status != 1)

{

Reset Bit3

Load_DTI(table3)

}

 

 

That way, I'm sequencing the data tables loading.

  • Upvote 1

Share this post


Link to post
Share on other sites

Thank you very much for the suggestion. I've created something along the same lines using ladder commands/functions, so that the PLC will keep trying to load the data tables if it’s been previously unsuccessful.

I wasn’t sure how to implement the code in the way that you wrote it out, Saragani. Is there a block in Unilogic/UniStream that allows you to write more “freeform” code, rather than sticking to normal ladder elements?
 

Share this post


Link to post
Share on other sites

Ah, I thought it might have been. I wish I could use that kind of code, as I find it hard to convert my current programming knowledge into ladder and think in that way!

Share this post


Link to post
Share on other sites

As I understand it, the Saragani pseudocode above refers to 'Status' which is the stored output of a call on the 'Load DTI ...' function. This value can only be changed by a subsequent call on this function.

 

If Status were ever to be set to a value of 1 - 'Function in progress' - then no more calls could be made on the 'Load DTI ...' function.

 

Is the only way to use this status to repeatedly call the function until it returns a value of 0 indicating success?

 

Regards

 

Robin Proctor

Share this post


Link to post
Share on other sites

Further to my original post, I have now revised my understanding of the Load DTI to File function status tag. I guess that this function runs as a separate thread to the main program scan, and posts a 1 in the status tag until it completes, when it finally posts a non-1 value (hopefully 0). On reading a 1 in this tag the ladder logic should be set to do nothing further on this scan, but to repeat the read on the next scan.

 

Am I correct in this interpretation?

 

Regards

 

Robin Proctor

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...