what I need is that for every single movement made by any of the motors being controlled, a logical "1" signal is generated exactly when that movement has finished, and then it must return to "0".
Without context, i.e. without relating the event to a specific command, your data acquisition is no more than a platonic exercise. Maybe your goal is to develop and test this ”data acquisition board“, but to obtain meaningful data, you should simply control the Duet by setting up a HTTP client https://github.com/Duet3D/RepRapFirmware/wiki/HTTP-requests#get-rr_gcode. By this, you could even observe RRF’s object model.
Does someone know how to proceed or which file do I have to modify?
RRF is Open Source, so feel free to study the code at GitHub. But beware: RRF is a very sophisticated piece of art, so you should have more than just some basic knowledge of C/C++.