Exemplo n.º 1
0
int epos_position_profile_start(epos_node_t* node, epos_position_profile_t*
    profile) {
  int pos = epos_gear_from_angle(&node->gear, profile->target_value);
  unsigned int vel = abs(epos_gear_from_angular_velocity(&node->gear,
    profile->velocity));
  unsigned int acc = abs(epos_gear_from_angular_acceleration(&node->gear,
    profile->acceleration));
  unsigned int dec = abs(epos_gear_from_angular_acceleration(&node->gear,
    profile->deceleration));
  short control = (profile->relative) ?
    EPOS_POSITION_PROFILE_CONTROL_SET_RELATIVE :
    EPOS_POSITION_PROFILE_CONTROL_SET_ABSOLUTE;

  if (!epos_control_set_mode(&node->control, epos_control_profile_pos) &&
      !epos_position_profile_set_velocity(&node->dev, vel) &&
      !epos_profile_set_acceleration(&node->dev, acc) &&
      !epos_profile_set_deceleration(&node->dev, dec) &&
      !epos_profile_set_type(&node->dev, profile->type) &&
      !epos_control_start(&node->control) &&
      !epos_position_profile_set_target(&node->dev, pos)) {
    profile->start_value = epos_node_get_position(node);
    error_return(&node->dev.error);
  
    timer_start(&profile->start_time);
    epos_device_set_control(&node->dev, control);
    timer_correct(&profile->start_time);
  }

  return node->dev.error.code;
}
Exemplo n.º 2
0
int epos_home_start(epos_node_t* node, const epos_home_t* home) {
  unsigned int switch_vel = abs(epos_gear_from_angular_velocity(&node->gear,
    home->switch_vel));
  unsigned int zero_vel = abs(epos_gear_from_angular_velocity(&node->gear,
    home->zero_vel));
  unsigned int acc = abs(epos_gear_from_angular_acceleration(&node->gear,
    home->acceleration));
  int offset = epos_gear_from_angle(&node->gear, home->offset);
  int pos = epos_gear_from_angle(&node->gear, home->position);

  if (!epos_control_set_mode(&node->control, epos_control_homing) &&
      !epos_home_set_method(&node->dev, home->method) &&
      !epos_home_set_current_threshold(&node->dev, home->current*1e3) &&
      !epos_home_set_switch_search_velocity(&node->dev, switch_vel) &&
      !epos_home_set_zero_search_velocity(&node->dev, zero_vel) &&
      !epos_home_set_acceleration(&node->dev, acc) &&
      !epos_home_set_offset(&node->dev, offset) &&
      !epos_home_set_position(&node->dev, pos) &&
      !epos_profile_set_type(&node->dev, home->type) &&
      !epos_device_set_control(&node->dev, EPOS_DEVICE_CONTROL_SHUTDOWN) &&
      !epos_control_start(&node->control))
    epos_device_set_control(&node->dev, EPOS_HOME_CONTROL_START);

  return node->dev.error.code;
}
Exemplo n.º 3
0
int main(int argc, char **argv) {
  config_parser_t parser;
  epos_node_t node;

  config_parser_init(&parser,
    "Start EPOS controller in the selected operation mode",
    "Establish the communication with a connected EPOS device and attempt to "
    "start the controller in the selected operation mode. The controller will "
    "be stopped if SIGINT is received. The communication interface depends "
    "on the momentarily selected alternative of the underlying CANopen "
    "library.");
  epos_node_init_config_parse(&node, &parser, 0, argc, argv,
    config_parser_exit_error);  
  config_parser_destroy(&parser);
  
  signal(SIGINT, epos_signaled);

  epos_node_connect(&node);
  error_exit(&node.error);
  
  epos_control_start(&node.control);
  error_exit(&node.error);
  
  while (!quit);
  
  epos_control_stop(&node.control);
  error_exit(&node.error);
  
  epos_node_disconnect(&node);
  error_exit(&node.error);

  epos_node_destroy(&node);
  return 0;
}
Exemplo n.º 4
0
int epos_velocity_start(epos_node_p node, epos_velocity_p velocity) {
  int result;
  int vel = epos_gear_from_angular_velocity(&node->gear,
    velocity->target_value);

  if (!(result = epos_control_set_type(&node->control, 
      epos_control_velocity)) &&
    !(result = epos_control_start(&node->control)))
    result = epos_velocity_set_demand(&node->dev, vel);

  return result;
}