Motor Speed Acceleration

Hey, I was wondering if there was a way to code my robot to slowly accelerate with the joystick just being held in an upward position. I’m coding using the standard V5 Software. I thought I could just have the code increases motor velocity as time went on with the joysticks at full. I can’t seem to figure out how to come it tho. I’ve got a two-motor tank steering. Any Ideas?

Are you using text or blocks?

Use the timer function and have velocity ramp up with time using a multiplier. After you hit a certain speed limit, set the speed to 100% and then reset the timer

2 Likes

A better solution imo which is more fluid is to do a rolling average of the controller input. Create an array and fill the array with the joystick values every 15 ish miliseconds. Then, get the average of the array and set that as the motor power. If the array exceeds 50 or so values then slice off all of the older values from the array.
Note: Now that I think about it a rolling average can be a convenient method to smooth out motion for autonomous :eyes: good discovery

6 Likes

I don’t think this is an ideal solution. First, it would not limit acceleration to a specific value, rather it would simply ramp between an old value and a new value over a specified time period (in your example 750ms). For example, it would take 750ms for the robot to go from 0m/s to 1m/s, which is an acceleration of 4/3 m/s^2. On the other hand, it would also take the robot 750ms to go from 0 m/s to 2 m/s, yielding an acceleration of 8/3 m/s^2. If the robot can handle the latter acceleration without slipping it’s wheels, then why limit it to half that when accelerating to 1 m/s?

Secondly, from my understanding the controller sends values to the brain every 10ms, so running your loop at 15ms would result in skipping a set of values of the joystick every other iteration, which might result in somewhat undesired behavior.

For OP, a topic which might be helpful to you is that of “Slew Rate”. There is a decent amount of talk on this forum about it and I woudl recommend that you read through those posts.

5 Likes

Good point. I was thinking about the acceleration issue as well. As your response about the controller being 10ms thats a good point.

I think the idea still is possible by making it such that the number of snapshots taken of the controller is proportional to the error which the error would be assumed to be controller desired - current motor output

Like you could keep a history of like the previous 500 snapshots of controller values and make it such that you get the latest int(abs(error)*kA) number of snapshots to average from, where kA is the value that you tune, where the greater kA, the less aggressive the transition.

2 Likes