Go to the source code of this file.
Defines | |
#define | timercpy(a, b) |
Functions | |
static void | ctrlc_handler (int sig) |
int | quit (int argc, char *argv[], void *data) |
int | stop (int argc, char *argv[], void *data) |
int | setsampletime (int argc, char *argv[], void *data) |
int | configspeedprofile (int argc, char *argv[], void *data) |
int | setpid (int argc, char *argv[], void *data) |
void * | kmot_log_task (void *arg) |
int | stoplog (int argc, char *argv[], void *data) |
int | startlog (int argc, char *argv[], void *data) |
int | init (int argc, char *argv[], void *data) |
int | setspeed (int argc, char *argv[], void *data) |
int | setspeedprofile (int argc, char *argv[], void *data) |
int | velprescaler (int argc, char *argv[], void *data) |
int | prescaler (int argc, char *argv[], void *data) |
int | setmultiplier (int argc, char *argv[], void *data) |
int | multiplier (int argc, char *argv[], void *data) |
int | settorque (int argc, char *argv[], void *data) |
int | openloop (int argc, char *argv[], void *data) |
int | setpos (int argc, char *argv[], void *data) |
int | moveat (int argc, char *argv[], void *data) |
int | moveatprofile (int argc, char *argv[], void *data) |
int | measure (int argc, char *argv[], void *data) |
int | test (int argc, char *argv[], void *data) |
int | statusclear (int argc, char *argv[], void *data) |
int | setoption (int argc, char *argv[], void *data) |
int | option (int argc, char *argv[], void *data) |
int | status (int argc, char *argv[], void *data) |
int | help (int argc, char *argv[], void *data) |
int | main (int argc, char *argv[]) |
void | kmot_GetSpeedMultiplier (knet_dev_t *dev, unsigned short *mult) |
void | kmot_SetSpeedMultiplier (knet_dev_t *dev, int mode) |
Variables | |
static int | quitReq = 0 |
static int | stopReq = 0 |
static int | currentCommand = 0 |
static FILE * | logfile |
static knet_dev_t * | motor |
static pthread_t | log_task |
static kb_command_t | cmds [] |
static char | buf [1024] |
#define timercpy | ( | a, | |||
b | ) |
Value:
(a)->tv_sec = (b)->tv_sec; \ (a)->tv_usec = (b)->tv_usec;
Definition at line 135 of file setco_test.c.
int configspeedprofile | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set the speed profile for the current controller. The speed profile is only used for the regSpeedProfile mode (refer to KoreMotor documentation). syntax: setspeedprofile <max speed>=""> <acceleration>
Definition at line 82 of file setco_test.c.
References kmot_SetSpeedProfile().
static void ctrlc_handler | ( | int | sig | ) | [static] |
Make sure the program terminate properly on a ctrl-c
Definition at line 43 of file setco_test.c.
References stopReq.
int help | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Display a list of available commands.
Definition at line 453 of file koala_GoAutomation.c.
References fd, and kb_command_s::name.
int init | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Initialize all the parameters for the current controller. This command must be called before using any other command, and the parameters should be modified for the type of motors and encoder used before using the program.
Definition at line 227 of file setco_test.c.
References kmot_ConfigurePID(), kmot_ResetError(), kmot_SetBlockedTime(), kmot_SetLimits(), kmot_SetMargin(), kmot_SetMode(), kmot_SetOptions(), kmot_SetSampleTime(), kmot_SetSpeedProfile(), kMotModeIdle, kMotRegCurrent, kMotRegPos, kMotRegSpeed, kMotSWOptStopMotorBlk, and kMotSWOptWindup.
void kmot_GetSpeedMultiplier | ( | knet_dev_t * | dev, | |
unsigned short * | mult | |||
) |
This function gets the pid speed multiplier.
Definition at line 158 of file kmot.c.
References knet_read8(), MOT_SpeedMultH, and MOT_SpeedMultL.
Referenced by multiplier().
void* kmot_log_task | ( | void * | arg | ) |
The data logging task
Definition at line 142 of file setco_test.c.
References currentCommand, kmot_GetMeasure(), kMotMesCurrent, kMotMesPos, kMotMesSpeed, logfile, position, and timercpy.
void kmot_SetSpeedMultiplier | ( | knet_dev_t * | dev, | |
int | mode | |||
) |
kmot_SetSpeedMultiplier -
dev | KNet Device Descriptor corresponding to the motor | |
prescale |
Definition at line 700 of file kmot.c.
References knet_write8(), MOT_SpeedMultH, and MOT_SpeedMultL.
Referenced by setmultiplier().
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Definition at line 674 of file setco_test.c.
References ctrlc_handler(), kb_init(), kb_msg(), kb_parse_command(), kb_set_debug_level(), kmot_GetFWVersion(), KMOT_REVISION, KMOT_VERSION, KNET_BUS_I2C, knet_close(), knet_open(), quitReq, and status().
int measure | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Get a set of measures from the current motor. This control returns the speed, position and current for the motor.
Definition at line 425 of file setco_test.c.
References kmot_GetMeasure(), kMotMesCurrent, kMotMesPos, and kMotMesSpeed.
int moveat | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set a new position regulation target for the current motor. The position will be reached using the speed profile and speed PID. The controller must be properly initialized before using regulation. syntax: setpos <target position>="">
Definition at line 392 of file setco_test.c.
References currentCommand, kmot_SetPoint(), and kMotRegPos.
int moveatprofile | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set a new position regulation target for the current motor. The position will be reached using the speed profile and speed PID. The controller must be properly initialized before using regulation. syntax: setpos <target poistion>="">
Definition at line 410 of file setco_test.c.
References currentCommand, kmot_SetPoint(), and kMotRegPosProfile.
int multiplier | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Get the speed multiplier for the current motor. The controller must be properly initialized before using regulation. syntax: getmultiplier
Definition at line 334 of file setco_test.c.
References kmot_GetSpeedMultiplier().
int openloop | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set a new open loop command for the current motor. The controller must be properly initialized. syntax: openloop <command>
Definition at line 363 of file setco_test.c.
References currentCommand, kmot_SetPoint(), and kMotRegOpenLoop.
int option | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Read and print the option settings of the current controller. The content of the software option register and the hardware option register will be displayed.
Definition at line 507 of file setco_test.c.
References kmot_GetOptions(), kMotHWOptAnSetPtInEn, kMotHWOptEncRes1x, kMotHWOptNormal, kMotHWOptTorqueInv, kMotSWOptSepD, kMotSWOptSoftStopErr, kMotSWOptSoftStopMax, kMotSWOptSoftStopMin, kMotSWOptStopMotorBlk, and kMotSWOptWindup.
int prescaler | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set a new speed prescaler for the current motor. The controller must be properly initialized before using regulation. syntax: prescaler <value[0..3]>
Definition at line 305 of file setco_test.c.
References currentCommand, and kmot_SetPrescale().
int quit | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
int setmultiplier | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set a new speed multiplierr for the current motor. The controller must be properly initialized before using regulation. syntax: multiplier <value[1..32768]>
Definition at line 319 of file setco_test.c.
References currentCommand, and kmot_SetSpeedMultiplier().
int setoption | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set the controller Software and Hardware options. Check the kmot.c documentation for details about option flags. Syntax: setoption <hardware> <software>
Definition at line 492 of file setco_test.c.
References kmot_SetOptions().
int setpid | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set the PID controller gains for the given motor. syntax: setpid <regulation type>=""> <Kp> <Ki> <Kd>
regulation types are: pos, posprofile, speed, speedprofile, and torque.
Definition at line 99 of file setco_test.c.
References kmot_ConfigurePID(), kMotRegPos, kMotRegPosProfile, kMotRegSpeed, kMotRegSpeedProfile, and kMotRegTorque.
int setpos | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set a new position regulation target for the current motor. The controller must be properly initialized before using regulation. syntax: setpos <target position>="">
Definition at line 378 of file setco_test.c.
References kmot_SetPosition().
int setsampletime | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set the SampleTime register (refer to KoreMotor documentation). syntax: setsampletime <sampletime>
Definition at line 68 of file setco_test.c.
References kmot_SetSampleTime().
int setspeed | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set a new speed regulation target for the current motor. The controller must be properly initialized before using regulation. syntax: setspeed <target speed>="">
Definition at line 252 of file setco_test.c.
References currentCommand, kmot_SetPoint(), and kMotRegSpeed.
int setspeedprofile | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set a new position regulation target for the current motor. The position will be reached using the speed profile and speed PID. The controller must be properly initialized before using regulation. syntax: setpos <target poistion>="">
Definition at line 268 of file setco_test.c.
References currentCommand, kmot_SetPoint(), and kMotRegSpeedProfile.
int settorque | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set a new torque regulation target for the current motor. The controller must be properly initialized before using regulation. syntax: settorque <target torque>="">
Definition at line 349 of file setco_test.c.
References currentCommand, kmot_SetPoint(), and kMotRegTorque.
int startlog | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Start logging motor measurements to the given file.
Definition at line 204 of file setco_test.c.
References KB_ERROR_PTHREAD, KB_FATAL, kmot_log_task(), and log_task.
int status | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Read and print the status of the current controller. The content of the status register and error register will be displayed.
Definition at line 556 of file setco_test.c.
References kmot_GetStatus(), kMotErrorBrownOut, kMotErrorMotorBlocked, kMotErrorPosOutOfRange, kMotErrorSampleTimeTooSmall, kMotErrorSoftStopMotor, kMotErrorSpeedOutOfRange, kMotErrorTorqueOutOfRange, kMotErrorWDTOverflow, kMotStatusCmdSat, kMotStatusDir, kMotStatusMoveDet, kMotStatusNearSetPt, kMotStatusOnSetPt, kMotStatusSoftCurCtrl, kMotStatusSoftStop, kMotStatusWindup, and status().
int statusclear | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Reset the error register of the motor controller.
Definition at line 482 of file setco_test.c.
References kmot_ResetError().
int stop | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Stop the current motor (set mode to stop motor mode).
Definition at line 59 of file setco_test.c.
References kmot_SetMode(), and kMotModeStopMotor.
int stoplog | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Stop logging motor measurements.
Definition at line 193 of file setco_test.c.
References KB_ERROR_PTHREAD, KB_FATAL, and log_task.
int test | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Launch a test routine which oscillates from (current pos + delta) and (current pos - delta). The position changes every 2 seconds. The routine can be stoped using the "stop" command. syntax: test <delta>
Definition at line 444 of file setco_test.c.
References kmot_GetMeasure(), kmot_SetPoint(), kMotMesPos, kMotRegPos, status(), and stopReq.
int velprescaler | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set a new velocity reductionprescaler for the current motor. The controller must be properly initialized before using regulation. syntax: velprescaler <value[0..3]>
Definition at line 291 of file setco_test.c.
References currentCommand, and kmot_SetVelocityPrescale().
char buf[1024] [static] |
Main program to process the command line.
Definition at line 672 of file setco_test.c.
kb_command_t cmds[] [static] |
The command table contains: command name : min number of args : max number of args : the function to call
Definition at line 622 of file setco_test.c.
int currentCommand = 0 [static] |
Definition at line 34 of file setco_test.c.
pthread_t log_task [static] |
Definition at line 38 of file setco_test.c.
FILE* logfile [static] |
Definition at line 36 of file setco_test.c.
knet_dev_t* motor [static] |
Definition at line 37 of file setco_test.c.
int quitReq = 0 [static] |
Definition at line 32 of file setco_test.c.
int stopReq = 0 [static] |
Definition at line 33 of file setco_test.c.