Пример #1
0
void tim1_up_tim10_isr(void) 
{
  //Clear the update interrupt flag
  timer_clear_flag(TIM1,TIM_SR_UIF);
	
    float voltage_joint_0 = 0.0f;      
    float voltage_joint_1 = 0.0f;
    float voltage_joint_2 = 0.0f;

    float joint_0_angle = 0.0f;
    float joint_1_angle = 0.0f;
    //float joint_2_angle = 0.0f;

	static int counter = 0;
	counter +=1 ;
	if(counter >=1500)// Print frequency each n cycles

	{
        voltage_joint_0	= voltage_measure (ADC1,ADC_CHANNEL1);      
        voltage_joint_1	= voltage_measure (ADC1,ADC_CHANNEL2);
        voltage_joint_2 = voltage_measure (ADC1,ADC_CHANNEL3);

        joint_0_angle = CONVERSION_FACTOR_JOINT_0*voltage_joint_0;
        joint_1_angle = CONVERSION_FACTOR_JOINT_1*voltage_joint_1;
        joint_2_angle = CONVERSION_FACTOR_JOINT_2*voltage_joint_2;  
        printf("%6.2f \n",joint_2_angle); 
		counter=0;
	}	

  }
Пример #2
0
void tim1_up_tim10_isr(void) 
{
  //oscilloscope flag: start of interrupt
  gpio_set(GPIOD, GPIO11);

   
  //Clear the update interrupt flag
  timer_clear_flag(TIM1,  TIM_SR_UIF);

  calc_freq();

// /* ORIGINAL
if (center_aligned_state==FIRST_HALF)
{
  //oscilloscope flag: start of First HALF
  gpio_set(GPIOB, GPIO15);
  voltage_measure (ADC1,ADC_CHANNEL1);
}
else 
{
  //oscilloscope flag: start of second half
  gpio_set(GPIOD, GPIO9);
  DTC_SVM();
  collecting_floating_data();
  colllecting_flux_linkage();
  gpio_clear(GPIOD, GPIO11);
}

  //oscilloscope flag: start of halves
  //gpio_clear(GPIOB, GPIO15);

  //oscilloscope flag: end of interrupt
  gpio_clear(GPIOD, GPIO9);
  
}
Пример #3
0
int main(void)
{
    system_init();



    while (1)
    {
  		
  float voltage_joint_0 = 0.0f;      
  //float voltage_joint_1 = 0.0f;
  //float voltage_joint_2 = 0.0f;
  //float voltage_joint_3 = 0.0f;

  float joint_0_angle = 0.0f;
  //float joint_1_angle = 0.0f;
  //float joint_2_angle = 0.0f;   
  //float joint_3_angle = 0.0f;

	
        voltage_joint_0	= voltage_measure (ADC1,ADC_CHANNEL1);      
        //voltage_joint_1	= voltage_measure (ADC1,ADC_CHANNEL2);
        //voltage_joint_2 = voltage_measure (ADC1,ADC_CHANNEL3);
        //voltage_joint_3 = voltage_measure (ADC1,ADC_CHANNEL4);

        joint_0_angle = CONVERSION_FACTOR_JOINT_0*voltage_joint_0;
        //joint_1_angle = CONVERSION_FACTOR_JOINT_1*voltage_joint_1;
        //joint_2_angle = CONVERSION_FACTOR_JOINT_2*voltage_joint_2;   
		//joint_3_angle = CONVERSION_FACTOR_JOINT_3*voltage_joint_3; 
		
		static int counter0 = 0;
		counter0+=1;
		if(counter0>=50000){
        //printf("%6.2f %6.2f %6.2f %6.2f \n",joint_0_angle,joint_1_angle,joint_2_angle, joint_3_angle);
        printf("%6.2f \n",joint_0_angle);
        counter0 =0; 
		}
    }


}
Пример #4
0
void adc_isr(void)
{


 
  static int adc_counter=0;
  static float V_stm32_A  = 0.0f;
  static float V_stm32_B  = 0.0f;
  static float V_stm32_strain_gauge = 0.0f;
  float V_stm32_Ud = 0.0f;
  float V_shunt_A  = 0.0f;
  float V_shunt_B  = 0.0f;
  float V_strain_gauge =0.0f;
  
// /* ORIGINAL
  if (adc_counter==0)
  {
    V_stm32_A = adc_read_regular(ADC1);
    voltage_measure (ADC1,ADC_CHANNEL2);
    adc_counter++;
  }
  else if (adc_counter==1)
  {
    V_stm32_B = adc_read_regular(ADC1);
    voltage_measure (ADC1,ADC_CHANNEL15);
    adc_counter++; 
  }

  else if (adc_counter==2)
  {
    V_stm32_strain_gauge = adc_read_regular(ADC1);
    voltage_measure (ADC1,ADC_CHANNEL3);
    adc_counter++; 
  }
  // */

  //V_stm32_A = adc_read_regular(ADC1);//agregada
  //V_stm32_B = adc_read_regular(ADC2);//agregada
  //V_stm32_strain_gauge = adc_read_regular(ADC3);//agregada
  //Porque si lo hago asi, no tengo que llamar a voltage_measure() despues de cada asignacion de adc_read_regular()??

  else //quitado
  {   //quitado
    V_stm32_Ud = adc_read_regular(ADC1)*(VREF/ADC_CONVERSION_FACTOR);
    U_d        =    V_stm32_Ud*BATTERY_VOLTAGE_CONVERTION_FACTOR; 

    V_shunt_A = (V_stm32_A*(VREF/ADC_CONVERSION_FACTOR)-V_DIFFERENTIAL_AMPLIFIER_REFFERENCE_A)/G_OP_AMP_A;
    i_sA      = V_shunt_A/R_SHUNT_A;

    V_shunt_B = (V_stm32_B*(VREF/ADC_CONVERSION_FACTOR)-V_DIFFERENTIAL_AMPLIFIER_REFFERENCE_B)/G_OP_AMP_B;
    i_sB      = V_shunt_B/R_SHUNT_B;

    //V_strain_gauge=V_stm32_strain_gauge*(VREF/ADC_CONVERSION_FACTOR);
    //strain_gauge = V_strain_gauge-strain_gauge_reference;

    V_strain_gauge=V_stm32_strain_gauge*(VREF/ADC_CONVERSION_FACTOR)-strain_gauge_reference;
    V_strain_gauge=te_moving_average_filter(V_strain_gauge);

    strain_gauge = V_strain_gauge*STRAIN_GAUGE_CONVERSION_FACTOR;
    //strain_gauge =te_moving_average_filter(strain_gauge);
    if (reset_strain_gauge_reference==true)
    {
/*
      strain_gauge_reference=strain_gauge_reference+strain_gauge;
      strain_gauge=0.0f;
      reset_strain_gauge_reference=false;
*/

      strain_gauge_reference=strain_gauge_reference+V_strain_gauge;
      V_strain_gauge=0.0f;
      reset_strain_gauge_reference=false;
    }
    //filtering currents

    //i_sA = isA_moving_average_filter(i_sA);
    //i_sB = isB_moving_average_filter(i_sB);
       
    adc_counter=0;

    DTC_SVM();

    //collecting_data();

      //oscilloscope flag: start of halves
  gpio_clear(GPIOB, GPIO15);
  
  //gpio_clear(GPIOD, GPIO14); //agregada  

  //oscilloscope flag: end of interrupt
  gpio_clear(GPIOD, GPIO9);
  //gpio_clear(GPIOD, GPIO11);
  }