ZHCU083I January 2013 – October 2021 TMS320F2802-Q1 , TMS320F28026-Q1 , TMS320F28026F , TMS320F28027-Q1 , TMS320F28027F , TMS320F28027F-Q1 , TMS320F28052-Q1 , TMS320F28052F , TMS320F28052F-Q1 , TMS320F28052M , TMS320F28052M-Q1 , TMS320F28054-Q1 , TMS320F28054F , TMS320F28054F-Q1 , TMS320F28054M , TMS320F28054M-Q1 , TMS320F2806-Q1 , TMS320F28062-Q1 , TMS320F28062F , TMS320F28062F-Q1 , TMS320F28068F , TMS320F28068M , TMS320F28069-Q1 , TMS320F28069F , TMS320F28069F-Q1 , TMS320F28069M , TMS320F28069M-Q1
该操作可在主循环中完成。本代码示例中包括与注排水阀及传感器进行交互所需的代码。作为洗衣机仿真的一部分,它还会更新水位信息。
if(gMotorVars.VelPlanRun == TRUE) {
STVELPLAN_setEnable(stVelPlanHandle, TRUE);
}
// Run SpinTAC Velocity Plan
STVELPLAN_run(stVelPlanHandle);
// Update sensor values for SpinTAC Plan
// Get values for washer valve components
STVELPLAN _getVar(stVelPlanHandle, 3, &gVelPanVar[3]); // Get value of FillVale
STVELPLAN _getVar(stVelPlanHandle, 3, &gVelPanVar[4]); // Get value of DrainValve
if(gVelPanVar[3] == TRUE) {
// if FillValve is open, increase water level
gWaterLevel += 1;
}
else if(gVelPanVar[4] == TRUE) {
// if DrainValve is open, decrease water level
gWaterLevel -= 1;
}
if(gWaterLevel >= WASHER_MAX_WATER_LEVEL) {
// if water level is greater than maximum, set fill sensor to true
gWaterLevel = WASHER_MAX_WATER_LEVEL;
gVelPanVar[0] = TRUE;
}
else {
// if water level is less than maximum, set FillSensor to false
gVelPanVar[0] = FALSE;
}
if(gWaterLevel <= WASHER_MIN_WATER_LEVEL) {
// if water level is at the minimum & set DrainSensor to true
gWaterLevel = WASHER_MIN_WATER_LEVEL;
gVelPanVar[1] = TRUE;
}
else {
// if water level is greater than minimum, set DrainSensor to false
gVelPanVar[1] = FALSE;
}
// Set values for washer sensor components
STVELPLAN _getVar(stVelPlanHandle, 0, gVelPanVar[0]); // Set value for FillSensor
STVELPLAN _getVar(stVelPlanHandle, 1, gVelPanVar[1]); // Set value for DrainSensor
if(STVELPLAN_getStatus(stVelPlanHandle) != ST_PLAN_IDLE) {
// Send the profile configuration to SpinTAC Move
gMotorVars.SpeedRef_krpm = _IQmpy(STVELPLAN_getVelocitySetpoint(stVelPlanHandle),
_IQ24(ST_SPEED_KRPM_PER_PU));
gMotorVars.MaxAccel_krpmps = _IQmpy(STVELPLAN_getAccelerationLimit(stVelPlanHandle),
_IQ24(ST_SPEED_KRPM_PER_PU));
gMotorVars.MaxJrk_krpmps2 = _IQ20mpy(STVELPLAN_getJerkLimit(stVelPlanHandle),
_IQ20(ST_SPEED_KRPM_PER_PU));
}
else {
STVELPLAN_setEnable(stVelPlanHandle, FALSE);
}