At times it is necessary to drive the relay through programming interface to automate some tests.
This post provides an implementation hint to work with CAPL and an interface circuit to drive a relay using Vector DAIO /DIO interface.
It is advised to read CAPLQuickstart_Generic_2018_Final.PDF as a preparation to understand CAPL usage in the context of CANoe. The document is available in vector website for download.
Vector IO configuration
Please use Vector I/O configuration page to set the pin mode correctly. after the configuration, each pin is accessible through system variables.
Please refer to VN5000_Manual_EN.PDF for additional details.
Interface circuit
This interface circuit is compatible with vector VN5640 port IO19. PIN 2 (DIN2) is used as digital output. This digital output has is push-pull arrangement to drive output.

GROUND LOOP & Protection circuit
To reduce potential device damage due to ground loops and potential differences between different devices in the test setup, some additional protection measure is necessary.
For this example, the following measures take care in the interface circuit.
- PIN 9 (Digital GND) is connected to relay card GND using 100R serial resistor.
- PIN 2 (DIN2) is connected to relay driver input pin using 100R serial resister. The relay driver itself has 1K serial resistor to drive the 12V relay. Relay when driven consumes about 30mA.
Simulation setup for CANoe
CAPL program
According this example program, when key ‘a’ is pressed, the output is turned OFF and when key ‘b’ is pressed, the output is turned ON.
on key 'a'
{
@IO::VN5600_1::DIN2 = 0;
}
on key 'b'
{
@IO::VN5600_1::DIN2 = 1;
}
Hope this helps. For typical use-case, instead key-press event, any other available events can be used by adapting the CAPL. However, the concept remains same.