Gradual Speed Ramp Up

Thank you very much! Will try the program this week. Will try to analyze your code, looks awesome!!!

BTW, this is the library I installed,

https://docs.arduino.cc/libraries/kalman-filter-library/#Releases

Cheers.
Andy

Howdy!

Finally got around to testing the code. The library I found was the Arduino Kalman Filter Library. Had to change the code for Kalman.n as opposed to HalmanFilter.h
All good until
if (rpm333ButtonState && (!rpm450ButtonState)) { // high state means on
target_velocity = velocityKalman.getEstimate(RPM333, 2.0, 2.0, 0.01);

Added screen shot with the error. Thanks for you patience, I am sure it will be something relatively simple.

Thank you. I have seen that, my issue is the member is not in the library. The library in the code cannot be addressed as written.

Are you sure? I thought you were using a generic kalman library you found because Valentine forgot to include the link to his. The class in that thread has a function getEstimate, so I think it should work.

You can see the error in the screen shot, so sadly no go for now.

@jazzboy Not sure if this is exactly what you are looking for but I just used a timer and used it to increase my speed over a set time. I’m happy with how it performs. Might be worth a try. Basically you start a timer using millis() and then make a variable to change it to a floating point number. Take the current millis() value and divide by the amount of time you want to spend speeding up(10 seconds in my case). Take that and multiply by your target max speed. Once you reach the target you need to lock the speed to your max value. No Kalman filter so the movement might be a little rough starting and stopping. Hope this helps.

void loop() {

// open loop velocity movement
// using motor.voltage_limit and motor.velocity_limit
// to turn the motor “backwards”, just set a negative target_velocity
myTime = millis();

duration = myTime - resetTime;//find duration of current sequence
timer = duration*1.0;//convert milliseconds to float
//target_velocity = MaxSpeed;

if(duration < 10000)
{

//Use floating point timer to increase target velocity
target_velocity = MaxSpeed*(timer/10000.0);

}
if(duration>10000 )
{
target_velocity = MaxSpeed; //Set maximum velocity
}

1 Like

Hi,

A simple way to ramp the speed up gradually is just to use our existing low pass filter class:

float target = 0.0f;
LowPassFilter targetFilter = LowPassFilter(1.0f); // 1s time constant 

…


void loop() {
   motor.move(targetFilter(target));
}

Of course this way of doing it will make any speed changes gradual, not just the initial ramp-up. Often that’s what you want though.

2 Likes

Many thanks. Will give it a try.

Thank you very much! Such an awesome community, much appreciated.