You are here

Question about custom coding to shutdown the motor

3 posts / 0 new
Last post
dsuresh
Offline
Last seen: 10 months 3 weeks ago
VESC Free
Joined: 2021-02-10 18:57
Posts: 42
Question about custom coding to shutdown the motor

Hi,

I had a question about custom coding the vesc. I am customizing the code to work in such a way that when the current consumed by the motor is less than X amps, i would like to shutdown the VESC. I know that there is an existing function which says that if the vesc is doing nothing shut it down, which doesn’t seem the perfect solution for my use case.
In my application, I want the motor running and if there is no load, the motor starts consuming lesser current. I would like to use that value and then compare that value to a predefined value in the code and if it is lesser than that value shut it down.
I am using the I batt value from the RT screen and trying to compare that value and check if that works but have been unsuccessful so far.

Any help is greatly appreciated

vadicus
Offline
Last seen: 1 day 4 hours ago
VESC Free
Joined: 2018-08-17 07:26
Posts: 427

You can do something like this:

if (motorCurrent < n && timeElapsed > 1000ms) {

shutdown();

}

Run a counter that resets the timeElapsed if the the current exceeds your threshold. Otherwise, when the counter meets your set threshold, initiate shutdown.

 

 

 

NextGen FOC High voltage 144v/34s, 30kw (https://vesc-project.com/node/1477)

dsuresh
Offline
Last seen: 10 months 3 weeks ago
VESC Free
Joined: 2021-02-10 18:57
Posts: 42

Thank you Vadicus for the suggestion. Do I need to run this code in shutdown.c or can I place this in any .c file? also do you know which parameter exactly is the motorcurrent. When I read the currents outputs from terminal.c, there are multiple of them namely current in, total current filtered, total current directional filtered, etc. Which one should I use from these to compare the current values?

Dave