1

I am working on an automation project where I need to handle 21 fixed mount bar-code scanners in parallel(i.e. all the scanner will be running all the time) to achieve that I am using multi-threading. Here each thread will handle one bar-code scanner.

Now, I want to update the scanned data in P.L.C (DB/Memory Blocks/Tags) by using O.P.C. So, I wanted to know is it possible to update P.L.C values by using O.P.C client in a multi-threaded application.
I am using Siemens P.L.C ( Model :- CPU 315-2 PN/DP, step 7, 300 series).

I would also like to know whether I should go with O.P.C Server or LibNoDave. there will be around 300 tags (Data blocks in P.L.C) which I need to read and check for Data Change event.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
V N Mishra
  • 11
  • 2
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Jan 23 '14 at 10:54
  • Think you will find this thread useful: http://stackoverflow.com/questions/18040338/delphi-omnithreadlibrary-opc-client – A Murray Jan 23 '14 at 21:22
  • Based on what I've observed, OPC DA seems to give one "data change event" thread per OPC Client allocated, but I don't know if this is guaranteed by a spec. – jrh May 08 '17 at 14:24

2 Answers2

0

The short answer is Yes, but there is more to it, the link provided by A Murray is good read. You should also consider whether going multi-threaded can truly bring you any speed benefit. You easily get through many thousands of data changes per second with OPC-DA and just a single thread - do you really need more threads?

ZbynekZ
  • 1,532
  • 10
  • 16
  • dear friend,thanks for your reply. I am not using multi-threading to get data change event. this is to perform parallel activity once I get the data change event, like open the socket for the scanners and triggering the scanner at the same time. – V N Mishra Jan 27 '14 at 03:30
  • If the parallel activity does not do anything OPC-related, then there is no problem in using it whatsoever. In fact, using multithreaded approach is often needed when writing the OPC callback handlers, because you are not supposed to block the callback for extended periods of time. So, in the callback handler, you just store the data somewhere, and retrieve the data from a separate thread. – ZbynekZ Feb 20 '14 at 15:03
0

Better keep your architecture as simple as possible and avoid lots of threads, multithreading can unnecessarily complicate things and there is also a performance price to pay in case the threads need to synchronize. Since you have one OPC server and multiple threads connecting to it you will have to be careful not having the threads interfere with each other. If I were you I would instead have one thread that sets up a subscription to the OPC server with all the barcode scanners. Then another thread to monitor that thread to see if it is still working.

AndersK
  • 35,813
  • 6
  • 60
  • 86