These two boards are supplied from a 24 V power supply like in the picture shown. I didn't design any of them. The first board cannot be modified at all, the second board can be modified completely. The two microcontrollers communicate using I2C through a 4-wire ribbon cable (3.3 V, SDL, SCL and GND). This communications cable is 5 cm long.
I imagine that the reason the ground of the valve driver is taken from the power supply in the second board is to keep this loop small and separated from the microcontroller ground, even if electrically it's the same point. However, I can't see if the way this is connected could be an issue or if it could be improved. The output pin toggles once a minute, but there's the option to connect a proportional valve that needs a 1 kHz PWM output from the GPIO to operate.

