parallaxinc / Simple-Libraries

Contents of the SimpleIDE workspace folder and its Parallax Learn Simple Libraries subfolder.
http://learn.parallax.com/propeller-c-set-simpleide/update-your-learn-folder
21 stars 21 forks source link

servo360 - try Increasing start pulse duration #147

Open AndyLindsay opened 6 years ago

AndyLindsay commented 6 years ago

Might alleviate swerves at start in: servo360 - ActivityBots with similarly asymmetric zero speed deadband not meeting navigation goals

AndyLindsay commented 6 years ago

Well, "Increasing", not so much. It only causes oscillations when the ActivityBot is supposed to be at rest.

However, picking S360_SETTING_VB_CCW and S360_SETTING_VB_CW relative to the motion start/stop thresholds has significant potential.

AndyLindsay commented 6 years ago

This commit to the Dev branch supports adjusting the "start moving" thresholds:

Defaults for y = mx + b calculations to determine transfer fuction from a requested speed that has converted to 4069ths of a rotation per second:

define S360_VM 180

define S360_VM_CCW S360_VM

define S360_VM_CW S360_VM

define S360_VB_CCW 200

define S360_VB_CW -200

Constants for adjusting the CCW and CW m and b in the transfer function's y = mx + b:

define S360_SETTING_VB_CCW 9

define S360_SETTING_VB_CW 10

define S360_SETTING_VM_CCW 11

define S360_SETTING_VM_CW 12

Function for adjusting start pulse duration:

int servo360_setTransferFunction(int pin, int constant, int value);

AndyLindsay commented 6 years ago

Here is an example that corrected servos tested to start moving CW between 1480 and 1490 us and CCW 1530 and 140 us.

/* 
  drive_goto variations.c

  This code demonstrates the problem in ActivityBots with servos that both have 
  the similar zero speed deadband offsets near the allowable limits. Example 
  instead of 1480 to 1520, both servos hare 1490 to 1530 us zero speed deadbands.

  The monitor (with SimpleIDE Terminal) functions have no effect unless you build 
  the libservo360 project with this un-commented:

    #define _servo360_monitor_

  For best results, use the Parallax WX ESP8266 WiFi Module - DIP for programming
  and terminal display.  
  https://www.parallax.com/product/32420d

  Make sure to re-comment it when done because it takes a signfiicant program memory.

*/

#include "simpletools.h"
#include "abdrive360.h"

int main()                    
{
  drive_speed(0, 0);
  pause(1000);
  servo360_monitorRun();
  pause(1000);

  servo360_setTransferFunction(12, S360_SETTING_VB_CCW, 250);
  servo360_setTransferFunction(12, S360_SETTING_VB_CW, -75);
  servo360_setTransferFunction(13, S360_SETTING_VB_CCW, 250 );
  servo360_setTransferFunction(13, S360_SETTING_VB_CW, -75);

  drive_goto(192, 192);
  pause(1000);
  drive_goto(-28, 28);
  pause(1000);
  drive_goto(28 * 2, -28 * 2);
  pause(1000);
  drive_goto(-28, 28);
  pause(1000);
  drive_goto(-192, -192);
  pause(1000);

  drive_goto(128, 192);
  pause(1000);
  drive_goto(-128, -192);
  pause(1000);
  drive_goto(192, 128);
  pause(1000);
  drive_goto(-192, -128);
  pause(1000);

  servo360_monitorEnd();
}