Arduino Forum

Using Arduino => Project Guidance => Topic started by: walttheboss on Jun 16, 2017, 06:10 am

Title: Cruise Control with the Arduino
Post by: walttheboss on Jun 16, 2017, 06:10 am
I am on a challenge to build a cruise control for under 30 USD.  My car(chinese microvan!) has a electronic gas pedal (TPS=throttle position sensor).  It has two pins that send a voltage from 0 to 5 volts to the engine computer.  Here is the plan and what I need help with is at the bottom.

Read wheel/axle rpm with hall sensors(solved and coded)
Interupts for brake and clutch (solved and coded)
When I press "set" the arduino UNO R3 will read the TPS voltage, match it with PWM or ADC converter, Throw two relays to replace the gas pedal(TPS) signal with mine.  Adjust voltage to maintain wheel RPM till brake/clutch/cancel input when the relays open and you are back to foot control!

My only problem is to make sure that the voltage I supply is tied to the same ground as the car.  The cars computer system operates on a 5 v bus.  The TPS supplie 5V, ground, two outputs and two more wires I am not sure of. 

WHAT is the best way to tie my arduino ground to the car's computer ground.  All of the signals are very low current.

Thanks in advance.
Title: Re: Cruise Control with the Arduino
Post by: wvmarle on Jun 16, 2017, 08:06 am
WHAT is the best way to tie my arduino ground to the car's computer ground.
By connecting a wire between the two of course, why?

That should be the easy part. The hard part will be to make sure that the cruise control (i.e. the gas pedal) will disengage 100% of the time with absolute certainty whenever it has to. So not only do you have to test your software very very well (using a proper test setup), you also have to test all our sensors very very well and make sure they are fully reliable.

You also will have to make sure your rpm sensor is 100% reliable as the last thing you want is it drifting and you suddenly start to speed up as your computer thinks you're slowing down and goes full throttle. A rear-end collision at highway speeds sounds like a recipe for mayhem.
Title: Re: Cruise Control with the Arduino
Post by: Robin2 on Jun 16, 2017, 08:17 am
Check with your automobile insurer before you start messing with the control system for a vehicle that is used in public.

IMHO if you have to ask questions about how to implement this project then you are not sufficiently expert to do it safely. I doubt if a real cruise control can be had for $300, never mind $30.

...R
Title: Re: Cruise Control with the Arduino
Post by: wvmarle on Jun 16, 2017, 09:02 am
Electronic cruise control can easily be built for under USD 10 in parts. The rest is for software, testing, etc - the part OP won't include in his final cost.
Title: Re: Cruise Control with the Arduino
Post by: Robin2 on Jun 16, 2017, 10:10 am
Electronic cruise control can easily be built for under USD 10 in parts.
Perhaps.

But when you buy a system you also pay for all the safety testing and the knowledge that you can sue the manufacturers if someone gets killed or injured because it does not work properly.

And it would be wise to check with Atmel to see if they approve their products for automotive applications.

...R
Title: Re: Cruise Control with the Arduino
Post by: wvmarle on Jun 16, 2017, 10:42 am
Indeed.
As it's automotive I would guess they also have to go through some form of certification before it's road legal.
OP got himself a nice little challenge - but not likely it can be tested only on the track, not on the public road.
Title: Re: Cruise Control with the Arduino
Post by: walttheboss on Jun 19, 2017, 12:02 am
Thanks to all of you for your replies.  I appreciate the concern.  I am a mechanical engineer and Math and Science teacher.  I will build in triple redundancy for cutoffs such as brake clutch over revving and accident avoidance.  I will be the only one using it and will be super careful to do all the testing.

I will be counting engine RPMs and Wheels RPMs so that if either of them change too fast based on basic dynamics calculations the system shuts off.

Thanks again.
Title: Re: Cruise Control with the Arduino
Post by: Robin2 on Jun 19, 2017, 08:41 am
I presume as a responsible professional engineer and teacher you have already made enquiries with your automobile insurer. What was their response?

...R
Title: Re: Cruise Control with the Arduino
Post by: hammy on Jun 19, 2017, 01:27 pm
I wouldn't attempt this on safety grounds .
When you say you have redundancy - is this multiple Arduinos and a voting algorithm ? Have you looked at fail safety ( e.g. Does the throttle driver always fail to close if a component dies ?)
As said if your car kills someone , you could be liable and be very poor for the rest of your life.
Title: Re: Cruise Control with the Arduino
Post by: wvmarle on Jun 19, 2017, 02:14 pm
You're in a pretty sad moral state if the risk of being sued for damages is what stops you from risking killing other people. I thought it should be that you simple don't want to risk killing someone.

