How to wire and read QM Series Photoelectric Sensor?

We installed 2sensors QMRB-0N-0A from QM. The specs are available here:

There is very little documentation about wiring (DIO or Analog?), if we can adjust them (distances,…) and how to read the output using Java.

We plugged one of them in a DIO but it always read “true” in Java.

Does anyone has experience with these sensors?
Thanks lovely community :wink:

We have always used the (more expensive) CX5 series sensors in the past, which have worked GREAT with DIO. Specifically, the equivalent to the sensor you mentioned is the CX5-AN-1A.

(Actually, the CX5 part number is diffuse with background suppression, so the direct QM equivalent would be QMRS-0N-0A, but I believe the wiring is identical. The CX3-AN-1A is the equivalent to the QMRB-0N-0A that you have).
For the CX5, we wire the brown wire to +12 VDC, the blue wire to (-), and the black wire runs to the signal pin on a DIO (white wire on a PWM cable).

In code, using the CX5, we have to do a sensorvar = 1 - DIO get value to get the sensor variable to read present as a “1”.

We tried the QMRB-0N-0A sensor this year, wired in the same fashion as the CX5, but they did not seem to function as expected. The signal would not switch and hold state when a cube was present; instead, it would flicker intermittently. Ultimately, we switched back to the CX5. I reported the issue to the Automation Direct folks (great people). Not sure if they diagnosed the problem - we moved on and had a working replacement, so I did not follow up with them.

Update - I sent the Automation Direct folks an email alerting them to this thread. One of their tech guys did suggest in an earlier email response to try plugging the QM sensor output into an ANALOG input. Again, we didn’t try any of that - we used what we knew worked and moved on. Good luck!

Hi Guys,

Travis is correct - the simplest solution is to plug it into an analog input, monitor the high and low value using smartdashboard or some console print statements, then write your program as:

if (analog input < xxx)

That is, use an analog input as a digital input. (FYI: “Digital Inputs” are really analog inputs, but the hardware makes the threshold decision for you).

The issue is, these are industrial sensors designed for 24Vdc systems. So the vendors can design them to switch on/off at a higher threshold than the 5V threshold we use on the roboRio - I assume to save money.

Bottom Line, for some industrial sensors, the low generated by the NPN output doesn’t go quite low enough to trigger a 5V input.

FYI: I ran into a team last weekend that was using the QMI7-0N-0A sensor (vs your QMRB-0N-0A) and they said it worked great with the digital inputs. (Same sensor, but infrared, 4-400mm vs your 5-100mm, and faster sensing speed. Same price). The compare tool on the AutomationDirect website does a side by side comparison for you.

I really need to catalog all of our inexpensive photo sensors so FRC teams know which are compatible out of the box with the roboRio DIO …

Please feel free to contact us here or via PM if you have any further questions.

The NPN sensor output is an open collector transistor. That won’t work well without a pullup resistor, and I don’t think the roboRIO’s analog inputs provide one. It’s simple to add a 10k or so resistor between the +5 and signal pins, but it isn’t just a matter of plugging it in.

A pull up will give you more margin and more reliable results, but it does work without a pull up because the analog input tends to float around mid level.

Thanks everyone, we are going to do some tests early next week. I’ll let you know our findings.

Thanks to all of you. With your help we have been able to make it work both on Digital and Analog, so we can choose what’s more convenient :wink:

The wiring is using a basic PWM cable plugged in into DIO or AIO (no external power source) and is as follow:

===== ========
Black ----- Blue
Red ----- Brown
White ----- Black

Works out of the box, the value needs to be inverted

Here is the code:

public class PhotoelectricSwitch_QMRB0N0A_DIO extends DigitalInput {

	public PhotoelectricSwitch_QMRB0N0A_DIO(int channel) {
	public boolean get()
		return !super.get();  // inverse logic

The voltage is as follows:

  • No Obstacle: ~0.33V
  • Obstacle: ~1.33V

Here is the code:

public class PhotoelectricSwitch_QMRB0N0A_AIO extends AnalogInput {

	public PhotoelectricSwitch_QMRB0N0A_AIO(int channel) {
	public boolean get()
		return getVoltage()>0.83; // 0.83 is the middle point

Note that this sensor needs to be at ~1 inch min from the obstacle. Anything closer won’t be detected.


Thanks for the followup!

Reminder that a pull-up on the analog pin will give you even more voltage difference.

But if you are happy with a 1 Volt swing, then you are good to go!