Go Back   EcoModder Forum > EcoModding > DIY / How-to
Register Now
 Register Now
 

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 10-03-2013, 02:56 PM   #1 (permalink)
Scandinavian creature
 
Join Date: Jun 2012
Location: Finland
Posts: 146

Golf ball - '94 Volkswagen Golf III
90 day: 28.46 mpg (US)
Thanks: 4
Thanked 27 Times in 22 Posts
Electrical cruise control

Hello!

So i did a cruise control. Well, actually it is constant throttle control at this point of development...

I saw that all aftermarket cruise controls are quite expensive, so i started to make my own.

I got familiar with Arduino platform, and saw that it is quite easy to start coding with Arduino IDE. Just install and that is it. Well it has many limitations and confusions compared to normal AVR, mainly on interrupts and pin numbering.
Well to the point...

So i made a feature list it needs:

2 buttons: more speed and less speed
1 input for release fuction triggered by brake and clutch
1 input for speedometer signal, or alternatily, fuel economy signal from MPGuino
ON/OFF switch to the whole thing
motor that holds the throttle at desired position, but can be freely rotated --> stepper
driver for the motor
programmable IC --> Arduino Nano (Atmega328P-AU)

So i first got an servo motor, but then i realized that servo does not spin freely, so i got an stepper motor, Arduino Nano and a L293D H-bridge-IC.
I had no idea of what strenght motor i would need, so i ordered about 40x40x40mm hybrid unipolar stepper motor for 12 Volts. It has 4 leads, so it needs an H-bridge circuit, or an H-bridge-IC.

I started building it, and first thing i noticed is that the driver IC heats a lot, and the motor gets about 5A of current. So i needed another way to handle it.
I tried the simplest thing first, resistors. 15R/10W for every lead of the motor, in total of 30R for both coils. It got the current to about 600mA, but in exchange, the resistors got about 2 Watts each, and they were hot. So i tried yet another way.
PWM. The acronym of the modern times. Pulse Width Modulation, meaning it switches the power on/off very fast, thus dropping the power with minimum heat. I made an pwm function that switches the enable pin of the L293D IC. And i added an potentiometer that adjusts the pwm duty. The perfect solution. Now the power power need can be adjusted with only an adjustment of a simple pot.

Then i was ready to install it in my car. I was thinking all kind of solutions how to attach it there, and i came into conclusion that i attach a steel wire directly to the motor shaft, and to accelerator wire.

For the code, for now, this is not yet a constant speed control, it is constant throttle control.
I have made an input for the speedometer signal, but not yet implemented the code for it. I am learning the coding little by little until i can do that.

I have made the whole circuit with proto board, but i made a better circuit with fet-H-bridge, and sent the drawings to a fab house, so i get the professional-looking boards at some day...


Today i got to finally test my proto on a 100km trip, and it works like a charm.


Here's some pictures about my build, and a schematic for the IC driver version. I have'nt tested the fet version yet.

Attached Thumbnails
Click image for larger version

Name:	tn_IMG_20130917_220522.jpg
Views:	1022
Size:	39.2 KB
ID:	13848   Click image for larger version

Name:	tn_IMG_20130917_223542.jpg
Views:	920
Size:	30.7 KB
ID:	13849   Click image for larger version

Name:	tn_IMG_20131003_140012.jpg
Views:	1013
Size:	24.2 KB
ID:	13850   Click image for larger version

Name:	tn_IMG_20131003_140023.jpg
Views:	961
Size:	32.1 KB
ID:	13851   Click image for larger version

Name:	tn_IMG_20131003_140030.jpg
Views:	941
Size:	39.7 KB
ID:	13852  

Click image for larger version

Name:	cruise.png
Views:	773
Size:	27.2 KB
ID:	13853  
__________________

Brrrmm
Now selling preassembled MPGuino's!
http://www.mthtek.net/mpguino/
  Reply With Quote
The Following User Says Thank You to Quezacotl For This Useful Post:
jeff88 (10-03-2013)
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 10-03-2013, 02:57 PM   #2 (permalink)
Scandinavian creature
 
Join Date: Jun 2012
Location: Finland
Posts: 146

Golf ball - '94 Volkswagen Golf III
90 day: 28.46 mpg (US)
Thanks: 4
Thanked 27 Times in 22 Posts
And here's the code, pin numbering might be other than in schematic, but it's easy to change.

Code:
/*
Cruise control by Marko Hämäläinen. mthtek.net
Compiled with Adruino IDE 1.0.4, with Atmega328

So, this is actually an constant throttle control,
but will be developed into constant speed control as soon as i learn to code that. And i will get rid of the TimerOne-library.

When you press either + or - button, the stepper motor nudges one step, locks to it's position, and fan starts blowing.
When you press the reset-button, it releases the stepper motor and fan stops blowing.
Reset-button should be wired that either clutch, brake, acceleration or a switch can trigger it. For safety!
Plus and minus-buttons can be wired wherever user wants them to be.

Stepper motor-driver used in this is L293D chip, using pwm on enable pins,
but because of excess heating(needs a fan and/or big sink) still while using pwm, i will replace it with FETs at some point.

Included library, TimerOne: http://playground.arduino.cc/code/timer1

A4 = pwm potentiometer
A5 = step speed potentiometer
3 = fan control (optional)
5 = spare for speedometer (not implemented yet)
6 = release motor
7 = step counter-clockwise
8 = step clockwise
10 = motor enable/disable/pwm (must be pwm pin)
(9,13),(11,12) = stepper
*/

