Thank you @Robin2 and @wvmarle, I will take your advice in consideration!
Glorymill:
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.
By using a voltage divider, I would detect if it is a malfunction in the wires, but if I would look at the current coming in on the signal, then I could assume that if there is no current on the line, then the sensor has an error. Because from what I understood so far I can have an error sensor, but not a malfunction on the line.
Yes, thank you, I was not aware of that!
This is a stupid question, but let s say that I would use a current sensor like ACS722 in series with the signal wire, but I could only give it 3.3V as an output from the micro controller. The ACS722 functions with 5V input. Therefore I thought that I have 3 options, but I am not sure if I am thinking correctly.
One option would be to use a step-up converter or an amplifier to amplify the voltage from 3.3V to 5V to input the ACS722.
Another option would be to take the voltage from the source of the sensors, and use lets say a voltage divider/ step-down converter/ optocoupler and make the 12V to 5V and feed that to the input of the ACS722
A third option would be to get a current sensor whici works on 3.3V, but that would be more expensive from what I have seen
From those I would opt for the first one, but I am not sure if that it would function as intended.
The more I think about this project the more convinced I become that you should put these technical questions to one side for a few moments and describe the thing you want to create and the risks that you want to avoid. At the moment it is still a classic XY problem
I would not be at all surprised if, when we know what you are doing, we were to give very different advice.
Robin2:
The more I think about this project the more convinced I become that you should put these technical questions to one side for a few moments and describe the thing you want to create and the risks that you want to avoid. At the moment it is still a classic XY problem
I would not be at all surprised if, when we know what you are doing, we were to give very different advice.
...R
I am sorry for not being clear enough. I just wanted an opinion in how to determine an error of a sensor. And I have had quite a lot of great responses/suggestions, and for that I am grateful.
I just want to be able to tell when the sensor has no current coming in on the signal line, which I can determine with the current sensor, but in the meantime I have read more about the ACS722 and I have seen that it has a low resolution since Arduino's ADC is running on 10bits. So maybe I will just use something like MLX91221 which works on 3.3V and has a better resolution since it is made for low-powered.
Just remember that current sensing works only for a few of many possible fault modes - those where the sensor fails as open circuit, or a wire failure. Drawing normal current doesn't necessarily mean the sensor works properly. That is what makes detecting a sensor fault so hard.
Best solution is probably as used in high reliability projects like aircraft: use two sensors from different make and model, preferably using different principles of operation. The moment the two sensors do not agree (one detects presence, the other not), that indicates a fault in one of the sensors. You still don't know which one of course, just that there is a fault.
wvmarle:
Just remember that current sensing works only for a few of many possible fault modes - those where the sensor fails as open circuit, or a wire failure. Drawing normal current doesn't necessarily mean the sensor works properly. That is what makes detecting a sensor fault so hard.
Best solution is probably as used in high reliability projects like aircraft: use two sensors from different make and model, preferably using different principles of operation. The moment the two sensors do not agree (one detects presence, the other not), that indicates a fault in one of the sensors. You still don't know which one of course, just that there is a fault.
yes, that is indeed a good solution. Thank you
Robin2:
Which is why I believe the OP needs to tell us what the project is.
...R
I am sorry. I will explain it properly now. I have a sensor and 2 electromagnets which control a door. The electromagnets are controlled using relays. The door is normally closed, but when an object is detected by the sensor (human approaches the door), then the door opens and stays open until the human is far enough for the doors to close safely. I wanted to detect the sensor error so there is no risk of the doors closing on the person. That is why I wanted to see if there is a current on the sensor line, because the sensor gives LOW or HIGH, but when it sends LOW, it does not mean that it has 0A on the line, it would still have something. So maybe if I ask the sensor manufacturer, they would tell me the normal operating amps so I can implement an error using this. I just did not want to add more sensors and make it very simple, but as far as I see it, that is not possible.
azk32:
So maybe if I ask the sensor manufacturer, they would tell me the normal operating amps so I can implement an error using this.
Ask the manufacturer a more open question such as "how can I detect a failure in your sensor". Also, be sure to describe for the manufacturer how you plan to use the sensor. They may suggest a more suitable sensor.
I just did not want to add more sensors and make it very simple, but as far as I see it, that is not possible.
My guess is that it won't be simple if the door closing machinery is powerful enough to cause injury. What do the makers of the door closing system advise?
Now that I think of it, the manufacturers of the door closing machinery would be the place where I would start enquiries - it must be a common question for them.