Skip to content

Signal Connector

The SignalConnector passes the value of one signal on to another signal and converts it on the way. The typical case is two controllers in one scene: the robot controller reports RobotReady, and the cell PLC expects that information on its own input Rob_Ready. The connector copies it across, and it can also turn an INT into a BOOL, pick a single bit out of a status word, build a word from single bits, or scale a value.

  • One connector has one source and one target. To couple in both directions, use two connectors.
  • The source is a PLC output (PLCOutputBool, PLCOutputInt, PLCOutputFloat): a value a controller writes, such as a robot output. The target is a PLC input (PLCInputBool, PLCInputInt, PLCInputFloat): a value the simulation writes and the other controller reads.
  • The connector can sit on any GameObject. Unlike ConnectSignal, it does not have to be on the target signal.
  • It checks the source every FixedUpdate and writes only when the converted value differs from what the target holds.

The SignalConnector is exported to realvirtual WEB with the same fields and gives the same results there (see Parity with realvirtual WEB).

The Mode decides the conversion and which two signal slots are used. Every mode uses exactly one source slot and one target slot.

ModeSource → targetWhat it does
CopyBOOL → BOOL, INT → INT, REAL → REAL, INT → REALPasses the value on unchanged. With Invert, a BOOL is negated.
IntToBoolINT → BOOLTrue when the INT is not 0, equals Compare Value, or is at least Compare Value (see Condition).
BoolToIntBOOL → INTWrites True Value for true and False Value for false.
BitFromWordINT → BOOLReads one bit (Bit) of the INT.
BitToWordBOOL → INTSets one bit (Bit) of the target word. Several connectors with different bits build the word together.
ScaleINT or REAL → INT or REALWrites source × Factor + Offset.

One connector handles one bit. To read eight bits of a status byte, use eight connectors with the same source and different Bit values. To build a word from eight BOOLs, use eight BitToWord connectors with the same target.

The Inspector shows only the settings and the signal slots the selected Mode uses.

Mode (enum) The conversion, see Modes. Default is Copy. When you change the mode in the Inspector, the slots the new mode does not use are cleared in the same step, and one undo brings back both the mode and the slots.

Enabled (boolean) When off, the connector writes nothing and takes part in no check. You can switch it during play mode; a BitToWord connector that is switched off sets its bit to 0.

Source Bool, Source Int, Source Float (PLC output) The source signal. Source Bool is used by Copy (BOOL), BoolToInt and BitToWord; Source Int by Copy (INT and INT → REAL), IntToBool, BitFromWord and Scale; Source Float by Copy (REAL) and Scale.

Target Bool, Target Int, Target Float (PLC input) The target signal. Target Bool is used by Copy (BOOL), IntToBool and BitFromWord; Target Int by Copy (INT), BoolToInt, BitToWord and Scale; Target Float by Copy (INT → REAL and REAL) and Scale.

Condition (enum) IntToBool only. NotZero (default) is true for every value other than 0, negative values included. Equals is true when the value equals Compare Value, GreaterOrEqual when it is at least Compare Value.

Compare Value (integer) IntToBool with Equals or GreaterOrEqual. The value to compare with. Default is 0.

True Value, False Value (integer) BoolToInt only. The INT written for true and for false. Defaults are 1 and 0.

Bit (integer) BitFromWord and BitToWord. The bit number, 0 is the least significant bit. It must be smaller than the width: 0–7 for Byte, 0–15 for Word, 0–31 for DWord. Default is 0.

Width (enum) The size of the INT: Byte (8 bit), Word (16 bit, default) or DWord (32 bit). It sets the range of Bit, how Scale reads an INT source, and the range an INT target of Scale is limited to.

Signed (boolean) Whether the INT is read and written as signed at Width. A Byte is −128 to 127 when signed and 0 to 255 when not. Default is on.

Factor, Offset (number) Scale only. The result is source × Factor + Offset. Defaults are 1 and 0, both without unit.

Rounding (enum) Scale with an INT target. Round (default) rounds halves away from zero, so 2.5 becomes 3 and −2.5 becomes −3. Truncate cuts towards zero, so 2.9 becomes 2 and −2.9 becomes −2.

Invert (boolean) Negates the BOOL result of Copy (BOOL), IntToBool and BitFromWord, and the bit a BitToWord connector contributes. Default is off.

  1. Create an empty GameObject next to the signals, for example Couplings.
  2. Add the component via Add Component > realvirtual > Utility > Signal Connector.
  3. Choose the Mode.
  4. Drag the source signal (a PLC output of the first interface) and the target signal (a PLC input of the second interface) into the two slots the Inspector shows.
  5. Set the remaining options, such as Bit and Width, and start the simulation.

