TI中文支持网
TI专业的中文技术问题搜集分享网站

使用28027F的PWMDAC功能,遇到问题,求解

我想要让28027F的EPWM4A和4B作为DAC输出,外部接口已经接了一个RC低通滤波器,截止频率800Hz.如下程序代码我应该怎么设置才能让EPWM4A和4B作为DA输出呢

#ifdef F2802xF
HAL_DacData_t gDacData;
#endif

 gDacData.ptrData[0] = &angle_gen.Angle_pu;
  gDacData.ptrData[1] = &gAdcData.I.value[0];
  gDacData.ptrData[2] = &gPwmData.Tabc.value[0];
  gDacData.ptrData[3] = &gPwmData.Tabc.value[1];
  HAL_setDacParameters(halHandle, &gDacData);
#ifdef F2802xF
  // connect inputs of the PWMDAC module.
  gDacData.value[0] = (*gDacData.ptrData[0]);  //
  gDacData.value[1] = (*gDacData.ptrData[1]);  //
  gDacData.value[2] = (*gDacData.ptrData[2]);  //
  gDacData.value[3] = (*gDacData.ptrData[3]);  //
  HAL_writeDacData(halHandle,&gDacData);
#endif
static inline void HAL_writeDacData(HAL_Handle handle,HAL_DacData_t *pDacData)
{
  HAL_Obj *obj = (HAL_Obj *)handle;
  // convert values from _IQ to _IQ15
  uint_least8_t cnt;
  _iq period;
  _iq dacData_sat_dc;
  _iq value;
  uint16_t cmpValue[4];
  period = (_iq)pDacData->PeriodMax;
  for(cnt=0;cnt<4;cnt++)
 {
   dacData_sat_dc = _IQmpy(pDacData->value[cnt], pDacData->gain[cnt]) + pDacData->offset[cnt];
   value = _IQmpy(dacData_sat_dc, period);
   cmpValue[cnt] = (uint16_t)_IQsat(value, period, 0);
 }
  // write the DAC data
  if(obj->pwmDacHandle[PWMDAC_Number_1])
  {
   PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_1], cmpValue[0]);
   PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_1], cmpValue[1]);
  }
  obj->pwmDacHandle[PWMDAC_Number_2];
   PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_2], cmpValue[2]);
   PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_2], cmpValue[3]);
  return;
} // end of HAL_writeDacData() function
void HAL_setDacParameters(HAL_Handle handle, HAL_DacData_t *pDacData)
{
 HAL_Obj *obj = (HAL_Obj *)handle;
 pDacData->PeriodMax = PWMDAC_getPeriod(obj->pwmDacHandle[PWMDAC_Number_1]);
 pDacData->offset[0] = _IQ(0.5);
 pDacData->offset[1] = _IQ(0.5);
 pDacData->offset[2] = _IQ(0.5);
 pDacData->offset[3] = _IQ(0.5);
 pDacData->gain[0] = _IQ(1.0);
 pDacData->gain[1] = _IQ(1.0);
 pDacData->gain[2] = _IQ(1.0);
 pDacData->gain[3] = _IQ(1.0);
 return;
} //end of HAL_setDacParameters() function

bob iuuiy:

好冷清,我发了好多帖子,怎么没有TI的人答疑呢?

我想要让28027F的EPWM4A和4B作为DAC输出,外部接口已经接了一个RC低通滤波器,截止频率800Hz.如下程序代码我应该怎么设置才能让EPWM4A和4B作为DA输出呢

#ifdef F2802xF
HAL_DacData_t gDacData;
#endif

 gDacData.ptrData[0] = &angle_gen.Angle_pu;
  gDacData.ptrData[1] = &gAdcData.I.value[0];
  gDacData.ptrData[2] = &gPwmData.Tabc.value[0];
  gDacData.ptrData[3] = &gPwmData.Tabc.value[1];
  HAL_setDacParameters(halHandle, &gDacData);
#ifdef F2802xF
  // connect inputs of the PWMDAC module.
  gDacData.value[0] = (*gDacData.ptrData[0]);  //
  gDacData.value[1] = (*gDacData.ptrData[1]);  //
  gDacData.value[2] = (*gDacData.ptrData[2]);  //
  gDacData.value[3] = (*gDacData.ptrData[3]);  //
  HAL_writeDacData(halHandle,&gDacData);
