Hey guys. Hoping to get some advice from the experienced people here. I know it's a long post, please bare with me....
1st up, in order to avoid any confusion in this post, when I refer to airbags, I mean airsprings and not airbags used for occupant safety in a vehicle.
I have installed 4 airbags in my car. I have a sensor monitoring the suspension height on each wheel. The sensor is basically a pot, supplied with 5v and giving a 0v - 5v output.
I also have an on-board air compressor and tank feeding a set of valves, which are opened/closed with solenoids. There are 2 valves per airbag, one to raise & one to lower it.
I have an Arduino Duemilanove which I'd like to use to monitor the 4 sensors and control the 8 solenoids. I've found circuits which clearly show how to wire the pot to the analog input of the Arduino and also how to use digital outputs to control solenoids.
The hardware is the easy part for me, it's the software that has me confused as I know practically nothing about programming......and I've been on this site for weeks, reading as much as I can and trying to learn. But I still don't know a void from an int from a loop.... :-/
I'd like to have the arduino do 4 things:
It has a ride height set as default, and when I start the car, it checks the sensors and adjusts to that height if necessary.
It stores 3 different ride heights, and I'm able to choose each one with a press of a button.
It constantly monitors each of the 4 sensors, and when it sees a change in ride height, it opens/closes a valve to bring the suspension back to the pre-determined ride height. I'd like to put a delay in as well, so it doesn't respond immediately, it waits maybe 5 secs, then adjust as necessary.
It monitors the car's battery voltage, and automatically turns the compressor OFF if the voltage drops below 10.5 volts, to prevent a dead battery.
I'd like to possibly do more, but for now, I just want to know if the above is achievable with the Arduino, and if so, how?
Let's get the warning out of the way. The Atmel data sheet on this processor says it should not be used for any automotive application.
Cases 1 and 2 are just special cases of 3.
Case 4 has been done to death on this forum and requires that you use a potential divider.
Now case 3 is where it can be complected. What you have in effect is a closed loop feedback system and this can be implemented in a number of ways. The classic servo control has integrators and step response to consider and involves a whole bunch of math to achieve either an over damped, under damped or critically damped system.
Also do a google on damping and look at the images.
The other alternative is the sort of on / off control used in things like electric cookers and fridges. Go full belt until it gets to where it is going and then shut it off until it drifts away. This is much easier to implement but the result is rougher.
Thank you for pointing that out. I can see why they would have that warning, and I've designed the system as a "fail safe" system. Should a bag blow or the control circuit fail, the bump stops will prevent the car from bottoming out & I can drive it until I can resolve the issue....
The damping idea is new to me & sounds interesting. Thanx for the links. I briefly looked at it just now, but seeing as I'm just feeling my way through this, I'm more than happy to skip the damping method for the time being and just focus on the rough on/off control.
It won't be as elegant as the damping method, but it will still be a closed loop feedback system, won't it? It will turn the solenoid on/off while still monitoring the input....which is exactly what I'm after.
Focusing on case 3, how would I go about doing this?
Also, in regard to the potential divider, do you mean use 2 resistors to drop the vehicle's 14v down to 5v and then feed this into the analog input and have the arduino monitor it until it drops below a pre-set threshold?
Focusing on case 3, how would I go about doing this?
In your loop() section just:-
read the sensors
Compare it to the figure you want
If it's above a threshold (plus a bit) then pump up your bag (small pulse)
If it's below the threshold (minus a bit) then pump down your bag (small pulse)
Having that in the loop will just keep on repeating it and eventually you will get to your set threshold. The bit you add or subtract is known as the hysteresis and stops it going up and down all the time. The size of the small pulse on your solenoids will determine how quickly you get to the point you want and the degree of undershoot and over shoot in the system.
do you mean use 2 resistors to drop the vehicle's 14v down to 5v and
Yes but I would count on a maximum voltage of 18V on a 12V car
You certainly make it sound simple and it makes sense, but I really don't know where to start
Any idea where I may be able to find some code that will do what I need? Or is there any similar code for anything else that I may be able to learn from?
In which case I don't think you are ready for this project. Do some of the tutorials first, like :- http://www.arduino.cc/en/Tutorial/HomePage
Learn how to flash an LED, how to read a pot, how to make a pot control the flashing of an LED. Then you will know enough to be able to make sense of my answers.
It is a bit like learning in a foreign language how to ask for directions to the train station. It's all well and good but useless unless you can understand the reply.
It would be all over the place, that's why I added:
Quote:
I'd like to put a delay in as well, so it doesn't respond immediately, it waits maybe 5 secs, then adjust as necessary.
Yes but you need more than a delay, if you take a reading just as you hit a bump you still shouldn't act on that reading alone, now, in 5 seconds, or 30 minutes later.
You need to average the readings over a reasonable period and ignore any that are too far out of spec. Then there's things that Grumpy mentioned like hysterisis.
#1 2 and 4 are straightforward, it's #4 that's the problem. It's not rocket surgury but also not a simple problem while the vehicle is moving.
If you're driving in town with a lot of stop/start you could take readings at the lights.
Is there any reason to think that the level will change anyway? Can't you just have 3 settings based on pressure?
Grumpy_Mike, thank you, I'll try those tutorials, hopefully the light will turn on...
Graynomad, one of us doesn't understand, and to be fair, it's probably me as I'm the one asking for help
This is how I envisage it's going to work. Re #3.
I don't see the arduino acting on any instant reading as such, rather it is monitoring the height. Let's say I pick a certain height as default, which the pot puts out as 2.5v. As I'm driving, the height is changing, maybe going up to 3.3v, and down to 1.8v. The arduino is seeing the changes but not acting on them until it sees the change has become permanent for a certain period. For example, I've loaded the car and the weight has caused the suspension to drop down. This new height puts out a voltage which is constant. The arduino sees the new constant voltage, and as the pre-determined time period passes (say 5 secs), it acts by switching the solenoid on to raise the suspension back to the default height. When the load is removed, obviously the reverse happens.
This isn't necessary while the vehicle is moving. If my height has changed permanently while I'm moving, I'm in trouble. I'm happy for it to work only while I'm stationery but I think I can work that out when the time comes. My vehicle does have a VSS, and I could possibly tap into it to provide info on speed.
I don't want a pressure based system as it would not be suitable IMO. The pressure in the bags would change as the load changes. By adjusting back to the same pressure as before, the height will change. I want the height as the constant, the pressure is what it needs to be to maintain the height.
I took that to mean all the time including while driving.
I'm happy for it to work only while I'm stationery but I think I can work that out when the time comes.
Like I said, at the lights or something, although there's no reason to believe things will change once the car starts moving (unless your load falls out the back) so I doubt you will have to implement this, although it will make the system automatic, without speed sensing you'll have to press a button or something to make it check.
By "load" are talking about adding the shopping one bag at a time, or dropping a crate with a forklift? The latter will cause a faulty reading if you happen to read just as the crate hits. I'd still average a few readings, not just work with one.
Yeah, to be specific, it is a light truck, so it's certainly more than the shopping, but not necessarily a 1 ton pallet/crate.
The latter will cause a faulty reading if you happen to read just as the crate hits
This comment I don't understand. I thought the arduino is constantly monitoring the analog inputs.
Again, as I understand it, it's just monitoring and seeing the load (voltage) change, but waiting to see a constant change before it reacts.
I thought the arduino is constantly monitoring the analog inputs.
That's up to how you write the program, but yes I think we're on the same page, maybe just consecutive paragraphs
I'd take say 5 readings over 5 seconds, ditch the highest and lowest then average the other 3 and use that value as your current ride height. Then make an adjustment only if that value is sufficiently different from the value used last time you adjusted.
In regards to the code, I'll do what Grumpy_Mike suggested and use the tutorials to attempt to write what I need. Again, being so new to this, I'm a little afraid I may go about it the wrong way and cobble together many lines to do something that is achievable much easier another way.
If you feel like offering some help with the code, feel free
I thought the arduino is constantly monitoring the analog inputs
It only looks at the analogue input when your code tells it to look, and only one at a time. You can do this quickly in succession to make it appear like it is constant monitoring but really it is only sampling. This applies to all computers.
You will find that out when you have done some playing about.
I'll make a start and stumble through it. I'd be greatfull if anyone helps out.
I was thinking about it a bit more and realized that it needs to be checking the analog input much more frequently than something like once a second.
Reason being, once it actually sees the constant change, it will activate the solenoid. This is when things start to happen quickly. With the solenoid activated, the air lifts the truck rapidly. To give an example, for approx .2 sec on time, there is about 10PSI increase, which is an easy 10mm if not more in height. So it needs to be checking the input at least 10 times per sec to be somewhat accurate, maybe more. Still do-able?