#include <TimerOne.h>
#include <Stepper.h>
// set the button pins working
int pot = A4;
int pwmPot = A5;
byte fan = 3; // optional fan for cooling when the stepper is on
byte plusButton = 8; // step clockwise
byte minusButton = 7; // step counter-clockwise
byte resetPin = 6; // release motor
byte motorState = 10; // L293D enable pin
byte plusState = HIGH; // set plusbutton HIGH
byte minusState = HIGH; // set minusbutton HIGH
byte resetState = HIGH; // set resetButton HIGH
int potState = 0;
int pwmPotState = 0;
// set the stepper function working
int stepsPerRevolution = 200;  // 1,3 degrees x 200 = 360 degrees
Stepper myStepper(stepsPerRevolution, 9,13,11,12); // digital pins 6,7,8,9
// variables
int stepCount = 0; // count the steps

void setup() {

  Timer1.initialize(25);         // 25 = 40kHz
  Timer1.pwm(motorState, 512);                // “pin”, “0-1024 = 0-100% duty”

  pinMode(plusButton, INPUT); // initialize buttons for inputs
  pinMode(minusButton, INPUT);
  pinMode(resetPin, INPUT);
  pinMode(pot, INPUT);
  pinMode(pwmPot, INPUT);
  pinMode(motorState, OUTPUT); // initialize outputs
  pinMode(fan, OUTPUT);
}

void loop(){
  // Read the state of the buttons and pots in beginning of every loop
  plusState = digitalRead(plusButton);
  minusState = digitalRead(minusButton);
  resetState = digitalRead(resetPin);
  potState = analogRead(pot);
  pwmPotState = analogRead(pwmPot);
 
  if (plusState == LOW && stepCount <= 700) {
    Timer1.pwm(motorState, pwmPotState);
    digitalWrite(fan, HIGH);
    myStepper.step(1);
    stepCount++;
    delay(potState);
  }
  if (minusState == LOW && stepCount >= -700) { 
    Timer1.pwm(motorState, pwmPotState);
    digitalWrite(fan, HIGH);
    myStepper.step(-1);
    stepCount--;
    delay(potState);
  }
  if (resetState == LOW) { // touch clutch, acc or brake = stepper off
    digitalWrite(motorState, LOW);
    digitalWrite(fan, LOW);
    stepCount = 0; // reset the position
  }
}
__________________

Brrrmm
Now selling preassembled MPGuino's!
http://www.mthtek.net/mpguino/
  Reply With Quote
Old 10-03-2013, 03:06 PM   #3 (permalink)
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,807

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 828
Thanked 708 Times in 456 Posts
Cool! So your cable allows you to freely operate your throttle (gas) pedal, when your throttle control is not engaged?

Edit: And how much do you know about PID algorithms? Might want to study up on them, if you want to get a constant speed (or constant load) controller out of this.
  Reply With Quote
Old 10-03-2013, 03:11 PM   #4 (permalink)
Scandinavian creature
 
Join Date: Jun 2012
Location: Finland
Posts: 146

Golf ball - '94 Volkswagen Golf III
90 day: 28.46 mpg (US)
Thanks: 4
Thanked 27 Times in 22 Posts
Quote:
Originally Posted by t vago View Post
Cool! So your cable allows you to freely operate your throttle (gas) pedal, when your throttle control is not engaged?
Yes, and i can actually press the gas pedal at same time when the throttle control is on too. Helps if i want to accelerate past someone.

But this is basically the same than someone has done with a normal cable, as hand operated throttle control, but this is just electric version of it.

Until i can rewrite the code to react on speed signal
But now i have lots to do. Need to fix some rust on my car, friend birthdays, gf time, my band training, apartment change... damn, and i just want to study coding
__________________

Brrrmm
Now selling preassembled MPGuino's!
http://www.mthtek.net/mpguino/
  Reply With Quote
Old 10-03-2013, 03:17 PM   #5 (permalink)
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,807

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 828
Thanked 708 Times in 456 Posts
Quote:
Originally Posted by Quezacotl View Post
But now i have lots to do. Need to fix some rust on my car, friend birthdays, gf time, my band training, apartment change... damn, and i just want to study coding
LOL! Join the club!
  Reply With Quote
Old 10-21-2013, 09:45 AM   #6 (permalink)
EcoModding Lurker
 
Demolite's Avatar
 
Join Date: Oct 2009
Location: Finland
Posts: 17

Carina - '93 Toyota Carina E GLi
Thanks: 0
Thanked 8 Times in 2 Posts
Nice to see someone try this. I have done a full cruise control this way a few years ago and would like to share some tips. I don't have any code to share or pictures.

