Permalink
Browse files

ESC Calibration

  • Loading branch information...
1 parent 9fc43d5 commit 026f1ae2be52c1e544e46d3d847f282e3dbe879c @readerror67 committed Oct 9, 2012
Showing with 34 additions and 1 deletion.
  1. +34 −1 src/cli.c
View
@@ -14,7 +14,7 @@ static void cliSave(char *cmdline);
static void cliSet(char *cmdline);
static void cliStatus(char *cmdline);
static void cliVersion(char *cmdline);
-
+static void cliCalib(char *cmdline);
// from sensors.c
extern uint8_t batteryCellCount;
extern uint8_t accHardware;
@@ -63,6 +63,7 @@ typedef struct {
// should be sorted a..z for bsearch()
const clicmd_t cmdTable[] = {
+ { "cal", "calibrate ESCs", cliCalib },
{ "cmix", "design custom mixer", cliCMix },
{ "defaults", "reset to defaults and reboot", cliDefaults },
{ "exit", "", cliExit },
@@ -615,6 +616,38 @@ static void cliMixer(char *cmdline)
}
}
+static void cliCalib(char *cmdline)
+{
+ bool complete = 0;
+ printf("Checking for Battery (currently %d ) ..\r\n",adcGetBattery());
+
+ if (adcGetBattery() >= 330)
+ {
+ uartPrint("Battery is plugged in, please unplug and rerun the process (safety).\r\n");
+ return;
+ }
+ while (complete == 0)
+ {
+ if(adcGetBattery() >= 330)
+ {
+ printf("Setting Max: (%d)\r\n", cfg.maxthrottle);
+ writeAllMotors(cfg.maxthrottle);
+ delay(4000);
+ printf("Setting Min: (%d)\r\n", cfg.mincommand);
+ writeAllMotors(cfg.mincommand);
+ delay(500);
+ uartPrint("Calibration is complete.\r\n");
+ complete = 1;
+ return;
+ }
+ else
+ {
+ printf("adcGetBattery() = %d\r\n", adcGetBattery());
+ delay(500);
+ }
+ }
+}
+
static void cliSave(char *cmdline)
{
uartPrint("Saving...");

0 comments on commit 026f1ae

Please sign in to comment.