Skip to content

Commit

Permalink
Update PLC best practice with DESC
Browse files Browse the repository at this point in the history
  • Loading branch information
anderssandstrom committed Sep 27, 2024
1 parent 7dbbb2d commit 78af68f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/PSI/best_practice/plcs/startup.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ${SCRIPTEXEC} ${ecmccfg_DIR}addSlave.cmd, "SLAVE_ID=10, HW_DESC=EL2819"

#- ############################################################################
#- Load PLC (note the include dir (INC) and the use of ECMC_EC_SLAVE_NUM)
${SCRIPTEXEC} ${ecmccfg_DIR}loadPLCFile.cmd, "FILE=./cfg/main.plc, INC=.:./cfg/, SAMPLE_RATE_MS=1000, PLC_MACROS='BO_S_ID=${ECMC_EC_SLAVE_NUM}'"
${SCRIPTEXEC} ${ecmccfg_DIR}loadPLCFile.cmd, "FILE=./cfg/main.plc, INC=.:./cfg/, DESC='Toggle bits', SAMPLE_RATE_MS=1000, PLC_MACROS='BO_S_ID=${ECMC_EC_SLAVE_NUM}'"

#- ############################################################################
#- Go active
Expand Down
17 changes: 15 additions & 2 deletions hugo/content/manual/PLC_cfg/best_practice.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ Here you can find some best practice configurations for common usecases.
* Macros
* MSI include, substitute
* Printouts
* Description

The complete examples with starup files can be found [here](https://github.com/paulscherrerinstitute/ecmccfg/tree/master/examples/PSI/best_practice)

### macros
Use of macros makes the code more generic. When loading a PLC file with "loadPLCFile.cmd", custom macros can be defined in "PLC\_MACROS":
```shell
${SCRIPTEXEC} ${ecmccfg_DIR}loadPLCFile.cmd, "FILE=./cfg/main.plc, INC=.:./cfg/, SAMPLE_RATE_MS=1000, PLC_MACROS='BO_S_ID=${ECMC_EC_SLAVE_NUM}'"
${SCRIPTEXEC} ${ecmccfg_DIR}loadPLCFile.cmd, "FILE=./cfg/main.plc, INC=.:./cfg/, DESC='Test', SAMPLE_RATE_MS=1000, PLC_MACROS='BO_S_ID=${ECMC_EC_SLAVE_NUM}'"
```
NOTE: ECMC\_EC\_SLAVE\_NUM expands to the ID of the last added slave.

Expand Down Expand Up @@ -66,7 +67,7 @@ Since all PLC files and PLC libs are parsed through MSI the "include" and "subst

When using the include command, the file location dir of the file must be added in the INC parameter when loading the PLC:
```shell
${SCRIPTEXEC} ${ecmccfg_DIR}loadPLCFile.cmd, "FILE=./cfg/main.plc, INC=.:./cfg/, SAMPLE_RATE_MS=1000, PLC_MACROS='BO_S_ID=${ECMC_EC_SLAVE_NUM}'"
${SCRIPTEXEC} ${ecmccfg_DIR}loadPLCFile.cmd, "FILE=./cfg/main.plc, INC=.:./cfg/, DESC='Test', SAMPLE_RATE_MS=1000, PLC_MACROS='BO_S_ID=${ECMC_EC_SLAVE_NUM}'"
```
The "INC" parameter can contain several directories separated with a ":", making it possible to include PLC files from several locations/modules.

Expand Down Expand Up @@ -113,3 +114,15 @@ Will result in the below if setting the DBG='' (and some other macros, see above
```C
println('Value: ', ec0.s10.binaryOutput01);
```
### Description
Always add a description when creating a PLC by setting the DESC macro when calling loadPLCFile.cmd.
Example:
```shell
${SCRIPTEXEC} ${ecmccfg_DIR}loadPLCFile.cmd, "FILE=./cfg/main.plc, INC=.:./cfg/, DESC='Toggle some bits', SAMPLE_RATE_MS=1000, PLC_MACROS='BO_S_ID=${ECMC_EC_SLAVE_NUM}'"
```

{{% notice info %}}
The description can maximum be 40 chars long.
{{% /notice %}}
2 changes: 1 addition & 1 deletion hugo/content/manual/general_cfg/startup/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ startup.cmd takes the following arguments:
ECMC_CONFIG_ROOT = root directory of ${MODULE}
ECMC_CONFIG_DB = database directory of ${MODULE}
EthercatMC_DB = database directory of EthercatMC
ECMC_EC_MASTER_ID = EtherCAT master id in use (for use in later scripts)
ECMC_EC_MASTER_ID = EtherCAT master id in use (for use in later scripts)
ECMC_EC_SAMPLE_RATE = EtherCAT bus sampling rate [Hz] (1000 default)
ECMC_EC_SAMPLE_RATE_MS = EtherCAT bus sampling rate [ms] (1 default)
ECMC_MODE = ecmc mode. FULL/DAQ, Defaults to FULL
Expand Down
2 changes: 1 addition & 1 deletion hugo/content/manual/knowledgebase/motion.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,5 @@ For this however, the IOC needs to be reconfigured to _not_ link the hardware to
4. `dbgrep "*s007*"`
5. There should be two PVs ending with, `-Drv01-Cmd` and `-Drv01-Spd`
6. Set `-Drv01-Cmd` to `1` and check the amplifier did enable, if you don't know how to check for an enabled amplifier, you should not use this command!
7. After the amplifier is engaged, write a small number to `-Drv01-Spd`. Dependinf on the scaling, the number might be in the range of 1..1000.
7. After the amplifier is engaged, write a small number to `-Drv01-Spd`. Depending on the scaling, the number might be in the range of 1..1000.
8. Observe the encoder, or in case of open-loop, the device itself.

0 comments on commit 78af68f

Please sign in to comment.