I have previously posted in the beginners section but I feel this is more advanced than I had first anticipated.
Previously I was trying to code something that would react to a change in distance... but I've found a similar problem which would require the same bit of code however is much easier to explain and think about.
Say you decide to put a picaxe in your car so that when you're on the motorway you can switch a button and then the picaxe will accelerate/decelerate/hold-contstant-speed dependant on the car in front.
Now, my purposose for this programming is to place it into a coating machine im trying to build, which requires a tension arm to be steady. However, for all that matters its the same as the cruise control idea above.
(To make explaining easier, i think its best we talk as though its the cruise control from here on out)
What doesnt work?
Simply saying if the car gets x distance away accelerate and if its x distance too close decelerate. This is because it makes an inverted bouncy ball effect. (the bounces get indefinately higher and higher) In other words, the car would start to get too close the car, then too far way, then even closer, then even further, then hit the car in front. This is because the pic isnt reacting intuitively enough.
I.e when it gets so far away I step down a potentiometer which will cause the car to go faster until it gets passed the upper limit (the point at which Ive said its too close) and then will step up the potentiometer and allow less voltage through which will cause the car to slow right down.
I need a system which will allow it to almost predict where the car will be in relation to the car infront and then speed up, slow down accordingly.
So if it gets really close I need the system to step up the potentiometer so that the car returns to its desired distance from the car ahead and then step down just enough to stop the car getting any further away.
I hope this makes sense!
Any Ideas?