Author Topic: DIY cruise control  (Read 8005 times)

Offline wmax351

  • ^ Quintessential Motobricker
  • Posts: 1237
DIY cruise control
« on: April 13, 2012, 04:38:23 AM »
I am thinking of making a cruise control as a project (to learn avr programming). I plan to use an arduino/avr microcontroller, and a large model aircraft servo motor, or a stepper motor. Should be able to make a much smaller form factor, for well under 30 dollars and a bit of time.

Rough idea of the arduino code. I would have to tweak the delay, and add a dead zone, (to adjust sensitivity) but this is most of what would be required.

Code: [Select]
#include <Servo.h>

Servo throttle;  // create servo object to control a servo

const int freqpin = 0 ; 
const int setpin = 1 ;
const int cutpin = 2 ;
int thrpos = 0 ;
int curspeed ;
int setspeed ;


void setup()
{
  throttle.attach(9);  // attaches the servo on pin 9 to the servo object
  pinMode(setpin, INPUT);
  pinMode(cutpin, INPUT);
}

void loop() // Main Running loop. Adjusts throttle while comparing speeds
{
  curspeed = analogRead(freqpin);            // reads the value of the frequency to voltage converter (value between 0 and 1023)



  if(digitalRead(setpin) == HIGH )           // reads the value of the "set" button


  {

    setspeed = analogRead(freqpin); 

  }

  if(digitalRead(cutpin) == HIGH )           // reads the value of the Cut button


  {

    setspeed = 0 ;                            // zeros the desired speed

  }


  if (setspeed > curspeed) {

    thrpos ++ ;                              // adjusts the throttle based on speed

  }

  if (setspeed < curspeed) {
    thrpos --  ;

  }

  throttle.write(thrpos);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there
}


  • Albuquerque, NM
  • 91 BMW K75 Standard, 98 Moto Guzzi California EV
Bikes:
Current:1991 BMW K75 Standard, 1998 Moto Guzzi California EV11
Past: '83 BMW R65LS, '75 Honda CB550F, '69 Honda CB175, 1999 Royal Enfield Bullet 500, 1973 Triumph Tiger TR7V, 1971 BMW R75/5 in Toaster outfit, 1979 Harley Davidson XLS-1000 Sportster Roadster

Offline billday

  • ^ Quintessential Motobricker
  • Posts: 1341
Re: DIY cruise control
« Reply #1 on: April 13, 2012, 07:14:28 PM »
Makes perfect sense to me.

(Not!)
  • New York State, USA 10977
  • 1985 K100

Offline wmax351

  • ^ Quintessential Motobricker
  • Posts: 1237
Re: DIY cruise control
« Reply #2 on: April 17, 2012, 02:36:40 AM »
Just bought an exhaust servo for a CBR600. It runs cables that close a baffle in the exhaust for more backpressure. Should have enough power for the throttles, which I will set up to open only part way. In addition, it is already set up to run bowden cables. I will reverse engineer the input, and set up a micro-controller to run it.

I will also run a PID (Proportion, Integral, Derivative) control, which will provide smooth, adaptive control for the speed.

Total cost, so far:

$8.50 for the Servo
$ 19.90 for the micro-controller, and related stuff for easy development (arduino clone). Final cost for additional units will be 5 bucks or so.
  • Albuquerque, NM
  • 91 BMW K75 Standard, 98 Moto Guzzi California EV
Bikes:
Current:1991 BMW K75 Standard, 1998 Moto Guzzi California EV11
Past: '83 BMW R65LS, '75 Honda CB550F, '69 Honda CB175, 1999 Royal Enfield Bullet 500, 1973 Triumph Tiger TR7V, 1971 BMW R75/5 in Toaster outfit, 1979 Harley Davidson XLS-1000 Sportster Roadster

Offline frankenduck

  • Adrninistrator
  • ^ Quintessential Motobricker
  • Posts: 4965
Re: DIY cruise control
« Reply #3 on: April 17, 2012, 09:50:23 AM »
Are you going to program to kill if the RPMs change by say, several hundred?  That's what the Audiovox does for 2 reasons:

a) you can disengage the cruise with the clutch
b) it prevents the CC from causing a runaway engine
Once I had a Collie pup. Dug a hole and covered him up. Now I sit there by the hour. Waiting for a Collie-flower.
New to K bikes? Click here.
K Bike Maintenance & Mods: Click here.
Buy parts here.

Offline wmax351

  • ^ Quintessential Motobricker
  • Posts: 1237
Re: DIY cruise control
« Reply #4 on: April 17, 2012, 12:52:43 PM »
Are you going to program to kill if the RPMs change by say, several hundred?  That's what the Audiovox does for 2 reasons:

a) you can disengage the cruise with the clutch
b) it prevents the CC from causing a runaway engine

Yeah. I was planning to do that, as well as an interrupt for the clutch, brake, etc.

The PID system should be quick enough to control rpm even in neutral. The "D" part detects rapid acceleration.
  • Albuquerque, NM
  • 91 BMW K75 Standard, 98 Moto Guzzi California EV
Bikes:
Current:1991 BMW K75 Standard, 1998 Moto Guzzi California EV11
Past: '83 BMW R65LS, '75 Honda CB550F, '69 Honda CB175, 1999 Royal Enfield Bullet 500, 1973 Triumph Tiger TR7V, 1971 BMW R75/5 in Toaster outfit, 1979 Harley Davidson XLS-1000 Sportster Roadster

Tags: