Skip to content

Commit 462a89b

Browse files
Merge pull request #28 from ISISComputingGroup/beckhoff_architecture
Beckhoff architecture
2 parents 99363b1 + d3c8265 commit 462a89b

File tree

8 files changed

+114
-54
lines changed

8 files changed

+114
-54
lines changed

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,6 @@
104104

105105
intersphinx_mapping = {
106106
"ibex_user_manual": ("https://isiscomputinggroup.github.io/ibex_user_manual/", None),
107+
"EPICS": ("https://docs.epics-controls.org/en/latest/", None),
107108
}
108109

doc/specific_iocs/motors/Beckhoff.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,9 @@ Current Beckhoff installations are:
1818

1919

2020
## Code on the controller
21-
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. Code running on the PLC lives [here](https://github.com/ISIS-Motion-Control).
21+
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. Code running on the PLC is kept in source control [here](https://github.com/ISIS-Motion-Control).
2222

23-
### Documentation
24-
- [Axis and Controller Commissioning Guide](https://stfc365.sharepoint.com/:w:/s/ISISMechatronics/Ee_aMxb5CF1Dlz-NUGW3OVgB0K7vQjXXwZDwSl5DSHN48w?e=GjqNEb&isSPOFile=1) document describing setting up a controller and TwinCAT solution for a new system and configuring real and virtual axes within TwinCAT environment.
25-
26-
## Troubleshooting
27-
see [Beckhoff troubleshooting](beckhoff/Beckhoff-troubleshooting)
28-
29-
## Testing
30-
See [Beckhoff testing](beckhoff/Beckhoff-testing)
23+
The [Axis and Controller Commissioning Guide](https://stfc365.sharepoint.com/:w:/r/sites/ISISMechatronics/Shared%20Documents/Beckhoff%20and%20TwinCAT/Commissioning/Axis%20and%20Controller%20Commissioning%20Guide.docx?d=w1633daef08f9435d973f8d5065b73958&csf=1&web=1&e=QFdAQk) document describing setting up a controller and TwinCAT solution for a new system and configuring real and virtual axes within TwinCAT environment.
3124

3225
## Commissioning a new Beckhoff on a beamline
3326
see [Beckhoff Commissioning](beckhoff/Beckhoff-commissioning)
@@ -38,16 +31,13 @@ see [Beckhoff Commissioning](beckhoff/Beckhoff-commissioning)
3831
we no longer use [tcIOC](https://github.com/ISISComputingGroup/EPICS-tcIoc) for numerous reasons, the most important being the dependence on the unreliable `.tpy` file format which was preventing us from integrating the new motion standard library code. We now use [`AdsDriver`](https://github.com/ISISComputingGroup/adsDriver) in conjunction with [`TwincatMotor`](https://github.com/ISISComputingGroup/EPICS-TwincatMotor).**
3932
```
4033

41-
### Beckhoff config area
34+
See [Beckhoff IOC Architecture](beckhoff/Beckhoff-architecture) for more information.
4235

43-
The config area contains a directory used for storing `.cmd` files for use with the `TC` IOC (in the same way as a galil or other motor controller). On an instrument it should look like this: `\instrument\apps\EPICS\support\motorExtensions\master\settings\<instname>\twincat\`.
44-
45-
### Quirks
36+
## Troubleshooting
37+
see [Beckhoff troubleshooting](beckhoff/Beckhoff-troubleshooting)
4638

47-
- The main quirk with the way we interact with Beckhoffs is that we use [`AdsDriver`](https://github.com/ISISComputingGroup/adsDriver) to spin up lots of intermediate PVs, in which our motor record uses with `dbpf` and `dbgf` instead of directly communicating with the device. In the future, we could integrate [`AdsDriver`](https://github.com/ISISComputingGroup/adsDriver) within our motor record for a more standard approach.
48-
- The Beckhoff uses whether it has been homed to set `ATHM` in the motor record, rather than just using the raw datum switch.
49-
- The "limits" shown on the table of motors summary view are not necessarily actual physical limit switches being engaged - the Beckhoff has more complex rules on whether motors can move back or forwards
50-
- The motor record sets `UEIP` (use encoder if present) to false to avoid using the encoder resolution to scale values. We have no control over whether to use or not use an encoder with a Beckhoff, the internal code handles it
39+
## Testing
40+
See [Beckhoff testing](beckhoff/Beckhoff-testing)
5141

5242
## Updating
5343

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Beckhoff IOC Architecture
2+
3+
[TC](https://github.com/ISISComputingGroup/EPICS-ioc/tree/master/TC) is the IOC responsible for communication with Beckhoff PLCs at ISIS.
4+
5+
At IOC startup, it uses [a command](https://github.com/ISISComputingGroup/adsDriver/blob/71a3404bd266cc260ff8802e1a1c017be09dbef4/adsApp/src/ioc_commands.cpp#L139-L199) to get the number of motion axes. Note that this may be more than 8, in which case we have to use [some logic](https://github.com/ISISComputingGroup/EPICS-ioc/blob/2ae20fd5997457a48469ced80f377eaaa49935b3/TC/iocBoot/iocTC-IOC-01/st-common.lua#L51-L55) to alias `MTR0109` to `MTR0201` so we can display it in the IBEX GUI's table of motors.
6+
7+
We have an EPICS motor record implementation which TC uses that interfaces some intermediate PVs, spun up [at runtime](https://github.com/ISISComputingGroup/EPICS-ioc/blob/97e2bd77c5909ff2f1b6c0cda7f175366b379102/TC/iocBoot/iocTC-IOC-01/st-common.lua#L30) per-axis by AdsDriver using [the Beckhoff Motor Extensions](https://github.com/ISISComputingGroup/EPICS-motorExtensions/tree/master/beckhoffApp) `.db` files.
8+
9+
This was originally done so we could drop in [`AdsDriver`](https://github.com/ISISComputingGroup/adsDriver) in place of another ADS EPICS module ([`tcIOC`](https://github.com/ISISComputingGroup/EPICS-tcIoc)) and debug EPICS to ADS communications more easily by bypassing the motor modules if we saw an issue. In the future, we could build [`AdsDriver`](https://github.com/ISISComputingGroup/adsDriver) calls into our motor module directly so we avoid this extra step. We still need to use `AdsDriver` to spin up extra, instrument-specific PVs - {ref}`beckhoff_arbitrary_fields`
10+
11+
This means that the EPICS motor record is essentially doing `dbgf` and `dbpf` as documented in the {external+EPICS:doc}`EPICS IOC Test Facilities <appdevguide/IOCTestFacilities>` respectively to read and write to these PVs, rather than just setting something on a device like a normal motion controller like a {doc}`../McLennan-motors` or {doc}`../Galil`.
12+
13+
`TC` also does some things "outside" the motor record such as forwarding the device's velocities to the motor record. This is because the PLC is commissioned with a sensible velocity in most cases and we don't want to overwrite this information, and it may change on the PLC due to safety system overloads and so on. We also do the same for axis description (to the `.DESC` field) - see {ref}`beckhoff_manual_commission_step`.
14+
15+
16+
### Beckhoff config area
17+
18+
The config area contains a directory used for storing `.cmd` files for use with the `TC` IOC (in the same way as a galil or other motor controller). On an instrument it should look like this: `\instrument\apps\EPICS\support\motorExtensions\master\settings\<instname>\twincat\`.
19+
20+
### Quirks
21+
- The Beckhoff uses whether it has been homed to set `ATHM` in the motor record, rather than just using the raw datum switch. This is different to a Galil which uses the datum switch.
22+
- The "limits" shown on the table of motors summary view are not necessarily actual physical limit switches being engaged - the Beckhoff has more complex rules on whether motors can move back or forwards.
23+
- The motor record sets `UEIP` (use encoder if present) to false to avoid using the encoder resolution to scale values. We have no control over whether to use or not use an encoder with a Beckhoff, the internal code handles it. As well as this, we do not retry (`.RCNT` and `.RDBD` fields of the motor record) as the motion control loop is handled by the PLC.
24+
- Some Beckhoff axes are virtual as the PLC can handle kinematics, for example many of the INTER axes. There isn't currently a way to differentiate real and virtual axes other than marking them with `v - ` in their `.DESC` fields.
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
# Beckhoff commissioning
22

33
## Commissioning steps
4+
45
These steps are for commissioning a Beckhoff on a beamline.
56

67
### Networking
8+
79
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, starting at 1 for the first controller (`192.168.1.221`)
810

911
### ADS routes
12+
1013
To actually communicate via the ADS transport layer you will need to set up a route on the instrument PC. To do so:
11-
1. (**these are included in the windows 10 clone so should already be installed to instrument machines**) Install the XAR tools
14+
1. (**these are included in the Windows 10 clone so should already be installed on instrument machines**) Install the XAR tools
1215
A copy of these will be hosted on `<public share>\third_party_installers\special_drivers\beckhoff\`. All of the defaults are fine so this should be a case of just clicking through the wizard and installing the drivers that show up.
1316
2. Set up an ADS route on the NDX:
1417
- `Right-click TwinCAT icon in system tray -> Router -> Edit Routes -> Add...` with these settings:
@@ -18,32 +21,38 @@ To actually communicate via the ADS transport layer you will need to set up a ro
1821
3. To confirm that this has been set up remote into the controller itself on the aforementioned IP address and check that the route to the NDX has been added automatically. You should not need to manually add a route in the controller.
1922

2023
### IOC setup
24+
2125
The IOC (`TC_01`) should in principle be able to talk via ADS at this point but will need setting up in the respective configs.
2226
- A `MTRCTRL` number will need to be given - this is the controller number as shown on the table of motors.
2327
- `Beckhoff_plc_code` should be specified as a macro, this may be removed in future releases, more information on this is available below however it should be set to `1` for instruments running the latest code.
2428
- Number of axes (`NUM_AXES` macro)
2529
- the `IP` and `AMSnetID` of the controller
2630

31+
{#beckhoff_manual_commission_step}
2732
#### Fields that aren't automatically populated
33+
2834
Although commissioning a Beckhoff is far simpler than a Galil from an IBEX perspective, there are some fields that need to be set manually for each axis. These are:
2935

3036
- Engineering units (`.EGU`) - [ticket to automatically populate](https://github.com/ISISComputingGroup/IBEX/issues/6855)
3137
- Axis description (`.DESC`) - [ticket to automatically populate](https://github.com/ISISComputingGroup/IBEX/issues/6860)
3238
- Note, if `stDescription` is actually filled out on a Beckhoff you can use the `FORWARD_DESC` macro set to `1` which will forward the PLC description to the corresponding motor record's `.DESC` field.
33-
- Soft limits
39+
- Soft limits - [ticket to automatically populate](https://github.com/ISISComputingGroup/IBEX/issues/8763)
3440

3541
These can be set via a `caput` and will be autosaved thereafter.
3642

3743
#### Axes, motion setpoints, jaws
38-
These are loaded in the usual way, you'll need to put your `axes.cmd` and `motionSetpoints.cmd` files in the `twincat` config directory
44+
45+
These are loaded in the usual way, you'll need to put your `axes.cmd` and `motionSetpoints.cmd` files in `motorExtensions\master\settings\<inst>\twincat\`
3946

4047
#### Jaws
4148

42-
Jaws controlled by Beckhoffs don't actually require any logic to calculate gaps & centres, as this is done on the controller using virtual axes for the gaps and centres, so instead we load in a `$(JAWS)/db/jaws_alias.db` file instead of the usual `jaws.db`. This takes macros for the (virtual) axes to use as the gaps and centres.
49+
This is currently done in the same way as any other motion controller where IBEX works out gaps and centres. This logic may move to the controller eventually, in which case we will need to use [The Jaws alias `.db`](https://github.com/ISISComputingGroup/EPICS-jaws/blob/master/jawsApp/Db/jaws_alias.substitutions)
4350

4451
#### If a controller has more than 8 axes
52+
4553
If a controller with more than 8 axes is going to be used, the TC IOC will alias records to the next controller number so they are shown in the GUI. For this to work you need to make sure that the next available controller number is not (and never will be, so long as the TC IOC uses it) used.
4654

55+
{#beckhoff_arbitrary_fields}
4756
#### Arbitrary fields
4857

49-
It was decided during [A meeting with the motion team](https://github.com/ISISComputingGroup/IBEX/issues/6916) that extra fields, for example LARMOR's air signals + bump strips will be exposed via a separate `PROG` file within the PLC. We should load these in from a `motorExtensions` `.cmd` file. Examples for LARMOR and SANS2D can be found in the settings directory of `motorExtensions\master\settings`
58+
It was decided during [A meeting with the motion team](https://github.com/ISISComputingGroup/IBEX/issues/6916) that extra fields, for example LARMOR's air signals + bump strips will be exposed via a separate `PROG` file within the PLC. We should load these in from a `motorExtensions` `.cmd` file. Examples for LARMOR and SANS2D can be found in the settings directory of `motorExtensions\master\settings`

doc/specific_iocs/motors/beckhoff/Beckhoff-testing.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,47 @@ _When you have finished testing/reviewing a PR, it is best to run `unsettick.bat
4747

4848
</details>
4949

50+
## Simulate an Instrument
51+
52+
To simulate an instrument's Beckhoff and make it virtual rather than driving physical motors etc. you need to:
53+
54+
1. Follow the above steps
55+
1. find the repo for that particular MCU within https://github.com/ISIS-Motion-Control
56+
1. `git clone --recurse-submodules <repo> <dir>`
57+
1. open up the solution in TwinCAT XAR
58+
1. change the `MCU_xxx` in the dropdown next to "solution" to `<local>`
59+
60+
There are a few things we need to disable in XAR in order to get this instance entirely virtual. these are:
61+
62+
(under the "solution" in the solution explorer)
63+
64+
License:
65+
1. in SYSTEM -> License remove any dongles (these are normally physical USB sticks)
66+
1. generate a "7 days trial license" from the top-level screen
67+
68+
I/O:
69+
70+
in `I/O -> Devices`, disable all devices that show up by right-clicking and selecting "disable"
71+
72+
Safety:
73+
74+
in `SAFETY`, disable all safety instances
75+
76+
Motion:
77+
78+
in `MOTION -> NC - Task 1 SVB` go to Axes and then expand all axes, then go to `Enc` and change the "type" to "Simulation encoder"
79+
80+
81+
After doing all of this you should be able to build the solution from "build" and then hit activate(icon that looks like stairs) and run it locally.
82+
83+
84+
5085
### Continuous Integration
5186

87+
```{warning}
88+
This is currently broken and this documentation will become out-of-date until https://github.com/ISISComputingGroup/IBEX/issues/7552 is complete to get them running again.
89+
```
90+
5291
<details><summary>Jenkins</summary>
5392

5493

doc/specific_iocs/motors/beckhoff/Beckhoff-troubleshooting.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,31 @@ See https://github.com/ISISComputingGroup/IBEX/issues/8339 for a detailed descri
2929

3030
The solution is to set `.DLY` to 0.25 in the motor record (which causes a 250ms "settle time" after motions).
3131

32+
## Instrument specific Beckhoff information
33+
34+
### SANDALS - Jaws and Sample Changer
35+
36+
SANDALS has a Beckhoff PLC which serves the Jaws permanently, and the Sample Changer when it is plugged in (over an [EtherCAT](https://en.wikipedia.org/wiki/EtherCAT) network)
37+
38+
Some of these axes are relatively-encoded, so need to be homed/calibrated before use after a power cycle. At the moment we use the `.ATHM` field to indicate this, so if the home icon is not shown on the Table of Motors the axes have not been calibrated and will error when a move is attempted.
39+
40+
The Sample changer has some `pt100` sensors for temperature mounted on it, these are fed in through the Beckhoff as extra fields. These are loaded by [this `.db`](https://github.com/ISISComputingGroup/EPICS-motorExtensions/blob/master/sandalsSampleChangerApp/Db/sandals_sample_changer_beckhoff_extras.substitutions)
41+
42+
### INTER - Detector tank including Jaws 4
43+
44+
This is currently the most complex implementation of using a Beckhoff PLC as it handles kinematics between physical axes and flight paths, traditionally "worked out" by the Reflectometry server. It has some custom routines which can be accessed from the PLC HMI or through the `INTER Beckhoff Diagnostics` device screen in IBEX.
45+
46+
It also controls some Jaws on the front of the tank.
47+
48+
### LARMOR - Detector Bench
49+
50+
This is a single axis. It lets IBEX know about an air PLC signal as it requires an air bearing to move. This is fed in by [this `.db`](https://github.com/ISISComputingGroup/EPICS-motorExtensions/blob/master/larmorBeckhoffExtrasApp/Db/larmor_beckhoff_extras.substitutions) and the bump strip signal is flipped and sent to the bump strip PV which is shown in the banner to indicate that motion has tripped.
51+
52+
### IMAT - Rotation and Height stage
53+
54+
This is currently just two axes, with no real quirks on our side.
55+
56+
### SURF - Cloche motion and jaws 1&2
57+
58+
SURF's motion involves the tank, including the supermirror and frame-overlap mirror, as well as Jaws 1 and 2. This has had issues with encoder radiation in the past which has required a PLC power cycle, which in turn then requires a power restore. In order to get this properly working, [this ticket](https://github.com/ISISComputingGroup/IBEX/issues/8464) needs to be completed.
59+

doc/specific_iocs/motors/beckhoff/Beckhoffs-‐-simulate-an-instrument.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

doc/spelling_wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ enums
233233
env
234234
erroring
235235
ess
236+
EtherCAT
236237
ethernet
237238
Eulerian
238239
Eurotherm

0 commit comments

Comments
 (0)