Difference between revisions of "PFMENU DOCS MC"

From DIDEAS Wiki
Jump to: navigation, search
m
m
Line 3: Line 3:
 
=motor controller=
 
=motor controller=
 
*1040 : read MC filter
 
*1040 : read MC filter
*1041 : set MC filter [[#set_filter]]
+
*1041 : set MC filter  
 
*1054 : get MR or MILE setting
 
*1054 : get MR or MILE setting
 
*1055 : set MR or MILE mode
 
*1055 : set MR or MILE mode
Line 47: Line 47:
  
 
*1118 : read ADCs (in_param==16 -> read all 16 channels), else thats the channel offset and read 10 channels
 
*1118 : read ADCs (in_param==16 -> read all 16 channels), else thats the channel offset and read 10 channels
 +
 +
==motor filter (PI control loop)==
 +
*1040 - get PI control parameters
 +
*1041 - set PI control parameters
 +
 
== overload current monitor==
 
== overload current monitor==
  

Revision as of 15:50, 1 February 2010

PF Users Navigation:

Edit

motor controller

  • 1040 : read MC filter
  • 1041 : set MC filter
  • 1054 : get MR or MILE setting
  • 1055 : set MR or MILE mode
  • 1100 : set mode
  • 1101 : get mode
  • 1102 : set torque
  • 1103 : get torque
  • 1104 : set speed
  • 1105 : get speed (and other info)
  • 1106 : get encoder
  • 1107 : set encoder zero
  • 1108 : set current offsets
  • 1109 : set motor mode
  • 1110 : set motor torque
  • 1111 : getdata
  • 1112 : REMOVED
  • 1113 : enable / disable mode zero current offset calibration (
  • 1114 : set ctrl param vQ and vD
  • 1115 : set ctrl param vQ and vD, and then set motor mode
    • cmd 1115 is the primary to set motor torque and mode.
    • parameters are 1115 <qPq> <qPd> <Mode>
    • Modes are :
      • 0 for shorted motor leads (safety mode)
      • 2 for zero encoder
      • 3 for close current loop torque mode
      • 4 for open loop voltage mode w/constant flux angle (adjust w/ set_position)
      • 6 for open loop voltage mode w/flux angle set by encoder (normal mode)
      • 7 to read and set motor controller current offsets


    • qPq and qPd are q15 format control reference parameters in the Q and D direction.
      • in modes (2?) and 3 - the Q and D parameters represent current with 1amp = ~1093
      • in mode 4 and 6 - the Q and D parameters represent voltage such that voltage on the motor is : Vq = qPq / 32768 * POWER SUPPLY VOLAGE
      • eg: a parameter of 800 with a supply of 21.6 volts -> vmot = .8/32.7 * 21.6 = 0.5 volts


  • 1116 : read current offsets
    • typically auto set by commanding mode 7.
  • 1117 : set motor filter (both Q and D)
  • 1118 : read ADCs (in_param==16 -> read all 16 channels), else thats the channel offset and read 10 channels

motor filter (PI control loop)

  • 1040 - get PI control parameters
  • 1041 - set PI control parameters

overload current monitor

  • 1120 - reads overload config and status:

0 to 1 : motor_max_sum, motor_decay 2 to 3 : present motor_phase_A_sum, motor_phase_A_overload_status 4 to 5 : present motor_phase_B_sum, motor_phase_B_overload_status 6 to 7 : battery_max_sum, battery_decay 8 to 9 : present battery_sum, battery_overload_status

  • 1121 <param> - like command 1120, but pass param==1 to reset sums and trips (eg clear overloads). Also needs to reset MC statemachine out of state 70.
  • 1122 <4x params> - use to set the overload config parameters
    • format : 1122 <motor maxsum> <bat maxsum> <motor decay> <bat decay>
  • The computation at 1KHZ, sums the ABS of the the scaled (1/256) Q15 current and subtracts the decay value from the sum. If the sum exceeds the max sum then there is an overload and the MC statemachine jumps to state 70, and various status flags are set (readable with command 1120).
  • As 1 amp is a q15 of 1093 (or 947), then a decay of 10 -> a q15 decay rate of 2560 or about 2.5 amps. Any current value larger than the decay will EVENTUALLY cause an overload.
  • the time in mS given a current for the overload to trip:

t = (1mS) * MAX_SUM / (q15_current/256 - DECAY)

  • for example with max_sum = 21000, decay=20
    • any current less than (20*256)/1093 [4.7amps] never trips
    • 8 amps trips in 1.5 secs: 1e-3 * 21000/((8*1093)/256 - 20)
    • 16 amps trips in 0.43 secs: 1e-3 * 21000/((16*1093)/256 - 20)
    • 24 amps trips in 0.25 secs: 1e-3 * 21000/((24*1093)/256 - 20)
    • 30 amps trips in 0.19 secs: 1e-3 * 21000/((30*1093)/256 - 20)
  • expected currents (based on a typical cycle)
    • 30 amps, 80mS
    • 25 amps, 100mS
    • 20 amps, 132mS
    • 15 amps, 195mS
    • 10 amps, 373mS
  • the decay to zero is also important - this is the time that given a sum "near" overload, it will take for the sum to drop to zero.
    • time_to_zero = 1mS * max_sum/decay
    • clearly if this time is greater than a cycle, then it is possible for the sum to grow cycle to cycle and trip at a later time.

behavior at overload

  • as the overload sum approach the limit :
    • at 80% the MC current is scaled back down at the rate of 1% per MS
    • at 90% the MC statemachine jumps to a safety impedance state (thus the robot servos to the zero position if there is time.)
    • at 100% the MC statemachine jumps to state 70, and shorts the motor leads
  • to see the MC SM state, special command 1420

reset the overload

To clean the overload:

  • first reset the status flags with special command "1121 1"
  • jump to the MC statemachine to a different state "1421 17" is an idle state, "1421 30" is imped
  • jump the SC statemachine to the desired state "170 77 3" is ES, "170 77 17" is do nothing.

encoder

  • 1050 : get 2x / 4x mode
  • 1051 : set 2x / 4x mode (in_param == 2 or 4)
  • 1052 : get direction
  • 1053 : set direction (in_param == +1 or -1)
  • 1055 : config for MR (0) or MILE encoder (1)

dataport

  • 1210 - (to be replaced w/ 1228) get baud
  • 1211 - (to be repalced w/ 1229) set baud (1,2,4,8,10)
  • 1228 : set current dataport baudrate (port)
  • 1229 : set current dataport baudrate (port, value) value is actual baud, will return actual baud
  • 1251 - set read back data variable
    • [data_position] [variable_id]
    • the data position is 0 to 4, and variable id is from this list
  • 1257 - dataport_set_select(val)
    • 0 : received values from SC
    • 1 : electronic fuse sums
    • 2 : all 5 SM values

IMPED

  • 1330 - get imp
  • 1331 - set imp
  • 1333 - set mc_sm to allow imped updates
  • 1340 - impdebug -> called imp_debug_params
  param[0] = imp.pos;
  param[1] = imp.rel_pos;
  param[2] = imp.speed;

  param[4] = imp.kp*1e6;
  param[5] = imp.kb*1e6;
  param[6] = imp.kp_enc*1e6;
  param[7] = imp.kb_rpm*1e6;

MC SM

  • 1411 - mc_sm debug
    • 0 mc_sm_debug
    • 1 mc_sm_ctrl_debug
    • 2 mc_imp_debug / mc_imp_debug_param+4
  • 1420 - get mode
  • 1421 - set mode (21 for imp mode)
  • 1422 - set ankle error state
  • 1430 - get max pos, max neg current (mA)
  • 1431 - set max pos, max neg current (mA) (disable torque limit)
  • 1432 - get torque limit : max pos, max neg torque
  • 1433 - set torque limit : max positive, max negative torque
  • 1435 - set max and min position
  • 1437 - set tics timeout (for torque offset)
  • 1439 - set max pos, max neg current (mA) (enable torque limit)
  • 1440 - get ff params
  • 1441 - set ff params
  • 1442 - return ff debug params
  • 1443 - enable/disable ff
  • 1460
  • 1461 - set IMP torque offset
  • 1464 (disabled) - switch to mode4, command a qVq and qVd
  • 1466 (disabled) - switch to mode6, command a qVq and qVd
  • 1468 - get resistance pulse and duration
  • 1469 - set resistance pulse amplitude and duration

debug (1411) options

    • 0 mc_sm_debug
  param[0] = sm->state;
  param[1] = sm->last_state;
  param[2] = sm->tics_in_current_state;
  param[3] = sm->tics_since_last_update;
  param[4] = sm->motor_is_active;
    • 1 mc_sm_ctrl_debug
  param[0] = ctrl->torque * 1000;
  param[1] = ctrl->current * 1000;
  param[2] = ctrl->qIq;
  param[3] = ctrl->qId;
  param[4] = ctrl->max_pos_current;
  param[5] = ctrl->max_neg_current;
  param[6] = ctrl->max_motor_enc_pos;
  param[7] = ctrl->max_motor_enc_pos;
  param[8] = ctrl->torque_offset * 1000;
  param[9] = ctrl->enable_imp_current_update;
    • 2 mc_imp_debug / mc_imp_debug_param+4
  param[0] = imp.pos;
  param[1] = imp.rel_pos;
  param[2] = imp.speed;

  param[4] = imp.kp*1e6;
  param[5] = imp.kb*1e6;
  param[6] = imp.kp_enc*1e6;
  param[7] = imp.kb_rpm*1e6;


    • case 5 :
	 data->param[0] = ff->hard_limit;                        // CMD_DOC:
	 data->param[1] = ff->activate_pos;                        // CMD_DOC:
	 data->param[2] = ff->torque_at_limit * 1000;                        // CMD_DOC:
	 data->param[3] = ff->zone;                        // CMD_DOC:
	 data->param[4] = ff->pos_scale_factor * 1e6;                        // CMD_DOC:
	 data->param[5] = ff->scale_factor * 1e9;                        // CMD_DOC:
	 data->param[6] = ctrl->torque * 1000;
	 data->param[7] = ctrl->current * 1000;
	 data->param[8] = ctrl->qIq;
	 data->param[9] = enc_pos;
	 data->param[9] = mc_filter.hall;
    • case 6 :
	 data->param[0] = ff->hard_limit;                        // CMD_DOC:
	 data->param[1] = ff->activate_pos;                        // CMD_DOC:
	 data->param[2] = ff->torque_at_limit * 1000;                        // CMD_DOC:
	 data->param[3] = ff->zone;                        // CMD_DOC:
	 data->param[4] = ff->pos_scale_factor * 1e6;                        // CMD_DOC:
	 data->param[5] = ff->scale_factor * 1e9;                        // CMD_DOC:
	 data->param[6] = ctrl->torque * 1000;
	 data->param[7] = ctrl->current * 1000;
	 data->param[8] = ctrl->qIq;
	 data->param[9] = mc_filter.hall;
    • case 7 :
	 int i;
	 extern INT32_T debug_ary[10];
	 for(i=0;i<10;i++) data->param[i] = debug_ary[i];

states

  • cmd 1420, 1421 to access state
typedef enum {
  MCSM_INIT, 
  MCSM_IDLE, 

  MCSM_MODE7,
  MCSM_MODE2,
  MCSM_MODE4A,
  MCSM_MODE4B,
  MCSM_MODE4C,
  MCSM_MODE4D,

  MCSM_MODE4_FIN,
  MCSM_BOOT_COMPLETE=20, 

  MCSM_IMP_MODE=30,
  MCSM_RESISTANCE_MODE,
  MCSM_ACTIVE, 
  MCSM_OVERLOAD, 
  MCSM_UPDATE_TIMEOUT,
  MCSM_ANKLE_READY,

  MCSM_RELAXED_MODE, // 36

  MCSM_ANKLE_ERROR=40,
  MCSM_ERROR=44,
  MCSM_POS_ERROR_POSITIVE=50,
  MCSM_POS_ERROR_NEGATIVE=52,
  MCSM_ENC_ERROR=60,

} MC_STATE_T;


encoder

  • 1050 : get encoder X mode and QEI register
  • 1051 : send encoder X mode (2 or 4)
  • 1052 : get direction
  • 1053 : set direction (-1 or +1)
  • 1055 : select MR or MILE encoder (0=MR, 1=MILE)
  • 1056 : read abs encoder debug parameters as updated in ISR
 param[0] = abs_enc.enc_position;
 param[1] = abs_enc.num_rotations;
 param[2] = abs_enc.enc_position + (INT32_T) abs_enc.num_rotations * (INT32_T)abs_enc.resolution;
 param[3] = ((long)abs_enc.last_diff*10000L) + abs_enc.sequential_errors;
 param[4] = abs_enc.zero_mech_ang_measured;
 param[5] = abs_enc.zero_mech_ang_stored;
 param[6] = abs_enc.resolution;
 param[7] = abs_enc.half_resolution;
 param[7] = abs_enc.max_encoder_error;
 param[8] = abs_enc.incremental_encoder_offset; 
 param[9] = abs_enc.invalid_count;
  • 1057 : set the present motor position to be the mechanical zero
  • 1059 : set the max encoder error