WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --My first ACS.NET Application
Microsoft C#Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 1 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --1 Introduction
This whitepaper contains a step-by-step explanation on how to create a very simple application in Microsoft C#, which is one of the.NET high-level software languages for interfacing to an ACS Motion Controller. The application connects to an ACS controller (can bephysical or simulator), enables the axis and produces an example of motion using jogging.

2 Downloading Visual Studio Community
1.

Browse to https://www.visualstudio.com/vs/community/2.

Download VS Community by pressing the download button

3.

Follow the onscreen instruction to install the software

3 Launching Visual Studio and Creating a Project1.

Launch Visual Studio or your copy of C# and open a new Windows Forms Application

2.

You will see the following screen. Click Create new project

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 2 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --3.

The following dialog box will appear

4.

Browse the project types on the left hand of the dialog and find Visual C# and Windows Classic Desktop. Select Windows Forms
App and change the name to MyACSapp.

5.

Click OK to create the project.

4 Building the Interface
The user interface will consist of five Buttons, one NumericUpDown and two TextBoxes. The buttons will be used to operate different
functions typical of a motion application. One TextBox will act as an output to the user in case there are any errors present whilerunning the motion application. The second TextBox will be used to enter the IP address of the controller that we wish to connect to.
The NumericUpDown allows the user to enter the speed when jogging. You will see the following screen:

FORM AREA

The components that will make the user interface have to be dropped into the form area shown above Form1[Design]. These components are available from the toolbox available on the left hand side of the Visual Studio environment. To keep this open press theat the top right of the Toolbox window.

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 3 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --1.

Click the button control in the Toolbox and drag it into the form area window as shown below.

2.

Click on this new button. This will display the properties area at the bottom right of the screen:

The properties listed here are only for the button1 object that you have selected.
3.

Change the text property to ‘Connect’. The Text property changes what is displayed in the user interface.

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 4 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --4.

Scroll down the list, change the (Name) property to ‘btnConnect’. The (Name) property changes the reference name used in theunderlying code. This is found under the Design Section

5.

You should now see the following in the form area:

6.

Repeat the same process for following Button Controls as shown in the table below. It’s best to repeat the above from step 1,
and not copy and paste.

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 5 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --Control Type

Design Name property

Text property

ButtonbtnConnect

Connect

ButtonbtnDisconnect

Disconnect

ButtonbtnEnable

EnableButtonbtnDisable

DisableButtonbtnJogJog

7.

Arrange the form as shown below:

8.

A text box will show the user if an error occurs while running the application. Add TextBox from the Toolbox by onto the form asbefore.

9.

As with the buttons previously, Change (Design) Name property to txtErrorInfo. The Text property does not need to be changed
because we want to start the application with an empty error indicator.

10. We will add a second text box that will allow entry of the IP address of the controller we wish to connect to. Change (Design)
Name property to RemoteAddressTB. The Text property can hold the IP address of the controller. For our example we will use
the IP address that ACS uses for its motion simulator.
11. To find the Simulator IP address, double-click the green and red arrow icon found in the windows application tray.

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 6 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --12. This will bring up the following window. Click on the simulator tab.

This shows the IP address of the simulator
13. Add the value of the IP address to the Text field of the RemoteAddressTB TextBox.

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 7 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --Just for clarity we will Add a Label from the Toolbox to add the words ‘IP address’ above the TextBox. We can change the Text property to ‘IP Address’.
14. Add a NumericUpDown indicator just above the Jog button. This will allow the user of the application to select the desired jog
speed. You may need to search for this control.

15. Change (Design) Name property to numFeedrate. The Text property does not need filled.
You should have your form layout looking like below.

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 8 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --5 Adding References
At this point the user interface components are all in place and we are ready to add the code. You will have to a make a ‘reference’ tothe ACS .NET libraries which are installed with the ACS SPiiPlus MMI Application Studio software.
1.

From the Solution Explorer on the right hand side of the C# environment. Expand References Folder as below.

2.

Right-click References, select Add Reference which will open the following screen

3.

Click Browse and go to the folder: C:\Program Files (x86)\ACS Motion Control\CommonFiles

4.

Select ‘ACS.SPiiPlusNET.dll’ and press OK

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 9 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --6 Adding the Code1.

In the Form1, double-click Connect button, the environment will automatically create a code where you can place your ownfunctionality.

2.

Under the Using Section at the top of the file add the reference as shown below: using ACS.SPiiPlusNET;

3.

Next we need to declare ‘Ch’ an Object of type API. Add the line of code after the Public Form1() function as shown below.

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 10 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --We want the Connect button to establish communication to the controller and if there are any errors to alert the user using our TextBox txtErrorInfo.
4.

