Motor start immediately function

Are there any features that you would like to add to the VESC?
jetigm
Posts: 7
Joined: 15 Dec 2016, 15:34
Location: Ukraine

Re: Motor start immediately function

Postby jetigm » 11 Jan 2017, 07:48

This code does not start up the motor. What is wrong?

Code: Select all

static THD_FUNCTION(example_thread, arg) {
   (void)arg;
   chRegSetThreadName("APP_EXAMPLE");
   
   timeout_reset();
   mc_interface_set_current(10);
   chThdSleepMilliseconds(500);
   mc_interface_release_motor();
   
   for(;;) {
      chThdSleepMilliseconds(500);
      timeout_reset();
   }
}

arvidb
Posts: 157
Joined: 26 Dec 2015, 14:38
Location: Sweden, Stockholm

Re: Motor start immediately function

Postby arvidb » 11 Jan 2017, 17:08

I cannot see anything wrong with that code (but note that I've not written any applications for the VESC myself).

What happens if you increase the delay before mc_interface_release_motor(), say to 5000 ms? What happens if you add a 5000 ms delay before the call to mc_interface_set_current(10)? Just for debugging...

pf26
Posts: 166
Joined: 28 Mar 2016, 14:37
Location: FR Valence

Re: Motor start immediately function

Postby pf26 » 13 Jan 2017, 13:53

Possibly your example_app task gets executed before another task initializes the reference current to 0.
I prefer this code :

Code: Select all

   static char a=0;  // required to be static
   for(;;) {   
      if (a==0) {
         mc_interface_set_current(20);
         a=1;
      }
      else if (a==1) {
          mc_interface_release_motor();     
    a=2;
   }     
      chThdSleepMilliseconds(500);
      timeout_reset();

But still, it may require a delay before executing, just to make sure nothing initializes the current reference after you set it here.

arvidb
Posts: 157
Joined: 26 Dec 2015, 14:38
Location: Sweden, Stockholm

Re: Motor start immediately function

Postby arvidb » 13 Jan 2017, 19:59

jetigm wrote:This code does not start up the motor. What is wrong?

I took another look at this, and I think this is a bug in main.c:

Code: Select all

   app_configuration appconf;
   conf_general_read_app_configuration(&appconf);
   app_init(&appconf);

   timeout_init();
   timeout_configure(appconf.timeout_msec, appconf.timeout_brake_current);


i.e. the app is started first and sets the output current, then the watchdog is initialised, which re-sets last_update_time to 0, which makes the timeout thread immediately trigger a timeout, which sets the current back to zero again. You could try a change of the code to :

Code: Select all

   app_configuration appconf;
   conf_general_read_app_configuration(&appconf);

   timeout_init();
   timeout_configure(appconf.timeout_msec, appconf.timeout_brake_current);

   app_init(&appconf);


... and see if it works. Please report back the results.

jetigm
Posts: 7
Joined: 15 Dec 2016, 15:34
Location: Ukraine

Re: Motor start immediately function

Postby jetigm » 24 Jan 2017, 17:54

Code: Select all

app_configuration appconf;
conf_general_read_app_configuration(&appconf);

timeout_init();
timeout_configure(appconf.timeout_msec, appconf.timeout_brake_current);

app_init(&appconf);

Does not work.

arvidb
Posts: 157
Joined: 26 Dec 2015, 14:38
Location: Sweden, Stockholm

Re: Motor start immediately function

Postby arvidb » 24 Jan 2017, 20:15

Sorry to hear that. :( I'm out of ideas now.


Return to “Feature Requests”

Who is online

Users browsing this forum: No registered users and 1 guest