subroutine TopDrive_OffMode
    
    use SimulationVariables
   
	IMPLICIT NONE
    
    
    data%State%TDS%N_new  = 0.d0
    
    !==================================================================
    !                  Rate limit for off Mode
    if (((data%State%TDS%N_old-data%State%TDS%N_new)/data%State%TDS%time_step)>(2.d0*data%State%TDS%RateChange)) then    ! baraye 0 shodan RateChange ro *2 karde ???
        data%State%TDS%N_ref = (-(2.d0*data%State%TDS%RateChange)*data%State%TDS%time_step)+data%State%TDS%N_old
        Call TopDrive_Solver
    !==================================================================
    else
    
        data%State%TDS%N_ref    = 0.d0
        data%State%TDS%N_new    = 0.d0
        data%State%TDS%N_old    = 0.d0
        data%State%TDS%Speed    = 0.d0
        data%State%TDS%TDS_wOld = 0.d0
    
    
        data%State%TDS%OperationFaultLed = 0
        data%State%TDS%Speed             = 0.d0                 !Speed [RPM]
        data%State%TDS%RpmGaugeOutput    = data%State%TDS%Speed
        data%State%TDS%RPMUnityOutput    = -data%State%TDS%RpmGaugeOutput
        data%State%TDS%SoundRPM          = 0
        data%State%TDS%Torque            = 0.d0                 ![ft.lbf]
        data%State%TDS%TorqueGaugeOutput = 0.d0                 ![ft.lbf]
        data%State%TDS%OldPowerMode      = 1
    
        data%State%TDS%OldPowerMode      = 0
    
    End if
    
    
end subroutine