#endif
static inline void HAL_writeDacData(HAL_Handle handle,HAL_DacData_t *pDacData)
{
  HAL_Obj *obj = (HAL_Obj *)handle;
  // convert values from _IQ to _IQ15
  uint_least8_t cnt;
  _iq period;
  _iq dacData_sat_dc;
  _iq value;
  uint16_t cmpValue[4];
  period = (_iq)pDacData->PeriodMax;
  for(cnt=0;cnt<4;cnt++)
 {
   dacData_sat_dc = _IQmpy(pDacData->value[cnt], pDacData->gain[cnt]) + pDacData->offset[cnt];
   value = _IQmpy(dacData_sat_dc, period);
   cmpValue[cnt] = (uint16_t)_IQsat(value, period, 0);
 }
  // write the DAC data
  if(obj->pwmDacHandle[PWMDAC_Number_1])
  {
   PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_1], cmpValue[0]);
   PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_1], cmpValue[1]);
  }
  obj->pwmDacHandle[PWMDAC_Number_2];
   PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_2], cmpValue[2]);
   PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_2], cmpValue[3]);
  return;
} // end of HAL_writeDacData() function
void HAL_setDacParameters(HAL_Handle handle, HAL_DacData_t *pDacData)
{
 HAL_Obj *obj = (HAL_Obj *)handle;
 pDacData->PeriodMax = PWMDAC_getPeriod(obj->pwmDacHandle[PWMDAC_Number_1]);
 pDacData->offset[0] = _IQ(0.5);
 pDacData->offset[1] = _IQ(0.5);
 pDacData->offset[2] = _IQ(0.5);
 pDacData->offset[3] = _IQ(0.5);
 pDacData->gain[0] = _IQ(1.0);
 pDacData->gain[1] = _IQ(1.0);
 pDacData->gain[2] = _IQ(1.0);
 pDacData->gain[3] = _IQ(1.0);
 return;
} //end of HAL_setDacParameters() function

Eric Ma:

回复 bob iuuiy:

你也没说出了什么问题呀。

PWM输出作为DAC,原理上是将归一化的变量作为占空比,输出PWM,然后经过滤波后就是对应的电压波形。

C:\ti\controlSUITE\development_kits\HVMotorCtrl+PfcKit_v2.1\HVPM_Enhanced_Sensorless_2803x

pwmdac1.MfuncC1 = qep1.ElecTheta; pwmdac1.MfuncC2 = smo1.Theta; PWMDAC_MACRO(6,pwmdac1) // PWMDAC 6A, 6B

这里面也有类似的说明。

我想要让28027F的EPWM4A和4B作为DAC输出,外部接口已经接了一个RC低通滤波器,截止频率800Hz.如下程序代码我应该怎么设置才能让EPWM4A和4B作为DA输出呢

#ifdef F2802xF
HAL_DacData_t gDacData;
#endif

 gDacData.ptrData[0] = &angle_gen.Angle_pu;
  gDacData.ptrData[1] = &gAdcData.I.value[0];
  gDacData.ptrData[2] = &gPwmData.Tabc.value[0];
  gDacData.ptrData[3] = &gPwmData.Tabc.value[1];
  HAL_setDacParameters(halHandle, &gDacData);
#ifdef F2802xF
  // connect inputs of the PWMDAC module.
  gDacData.value[0] = (*gDacData.ptrData[0]);  //
  gDacData.value[1] = (*gDacData.ptrData[1]);  //
  gDacData.value[2] = (*gDacData.ptrData[2]);  //
  gDacData.value[3] = (*gDacData.ptrData[3]);  //
  HAL_writeDacData(halHandle,&gDacData);
#endif
static inline void HAL_writeDacData(HAL_Handle handle,HAL_DacData_t *pDacData)
{
  HAL_Obj *obj = (HAL_Obj *)handle;
  // convert values from _IQ to _IQ15
  uint_least8_t cnt;
  _iq period;
  _iq dacData_sat_dc;
  _iq value;
  uint16_t cmpValue[4];
  period = (_iq)pDacData->PeriodMax;
  for(cnt=0;cnt<4;cnt++)
 {
   dacData_sat_dc = _IQmpy(pDacData->value[cnt], pDacData->gain[cnt]) + pDacData->offset[cnt];
   value = _IQmpy(dacData_sat_dc, period);
   cmpValue[cnt] = (uint16_t)_IQsat(value, period, 0);
 }
  // write the DAC data
  if(obj->pwmDacHandle[PWMDAC_Number_1])
  {
   PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_1], cmpValue[0]);
   PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_1], cmpValue[1]);
  }
  obj->pwmDacHandle[PWMDAC_Number_2];
   PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_2], cmpValue[2]);
   PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_2], cmpValue[3]);
  return;
} // end of HAL_writeDacData() function
void HAL_setDacParameters(HAL_Handle handle, HAL_DacData_t *pDacData)
{
 HAL_Obj *obj = (HAL_Obj *)handle;
 pDacData->PeriodMax = PWMDAC_getPeriod(obj->pwmDacHandle[PWMDAC_Number_1]);
 pDacData->offset[0] = _IQ(0.5);
 pDacData->offset[1] = _IQ(0.5);
 pDacData->offset[2] = _IQ(0.5);
 pDacData->offset[3] = _IQ(0.5);
 pDacData->gain[0] = _IQ(1.0);
 pDacData->gain[1] = _IQ(1.0);
 pDacData->gain[2] = _IQ(1.0);
 pDacData->gain[3] = _IQ(1.0);
 return;
} //end of HAL_setDacParameters() function

bob iuuiy:

