PWM speed controller, opto coupling, and torque questions

hey guys,

I think I have a similar question. Is this about linking the ground of the stepper supply to the arduino ground (I'm a complete noob, so I might be mistaking)?

I'm currently wiring up a stepper with a L293d dual H-bridge ic to my arduino mega (http://www.arduino.cc/en/Reference/StepperBipolarCircuit). There are four ground pins that could be either a 5v ground to close the microcontroller circuit or a 24v ground to close the psu circuit.

Do I connect both ground wires to both the arduino GND-pin and the psu ground? Can you help me with this?
thanks in advance.

cheers, tim