adccommunitymod (AutomationDirect) asked a question.

Click: can a program know if it's running for the first time?

Created Date: June 08,2012

Created By: AlbertL

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

I think this might end up as a suggested Click firmware improvement, but being a PLC newbie I thought I should ask first. Currently, the value in a memory address that's defined as Retentive is retained when a new program is loaded into the PLC, if the new program also defines that address as Retentive. That's desirable in some cases, but in other cases you'd want the Retentive memory to be initialized to zero when the new program is loaded, because the "left-over " data from the old program wouldn't be meaningful for the new program. So I'm wondering, is there a way for a program to know when it's being run for the first time, as opposed to just restarting after power-up or a switch from STOP to RUN mode? I'm thinking of something like the 1st Scan system control register, but that would only be active on the first scan of the first run of a newly-loaded program. The program could use that bit to decide if it should initialize certain retentive addresses, or use the data that was left there by the previous execution of the program.


  • adccommunitymod (AutomationDirect)

    Created Date: June 08,2012

    Created by: bcarlton

    In your offline file set a retentive address to zero. On the program first pass, if that location is zero then perform the initialization procedure and write some non-zero value to that retentive address.

  • adccommunitymod (AutomationDirect)

    Created Date: June 08,2012

    Created by: AlbertL

    Thanks for the suggestion. The thing is, I can't find a way to set an initial value for a retentive address. In the Address Picker, when you set the Retentive attribute to Yes, the Initial Value field changes to Disable. If it is somehow possible to do that, it would be a good solution.

  • adccommunitymod (AutomationDirect)

    Created Date: June 08,2012

    Created by: bcarlton

    Load it into the Click. let it run. set the value back to zero while online. then save.

  • adccommunitymod (AutomationDirect)

    Created Date: June 08,2012

    Created by: AlbertL

    I think this might end up as a suggested Click firmware improvement, but being a PLC newbie I thought I should ask first.

    Currently, the value in a memory address that's defined as Retentive is retained when a new program is loaded into the PLC, if the new program also defines that address as Retentive.

    That's desirable in some cases, but in other cases you'd want the Retentive memory to be initialized to zero when the new program is loaded, because the "left-over " data from the old program wouldn't be meaningful for the new program.

    So I'm wondering, is there a way for a program to know when it's being run for the first time, as opposed to just restarting after power-up or a switch from STOP to RUN mode? I'm thinking of something like the 1st Scan system control register, but that would only be active on the first scan of the first run of a newly-loaded program. The program could use that bit to decide if it should initialize certain retentive addresses, or use the data that was left there by the previous execution of the program.

    Expand Post