Endless mode (as Mellow boards have)

7 posts / 0 new
Oyta
Offline
Last seen: 2 weeks 2 days ago
Joined: 2017-05-24 12:30
Posts: 19
Endless mode (as Mellow boards have)

An low battery / prolonging battery / skate feature request! The Mellow Boards Endless mode is quite nice. It would be great to have this option available. Take a look at their official YouTube-channel that introduces the mode: https://www.youtube.com/watch?v=AWWLP7TwsDU

So how I understand the feature is that as long as the throttle or brake is not activated, the ESC listens to the RPM. In my simple mind without knowing much about the bldc-code, I thought the following logic:

# Pseudo code

// User is not using the remote
If !throttle_active and !brake_active and endless_mode {

// The board is moving forward in less than 25 kmh
If Current_RPM > 0 and Current_RPM < RPM_25_kmh {

// The last measured RPM is bigger than the registered target.
// That means that the user has    pushed the board and increased
// the speed or that it is a downhill. Plus 3 is to not update
// current RPM if it just reduced the speed (every 0.1 second).
If Current_RPM > (Target_RPM + 3) {

// Set the new target RPM for which the VESC shall keep for 0.1 second
Target_RPM = Current_RPM

// Reset the timer
Timer = now()
}

// Timer reach threshold - reduce the RPM.
If Timer >= 100 ms {

// Reduced the Target_RPM with a rate of 30 RPM per second
Target_RPM = Target_RPM - 3

// Reset timer
Timer = now()
}

// Give sufficient power to keep the Target_RPM
Give_power( Target_RPM )
}
}

timower
Offline
Last seen: 1 year 1 week ago
Joined: 2017-09-07 23:55
Posts: 2

I tried to implement this as a custom app, but it has a few problems.

One problem is overshoot, when setting the RPM the vesc uses a PID controller to set the current based on the rpm error. Now when someone jumps off the board for example the rpm will overshoot quickly causing the endless mode to continuously accelerate.

Another problem is discriminating between pushing and going down a hill for example, this can be ignored if the user brakes.

But I'm currently searching for a solution to the overshoot problem. So if anyone has any ideas, please tell me

Oyta
Offline
Last seen: 2 weeks 2 days ago
Joined: 2017-05-24 12:30
Posts: 19

Interesting! I am not familiar with the bldc code - it is a lot of reading up on. Do you have your code on github, then I can try to understand  your implementation?

Oyta
Offline
Last seen: 2 weeks 2 days ago
Joined: 2017-05-24 12:30
Posts: 19

In the Nunchuck app there is some code to maintain speed while using cruise control. https://github.com/vedderb/bldc/blob/79bfbe62344a29817c5e3ea982a2c27d34c6c881/applications/app_nunchuk.c#L268

So I haven't tested the cruise control, so I do not know what happens if jumping off - will it accelerate or just keep the speed? I would have guessed that the PID keeps the speed, but that is just a guess. I had a quick look at the code and didn't see anything coping with this specific case.

When it comes to downhill or pushing I would say the behavior is equal, so no need to separate those cases. Shouldn't it be the same? I think it is important give a max speed option of this feature. It should be user configurable, but in pushing scenarios I'd say 20 or 25 kmh is enough. But making it user configurable it does not matter what I mean :)

timower
Offline
Last seen: 1 year 1 week ago
Joined: 2017-09-07 23:55
Posts: 2

The cruise control mode does indeed work, it just maintains a set speed. This means that when jumping off the PID controller will try to maintain the speed as best as it can, but will generaly overshoot (even just a very small amount) as it can't respond immediately.

This becomes a problem when implementing endless mode, as my method was to change the set point when the current speed is bigger than the set speed. But when overshooting this cause the setpoint to rise, causing the board to accelerate a little bit causing more overshoot and so on.

Also, driving down a hill would require braking as I can't distinguish between pushing and accelerating due to gravity.

I'm curious how mellow boards handle this (mainly when jumping off the board in endless mode).

Oyta
Offline
Last seen: 2 weeks 2 days ago
Joined: 2017-05-24 12:30
Posts: 19

So I revisit this every now and then - I don't have enough time too really get into VESC programming yet. But it helps to gain some knowledge.

It looks like it is this line which sets the pid:https://github.com/vedderb/bldc/blob/79bfbe62344a29817c5e3ea982a2c27d34c6c881/applications/app_nunchuk.c#L317 I guess this is known to you @timower, but just to get the discussion further.

pid_rpm += (out_val * config.stick_erpm_per_s_in_cc) / ((float)OUTPUT_ITERATION_TIME_MS * 1000.0);

if (pid_rpm > (rpm_filtered + config.stick_erpm_per_s_in_cc)) {
pid_rpm = rpm_filtered + config.stick_erpm_per_s_in_cc;
}
• rpm_filtered: I guess this is the current RPM of the motor?
• pid_rpm is the input RPM value to the PID. This is what we should set, and reduce slowly in Endless Mode. If the problem is overshooting, we should try to set an threshold so avoid that.
• out_val: is this the factor for speed ramping? We can rule that one out for this application.
• config.stick_erpm_per_s_in_cc: max erpm change per second in cruisecontrol mode?

So if what I wrote is correct, we could do something like:

if( rpm_filtered > config.endless_mode_max_rpm ) {
// free roll - no power to motors?
}
else {
pid_rpm = rpm_filtered + config.endless_mode_reduce_number_of_rpm // reduce with negative number to decelerate
}

There must of course be more logic around this, like the pseudo code I wrote in the first post.

But, this cannot be correct, because where would the overshooting occur in this example? There must be some knowledge I don't have that is limiting my answers!

Jfriesen
Offline
Last seen: 1 month 3 weeks ago
Joined: 2017-10-24 22:49
Posts: 2

The key here is oing to be properly tuning the PID controller for speed. You are going to need a damped speed controller that has no overshoot in order to achieve what you want. Increasing the derivative term or decreasing the P and I terms will achieve this.

Jeff