-
Notifications
You must be signed in to change notification settings - Fork 2
Beckhoff
Wiki > The Backend System > IOCs > Motor IOCs > Beckhoff
Beckhoff motor controllers are the most complex in use at ISIS and will be the standard going forward. A Beckhoff controller is basically a generic PLC that includes a number of useful functions out of the box for running motors. The generality of a beckhoff means that it will most likely be used in the future for measuring and controlling other hardware outside of motion. A more detailed presentation has been given about Beckhoffs in a Code Chat entitled Layers, Onions and Ogres.
Unlike most other devices (except the Galil) the computing group has some oversight over the PLC code written on the controller. It has been agreed that this code will mostly be written by IDD, with oversight from computing to guide good programming practices, assist in debugging etc. The ISIS first version of this code is stored at https://github.com/ISISComputingGroup/BeckhoffPLCCode/, which has an accompanying wiki to discuss specifics of the codebase. However, going forward the code will be written in collaboration with the ESS and stored here.
Beckhoff code can be run as a simulated system on a developer machine by doing the following:
- Download and install TwinCAT 3 XAE more information can be found about this here. You will need to either create an account or register yourself as a guest. The XAE is really just a Visual Studio plugin.
- Start the Twincat XAE. This can be done by clicking on the TwinCat icon in the system tray.
- Open the Twincat project that you are interested in. For example there is a simple test PLC here
- Ensure that you have the following toolbars enabled in the XAE:
TwinCAT PLCTwinCAT XAE Base
- Click the
Activate Configurationbutton - TwinCAT will ask you to enter a code to get a trial license. You will need to do this once a week.
- If prompted if you wish to start the system in
Run ModeclickOk. Otherwise start run mode using the button next toActivate Configuration - You now have a simulated beckhoff PLC running on your PC. This behaves the same as real hardware and so all development can be done against it. You could now also run an IOC up talking to this local PLC.
- To see what is happening inside this PLC in more detail, and to change values, you can use the login button
Beckhoff provides an automation interface which can do any of the things you can do in the Twincat XAE automatically through DCOM. A C# (Beckhoff do not fully support a Python interface 😢) program (AutomationTools) has been written to leverage this interface in the following way to write integration tests for the Beckhoff:

- Jenkins will pull the Beckhoff PLC code from github
-
build.batis run to first build theAutomationToolsthemselves then to build the PLC code using theautomation interface. This build will also create a*.tpyfile, which outlines how to connect to the PLC and can be used to configure the IOC itself. - The IOC test framework is started. This will first use the
AutomationToolsprogram to run a local simulated PLC. Then startup and test the Beckhoff twincat in the usual way.
This is currently being run on the ndw1926 node on Jenkins. A quirk of using this DCOM interface is that the Jenkins slave must be run as an interactive user and thus not as a service. To do this there is a bat file that should run on startup inside C:\Users\ibexbuilder\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.
To run tests locally you must build the solution in the BeckhoffPLCCode>util_scripts>AutomationTools directory to create the AutomationTools binary (used by the IOCTestFramework to run the Beckhoff emulator). Once this is done you can run the following from your BeckhoffPLCCode directory to begin testing:
python %EPICS_KIT_ROOT%\\support\\IocTestFramework\\master\\run_tests.py -tp ".\\dummy_PLC\\tests"
Beckhoffs are connected to NDX machines via private networks, in much the same way as the Galils. By convention Beckhoffs live in the 192.168.1.22X range.
There are currently two IOCs that we have to communicate with Beckhoffs.
This IOC was originally written by ESS. It uses an ASCII protocol over TCP/IP to do the communication and is very specifically designed for motion. There is a simulator which can be run using the following steps:
cd EPICS\support\MCAG_Base_Project\master\epics\simulatordoit.bat- Start the IOC (host macros needs to be set to 127.0.0.1:5024)