A cruise control is a great challenge, lots of interesting engineering aspects, but without third-party certification it's not something you should take on the public roads, period. Such experiments belong on the test track, in a car with independent kill switch (e.g. a physical button to cut the power to the fuel pump). There you work out the bugs, you do your stress tests, and when that's all done you can with a clear conscience say you did the best you could to make sure nothing goes wrong.

That's why a commercial cruise control costs USD 300 to install in your car, while it's maybe USD 10-20 worth of electronics.
Title: Re: Cruise Control with the Arduino
Post by: roosterqmoney on Jun 21, 2017, 01:18 am
I say screw the haters man, go for it. People thought the wright brothers were nuts, I probably wouldn't try building self driving capabilities into your car, but cruise control should be cake.  The vehicle's ground is the chassis. just tap into anything structural with a 10/32 and a ground pigtail and your in business.
Title: Re: Cruise Control with the Arduino
Post by: Boardburner2 on Jun 21, 2017, 03:31 am
That's why a commercial cruise control costs USD 300 to install in your car, while it's maybe USD 10-20 worth of electronics.
Not quite.
They cost that because the manufacturer has to undergo expensive testing procedures to make sure they are safe and to make profit.

Nothing to stop you experimenting though.

If you wish to use on a road going vehicle be very careful.

An acquaintance of mine removed the passenger seat from a luton van to accommodate the length of a carpet roll.
This is a modification to a vehicle, if you do not inform your insurance co. it invalidates the insurance.
This is a common practice for carpet fitters and in the event of an accident could mean you have to buy a new vehicle.
What you propose however  affects the running properties ov the vehicle.
In the event of a problem involving a third party you could possibly face a very expensive legal/liability bill for which your insurance will not cover you.
Title: Re: Cruise Control with the Arduino
Post by: Robin2 on Jun 21, 2017, 09:09 am
The vehicle's ground is the chassis. just tap into anything structural with a 10/32 and a ground pigtail and your in business.
Geez .... 


...R
Title: Re: Cruise Control with the Arduino
Post by: walttheboss on Dec 17, 2017, 12:37 am
Thanks again to you all for your concern.  I am doing this to prove it can be done.  I do not intend on using it on a regular basis.  As I do the testing I will update this forum.
Title: Re: Cruise Control with the Arduino
Post by: Robin2 on Dec 17, 2017, 11:21 am
I do not intend on using it on a regular basis.
One paraplegic on the irregular day would be one too many.

...R
Title: Re: Cruise Control with the Arduino
Post by: Snabark on Jul 26, 2018, 01:09 pm
Hello sir
Nice to find some one intrest in this topic
I want to do exact same project
This my post
https://forum.arduino.cc/index.php?topic=560154.0
I ommitted the speedometer option

Do you do it
Does it function well
Can you tell us the full details
So we can replicate your work

Thanks
Title: Re: Cruise Control with the Arduino
Post by: walttheboss on Aug 10, 2018, 02:43 am
Hello @Snabark.  Thanks for your reply.  If you read through the post the responses were very strong against the project.  Whether or not I did it I will not say for fear that some well meaning person will go after me or remove me from the forums altogether.  My ComSci class is writing a book on the Arduino and it just might appear in that book in a hidden form.  If you find me in another way or personal message I will reply more in detail.
Title: Re: Cruise Control with the Arduino
Post by: gmcmurry on Aug 10, 2018, 05:47 am
Its interesting how you can ask a simple question and all of us try to put on lawyer hats.

Cruise control is actually quite difficult.  Forget all the (how do you turn it off stuff for a minute).

Think about how much do you need to accelerate when you are not going the desired speed:

What if you are going up hill?
What if you are going down hill?
How powerful is your motor?
How much "gas" do you give it when you are falling behind?

I have a project where I have been trying to tweek these things and it is difficult.

For any vehicle, it is different depending on what speed you are going...  You can give more acceleration at low speeds than you can at high speeds.

Its loads of fun to play with this type project.  The interface to your 0-5v is the EASY part.

https://en.wikipedia.org/wiki/PID_controller

PID is what it is all called.  Great reading, etc.

Google PID for more.

Try asking us here for more specific interface info, like-- "how do I generater a 0 - 5 volt signal to adjust the throttle on my engine?"

How do I measure the speed of a rotating shaft and turn it into MPH?



Greg

Title: Re: Cruise Control with the Arduino
Post by: Delta_G on Aug 10, 2018, 05:52 am
put on lawyer hats.
Not so much lawyer.  More like guy-with-some-common-sense. 

I don't know where this guy is trying out his new cruise control, so I have to worry that it might be near to where I am driving.

Then I see:

Quote
I am a mechanical engineer and Math and Science teacher.
Followed by:

Quote
WHAT is the way to tie my arduino ground to the car's computer ground
and I know that this guy is either 1. a liar  2. stupid  or 3.  the worst engineer ever. 


