-3

Does anyone know a C# read data command will take place in which step of PLC cycle?

The PLC process steps are:

  1. The operating system starts the scan cycle monitoring time.
  2. The CPU writes the values from the process-image output table in the output modules.
  3. The CPU reads out the status of the inputs at the inputs modules and updates the process-image input table.
  4. The CPU processes the user program in time slices and performs the operations specified in the program.
  5. At the end of a cycle, the operating system executes pending tasks, such as the loading and clearing of blocks.
  6. The CPU the goes back to the begining of the cycle after the configured minimum cycle time, as necessary, and starts cycle time monitoring again.

My purpose is to find out how a C# application can affect on PLC CPU scan cycle time.

phuzi
  • 12,078
  • 3
  • 26
  • 50
Sara J
  • 3
  • 3
  • 1
    You're asking people to guess what *your* code or library does or will do. There's no `C# read data command`, that's something your own application or SDK will do. One application may read from a file, another from a socket, another from an HTTP stream – Panagiotis Kanavos Jul 25 '22 at 09:27
  • 1
    `The operating system starts the scan cycle monitoring time.` what operating system are you referring to? Because that's not what either Windows or Linux typically do. Some embedded versions maybe, but Siemens has a myriad of products with different software. Smaller ones won't run an OS – Panagiotis Kanavos Jul 25 '22 at 09:30
  • @PanagiotisKanavos : My C# application is reading I/O from Siemens S7-300 PLC. – Sara J Jul 25 '22 at 09:33
  • @PanagiotisKanavos : My C# application is running on Linux. – Sara J Jul 25 '22 at 09:34
  • The steps I mentioned is collected from Siemens documentation, which means a PLC internally do that steps. – Sara J Jul 25 '22 at 09:37
  • "how a C# application can affect on PLC CPU scan cycle time", in my experience, external applications usually just read/writes registers. If you need to control some internal property like cycle time I would expect that to be some specific method in your API. If your API seem to lack such a method I would guess that it would not be possible. But you might want to contact your PLC vendor since they should be experts in your particular PLC. – JonasH Jul 25 '22 at 09:46
  • @JonasH : My C# application read PLC's I/O and I was wondering to know if my C# app can increase the PLC scan cycle time. I don't want to control PLC's cycle time. – Sara J Jul 25 '22 at 09:52
  • I have no idea what "scan cycle time" is, but search the documentation. If you cannot find anything in the documentation, ask your vendor. That should be the general approach for highly specific questions like this. SO is not great for highly specific questions, since the chance a Siemens S7-300 PLC expert reads your question is much lower than for more generic programming questions. – JonasH Jul 25 '22 at 09:57
  • Operations are be blocked in the Siemans driver so you can read/write from c# without adding any timers. – jdweng Jul 25 '22 at 10:23
  • @jdweng : What does the "Operations are be blocked", could you please explain more? – Sara J Jul 25 '22 at 10:26
  • The low level driver doesn't return until the operation is completed (or is buffered). So you do not have to wait in c# before doing next operation. – jdweng Jul 25 '22 at 10:31
  • @jdweng : Yes, but in this project the most important thing for me is the C# app shouldn't interrupt the PLC not vise versa – Sara J Jul 25 '22 at 10:37
  • Your task is to determine if there is any impact. So best way of testing is to first just have c# read cycle number and compare PLC time with and without c# running. Then have c# read data at cycle 1 and see the impact. Then repeat and read data at only cycle 2. the repeat until you read at each one of the cycles. Then compare results. – jdweng Jul 25 '22 at 11:14
  • @jdweng : It's a good idea and actually I had done it before and I couldn't see any difference in PLC scan cycle time when C# app is running and when it is not running. I wanted to figure out how C# app affect on PLC, because in PLC every micro second is important... I was worry if after some months the c# app increase PLC scan cycle time (Maybe PLC stacking c# commands because they have low priority) – Sara J Jul 25 '22 at 11:27

1 Answers1

0

It really depends on how you read values from the PLC, but - in general - it's irrelevant: whenever you read, you get the value stored in PLC memory at that time.

From my experience, client applications connected to PLCs have no measurable effect on scan cycle time. By the way, I highly recommend you to use OPC UA subscriptions to maximize read / write efficiency and let the PLC firmware manage tasks internally.

Probably a more detailed answer is possibile with additional details (PLC type, library used for connection / data read-write, ecc).

IFrank
  • 419
  • 1
  • 5
  • 12
  • 1
    Thanks for your answer @FrankProp, yes you are right. I also asked the question in Siemens forum and the conclution was => " The read or write commands are handled in another process than the PLC commands. There is no synchronization between the PLC cycle and the processing of the commands. " – Sara J Aug 24 '22 at 07:17
  • @SaraJ you’re welcome. Thank you too for posting the update from Siemens forum. – IFrank Aug 25 '22 at 12:32