Help to throw an error state if a sensor gets disconnected / wire breaks

Hi all i'm designing an autolevel controller for my airbag suspension in my car.

Overview of how it works so far

The sensors are rotary pots connected to arms that attach to chassis and moving suspension arms so as the car is lowered the pot moves clockwise as the car is raised the pot moves counterclockwise.

The program reads the sensor positions and if they are inside a set range it updates the last time each corner was stable to the current time.

When they fall below or above this range the program checks if they are outside the range and compares it with a time value (10 seconds) if after 10 seconds they are still outside the range it inflates or deflates that corner until that sensor is back stable again and repeats over and over.

The Issue
My concern is if a wire is broken the car will inflate or drop on that 1 corner and continue to do so even if the sensor isnt responding.

This leads me to my question:
I have a couple of ideas but im not sure how to go about it

First idea is to have an array containing the amount of time each valve has been on for and if it exceeds a set time say 1 second and the sensor hasnt changed value then throw a code (Serial print) and disable that corner from autolevelling ( this could have its own issues due to noise so if a sensor wire is actually broken the sensor value will change anyway due to noise and interference unless i put an extra pulldown resistor or something?)

Second idea (not sure if possible) is to essentially see if the sensor is incrementing correctly basically if the new sensor value is +1 or -1 from the last sensor value it is working correctly. If for any reason it breaks or is disconnected then the sensor value will go from say 122 to maybe 244 or 1 or etc meaning it didnt move to that position fluently it was suddenly changed. this would have to have some tolerence im guessing but pretty sure the arduino can process this faster than the sensor can move maybe?

3rd idea is to add pressure sensors as well as height sensors so if the pressure changes and the height doesnt then something is wrong and vice versa. ( i will probably do this as well but this also ahs its own issues and id rather just work of sensors)

Any ideas are appreciated or ways to try and code this?

I can provide my current code if needed but its not so much the whole code im needing help with just a plausible way to add a safety feature to see if the sensor is giving results that are sensible if that makes sense

The Arduino can not tell that a pin has something connected to it, or not. It can record when the pin changes state, and determine if that is happening too often, or not often enough. It has no idea what that means, though, or if it is a problem.

You would be far better off making SURE that the wires can't become disconnected.

PaulS:
The Arduino can not tell that a pin has something connected to it, or not. It can record when the pin changes state, and determine if that is happening too often, or not often enough. It has no idea what that means, though, or if it is a problem.

You would be far better off making SURE that the wires can't become disconnected.

I'm not wanting it to know this. My 3 ideas didn't say for it to see if it becomes disconnected but rather test if something happens and therefore give the implication it is disconnected. Not trying to be smart or have a go but did you read the 3 ideas I had?

If the wire breaks say a branch hits it and snaps the wire out then the car levels itself to that sensor data while driving then that is an issue because the sensor data being received is no longer relative. I want to put something in place for this and it is possible at keast for 2 of the ways I suggested was just wanting to see if anyone had any ideas

I'm well aware it doesn't simply know when something is connected or not. If it did then I wouldn't be asking this haha.

If the values obtained by the sensor are doing something though it can be assumed that something is wrong and that's where my question stands.

It's a linear potentiometer so I don't know if I can say that if the last known value is different to the current value by more than a threshold of 1 or 2 or something ( would have to test) it means its not moving in a linear way or essentially moving around rather it's had a previous value and now the new value is say over half a turn away but it hasn't moved there smoothly then it means something has happened to the wire.

Or another idea was to test when it was autolevelling and see if while the relays for solenoids are on if the values for sensors have changed and if they aren't changing it means the sensor has something wrong with it etc.

I was hoping for some suggestions along these lines

What about a pull down resistor on an analog input can that be done? So if the 10k pot is connected the analog input will be getting it's values from the pot but if it breaks say have a 100k resistor between the analog input pin and ground so any really low background noise shouldn't be read and the analog input will see 0 at the arduino possibly? Something along these lines?

My preference is for your 2nd idea in your Original Post. It is simple and should deal with most situations. Adding more equipment just means more things to go wrong.

It my also be useful to compare the time between changed values for all the sensors. I imagine they will all move at much the same rate so a sensor that is showing too many or too few changes would be suspect.

And, of course, you should connect everything robustly so that the probability of a failure is very low to start with. With properly engineered connections the probability of failure may be so low that the extra complexity of software to test for a failure is not worthwhile. There may be better uses for your software development time.

...R

Robin2:
My preference is for your 2nd idea in your Original Post. It is simple and should deal with most situations. Adding more equipment just means more things to go wrong.

It my also be useful to compare the time between changed values for all the sensors. I imagine they will all move at much the same rate so a sensor that is showing too many or too few changes would be suspect.