回复 Eric Ma:

你好,我使用的是28027F,我怎么样修改Lab1b里面的程序让EPWM4A和4B的输出端口能观察到对应的电压波形呢

我想要让28027F的EPWM4A和4B作为DAC输出,外部接口已经接了一个RC低通滤波器,截止频率800Hz.如下程序代码我应该怎么设置才能让EPWM4A和4B作为DA输出呢

#ifdef F2802xF
HAL_DacData_t gDacData;
#endif

 gDacData.ptrData[0] = &angle_gen.Angle_pu;
  gDacData.ptrData[1] = &gAdcData.I.value[0];
  gDacData.ptrData[2] = &gPwmData.Tabc.value[0];
  gDacData.ptrData[3] = &gPwmData.Tabc.value[1];
  HAL_setDacParameters(halHandle, &gDacData);
#ifdef F2802xF
  // connect inputs of the PWMDAC module.
  gDacData.value[0] = (*gDacData.ptrData[0]);  //
  gDacData.value[1] = (*gDacData.ptrData[1]);  //
  gDacData.value[2] = (*gDacData.ptrData[2]);  //
  gDacData.value[3] = (*gDacData.ptrData[3]);  //
  HAL_writeDacData(halHandle,&gDacData);
#endif
static inline void HAL_writeDacData(HAL_Handle handle,HAL_DacData_t *pDacData)
{
  HAL_Obj *obj = (HAL_Obj *)handle;
  // convert values from _IQ to _IQ15
  uint_least8_t cnt;
  _iq period;
  _iq dacData_sat_dc;
  _iq value;
  uint16_t cmpValue[4];
  period = (_iq)pDacData->PeriodMax;
  for(cnt=0;cnt<4;cnt++)
 {
   dacData_sat_dc = _IQmpy(pDacData->value[cnt], pDacData->gain[cnt]) + pDacData->offset[cnt];
   value = _IQmpy(dacData_sat_dc, period);
   cmpValue[cnt] = (uint16_t)_IQsat(value, period, 0);
 }
  // write the DAC data
  if(obj->pwmDacHandle[PWMDAC_Number_1])
  {
   PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_1], cmpValue[0]);
   PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_1], cmpValue[1]);
  }
  obj->pwmDacHandle[PWMDAC_Number_2];
   PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_2], cmpValue[2]);
   PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_2], cmpValue[3]);
  return;
} // end of HAL_writeDacData() function
void HAL_setDacParameters(HAL_Handle handle, HAL_DacData_t *pDacData)
{
 HAL_Obj *obj = (HAL_Obj *)handle;
 pDacData->PeriodMax = PWMDAC_getPeriod(obj->pwmDacHandle[PWMDAC_Number_1]);
 pDacData->offset[0] = _IQ(0.5);
 pDacData->offset[1] = _IQ(0.5);
 pDacData->offset[2] = _IQ(0.5);
 pDacData->offset[3] = _IQ(0.5);
 pDacData->gain[0] = _IQ(1.0);
 pDacData->gain[1] = _IQ(1.0);
 pDacData->gain[2] = _IQ(1.0);
 pDacData->gain[3] = _IQ(1.0);
 return;
} //end of HAL_setDacParameters() function

bob iuuiy:

回复 bob iuuiy:

我是想用28027F的EPWM4A和EPWM4B作为PWMDAC输出观察采集到的电流和电压值,这在程序中如何设置,我在Lab1b中看到的只有下面这些语句,我应该修改哪些参数将DA输出配置成EPWM4A和EPWM4B口。

HAL_DacData_t gDacData;

  HAL_setDacParameters(halHandle, &gDacData);

  HAL_writeDacData(halHandle,&gDacData);

static inline void HAL_writeDacData(HAL_Handle handle,HAL_DacData_t *pDacData){  HAL_Obj *obj = (HAL_Obj *)handle;
  // convert values from _IQ to _IQ15  uint_least8_t cnt;  _iq period;  _iq dacData_sat_dc;  _iq value;  uint16_t cmpValue[4];
  period = (_iq)pDacData->PeriodMax;
  for(cnt=0;cnt<4;cnt++)  {   dacData_sat_dc = _IQmpy(pDacData->value[cnt], pDacData->gain[cnt]) + pDacData->offset[cnt];   value = _IQmpy(dacData_sat_dc, period);   cmpValue[cnt] = (uint16_t)_IQsat(value, period, 0);  }
  // write the DAC data  if(obj->pwmDacHandle[PWMDAC_Number_1])  {   PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_1], cmpValue[0]);   PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_1], cmpValue[1]);  }
  if(obj->pwmDacHandle[PWMDAC_Number_2])  {   PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_2], cmpValue[2]);   PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_2], cmpValue[3]);  }
  return;} // end of HAL_writeDacData() function
如何修改PWMDAC通道

赞(0)
未经允许不得转载:TI中文支持网 » 使用28027F的PWMDAC功能,遇到问题,求解
分享到: 更多 (0)