Hello,
Welcome to the forums!
The data sheet is not very clear, in fact I think it is a really good example of a rubbish datasheet.
Reading it several times, I think the following is correct:
- pin 2 white "L/D" is an input to control whether the sensors switches ON when it see light or dark. You can just leave it unconnected to get the default - dark switching but I can't tell what that means!
- pin 3 Blue "M" must be the ground (0V)
- pin 1 Brown "L+" is the supply (10V to 30V)
- pin 4 Black "Q" is the output (0V to supply minus 1.8V)
I would suggest using a 12V power supply to give power to the Netduino and the sensor.
The output voltage of the sensor is too high as you have already identified, but that is easily fixed with a potential divider.
With a 12V supply, the input voltage to the divider will be 12V - 1.8V = 10.2V. The output needs to be between 2V and 5V.
Choose the resistors so that they take (a lot) less than 100mA from the sensor's output - I would aim to only draw about 5 to 10mA.
Look up potential dividers on google - if you get stuck, just ask.
Its not clear what to connect the L/D input to to switch mode, but it mentions "open-collector" so I think the most likely option is that you connect it to ground (0V) to change the mode. I don't think that really matters as the Netduino software can invert it anyway.
A few random thoughts:
Do you know what PNP stands for in the context of this sensor? - I don't think it means "pnp" as in the BJT transistor.
Do you know if this sensor is good at detecting sheep?
It looks expensive and does not have a very long range - I guess you have a narrow gap?
You might want to put a bicycle reflector on the opposite side of the gap to get a good return until the sheep passes through.
Hope this helps - have fun counting sheep - Paul