Here is the solution that I use for the extended I / O in output in order to control relays in 24V. The connection is almost identical except GND and VCC. VCC must not be connected for use> 5V.