I used a software PID-control on the Arduino to regulate the throttle. The input signal was RPM, not speed (manual transmission). That way if a gear popped out, it didn't rev itself to death. So it was like a constant rpm control. On automatic transmissions you have to use the speed signal also, and implement rpm limits to stop operation. I used an aftermarket cruise control actuator, which had all the gearing for the motor and cable control. I got it from a junk yard, and was very cheap. The worm gear structure makes life easier for the H-bridge, as it only has to supply power when the motor moves. No holding current is needed. It also had a safety magnetic clutch, that disengaged the cable from the controller motor in case of emergency (had to use it a few times when testing). All in all, a very nice and interesting project, although the gas I spent adjusting it all ended up costing more than a full cruise control kit from the junk yard.

Judging from your pictures you have a Bosch Monojetronic setup, in which case you could also try using the original throttle actuator motor with some electrical trickery.

Best of luck!
  Reply With Quote
Old 10-21-2013, 02:35 PM   #7 (permalink)
Scandinavian creature
 
Join Date: Jun 2012
Location: Finland
Posts: 146

Golf ball - '94 Volkswagen Golf III
90 day: 28.46 mpg (US)
Thanks: 4
Thanked 27 Times in 22 Posts
Close guess, Mono-motronic
Yeah, i was thinking about that i modify the existing motor, but then i decided to not to, because i have people willing to have cheap cruise control

The RPM way would be the way like you said. But actually i have thought that i make it that it can take either speed or mpguino instant signal. It shouldn't differ much if it is RPM or speed.

I have already rewritten the code so it can take pulses in(speed or whatever). But now i'm waiting that i get the new PCBs, so i can make another board and test the code.
I'm learning about the interrupts little by little. Now i'm at that stage that i have interrupts running on the buttons and the incoming signal.
After i get that to work and running safely, i will do the PID-control.

I was thinking about the worm gear structure too, or servo-motor, but then i couldn't figure out how to make it safe. How exactly the clutch-thing works on the aftermarket unit? I would imagine that it releases the cable everytime you press any pedal, or like you said, in emergency.

And about the pedals. The release signal must come from all the pedals(well not necessarily gas pedal). So far i have figured that i can take the brake pedal signal from same wire where brake light goes. But for the clutch pedal, i can't figure out any easy solution.
A micro switch would be the first that pops in mind, but in reality, it is quite cumbersome to install it. Any ideas?
__________________

Brrrmm
Now selling preassembled MPGuino's!
http://www.mthtek.net/mpguino/
  Reply With Quote
Old 10-21-2013, 07:41 PM   #8 (permalink)
EcoModding Lurker
 
Join Date: Sep 2013
Location: peoria, IL
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Honestly I would love to just have the constant throttle setup but my car is electric throttle
  Reply With Quote
The Following User Says Thank You to dragoonmc For This Useful Post:
chumly (10-21-2013)
Old 10-21-2013, 07:59 PM   #9 (permalink)
EcoModding Lurker
 
Demolite's Avatar
 
Join Date: Oct 2009
Location: Finland
Posts: 17

Carina - '93 Toyota Carina E GLi
Thanks: 0
Thanked 8 Times in 2 Posts
Had to be one of those two. Mono-motronic could be a bit harder then, as it should have an optical position sensor inside the actuator for fine tuning.

The RPM method is the simplest if you want to make a "universal" type cruise for a manual transmission gasoline engine. A ignition coil is always there and the signal can be taken from that. Electronic speed sensors don't exist on all vehicles. But keep in mind, the coil signal will have to be well filtered before entering the arduino.

The clutch switch is not absolutely necessary. But you do need the rpm signal for the safety of your engine. The clutch signal can be "added" in software. As the car is moving in high gear and the cruise is used, the momentum of the car keeps the revs pretty stable over a short period of time. As the clutch is pressed, that momentum disconnects and causes rpm to shoot up (cruise is still giving throttle). A clever piece of code could notice that and disable the cruise in a blink of an eye... It also takes care of other bad things that could happen (gear pops out, wheel slipping on ice, etc.). Brakes do need a switch though.

What comes to the magnetic clutch, its very simple really. The gears are connected to the cable "spool" with magnetic coupling. The spool is in a basket with a magnet on the side. When the electromagnet is on, the basket and spool move with each other. When its off, the spool will be free to move. So if power to the cruise goes off, cruise goes off.. Though a stepper motor will do this too, when used without a worm gear. Steppers are more accurate as well. They all have their advantages. You have to choose.

Also when making the PID, make it adjustable by serial commands, and have a friend with a laptop handy. Saves a LOT of time and most importantly, gas.

When it comes to electronic throttle cars, messing with the throttle signal voltage is your pick. Throttle contol voltage goes in the controller and modified voltage comes out. Input=output, until "cruise", when output stays at the last value. This is of course risky at best, letting an external controller control the throttle fully, so its done at your own risk.


Last edited by Demolite; 10-21-2013 at 08:16 PM..
  Reply With Quote
Reply  Post New Thread






Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com