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.
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?