Hello:
I'm looking to find a way to read 16 independent digital inputs which can change their state at rates of 10 to 50 ms.
According to their states I'll have to follow some procedures, do basic math, send that data to a PC and place some states at the digital outputs. I feel quite confident if the routine goes in TBasic (still I can't figure it out how to do it using Ladder).
So far - to test the fundamentals - I have placed a Custom Function with a routine which basically writes a user message, and then changes an output inside a cycle using the SETIO/CLRIO and later the REFRESH (It loops continuosly without returning to the ladder in order to keep it simple to program).
However, with the above, the LCD shows the message to the user, but doesn't refresh the output state accordingly.
The problem seem to dissapear if I place a DELAY of about 1 or 2 secs beetwen every cycle excecution. (Here I understand that it should take only 2ms after the REFRESH is called).
The above derives the following questions about the PLC's behaviour:
- Does the PLC performs the steps which follow the REFRESH simultaneously to the update of the phisycal states? (I mean, does the REFRESH function performs independent of the other processes?)
- Does the REFRESH function takes the same estimated of 2ms of the Ladder to update the physical input/output?
I guess that if I could manage efficiently the REFRESH inside the Custom Function, I would be able to perform the activities in a convenient TBASIC program.
I will appreciate any advise about the use of REFRESH, or maybe in the way I should call the Custom Function without having more pieces of code in Ladder.
Best regards,
Mauro