PID regulated SOLEX moped
hello friends! first of all, sorry english.. doing best!
i'm going convert old solex moped (with broken engine) electric bicycle.
i have lot of ideas on fun things want add arduino going involved:
pid-cruise control. (for fun of it) think it's awesome.
gps (later project)
lights (easy done)
speedometer (easy done)
"battery health meter" (easy done)
now first of i've looked trough excellent pid library brett beauregard.
i put code 1 of bretts example code , bit of code read revolutions/sec motor hall effect switch.
i plugged in , kinda worked (the motor acted kinda strange run smoothly). first of don't know how tune pid , i'm not sure code think should.
this idea of how works:
input: rev/sec hall effect switch.
setpoint: speed set potentiometer.
output: pwm arduino motor driver.
you may ask things +140 for:
my motor controller curtis wig-wag control. can controlled 0-5v output arduino (with rc-filter between). has neutral mode if voltage between 2.2v , 2.8v. if it's more 2.8v motor spins in 1 direction , if it's less 2.2v spins in other direction.
so output should never go under analogwrite 140 (i've tested curtis different pwm , 140 seems value neutral.)
the motor goes 66rev/sec. (bosch gpa 24v 750w)
so need add parameters pid tuning of code , parameters p , d should start workingfrom. guess it's else cruise control example controlling heat.


best regards
//isak nordell sweden
i'm going convert old solex moped (with broken engine) electric bicycle.
i have lot of ideas on fun things want add arduino going involved:
pid-cruise control. (for fun of it) think it's awesome.
gps (later project)
lights (easy done)
speedometer (easy done)
"battery health meter" (easy done)
now first of i've looked trough excellent pid library brett beauregard.
i put code 1 of bretts example code , bit of code read revolutions/sec motor hall effect switch.
i plugged in , kinda worked (the motor acted kinda strange run smoothly). first of don't know how tune pid , i'm not sure code think should.
this idea of how works:
input: rev/sec hall effect switch.
setpoint: speed set potentiometer.
output: pwm arduino motor driver.
code: [select]
/********************************************************
* pid simple example
* reading hz control analog pwm output 3
********************************************************/
#include <pid_beta6.h>
//+++++feedback
volatile byte hzcount;
unsigned long hz;
unsigned long timeold;
//+++++feedback
//define variables we'll connecting to
double setpoint, input, output;
//specify links , initial tuning parameters
pid mypid(&input, &output, &setpoint,2,5,1);
void setup()
{
//+feedback+ hall effect switch
attachinterrupt(0, hz_fun, rising);
hzcount = 0;
hz = 0; // [b]input[/b]
timeold = 0;
//+feedback+ hall effect switch
//initialize variables we're linked to
input = hz;
setpoint = (analogread(0)/9)+140;
//turn pid on
mypid.setmode(auto);
serial.begin(9600);
}
void loop()
{
//+feedback+ hall effect switch
if (hzcount >= 5) { //higher number better resolution
hz = 1000/(millis() - timeold)*hzcount+140; //140->206 //motor rev/sec max 66
timeold = millis();
hzcount = 0;
}
//+feedback+ hall effect switch
input = hz;
mypid.compute();
analogwrite(3,output); // [b]pwm motor controller[/b]
}
//+feedback+ hall effect switch
void hz_fun()
{
hzcount++;
}
//+feedback+ hall effect switchyou may ask things +140 for:
my motor controller curtis wig-wag control. can controlled 0-5v output arduino (with rc-filter between). has neutral mode if voltage between 2.2v , 2.8v. if it's more 2.8v motor spins in 1 direction , if it's less 2.2v spins in other direction.
so output should never go under analogwrite 140 (i've tested curtis different pwm , 140 seems value neutral.)
the motor goes 66rev/sec. (bosch gpa 24v 750w)
so need add parameters pid tuning of code , parameters p , d should start workingfrom. guess it's else cruise control example controlling heat.
best regards
//isak nordell sweden
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > PID regulated SOLEX moped
arduino
Comments
Post a Comment