Jump to content

Retain counter


crash888

Recommended Posts

I have written a project for a Unitronics US5-B10-T42 PLC. I have been able to get all of my features to work except for 1 very simple item that should be a no brainer.

I have a counter that is supposed to keep track of all cycles for the history of the machine. I have attached the details below. Even though I have checked the "retain" box each time power is removed the counter resets.

Please note as well that I was also getting a RTC error each time I connected to this plc until I did some troubleshooting and found that the battery was dead in this brand new PLC. Once I changed to a new battery the RTC error disappeared but my counter still will not "retain" its value

Any help will be greatly appreciated

retain counter.png

Link to comment
Share on other sites

  • MVP 2023
1 hour ago, ORSO2001 said:

theoretically the "initial value" is checked just for the really first time that the program run...others reboot the retain has to save the last value that it took before the power off....

It would be nice if UniLogic (and VisiLogic) had the option to assign a value to integer operands on download similar to what is done with timer presets. Nevertheless, Gabriel Franco is absolutely correct in solving crash888's problem.

Link to comment
Share on other sites

Hi Flex,

maybe (or for sure) I misunderstood what crash888 said...i though that crash888 was just trying to put the PC and the PLC online (without download the project)...however I did a check and the retain variable take the last value that these has after every reboot and also after a "download" of the project (same project)...just if you select "reset retain variables" these will be reset at the initial value...so...what I am wrong or what I am not understanding about the issue/question (seriously)?

Link to comment
Share on other sites

  • MVP 2023

crash888's problem was that he wanted the value of the operand (COUNTER2) to be retained when the PLC is rebooted (retain checkbox was checked). He found that instead it was being reset to zero. Gabriel Franco correctly noted that crash888 also had a value entered in the box for Initial Value, so while the value was retained, it was immediately being overwritten on the first scan by the value (0) in the Initial Value box.

Unitronics needs to automatically uncheck the retained value checkbox and grayout the feature when something is entered into the Initial Value box, or grayout the Initial Value box when the retain is checked, since they are contradictory.

Link to comment
Share on other sites

I disagree with the last comment:

"Unitronics needs to automatically uncheck the retained value checkbox and grayout the feature when something is entered into the Initial Value box, or grayout the Initial Value box when the retain is checked, since they are contradictory."

 

@ORSO2001 comments are the correct behavior.

When creating a new tag set as retained, and setting on initial value, the new value will be set on the next download (since the tag does not exist in the plc).

The value of the tag should be retained on reboot and on next downloads, and would only be set back to it's initial value if the "Init Retained Tags" is being called from UniLogic.

 

If the problem that @crash888 is experiencing, is reproduced by the other people that replied to this thread, then we will try to reproduce it here as well.

Otherwise, it might be something with the project or the PLC, and need to be investigated individually with the customer.

 

Link to comment
Share on other sites

  • MVP 2023
34 minutes ago, pascal said:

another thing to mention -> you are not using correct ladder....

block 55 -> you should place the increment functions one after the other....

if [counter] ------ inc [counter 1]-------inc [counter2]

Why do you say this? It is functionally equivalent to place these increments in either series or parallel.

Link to comment
Share on other sites

Maybe in unilogic this is correct, but (I'm not 100% sure) if you do program like this in visilogic, the result could be inpredictive ?

the things I learned, thanks to this forum, is to keep the rungs as short and clean as possible

Now i can't think of any problems I had before, but sometimes when you program and you think it's correct, the PLC isn't executing the way you programmed it...

Maybe I'm to scared to program like this, but I'd rather be sure than guessing 😉😉

Link to comment
Share on other sites

  • MVP 2023
6 hours ago, pascal said:

the things I learned, thanks to this forum, is to keep the rungs as short and clean as possible

Yes, you've learned that from me and a few other senior members of this forum. The issue is that when the rung is overly complex, the compiler may not execute the steps in the order you might think. In this case, it doesn't matter which order the two increment functions are executed therefore it doesn't matter whether the rung is set up as serial or parallel.

Link to comment
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
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.