Either way, it doesn't instill a lot of confidence and I know that I might have to drive around some idiot trying to build a cruise control on a highway.  If it isn't this guy it will be some other numb-skull who reads this thread and decides it's all good to control a 2 ton machine at 70 miles per hour with a $2 hobby microcontroller. 

All I'm saying is, Do your testing on a track and not the street.

That's it.  And I don't think that is too much to ask.  Please consider my safety and not just your own desire to do something stupid. 
Title: Re: Cruise Control with the Arduino
Post by: walttheboss on Aug 10, 2018, 06:08 am
All well said.  As to which of the three choices I am(liar, stupid, worst engineer) only time will tell. I don't mind any of those names.  Except liar I suppose.

As to how the program works there is a learning cycle/program.  With an accelerometer I can help the controller to pick the right numbers.  When going uphill or downhill.  When the unit is installed it will learn the right parameters quite quickly.  So a 5 liter engine or 1.3 will configure itself with different numbers.  Once you have those numbers you lock them in.

So when the car begins going uphill the program kicks in faster and more agressively.  If you begin to crest a hill the increment numbers decrease so you don't launch over the crest of the hill. 

Its been a great project.  Keep your helmets on all of you!! :)
Title: Re: Cruise Control with the Arduino
Post by: Delta_G on Aug 10, 2018, 06:17 am
Again, please test far away from me.  On a track.  Like a real engineer.  Not on the highway like an idiot where someone can get hurt. 
Title: Re: Cruise Control with the Arduino
Post by: walttheboss on Aug 10, 2018, 06:23 am
Again, please test far away from me.  On a track.  Like a real engineer.  Not on the highway like an idiot where someone can get hurt. 
Again, please test far away from me.  On a track.  Like a real engineer.  Not on the highway like an idiot where someone can get hurt. 
Absolutely.  I will test up on a lift at a shop first. Then on an abandoned highway near my house. (GMT+8).  Then maybe on the road if I am happy with it.  Or maybe I already did all of this.  Say no more.

Thanks for keeping me honest @Delta_G  I appreciate it.
Title: Re: Cruise Control with the Arduino
Post by: srnet on Aug 10, 2018, 10:14 am
Is the standard Arduino, such as the UNO, suitable (and safe) for use in a harsh automotive environments ?
Title: Re: Cruise Control with the Arduino
Post by: KawasakiZx10r on Aug 10, 2018, 05:17 pm
Firstly ATmel has been bought my Microchip so with that out the way here's an interesting thing there is a 328p and 328p-automotive

ATMEGA328P-AUTOMOTIVE (https://www.microchip.com/wwwproducts/en/ATMEGA328P-AUTOMOTIVE#additional-features)

ATmega328P (https://www.microchip.com/wwwproducts/en/ATmega328P)

both have the same specs but i assume one has been far more tested, can anyone spot something that is different between the two ?
Title: Re: Cruise Control with the Arduino
Post by: wvmarle on Aug 11, 2018, 10:56 am
Usually the main difference is in the operating temperature range, which is much greater for automotive versions.

I'd be impressed if you can measure the slight slope of a highway (usually <4% incline) with an accellerometer - as the signal is easily drowned in the noise of the vibrations of the car's engine, the bumps in the road, etc.
Title: Re: Cruise Control with the Arduino
Post by: gmcmurry on Aug 11, 2018, 05:04 pm
Here is a good article, though written for Basic Stamp, about using PID.  Believe me, this part of your project will be the most interesting.

http://learn.parallax.com/tutorials/language/pbasic/pid-control/proportional-integral-and-derivative (http://learn.parallax.com/tutorials/language/pbasic/pid-control/proportional-integral-and-derivative)

I have built many devices that ride around in all sorts of vehicles.  You will not have a problem there. 

You need a speed pickup, which could be something like a Cherry KB15MKW01 Gear Sensor.  It can sense a piece of metal flying by and generates a nice open collector signal.  Just attach it to your Arduino and use a pull up resistor.  It is a hall effect device and any sort of rotating shaft with a bolt in it (or similar) will give you a nice speed reference.

I would buffer your Analog throttle output with another OpAmp.  Always nice to have a couple of pots on there to adjust the range without having to get out your computer.  And use use a simple double throw relay to switch out your gas pedal and in your Cruse Control.  That way, your emergency / kill system could easily just revert to your gas pedal when you take away power from the relay.

An Opto Isolated pick up off your brake light will give you a signal to release the Cruise Control when you touch the brake.

Then a couple of buttons to turn things on and off.  You might also like to use a pot to set your speed in your first model, instead of trying to capture your current speed with a button press.  Do both, simple logic.

I have done all this but my programming ability is limited and the PID work I have done needs some help.

Forget the accelerometer and stuff like that.  Your software should just keep track of how fast your system responds to corrections.  Its a classic servo loop you have to close and all well written about on the internet.

Its a great project.

Greg