Expand description
PLC link: the simulator as an OPC UA server. A PLC (or any client) sends targets and setpoints and reads back every signal. The servo loops stay inside the simulator; OPC UA is far too slow to close them.
The variables are generated from the simulation’s signal list, never written per machine:
| node (string id in the simulator’s namespace) | type | access | meaning |
|---|---|---|---|
signal.<signal id> | Double | read | every signal of the simulation |
command.target.<axis id> | Double | write | target of the next point-to-point move |
command.move | Boolean | write | true starts the move to the targets |
command.setpoint.<axis id> | Double | write | streamed position setpoint, interpolated |
command.cycle | Boolean | write | true starts the cycle, false stops it |
command.disable | Boolean | write | true switches the drives off (brakes on) |
command.enable | Boolean | write | true switches the drives on again |
command.stop_category | Int32 | write | 0, 1 or 2 stops the machine in that stop category (Command::Halt) |
command.path | String | write | a path, in the text of a path file |
command.path_time_optimal | Boolean | write | plan the path as fast as the motors allow |
command.run_path | Boolean | write | true plans command.path and runs it |
status.busy | Boolean | read | a move, path or the cycle is under way |
status.refused | String | read | key of the last refused command, or empty |
An axis the PLC does not write stays where it is: command.target.<axis id> reads the planned position
until it is written, and again after the move it was written for; command.setpoint.<axis id> reads the
setpoint the controller follows, which is the planned position whenever no setpoint is on its way. So a
write to one axis never carries an old value for the others.
The path is planned from where the machine stands when command.run_path arrives, as
Sim::plan_path plans it (format: see sim_components::path). A path that cannot be read is refused with
opcua-error-path-line; one that cannot be planned or run with the key the planner or the controller gives.
status.refused keeps a refusal until a command of the same kind (move, setpoint, cycle start, …) is
accepted. Accepted commands of another kind, such as a stream of setpoints, do not wipe it.
Next to these, every axis has PLCopen motion function blocks as handshake variables (see plcopen and
docs/plc.md), in the folder axis.<axis id>:
| node | type | access | meaning |
|---|---|---|---|
axis.<id>.Power.Enable | Boolean | write | MC_Power: true powers the axis |
axis.<id>.Power.Status, .Valid | Boolean | read | drives on; on and without error |
axis.<id>.Power.Error, .ErrorID | Boolean, UInt16 | read | the axis error (ErrorStop), also unpowered |
axis.<id>.<FB>.Execute | Boolean | write | rising edge starts FB = Home, MoveAbsolute, MoveRelative, Stop, Reset, GearIn, GearOut, CamIn, CamOut |
axis.<id>.GearIn.Master, .CamIn.Master, .CamIn.Table | String | write | the master’s axis id; the client’s cam table |
axis.<id>.GearIn.RatioNumerator, …, .CamIn.CamTableID | Double | write | inputs of GearIn and CamIn, taken on the rising edge |
axis.<id>.MoveAbsolute.Position, .Velocity, .Acceleration, .Deceleration, .Jerk | Double | write | inputs, taken on the rising edge |
axis.<id>.MoveRelative.Distance, … | Double | write | as for MoveAbsolute |
axis.<id>.Stop.Deceleration | Double | write | braking deceleration of MC_Stop |
axis.<id>.<FB>.Done, .Busy, .Active, .CommandAborted, .Error | Boolean | read | outputs (InGear, InSync for GearIn, CamIn) |
axis.<id>.<FB>.ErrorID | UInt16 | read | why the block failed, 0 without error |
axis.<id>.State, .StateID | String, Int32 | read | PLCopen state (Disabled 1, Standstill 2, ErrorStop 3, Stopping 4, Homing 5, DiscreteMotion 6, ContinuousMotion 7, SynchronizedMotion 8) |
axis.<id>.ActualPosition, .ActualVelocity | Double | read | from the simulated axis |
axis.<id>.IsHomed, .Error, .ErrorID | Boolean, Boolean, UInt16 | read | homed; the axis error (ErrorStop) |
The loop’s real-time pacing is measured from the wall-clock times of its ticks, since the start or the last
command.reset_pacing:
| node | type | access | meaning |
|---|---|---|---|
status.cycle_s | Double | read | the loop’s nominal cycle |
status.cycle_period_s | Double | read | mean measured time between ticks |
status.jitter_max_s | Double | read | largest deviation of a tick period from the cycle |
status.jitter_rms_s | Double | read | root mean square of that deviation |
status.overruns | UInt64 | read | ticks that came more than a whole cycle late |
status.cycles | UInt64 | read | ticks measured |
status.realtime_factor | Double | read | simulated time over wall-clock time |
status.steps | UInt64 | read | simulation steps since the start |
command.reset_pacing | Boolean | write | true starts the measurement anew |
The clients’ cycle, from the arrival times of their Read and Write requests (ClientTiming), reset with the pacing:
| node | type | access | meaning |
|---|---|---|---|
status.client_writes, status.client_reads | UInt64 | read | intervals measured |
status.client_write_mean_s, status.client_read_mean_s | Double | read | mean interval |
status.client_write_std_s, status.client_read_std_s | Double | read | standard deviation of the intervals |
status.client_write_max_s, status.client_read_max_s | Double | read | largest interval |
Endpoints, certificates and users: see Security. docs/plc.md has the IEC 61131-3 type of every node.
Modules§
- plcopen
- One axis as PLCopen motion sees it: the function blocks MC_Power, MC_Home, MC_MoveAbsolute, MC_MoveRelative, MC_Stop and MC_Reset, and of synchronised motion MC_GearIn, MC_GearOut, MC_CamIn and MC_CamOut, as handshake variables, and the axis state machine behind them.
Structs§
- Client
Timing - How regularly the clients read and write the simulator’s variables: a PLC that reads and writes once a task cycle shows its cycle and jitter here. One Read or Write request counts once, however many variables it holds; reads of other attributes than the value (browsing) and subscriptions do not count.
- Intervals
- The time between consecutive requests of one kind (Read or Write) from the clients, since the last reset.
- Link
- Link
Error - A failure to start, as a translation key and a detail.
- Pacing
- The loop’s real-time pacing, measured from the wall-clock times of its ticks since the last reset.
- Security
- How the server lets clients in. It offers at the same URL the security policy
Noneand every policy ofPOLICIESwithSignand withSignAndEncrypt. Its application instance certificate (self-signed, valid for 365 days) is created in the pki folder on the first start:own/cert.derandprivate/private.pem(certificate_days_left,renew_certificate). - Timed
- The simple in-memory node manager, with the arrival of every Read and Write request timed.
Constants§
- NAMESPACE
- POLICIES
- The secured endpoints, each offered with
Signand withSignAndEncrypt: every policy async-opcua has that OPC UA does not deprecate (Basic128Rsa15 and Basic256 are, and are left out).
Statics§
- I18N
- (language code, translation file contents) for the link’s own messages.
Functions§
- certificate_
days_ left - Days until the server’s certificate in
pki_direxpires (negative once it has);Nonewithout one (the next start creates it). - configured
- The config of
--config FILE(or else the machine’s default) with every--set path=valueon top, read as sim-cli reads them; and the trajectory of--trajectory FILE(sim_components::path::parse_trajectory), to run at the start (Link::run_trajectory). - number
- A number a client wrote, of any IEC 61131-3 numeric type: LREAL, REAL, SINT, INT, DINT, LINT, USINT, UINT, UDINT, ULINT. A 64-bit integer beyond 2^53 is refused: a double would not hold it exactly.
- renew_
certificate - Sets the server’s certificate and private key in
pki_diraside (.oldbeside them, replacing an older one), so that the next start creates new ones, valid for 365 days. Clients that trusted the old certificate must trust the new one. Nothing to do without one. - serve
- Starts the server on
listenerand the simulation behind it, in real time, in ticks ofcycle.labelsnames the variables for people browsing the server;pki_dirholds the server’s keys. Anonymous clients, and only client certificates already trusted:Security::default(). - serve_
secured serve, letting clients in assecuritysays.