And, of course, you should connect everything robustly so that the probability of a failure is very low to start with. With properly engineered connections the probability of failure may be so low that the extra complexity of software to test for a failure is not worthwhile. There may be better uses for your software development time.

...R

Second as in the test time relays have been on and no change to sensor? Or second as in pulldown resistor on analog input as well as sensor?

My issue with the testing time and looking for change is that when I disconnected the analog sensor it was still getting some changes when nothing was connected to it I'm guessing due to nothing making it go low or high jist sort of floating and getting noise and background emf or something. Can I use a pullup or pull down resistor of much higher resistance in conjunction with my 10k pot for this reason or will that encounter issues?

And I'm not so worried about coming disconnected everything is soldered and good plugs on sensors my issue is if the sensor dies after a certain amount of time for some reason or wire breaks off at sensor due to a stick or something not likely but I want to cover myself

Not trying to be smart or have a go but did you read the 3 ideas I had?

No need - this is a problem as old as computers if not older. It is impossible, for the software, to tell if the fault is in the wiring , the Rx hardware or the TX software. As you are talking to dumb hardware the best you could do is check if the values obtained are with in limits. But you will need to design the hardware in such a way that a fault (any fault) gives out of range readings in the event of any fault. This is a very difficult problem.

IF you where using "intelligent" hardware then there are a few tricks that can help but even then you will not be able to tell a TX fault from a RX fault from a problem with the cable.

This is a problem that is older than computing!

Your error lies in thinking about the cause of the fault and not the symptoms it causes. In your case a fault in the cable will show the same symptoms as a fault in the RX hardware ant the same symptoms as a fault in the TX hardware.

As PaulS said it's far better to prevent (or at least try) the fault in the first place.

Mark

darcy_d:
Second as in the test time relays have been on and no change to sensor? Or second as in pulldown resistor on analog input as well as sensor?

I'm a simple soul. I meant the one that YOU titled "Second idea"

Second idea (not sure if possible) is to essentially see if the sensor is incrementing correctly

...R

holmes4:
No need - this is a problem as old as computers if not older. It is impossible, for the software, to tell if the fault is in the wiring , the Rx hardware or the TX software. As you are talking to dumb hardware the best you could do is check if the values obtained are with in limits. But you will need to design the hardware in such a way that a fault (any fault) gives out of range readings in the event of any fault. This is a very difficult problem.

IF you where using "intelligent" hardware then there are a few tricks that can help but even then you will not be able to tell a TX fault from a RX fault from a problem with the cable.

This is a problem that is older than computing!

Your error lies in thinking about the cause of the fault and not the symptoms it causes. In your case a fault in the cable will show the same symptoms as a fault in the RX hardware ant the same symptoms as a fault in the TX hardware.

As PaulS said it's far better to prevent (or at least try) the fault in the first place.

Mark

i'm sorry but what?... There is many ways to solve this issue i was looking for ideas from others to see if there was any other ideas people had extra to mine. Yes i get that you cant directly tell a fault in the wiring BUT you can take the values obtained from the sensor and use them to see if they are outside what they should be or not doing what they should.

For example the suspension has a set limit it can travel and those limits are stored in the eeprom so at any 1 time if the value of each sensor lies outside the range of the min and max values for that sensor then something is wrong so that could trigger an error state...

And no matter what if its a fault in RX or TX it still needs to be able to turn off the autolevel for that corner to avoid the car leveling to unstable/incorrect data

Robin2:
I'm a simple soul. I meant the one that YOU titled "Second idea"
...R

haha no worries Yeah i think that will work only issue i see with that is how fast can the arduino run a loop? if its say x times a second and the suspension can change a value between 0 and 255 in 2x a second then we have an issue and the sensor wont be able to keep up with how fast the suspension travel is. that could be taken care of by the use of testing an increment of 2 rather than incrementing by 1 or similar.

darcy_d:
haha no worries Yeah i think that will work only issue i see with that is how fast can the arduino run a loop?

That will be determined by the way you write your program. Many hundreds, if not thousands of times per second should be your goal.

What bothers me is the possibility of the potentiometers wearing out in 5 or 10 minutes. :slight_smile:

...R

Robin2:
That will be determined by the way you write your program. Many hundreds, if not thousands of times per second should be your goal.

What bothers me is the possibility of the potentiometers wearing out in 5 or 10 minutes. :slight_smile:

...R

yeah i dont know how long they are going to last i had over 50 10k pots so thought id try it... haha any ideas on something rotary that gives variable resistance but is a better solution?

Maybe a non contact pot or something i’ll look into it

I'll leave the pros and con$ to you but, current loop sensors easily provide line break detection.