Welcome to the world of PLC & computer programming. I do not know the answer to this particular problem you have but be advised that if you get into this area of the business be prepared to spend alot of time & money chasing software problems like this. It will be hard to build these costs into a project. That is just the nature of the business.

Software is supposed to always work the same way. The trick is to get it working the first time.

Good luck.