A robot controller and a cell PLC share a scene. The robot reports its state with the BOOL output RobotReady and the INT status word RobotStatus. The PLC expects BOOL inputs.

ConnectorModeSourceTargetSettings
ReadyCopyRobotReady (robot output)Rob_Ready (PLC input)—
In home positionBitFromWordRobotStatusRob_HomeBit 0, Width Word
Gripper closedBitFromWordRobotStatusRob_GripClosedBit 3, Width Word
FaultIntToBoolRobotErrorCodeRob_FaultCondition NotZero

In the other direction, the PLC releases the robot with BOOL outputs that the robot reads as one INT command word:

ConnectorModeSourceTargetSettings
StartBitToWordPLC_RobStartRobotCommandBit 0
ResetBitToWordPLC_RobResetRobotCommandBit 1

With PLC_RobStart true and PLC_RobReset false, RobotCommand is 1.

The same rules apply in Unity, in realvirtual WEB and in realvirtual CONNECT.

  • INT values are 32-bit signed. A DWORD with bit 31 set is a negative number: 0x80000000 is −2147483648 and 0xFFFFFFFF is −1. BitFromWord with Bit 31 on −2147483648 gives true.
  • Width and Signed only change how a number is read or limited. With Byte and Signed on, the INT 255 is read as −1. With Signed off, it is read as 255.
  • Scale into an INT target is limited to the range of Width and Signed. 300 into an unsigned Byte becomes 255, 40000 into a signed Word becomes 32767.
  • REAL targets are 32-bit floats. 16777217 is written as 16777216. A result that is not a finite number, such as NaN or a value beyond the float range, is not written; the target keeps its last value.
  • BitToWord builds the whole word. The target word holds exactly the bits of the BitToWord connectors that write it. Bits that no connector writes are 0, and the connector never reads the target back. When you disable or remove a bit connector, its bit becomes 0; when the last one goes, the word is set to 0. If the connectors of one word have different settings, the widest Width applies, and the word is signed only when all of them are Signed.
  • IntToBool with NotZero treats negative values as true. The older ConnectSignal component only turns positive values into true.

The connector checks its setup when the simulation starts, and again when you change it in the Inspector during play mode or switch Enabled. It reports problems as warnings in the Console. Each warning names the GameObject and carries the same problem code as the Problems panel of realvirtual WEB. A disabled connector reports nothing.

CodeMeaning
signal-connector-unresolvedA slot the mode needs is empty. The connector writes nothing.
signal-connector-slot-mismatchA slot is set that the mode does not use, for example after editing the scene file by hand. The connector still works on the slots of its mode.
signal-connector-fan-inMore than one writer on the same target: two connectors, or a connector and a ConnectSignal on the target. Several BitToWord connectors may share one word only if each uses a different bit and a different source. All writers on that target stop writing.
signal-connector-cycleThe target leads back to the source, over other connectors or a ConnectSignal (for example a connector from A to B and a ConnectSignal on A that copies B). The connector writes nothing.
signal-connector-widthBit does not fit the Width, for example bit 16 in a Word. The connector writes nothing.
signal-connector-nonfiniteThe converted value is NaN or beyond the float range and was not written.

In Unity, the slot types already make sure the target is a PLC input, so the WEB code signal-connector-direction does not occur. A ConnectSignal that is added or changed while the simulation runs is only taken into account at the next check of the connector.

A forced target (signal Override) keeps its forced value. The connector keeps calculating in the background, so the current value appears as soon as the force is released.

The GLB export carries the SignalConnector with all its fields, and realvirtual WEB runs the same conversion on it. The results are the same; only the timing differs:

  • Unity works in ticks. Each connector reads its source once per FixedUpdate. In a chain such as A → B → C over several connectors, or with several BitToWord connectors on one word, the final value can arrive one or more FixedUpdate cycles later, depending on the execution order of the components.
  • realvirtual WEB passes a change on at once. A new source value reaches the target in the same step, through a whole chain.

The end values are the same in both. Do not build PLC logic that depends on a value arriving in exactly the same cycle as its source.

The older ConnectSignal component sits on the target signal and copies one source onto it without options. It follows a fixed rule: an INT onto a BOOL is true when the INT is greater than 0 (a negative INT is false), a BOOL onto an INT is 1 or 0, and everything else is copied unchanged. Existing scenes keep working. For new couplings, use the SignalConnector.