Search code examples
automationplc

Resetting integer (DS) to 0 in Ladder Logic for PLC (Koyo's Click PLC)


I'm not sure if this is the good website for ladder logic programming questions but I will it a try.

I'm using a Click PLC C0-01 DR-D by Koyo (Desc page: http://www.automationdirect.com/adc/Overview/Catalog/Software_Products/Programmable_Controller_Software/CLICK_PLC_Programming_Software) with it's free software. I'm trying to make a program in Ladder Logic to executes multiples operations by the PLC. To keep track of the current operation, I use an integer value I'm incrementing as the current operation ID. However, I'm not able to reset this value to 0.

First I tried with the COPY but there's a radio button to ignore zeros. This radio button is checked and disabled (can't change it). Forcing to suppress zeros. The documentation of the software says "Option: This Option is available when the Source is a Data Memory Register Address and the Destination is a TXT Address." But since I just want an ID and I need to compare this ID with = everywhere in my program and increment it, I don't want to put a string.

Then, I can use math to assign a formula to a variable. I tried put zero and it's working half the time. Note that the "One shot" checkbox isn't selected even if it may to be acting like so.

Math to set to zero

About this option, the documentation says "One Shot: Select One Shot to solve the formula only once after each OFF-to-ON transition of the enabling rung." However, to be able to set the value to 0 again, I need to restart the PLC. When I first execute the program everything is fine because the value is already 0. When I restart it, the value didn't reset so it's still 7 and it skips all my operations. Then it resets to 0 (it's doing so at the end) and when I restart the PLC, I'm able to run it normally for one time. Here an example of the current passing but the value not set:

enter image description here

Is it a bug from the PLC ? Is there a workaround ?

In short, I'm looking for a reliable way to set a value to 0.

Thanks in advance for the answers. Sorry If I violated 40 rules, I'm new and happy to join this community.


Solution

  • I though I resolved my problem but I just pushed it further. Thanks to Garry Shortt with his youtube channel dedicated to PLC programming for helping me out with my problem.

    His explanation to the problem is "Changed the math to a copy command and placed it in the main program where you had it before. The program seems to work well. The only thing that I can think of is when you use subroutines, and they are not being scanned. The items within the routine is the same unless you them changed in another part of your program."

    Hope it will be helpful for someone someday.