I am new to this, so please have patience if I am not explaining properly.
I have a sensor and an arduino nano. The sensor has 3 pins: +12V, -12V and signal. The sensor is powered from an external power source of 12V and the signal wire goes into one of the digital pins of arduino. The sensor just gives a HIGH if event is detected and LOW if the event is not detected. I am using the internal pull-up resistor for the signal btw.
Now what I want to see is if the sensor suddenly malfunctions, like if the power source stops functioning. So I thought of 2 options but I am not quite sure yet which one is the best or if there are any other options (I am open to suggestions).
One would be to attach a 10k resistor to the signal and put it in another pin. This way I would know if the signal is receiving or not data. But for this I am not so sure, because this is basically a pull up resistor so would this end up working just like the internal one and thus become useless?
Second would be to use a step down voltage or a voltage divider to lower the positive 12V to 3.3V and then attach a resistor (perhaps 10k) to it and a digital pin and read the value. If it is 1 it would mean there is a voltage drop and the circuit is up and running, but if it is 0, then there is no voltage drop and then it would give the error.
Which one of those would be more feasible and why? Is there any other option?
12 volts to a Arduino Uno pin? -12V to a Arduino pin? And you want to know if using an additional pin on the Arduino to send another +/-12 volt signal to will make things work
Or
You want to use some kind of logic shifting to send some kind of voltage to the Arduino.
Ok, Most likely when the Arduino pin got 12 votls it quit. Most likely when the Aruino got -12 volts, it quit. QUit working that is.
The Arduino Uno and Mega are 12V devices.
If your MCU is 3.3V and you put +/-12V into it, it quit.
The very first thing, I'd do is to find a sensor that does not use +/-12Volt or figure out a circuit that is going to translate +/-12V signals to the MCU operating voltages, without losing data.
Robin2:
It would make life a lot easier if you tell us what the sensor is and post a link to its datasheet.
There is a difference between a sensor malfunction and a sensor power supply malfunction.
...R
Oh I see. I thought that if there is a sensor malfunction then the power supply might be involved. Clearly I understood this wrong.
Idahowalker:
12 volts to a Arduino Uno pin? -12V to a Arduino pin? And you want to know if using an additional pin on the Arduino to send another +/-12 volt signal to will make things work
Or
You want to use some kind of logic shifting to send some kind of voltage to the Arduino.
Ok, Most likely when the Arduino pin got 12 votls it quit. Most likely when the Aruino got -12 volts, it quit. QUit working that is.
The Arduino Uno and Mega are 12V devices.
If your MCU is 3.3V and you put +/-12V into it, it quit.
The very first thing, I'd do is to find a sensor that does not use +/-12Volt or figure out a circuit that is going to translate +/-12V signals to the MCU operating voltages, without losing data.
I never intended to attach 12v to arduino. I am using an external power supply for the sensor. I know that Arduinos are supposed to be powered with 5V (I am powering it from the USB of the laptop). I wanted to use a power shifter to shift from 12V to 3.3V to put on the Arduino pin together with a resistor to check if it has power. (malfunction on the line)
I don't see an obvious way of telling whether the sensor malfunctions other than having a separate system that places an object in front of it. If it doesn't react, the sensor is broken (or of course the system that is to move this test object malfunctioned).
The sensor drawing power does not necessarily mean the sensor is working fine. It can draw power and malfunction at the same time. In case of a malfunction the output will likely be 0V, possibly 12V (supply voltage).
This is why most industrial sensors never produce a zero signal. Very common is a 4-20 mA current loop (less than 4 or more than 20 mA is a clear malfunction), or maybe 1-4V when on a 0-5V supply. Many malfunctions, including power supply outages, cause the output to go outside that range.
By the way, you quite certainly don't have a +12V/-12V supply, which would be a 24V total supply with a centre ground point (0V). Your 12V DC supply's output wires are conventionally called +12V and ground or 0V; of course you could call it +6V and -6V, that's the same, but rather unusual as you most likely don't have the 0V mid point available. Still 12V difference between them.
azk32:
Oh I see. I thought that if there is a sensor malfunction then the power supply might be involved.
I think your logic is the wrong way round.
If there is a power supply problem then the sensor won't work - but that would not be the fault of the sensor.
And I presume there could be a fault with the sensor even though the power supply is functioning normally - but I have no idea how you could detect that other than to place an object in front of the sensor and discover that it is not detected.
wvmarle:
I don't see an obvious way of telling whether the sensor malfunctions other than having a separate system that places an object in front of it. If it doesn't react, the sensor is broken (or of course the system that is to move this test object malfunctioned).
The sensor drawing power does not necessarily mean the sensor is working fine. It can draw power and malfunction at the same time. In case of a malfunction the output will likely be 0V, possibly 12V (supply voltage).
This is why most industrial sensors never produce a zero signal. Very common is a 4-20 mA current loop (less than 4 or more than 20 mA is a clear malfunction), or maybe 1-4V when on a 0-5V supply. Many malfunctions, including power supply outages, cause the output to go outside that range.
By the way, you quite certainly don't have a +12V/-12V supply, which would be a 24V total supply with a centre ground point (0V). Your 12V DC supply's output wires are conventionally called +12V and ground or 0V; of course you could call it +6V and -6V, that's the same, but rather unusual as you most likely don't have the 0V mid point available. Still 12V difference between them.
Yes, I am sorry, the naming problem is my fault. I should have said 12V DC supply instead of +12V/-12V.
The sensor would be running in an application so I wanted to stop the system completely if the sensor starts to malfunction. I was misunderstanding the malfunction, thank you for clarifying it!
Oh I see, so perhaps if I use something like this https://www.ti.com/lit/ds/symlink/ina219.pdf I could measure the current and determine if it is within the correct range? Would you say that is a good option?
Robin2:
I think your logic is the wrong way round.
If there is a power supply problem then the sensor won't work - but that would not be the fault of the sensor.
And I presume there could be a fault with the sensor even though the power supply is functioning normally - but I have no idea how you could detect that other than to place an object in front of the sensor and discover that it is not detected.
...R
Yes, thank you! I see now that my logic was wrong. Thank you for your advice!
azk32:
Oh I see, so perhaps if I use something like this https://www.ti.com/lit/ds/symlink/ina219.pdf I could measure the current and determine if it is within the correct range? Would you say that is a good option?
That will only work if you know (from the product datasheet) the normal working current and the current that will flow in a fault situation. I suspect that information is not readily available. Also I suspect that the normal working current varies widely.
Another option, if reliability is really important, is to use three identical sensors and assume that if the value from one of them is different then it is faulty. Maybe you also need three separate power supplies?
Robin2:
That will only work if you know (from the product datasheet) the normal working current and the current that will flow in a fault situation. I suspect that information is not readily available. Also I suspect that the normal working current varies widely.
Another option, if reliability is really important, is to use three identical sensors and assume that if the value from one of them is different then it is faulty. Maybe you also need three separate power supplies?
...R
That is true. I could not find the normal working current and the current that will flow in a fault situation.
That would be indeed a good solution but perhaps an overkill as they are very expensive.
I was thinking perhaps to put a current sensor and if it detects no current, then it would signal an error. But since the current can also be higher than a certain amount to give errors, that would be quite tricky to do.
azk32:
let's say that there is a 0.01% chance of someone dying if the sensor does not work
Then I would not worry about the cost of the two extra sensors.
What is the project in which people's lives would be at risk? You should be aware that the Atmega datasheets say that the products should NOT be used in life support projects.
Hello,
Sick is a brand that supplies products for industrial automation applications.
Typically these devices have digital output signals at 0-24V logic 0 - logic 1.
You could use a simple voltage divider (2 resistors) to reduce the 24V to 5V or 3.3V.
Do not forget to connect your 0V of the sensor supply with the 0V of your Arduino.
And whatever you do: first measure with a multimeter before making a connection.
Best regards,
Johi.
Robin2:
Then I would not worry about the cost of the two extra sensors.
What is the project in which people's lives would be at risk? You should be aware that the Atmega datasheets say that the products should NOT be used in life support projects.
...R
Technically it is not life support. I would use it to open some doors based on the information received from the sensors, but there is a very small risk the door would close on the person/object if the sensor malfunctions. So in this case I would use the error to tell the doors to stay open for instance, so no one could get hurt.
JOHI:
Hello,
Sick is a brand that supplies products for industrial automation applications.
Typically these devices have digital output signals at 0-24V logic 0 - logic 1.
You could use a simple voltage divider (2 resistors) to reduce the 24V to 5V or 3.3V.
Do not forget to connect your 0V of the sensor supply with the 0V of your Arduino.
And whatever you do: first measure with a multimeter before making a connection.
Best regards,
Johi.
I think you’ve identified a starting point...
You need to monitor the power source is within spec (usually average voltage over some period), then as suggested, validate your sensor values over several samples.
If they vary, or are out of range - there’s something that needs attention.
Yes indeed. I think for now I will try to monitor the current flowing through the sensor's signal and I will try to see what the upper limit is based on some averages.
azk32:
but there is a very small risk the door would close on the person/object if the sensor malfunctions. So in this case I would use the error to tell the doors to stay open for instance, so no one could get hurt.
I'm assuming (as you have not told us) that you are using the Lidar sensor to detect when someone approaches so that the door will open automatically.
If your concern is that the closing door might crush someone then you need a different approach. The door mechanism itself needs to be be able to sense when there is an obstacle preventing it from closing. That is common in the doors of elevators.
You should also have a sensor on the door that detects if something is stuck in it. E.g. a pressure sensitive edge, or a current sensor on the door motor (current rises when more resistance is encountered), or a speed sensor on the door closing hinge (speed goes down when something is hit). There may be other options. This way even if the object sensor is working perfectly fine if something or someone gets stuck in the door it still won't get crushed.
If the sensor output is either 12v (high) or 0v (low) then you could use a voltage divider (two resistors, say 10k and 5k in series) between the output and 0v. Feed the centre point between the resistors to an Arduino digital input and a high from the sensor (12v) will put about 4v onto the digital input, creating a logical high at the input pin.
As for malfunction detection, this can easily be achieved by temporarily introducing an object into the sensor's field of vision when the output of the sensor is low, then testing the Arduino digital input to see if it goes high.
More advanced detectors can exclude parts of their field of vision (map them out) so that the object can be permanently left in that area (ignored by the sensor's software). Command the sensor to include it's full field and the otherwise ignored object will be detected.
Note: the sensor you specified is not approved for use in safety critical applications.