示例#1
0
void accelerometer_config(void)
{
	/* Configure analog inputs for accelerometer reading */
	analog_config(ANALOG9);
	analog_config(ANALOG10);
	analog_config(ANALOG4);
}
示例#2
0
int bebopr_pre_init( void)
{
  int result = -1;

  result = analog_config( analog_config_data, NR_ITEMS( analog_config_data));
  if (result < 0) {
    fprintf( stderr, "analog_config failed!\n");
    goto done;
  }
  result = temp_config( temp_config_data, NR_ITEMS( temp_config_data));
  if (result < 0) {
    fprintf( stderr, "temp_config failed!\n");
    goto done;
  }
  result = pwm_config( pwm_config_data, NR_ITEMS( pwm_config_data));
  if (result < 0) {
    fprintf( stderr, "pwm_config failed!\n");
    goto done;
  }
  result = heater_config( heater_config_data, NR_ITEMS( heater_config_data));
  if (result < 0) {
    fprintf( stderr, "heater_config failed!\n");
    goto done;
  }
  result = get_step_io_config( EEPROM_PATH);
  // Only differentiate between Pololu and TB6560, default to Pololu
  if (result == TB6560_DRIVERS) {
    use_pololu_drivers = 0;
  }
  fprintf( stderr, "Using stepper driver configuration: '%s'\n", (use_pololu_drivers) ? "Pololu" : "TB6560");
  result = 0;
 done:
  return result;
}
示例#3
0
void main(void)

{
   slave_id();
   port_configure();
   //ini();
   
   analog_config();
   while(true)
   {
   analog_read();             // Le posicao corrente
   
   
   if (buffer_adc>250)       // Limite mecanico superior
   {
      stop_engine();
      limit_up=0;
      limit_down=1;
   }
   
   else if (buffer_adc<10)    // Limite mecanico inferior
   {
      stop_engine();
      limit_down=0;
      limit_up=1;
   }
   else if ((buffer_adc==buffer_pos))  // Para motor em posicao
   {
      stop_engine();
   }
   else if ((buffer_adc>buffer_pos) && limit_down!=0)
   {
      move_down();
      limit_up=1;             //liberta limite cima
   }
   else if ((buffer_adc<buffer_pos) && limit_up!=0)
   {
      move_up();
      limit_down=1;           //liberta limite baixo
   }
   
   }

}
示例#4
0
int main(void)
{
    uint8_t circuit_idx = 0;
    volatile uint16_t v_mean, i_mean, v_gain_rms2, i_gain_rms2;

    board_init();
    sysclk_init();
    communication_init();
    time_init();

     /*
     *  V_Offset, I_offset, tension y corriente 0
     *  - esperar sart desde la PC
     *  - Medir y promediar el canal de tension
     *  - Medir y promediar el canal de corriente
     *  - enviar resultados
     *  V_gian, I_gain, se le pone una tension y corriente conocidas
     *  - esperar sart desde la PC
     *  - Medir y promediar el canal de tension
     *  - Medir y promediar el canal de corriente
     *  - enviar resultados
     */

    for(circuit_idx=0; circuit_idx<N_CIRCUITS; circuit_idx++)
    {
        getchar_from_pi();
        analog_config(&CIRCUITS[circuit_idx]);
        v_mean = analog_get_V_sample_calibration();
        i_mean = analog_get_I_sample_calibration();
        send_to_pi_mean_calibration(v_mean, i_mean);

        getchar_from_pi();
        v_gain_rms2 = analog_get_V_rms_sample_calibration(v_mean);
        i_gain_rms2 = analog_get_I_rms_sample_calibration(i_mean);
        send_to_pi_gain_calibration(v_gain_rms2, i_gain_rms2);
    }
}
示例#5
0
/*
 * Setup all sub sys of unicorn
 */
static int unicorn_setup()
{
    int ret = 0; 

    if (bbp_board_type == BOARD_BBP1) {
        printf("Board is FastBot BBP 1\n");
        ret = analog_config(analog_config_bbp1, NR_ITEMS(analog_config_bbp1));
        if (ret < 0) {
            printf("analog_config failed\n");
            goto out;
        }

        ret = temp_config(temp_config_data_bbp1, NR_ITEMS(temp_config_data_bbp1));
        if (ret < 0) {
            printf("temp_config failed\n");
            goto out;
        }

        ret = pwm_config(pwm_config_bbp1, NR_ITEMS(pwm_config_bbp1));
        if (ret < 0) {
            printf("pwm_config failed\n");
            goto out;
        }
        
        ret = fan_config(fan_config_bbp1, NR_ITEMS(fan_config_bbp1));
        if (ret < 0) {
            printf("fan_config failed\n");
            goto out;
        }

        ret = heater_config(heater_config_data_bbp, NR_ITEMS(heater_config_data_bbp));
        if (ret < 0) {
            printf("heater_config failed\n");
            goto out;
        }

        ret = stepper_config(stepper_config_bbp1, NR_ITEMS(stepper_config_bbp1));
        if (ret < 0) {
            printf("stepper_config failed\n");
            goto out;
        }
    } else if (bbp_board_type == BOARD_BBP1S) {
        printf("Board is FastBot BBP 1s\n");
        ret = analog_config(analog_config_bbp1s, NR_ITEMS(analog_config_bbp1s));
        if (ret < 0) {
            printf("analog_config failed\n");
            goto out;
        }

        ret = temp_config(temp_config_data_bbp1s, NR_ITEMS(temp_config_data_bbp1s));
        if (ret < 0) {
            printf("temp_config failed\n");
            goto out;
        }

        ret = pwm_config(pwm_config_bbp1s, NR_ITEMS(pwm_config_bbp1s));
        if (ret < 0) {
            printf("pwm_config failed\n");
            goto out;
        }
        
        ret = fan_config(fan_config_bbp1s, NR_ITEMS(fan_config_bbp1s));
        if (ret < 0) {
            printf("fan_config failed\n");
            goto out;
        }

        ret = heater_config(heater_config_data_bbp1s, NR_ITEMS(heater_config_data_bbp1s));
        if (ret < 0) {
            printf("heater_config failed\n");
            goto out;
        }

#ifdef SERVO
		if (bbp_board_type == BOARD_BBP1S) {
			ret = servo_config(servo_config_data, NR_ITEMS(servo_config_data));
			if (ret < 0) {
				printf("servo_config failed\n");
				goto out;
			}
		}
#endif

        ret = stepper_config(stepper_config_bbp1s, NR_ITEMS(stepper_config_bbp1s));
        if (ret < 0) {
            printf("stepper_config failed\n");
            goto out;
        }
    } else {
        printf("Not supported board!\n");
    }
out:
    return ret;
}