Example Program Drafts

Showing results for 
Search instead for 
Did you mean: 

Interactively Configuring an EPICS Client & Server Using LabVIEW DSC Module

Experimental Physics and Industrial Control System (EPICS) is a Channel Access (CA) Protocol communication method often used by Big Physics to implement distributed control systems for large scale experiments. EPICS uses a client/server architecture to communicate between various devices.

Using LabVIEW and the Datalogging and Supervisory Control (DSC) Module a LabVIEW VI can be configured as either an EPICS server or an EPICS client. The following tutorial details how to interactively configure both an EPICS client and EPICS server in LabVIEW.

GOAL: Create an EPICS server which publishes parameters (frequency and amplitude) to an EPICS network. Create an EPICS client which reads parameters published by the server and generates a sine function.

PROCEDURE: Creating the EPICS Server

     1.  Create a new LabVIEW project and save the project as "EPICS Example.lvproj"

     2.  Add two Virtual Folders to the project. Name one "Client" and the other "Server". Your project should now look like Figure 1.

               a.  (Right Click) My Computer » New » Virtual Folder

Figure 1.jpg

                            Figure 1: Project Window

     3.  Add a new Library to the Server folder created in step 2. Name this library "Server Library.lvlib"

               a.  (Right Click) Server » New » Library

     4.  Add the Network - Published Shared Variables listed in Table 1 to Server Library.lvlib created in step 3.

               a.  (Right Click) Server Library.lvlib » New » Variable

               b.  Configure the variables based on the parameters in Table 1. See Figure 2

Variable Type
Data Type
AmplitudeNetwork - PublishedDouble
FrequencyNetwork - PublishedDouble

                                                       Table 1: Shared Variable Parameters

Figure 2.jpg

                                            Figure 2: Shared Variable Properties

     5.  Add a new EPICS Server I/O Server to Server Library.lvlib

          a.  (Right Click) Server Library.lvlib » New » I/O Server

                    b.  Select EPICS Server » Continue...

                    c.  Select Add/Remove Variables...

                    d.  Navigate to the shared variables created in step 4 and add them to the I/O Server. See Figure 3.

                    e. Click OK

Figure 3.jpg

                         Figure 3: Adding Variables to the EPICS Server I/O Server

     6.  A window labeled "Configure EPICS Server I/O Server" will appear. Make note of the PV (Process Variable) names as they will be needed in a later step. See Figure 4.

Figure 4.jpg

                                    Figure 4: Newly Created EPICS Process Variables

     7.  Create a new VI under the Server folder.

               a.  (Right Click) Server » New » VI

               b.  Create the VI shown in Figure 5

               c.  Save the VI as "Server.vi"

Server.pngFigure 5.jpg

                                                  Figure 5: EPICS Server VI

     8.  The EPICS Server is now complete.

PROCEDURE: Creating the EPICS Client

     1.  Add a new Library to the Client folder. Name this library "Client Library.lvlib".

               a.  (Right Click) Client » New » Library

     2. Add a new EPICS Client I/O Server to "Client Library.lvlib"

               a.  (Right Click) Client Library.lvlib » New » I/O Server

               b.  Select EPICS Client » Continue...

               c.  In the "Configure EPICS Client I/O Server" window, add two Records to the Process Variables list. See Figure 6.

               d.  Change the name of each record to match the name of the server process variables created in step 5 and 6 of the above section. See Figure 6.

               e.  Click OK

Figure 6.jpg

              Figure 6: Linking EPICS Client to Server Process Variables

     3.  Create Network Published Shared Variables bound to the EPICS Client I/O Server

               a.  (Right Click) EPICS Client1 » Create Bound Variables...

               b.  Expand the Browse Source tree down to the EPICS Client until you can see the process variables for frequency & amplitude.

               c.  Expand amplitude and frequency so you can see the VAL for each.
               d.  Add the VAL for each process variable to the Added Variables list. See Figure 7.

               e. Click OK

Fig 7.jpg

                              Figure 7: Creating Shared Variables Bound to EPICS Client

     4.  (OPTIONAL but recommended) Upon the creation of the bound shared variables, the Multiple Variable Editor window opens.

               a.  It is useful, but not required to rename the shared variables created in step 3 to something more meaningful than VAL and VAL1.

               b.  By looking under the Network-Published: Project Path column one can see the process variable that the shared variables are bound to. See Figure 8.

               c.  Change the Name of the shared variable accordingly. To something such as "Client Amplitude" (thus to avoid confusion with the variables on the server side).

Fig 8.jpg

                                       Figure 8: Renaming Client Shared Variables

     5. Create a new VI under the Client folder.

               a.  (Right Click) Client » New » VI

               b.  Create the VI shown in Figure 9.

               c.  Save the VI as "Client.vi"

Client.pngFig 9.jpg

                                                                      Figure 9: EPICS Client VI

     6.  The EPICS Client is now complete.

PROCEDURE: Running the VIs

     1. Run Server.vi

     2. Run Client.vi

     3. Observe the communication between the server and client by adjusting the parameters on the client side. See Figure 10.

Fig 10_1.jpgFig 10_2.jpg

                                                                                     Figure 10: EPICS Client & Server Communication

     4. Open Distributed System Manager

               a.  Tools » Distributed System Manager

               b.  Browse into Localhost. See Figure 11.

               c.  Here you can observe all the shared variables and EPICS Process variables. Note the flow of data between the elements of this communication process.

                         1. Amplitude - Shared variable on the server side (Bound to EPICS server process variable)

                         2. VAL - Value of Amplitude process variable published by the EPICS server.

                         3. VAL - Value of Amplitude process variable read by the EPICS client.

                         4. Client Amplitude - Shared variable on the server side (Bound to EPICS client process variable)

Fig 11.jpg

                Figure 11: Viewing the Communication Process in Distributed System Manager     

Attached are zipped versions of this project for both LabVIEW 2011 and LabVIEW 2009.

*NOTE: Project will not run properly when opened on other computers because the process variables will not exist with the same name or path. It will be necessary to rebuild the Client & Server I/O servers and rebind the shared variables on the client side. *

Nick C | Software Project Manager - LabVIEW Real-Time | National Instruments
Active Participant Larry.C
Active Participant

Hi Nick C,

This is a really good walkthrough but I am having a slight issue. When running both the server and client they deploy without errors but the client produces an error on run time from the variables stating that there is a communication issue:    LabVIEW:  (Hex 0x8BBB0004) General communications failure.

Any thoughts on what could be causing this?



Larry Colvin
Senior Test Development Engineer
Dyson Technology Ltd.

Member Nick-C


Have you worked this tutorial from the start, or are you trying to run the VIs I have attached? If you are running the attached files, the process variables will be named for my computer and therefore will not exist on your machine. You will need to reconfigure the I/O servers.

If that is not the case, the easiest way to troubleshoot these issues it to open Distributed System Manager to find at which point in the passing of data the communication stops. General communication failure is not specific enough for me to really pinpoint where the problem is coming from. Let me know what steps you are at and if you have any additional information I'd be happy to try and help you troubleshoot further.


Nick C | Software Project Manager - LabVIEW Real-Time | National Instruments
Member wdreesen

So I got this error as well.  I hit continue and it came up on the Frequency variable with the same error again. I pressed continue and after a few seconds the data started showing up on the waveform graph.  It looks to me like it takes some time before the server is actually publishing data before the client can read it.