Thanks for the answers.
1. The outputs of the DAQmx-read function (Digital signal 1 channel 1 sample) is zero most of the time and -1 when passing the light barrier not the voltages. Sorry for being inaccurate.
When I use the DAQmx-read function with Digital Bool (at the zeroing channel), a display element (LED) is turned on most of the time and turned out when passing the light barrier. This explains the problem with continually zeroing.
2. Since I had nothing to do with the hardware wiring, I will check the wiring together with our electrician.
3. The encoder is the model IH740 from global encoder (IH 740 250R33-00300). The link to the data sheet: http://www.globalencoder.com/xist4c/download/web/IH740_uplId_2013__coId_1618_.pdf (couldnt attach it here. It said: "The contents of the attachment doesn't match its file type.")
4. DAQ Hardware is NI9421
The hint with the "Not" gate is good. But I dont know where to wire it to in the given program. I think I would have to change the DAQmx-read function itself then.
I will let you know, when we checked the wiring.
Thanks.