How can I set max ERPM and Watt power output on the fly?

Hi, I have a E-Bike that I have made with a 6384 motor, and a VESC, but the problem is that Australia has just come out with new EV rules, and they are super sticked.

Is there any way I can have a switch on the handle bars, that when flicked lowers the ERPM and the max watt output, then when flicked again sets it back?

Would an Arduino plugged into the TX and RX ports on the VESC be able to do it, sending the necessary commands to the VESC when the switch is flicked?

If so, how would I go about doing it? Or is there a better way to do this?

Thanks, Elliot

I think this is what you want.

2 Likes

This is pretty much perfect, apart from the fact that you need to use a phone to change the profiles, is there any way to make this work with a switch?

1 Like

Most remotes have different speed profiles. I haven’t ventured into adc remotes yet though so I’m not sure on that.

i think the “speed profiles” of the remotes that have em built in just limit the throttle output value to a fraction of the full throw
at least, the puck does that

3 Likes

True true… I know with the Freesk8 app you can set your different speed profiles. Not sure if you can set them to quick switch profiles on your remote though… @skate420 @DerelictRobot maybe you could shed some light.

1 Like

You could use an arduino to send the COMM_SET_MCCONF_TEMP_SETUP packet to the VESC

There isn’t documentation or a guide but there are code examples on github
VESC Source
VESC Tool Source
FreeSK8 Mobile

4 Likes

There are ready made Arduino libraries that even have examples how to set a temporary VESC profile.
I Already testet this one and it works flawless.

Set profile example
/*
  Name:    setLocalProfile.ino
  Created: 19-08-2018
  Author:  Mr_fish77
  Description: Example to use the setLocalProfile method, to modify the max speed
*/

#include <VescUart.h>

/** Initiate VescUart class */
VescUart UART;

void setup() {

  /** Setup Serial port to display data */
  Serial.begin(115200);

  /** Setup UART port (Serial1 on Atmega32u4) */
  Serial1.begin(115200);

  while (!Serial) {
    ;
  }
  /** Define which ports to use as UART */
  UART.setSerialPort(&Serial1);
  UART.setDebugPort(&Serial);
  delay(2000);

  /** Call the function getVescValues() to acquire data from VESC */
  if ( UART.getFWversion()) {
    Serial.print("FW v");
    Serial.print(UART.fw_version.major);
    Serial.print(".");
    Serial.println(UART.fw_version.minor);

  }
  else
  {
    Serial.println("Failed to get data!");
  }


  delay(1000);
  Serial.println("Set new  profile!");

  bool store = false;
  bool forward_can = false;
  bool ack = false;
  bool divide_by_controllers = false;
  float current_min_rel = 1.0;
  float current_max_rel = 1.0;
  float speed_max_reverse = -15;
  float speed_max = 15;
  float duty_min = 0.005;
  float duty_max = 0.95;
  float watt_min = -1500000.0;
  float watt_max = 1500000.0 ;

  /**
     @brief      Set a profile
     @param    store save persistently the new profile in vesc memory
     @param    forward_can forward profile to slave Vesc through  can bus (not tested)
     @param    divide_by_controllers divied the watt limit by the number of VESC
     @param    current_min_rel this value is multiplied with the maximum current. It is a convenient method to scale the current limits without forgetting the actual maximum value.  DEFAULT = 1
     @param    current_min_rel this value is multiplied with the minimum current. It is a convenient method to scale the current limits without forgetting the actual minimal value.  DEFAULT = 1
     @param    speed_max_reverse maximum reverse speed in m/s. In order, to use it make sure to set the wheel diameter and gear ratio in VESC Tool   (m/s = (km/h / 3.6) )
     @param    speed_max_reverse maximum speed in m/s. In order, to use it make sure to set the wheel diameter and gear ratio in VESC Tool
     @param    duty_min minimum duty cycle. DEFAULT = 0.005
     @param    duty_min maximum duty cycle. DEFAULT = 1
     @param    watt_min minimum watt value. DEFAULT = - 1500000.0
     @param    watt_max maximum watt value. DEFAULT =  1500000.0
  */
  UART.setLocalProfile(store, forward_can, divide_by_controllers, current_min_rel, current_max_rel, speed_max_reverse, speed_max, duty_min, duty_max, watt_min, watt_max);

  delay(1000);
}

void loop() {

}
4 Likes

Oh lets go, thanks, this is perfect I think. Is there somewhere I can go for more documentation?

I didn’t really find documentation beyond the examples. If you have somewhat basic Arduino knowledge you should be able to just modify the examples to fit your needs.

1 Like

I’m digging up this old thread again because I would like to set max erpm over uart.
I installed the SolidGeek library but unfortunately it looks like the “UART.setLocalProfile” command is not defined in there. Does anyone have any idea or a suitable library?

Thanks to Blise518B for sharing the .ino!

I’ve found it! :grinning:

https://github.com/mr-fish77/VescUart