Add the following section of code within the Connect event handler function. Notice with the editor that as you start typing thecode it may give you the option to auto-complete. Press tab if a correct suggestion shows and the word will auto-complete. Also
notice that any characters following two forward slashes “//” is a comment that the compiler will ignore and is therefore fordocumentation purposes.

5.

To get back to the Windows Form click on the tab “Form1.cs[Design]” at the top, as shown below.

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 11 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --6.

Double-click the Disconnect button, and add the following code:

7.

Click the tab “Form1.cs[Design]” at the top again

8.

Double-click the Enable button, and add the following code:

9.

Click the tab “Form1.cs[Design]” at the top

10. Double-click the Disable button, and add the following code:

You have seen that by double-clicking any of the buttons the environment automatically creates the code that becomes the event
handler for the event “Click” of the object that you selected. There are other events available, depending on the control that can beused to execute other functionality. In our application the Jog button will use the “MouseDown” and “MouseUp” events. We want tojog the motor while the Jog button is being pressed (MouseDown) but we want to stop the motor from jogging when the button isreleased (MouseUp event). The next step is to create the code for the MouseDown event for the Jog button. Carry out the following
set of steps:
1.

Return to the Form view and click the Jog button and refer to the Properties in the bottom right of the screen

2.

Click below:

button and the dialog box will show you all of the possible events that the Jog button control can respond to as

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 12 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --3.

Find the MouseDown event.

4.

Enter the name of function to handle the mouse down event as btnJog_MouseDown (as shown below).

5.

Press Enter and code will be generated:

6.

Add the following code inside the function:

7.

Click the tab “Form1.cs[Design]” at the top

8.

Repeat from step 1 and add code for btnJog_MouseUp event. The MouseUp events will halt the motion because we want tomake the motion come to a rest after the key is released by the user.

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 13 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --9.

Build the application by selecting Build Solution from the Build toolbar.

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 14 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --7 Testing your .NET Application
1.

Find the SPiiPlus User Mode Driver application you used to find the simulator IP address and select the connected applications.

2.

Run the C# application now by pressing the3.

When connect is pressed you should see the application connect in the SPiiPlus User Mode Driver application. When you press
disconnect you should see it disappear.

4.

Run the SpiiPlus MMI Software and create a work space that connects to the motion simulator.

5.

Bring up the Motion Manager and use the ‘create motion’ to bring up the Jog Motion.

6.

Switch back to your .NET application and make sure you are connected to the simulator. Press the Enable Button (and Disable)
and you should see the ‘Motor State’ change in the Motion Manager.

7.

Within the SPiiPlus MMI create a watch component for a variable that reference motion distance for example FPOS(0)button at the top of Visual studio environment.

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.ws

Page 15 of 16

WHITE PAPER – My first ACS.NET Application-- Dr. Cliff Jolliffe --8.

By entering a jog value within your .NET application and pressing the jog button you can see the distance change.

AuthorDr. Cliff Jolliffe, Head of Segment Marketing Automation at Physik Instrumente (PI) GmbH & Co. KG.

For many years, PI (Physik Instrumente), founded in 1970, has been a market and technology leader for high precision positioning
technology and piezo applications in the semiconductor industry, life sciences, photonics, and in industrial automation. In close cooperation with customers from all over the world, and for 50 years now, PI's specialists (approx. 1,300) have been pushing, again andagain, the boundaries of what is technically possible, and developing customized solutions from scratch. Technologies from PI achieve
reproducible accuracies in the millionth of a millimeter range. More than 350 granted and registered patents underline the company'sclaim to innovation.
PI develops, manufactures, and qualifies all core technologies in house, thereby constantly setting new standards for precision positioning: Piezoceramic patch transducers and actuators, electromagnetic drives, and sensors working in the nanometer range. As themajority owner of ACS Motion Control, PI is also a leading global manufacturer of modular motion control systems for multi-axis drive
systems, and develops customized complete systems for industrial applications with the highest precision and dynamics.
With six manufacturing sites and 15 sales and service offices in Europe, North America, and Asia, PI is represented wherever high techsolutions are developed and manufactured.

Physik Instrumente (PI) GmbH & Co. KG, Auf der Roemerstrasse 1, 76228 Karlsruhe, Germany
Phone +49 721 4846-0, Fax +49 721 4846-1019, Email info@pi.ws, www.pi.wsPage 16 of 16

WP4015 ACS.Net Application 06/2018.0 Subject to changes. © Physik Instrumente (PI) GmbH & Co. KG 2018

About PI