src/occ_405/amec/amec_controller.c
//*************************************************************************
// Function Specification
//
// Name: amec_controller_dimm_thermal
//
// Description: This function implements the Proportional Controller for the
//              DIMM thermal control. Although it doesn't return any
//              results, it populates the thermal vote in the field
//              g_amec->thermaldimm.speed_request.
//
// Task Flags:
//
// End Function Specification
Function Specification
Name: amec_controller_dimm_thermal

This function implements the Proportional Controller for the
DIMM thermal control. Although it doesn't return any
results, it populates the thermal vote in the field
g_amec->thermaldimm.speed_request.

Task Flags.

End Function Specification
Function Specification Name : amec_controller_dimm_thermal This function implements the Proportional Controller for the DIMM thermal control . Although it doesn ' t return any results it populates the thermal vote in the field g_amec - > thermaldimm . speed_request . Task Flags . End Function Specification
void amec_controller_dimm_thermal()
{
    uint16_t                      l_thermal_winner = 0;
    uint16_t                      l_residue = 0;
    uint16_t                      l_old_residue = 0;
    int16_t                       l_error = 0;
    int16_t                       l_mem_speed = 0;
    int16_t                       l_throttle_chg = 0;
    int32_t                       l_throttle = 0;
    sensor_t                    * l_sensor = NULL;
    l_sensor = getSensorByGsid(TEMPDIMMTHRM);
    if(G_dimm_temp_expired_bitmap.bigword)
    {
       l_thermal_winner = g_amec->thermaldimm.setpoint + 10;
    }
    else
    {
        l_thermal_winner = l_sensor->sample * 10;
    }
    if (g_amec->thermaldimm.setpoint == l_thermal_winner)
        return;
    l_error = g_amec->thermaldimm.setpoint - l_thermal_winner;
    l_throttle = (int32_t) l_error * g_amec->thermaldimm.Pgain;
    l_residue = (uint16_t) l_throttle;
    l_throttle_chg = (int16_t) (l_throttle >> 16);
    if ((int16_t) l_throttle_chg > AMEC_MEMORY_SPEED_CHANGE_LIMIT)
    {
        l_throttle_chg = AMEC_MEMORY_SPEED_CHANGE_LIMIT;
    }
    else
    {
        if ((int16_t) l_throttle_chg < (-AMEC_MEMORY_SPEED_CHANGE_LIMIT))
        {
            l_throttle_chg = -AMEC_MEMORY_SPEED_CHANGE_LIMIT;
        }
    }
    l_mem_speed = g_amec->thermaldimm.speed_request +
        (int16_t) l_throttle_chg * AMEC_MEMORY_STEP_SIZE;
    l_old_residue = g_amec->thermaldimm.total_res;
    g_amec->thermaldimm.total_res += l_residue;
    if (g_amec->thermaldimm.total_res < l_old_residue)
    {
        l_mem_speed += AMEC_MEMORY_STEP_SIZE;
    }
    if (l_mem_speed > AMEC_MEMORY_MAX_STEP)
        l_mem_speed = AMEC_MEMORY_MAX_STEP;
    if (l_mem_speed < AMEC_MEMORY_MIN_STEP)
        l_mem_speed = AMEC_MEMORY_MIN_STEP;
    g_amec->thermaldimm.speed_request = (uint16_t) l_mem_speed;
    if(g_amec->thermaldimm.speed_request < AMEC_MEMORY_MAX_STEP)
    {
       sensor_update(AMECSENSOR_PTR(MEMOTTHROT), 1);
    }
    else  
    {
       sensor_update(AMECSENSOR_PTR(MEMOTTHROT), 0);
    }
}
void amec_controller_dimm_thermal ( ) { uint16_t l_thermal_winner = 0 ; uint16_t l_residue = 0 ; uint16_t l_old_residue = 0 ; int16_t l_error = 0 ; int16_t l_mem_speed = 0 ; int16_t l_throttle_chg = 0 ; int32_t l_throttle = 0 ; sensor_t * l_sensor = NULL ; l_sensor = getSensorByGsid ( TEMPDIMMTHRM ) ; if ( G_dimm_temp_expired_bitmap . bigword ) { l_thermal_winner = g_amec -> thermaldimm . setpoint + 10 ; } else { l_thermal_winner = l_sensor -> sample * 10 ; } if ( g_amec -> thermaldimm . setpoint == l_thermal_winner ) return ; l_error = g_amec -> thermaldimm . setpoint - l_thermal_winner ; l_throttle = ( int32_t ) l_error * g_amec -> thermaldimm . Pgain ; l_residue = ( uint16_t ) l_throttle ; l_throttle_chg = ( int16_t ) ( l_throttle >> 16 ) ; if ( ( int16_t ) l_throttle_chg > AMEC_MEMORY_SPEED_CHANGE_LIMIT ) { l_throttle_chg = AMEC_MEMORY_SPEED_CHANGE_LIMIT ; } else { if ( ( int16_t ) l_throttle_chg < ( - AMEC_MEMORY_SPEED_CHANGE_LIMIT ) ) { l_throttle_chg = - AMEC_MEMORY_SPEED_CHANGE_LIMIT ; } } l_mem_speed = g_amec -> thermaldimm . speed_request + ( int16_t ) l_throttle_chg * AMEC_MEMORY_STEP_SIZE ; l_old_residue = g_amec -> thermaldimm . total_res ; g_amec -> thermaldimm . total_res += l_residue ; if ( g_amec -> thermaldimm . total_res < l_old_residue ) { l_mem_speed += AMEC_MEMORY_STEP_SIZE ; } if ( l_mem_speed > AMEC_MEMORY_MAX_STEP ) l_mem_speed = AMEC_MEMORY_MAX_STEP ; if ( l_mem_speed < AMEC_MEMORY_MIN_STEP ) l_mem_speed = AMEC_MEMORY_MIN_STEP ; g_amec -> thermaldimm . speed_request = ( uint16_t ) l_mem_speed ; if ( g_amec -> thermaldimm . speed_request < AMEC_MEMORY_MAX_STEP ) { sensor_update ( AMECSENSOR_PTR ( MEMOTTHROT ) , 1 ) ; } else { sensor_update ( AMECSENSOR_PTR ( MEMOTTHROT ) , 0 ) ; } }
Function Specification
Name: amec_controller_dimm_thermal
Function Specification Name : amec_controller_dimm_thermal
/*------------------------------------------------------------------------*/ /*  Local Variables                                                       */ /*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/ /*  Code                                                                  */ /*------------------------------------------------------------------------*/ // Get TEMPDIMMTHRM sensor value //we were not able to read one or more dimm temperatures. //Assume temperature is at the setpoint plus 1 degree C. // Use the highest temperature of all DIMMs in 0.1 degrees C // Check if there is an error // Calculate the thermal control error // Proportional Controller for the thermal control loop based on DIMM // temperatures // Calculate the new thermal speed request for DIMMs // Proceed with residue summation to correctly follow set-point // Enforce actuator saturation limits // Generate the new thermal speed request // Update the Memory OT Throttle Sensor // Memory speed is less than max indicate throttle due to OT // not currently throttled due to OT