Exemplo n.º 1
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);
  
}
Exemplo n.º 2
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);
  }