Beispiel #1
0
/* Model output function */
void arbeitspunkt_output(int_T tid)
{
  /* local block i/o variables */
  real_T rtb_AnalogInput;

  {
    real_T currentTime;

    /* Step: '<Root>/4V_Step' */
    currentTime = arbeitspunkt_M->Timing.t[0];
    if (currentTime < arbeitspunkt_P.V_Step_Time) {
      arbeitspunkt_B.V_Step = arbeitspunkt_P.V_Step_Y0;
    } else {
      arbeitspunkt_B.V_Step = arbeitspunkt_P.V_Step_YFinal;
    }

    /* Sum: '<Root>/Add' incorporates:
     *  Constant: '<Root>/Offset_OUT'
     */
    arbeitspunkt_B.Add = arbeitspunkt_B.V_Step + arbeitspunkt_P.Offset_OUT_Value;

    /* S-Function Block: <Root>/Analog Output */
    {
      {
        ANALOGIOPARM parm;
        parm.mode = (RANGEMODE) arbeitspunkt_P.AnalogOutput_RangeMode;
        parm.rangeidx = arbeitspunkt_P.AnalogOutput_VoltRange;
        RTBIO_DriverIO(0, ANALOGOUTPUT, IOWRITE, 1,
                       &arbeitspunkt_P.AnalogOutput_Channels,
                       &arbeitspunkt_B.Add, &parm);
      }
    }

    /* S-Function Block: <Root>/Analog Input */
    {
      ANALOGIOPARM parm;
      parm.mode = (RANGEMODE) arbeitspunkt_P.AnalogInput_RangeMode;
      parm.rangeidx = arbeitspunkt_P.AnalogInput_VoltRange;
      RTBIO_DriverIO(0, ANALOGINPUT, IOREAD, 1,
                     &arbeitspunkt_P.AnalogInput_Channels, &rtb_AnalogInput,
                     &parm);
    }

    /* Sum: '<Root>/Add1' incorporates:
     *  Constant: '<Root>/Offset_IN'
     */
    arbeitspunkt_B.Add1 = rtb_AnalogInput + arbeitspunkt_P.Offset_IN_Value;
  }

  UNUSED_PARAMETER(tid);
}
Beispiel #2
0
void MdlStart(void)
{
  /* S-Function Block: <Root>/Analog Output */
  {
    {
      ANALOGIOPARM parm;
      parm.mode = (RANGEMODE) arbeitspunkt_P.AnalogOutput_RangeMode;
      parm.rangeidx = arbeitspunkt_P.AnalogOutput_VoltRange;
      RTBIO_DriverIO(0, ANALOGOUTPUT, IOWRITE, 1,
                     &arbeitspunkt_P.AnalogOutput_Channels,
                     &arbeitspunkt_P.AnalogOutput_InitialValue, &parm);
    }
  }

  MdlInitialize();
}
Beispiel #3
0
/* Model terminate function */
void arbeitspunkt_terminate(void)
{
  /* S-Function Block: <Root>/Analog Output */
  {
    {
      ANALOGIOPARM parm;
      parm.mode = (RANGEMODE) arbeitspunkt_P.AnalogOutput_RangeMode;
      parm.rangeidx = arbeitspunkt_P.AnalogOutput_VoltRange;
      RTBIO_DriverIO(0, ANALOGOUTPUT, IOWRITE, 1,
                     &arbeitspunkt_P.AnalogOutput_Channels,
                     &arbeitspunkt_P.AnalogOutput_FinalValue, &parm);
    }
  }

  /* External mode */
  rtExtModeShutdown(2);
}
Beispiel #4
0
/* Model terminate function */
void Maglev_PD_terminate(void)
{
  /* S-Function Block: <S4>/Analog Output */
  {
    {
      ANALOGIOPARM parm;
      parm.mode = (RANGEMODE) Maglev_PD_P.AnalogOutput_RangeMode;
      parm.rangeidx = Maglev_PD_P.AnalogOutput_VoltRange;
      RTBIO_DriverIO(0, ANALOGOUTPUT, IOWRITE, 1,
                     &Maglev_PD_P.AnalogOutput_Channels,
                     &Maglev_PD_P.AnalogOutput_FinalValue, &parm);
    }
  }

  /* External mode */
  rtExtModeShutdown(3);
}
Beispiel #5
0
/* Model output function */
void Maglev_PD_output(int_T tid)
{
  /* local block i/o variables */
  real_T rtb_Sinus;
  real_T rtb_Square;
  real_T rtb_DiscreteTransferFcn1;
  real_T rtb_Saturation;

  {
    real_T currentTime;

    /* S-Function Block: <S3>/Analog Input */
    {
      ANALOGIOPARM parm;
      parm.mode = (RANGEMODE) Maglev_PD_P.AnalogInput_RangeMode;
      parm.rangeidx = Maglev_PD_P.AnalogInput_VoltRange;
      RTBIO_DriverIO(0, ANALOGINPUT, IOREAD, 1,
                     &Maglev_PD_P.AnalogInput_Channels, &Maglev_PD_B.AnalogInput,
                     &parm);
    }

    /* Step: '<Root>/Step' */
    currentTime = Maglev_PD_M->Timing.t[0];
    if (currentTime < Maglev_PD_P.Step_Time) {
      currentTime = Maglev_PD_P.Step_Y0;
    } else {
      currentTime = Maglev_PD_P.Step_YFinal;
    }

    /* SignalGenerator: '<Root>/Sinus' */
    {
      real_T sin2PiFT = sin(6.2831853071795862E+000*Maglev_PD_P.Sinus_Frequency*
                            Maglev_PD_M->Timing.t[0]);
      rtb_Sinus = Maglev_PD_P.Sinus_Amplitude*sin2PiFT;
    }

    /* SignalGenerator: '<Root>/Square' */
    {
      real_T phase = Maglev_PD_P.Square_Frequency*Maglev_PD_M->Timing.t[0];
      phase = phase-floor(phase);
      rtb_Square = ( phase >= 0.5 ) ?
        Maglev_PD_P.Square_Amplitude : -Maglev_PD_P.Square_Amplitude;
    }

    /* Switch: '<S5>/SwitchControl' incorporates:
     *  Constant: '<Root>/Constant'
     *  Constant: '<S5>/Constant'
     *  Sum: '<Root>/Sum'
     */
    if (Maglev_PD_P.Constant_Value_b > Maglev_PD_P.SwitchControl_Threshold) {
      Maglev_PD_B.SwitchControl = currentTime;
    } else {
      /* Switch: '<S6>/SwitchControl' incorporates:
       *  Constant: '<S6>/Constant'
       */
      if (Maglev_PD_P.Constant_Value_p > Maglev_PD_P.SwitchControl_Threshold_a)
      {
        currentTime = rtb_Sinus;
      } else {
        currentTime = rtb_Square;
      }

      Maglev_PD_B.SwitchControl = currentTime + Maglev_PD_P.Constant_Value_d;
    }

    /* Sum: '<Root>/Sum1' */
    Maglev_PD_B.Sum1 = Maglev_PD_B.SwitchControl - Maglev_PD_B.AnalogInput;

    /* Gain: '<S7>/Gain' */
    currentTime = Maglev_PD_P.Gain_Gain * Maglev_PD_B.Sum1;

    /* Gain: '<S7>/Gain3' */
    Maglev_PD_B.Gain3 = Maglev_PD_P.Gain3_Gain * Maglev_PD_B.Sum1;

    /* DiscreteTransferFcn: '<S7>/Discrete Transfer Fcn1' */
    rtb_DiscreteTransferFcn1 = Maglev_PD_P.DiscreteTransferFcn1_D*
      Maglev_PD_B.Gain3;
    rtb_DiscreteTransferFcn1 += Maglev_PD_P.DiscreteTransferFcn1_C*
      Maglev_PD_DWork.DiscreteTransferFcn1_DSTATE;

    /* Gain: '<S7>/Gain1' */
    Maglev_PD_B.Gain1 = Maglev_PD_P.Gain1_Gain * Maglev_PD_B.Sum1;

    /* DiscreteTransferFcn: '<S7>/Discrete Transfer Fcn' */
    rtb_Saturation = Maglev_PD_P.DiscreteTransferFcn_D*Maglev_PD_B.Gain1;
    rtb_Saturation += Maglev_PD_P.DiscreteTransferFcn_C*
      Maglev_PD_DWork.DiscreteTransferFcn_DSTATE;

    /* Gain: '<S7>/Gain2' incorporates:
     *  Sum: '<S7>/Sum'
     */
    Maglev_PD_B.Gain2 = ((currentTime + rtb_DiscreteTransferFcn1) +
                         rtb_Saturation) * Maglev_PD_P.Gain2_Gain;

    /* Sum: '<S4>/Add' incorporates:
     *  Constant: '<S4>/Constant'
     */
    rtb_Saturation = Maglev_PD_P.Constant_Value + Maglev_PD_B.Gain2;

    /* Saturate: '<S4>/Saturation' */
    rtb_Saturation = rt_SATURATE(rtb_Saturation, Maglev_PD_P.Saturation_LowerSat,
      Maglev_PD_P.Saturation_UpperSat);

    /* S-Function Block: <S4>/Analog Output */
    {
      {
        ANALOGIOPARM parm;
        parm.mode = (RANGEMODE) Maglev_PD_P.AnalogOutput_RangeMode;
        parm.rangeidx = Maglev_PD_P.AnalogOutput_VoltRange;
        RTBIO_DriverIO(0, ANALOGOUTPUT, IOWRITE, 1,
                       &Maglev_PD_P.AnalogOutput_Channels, &rtb_Saturation,
                       &parm);
      }
    }

    /* Clock: '<Root>/Clock' */
    Maglev_PD_B.Clock = Maglev_PD_M->Timing.t[0];
    if (Maglev_PD_M->Timing.TaskCounters.TID[2] == 0) {
    }

    /* Sum: '<S1>/Sum1' incorporates:
     *  Constant: '<S1>/Constant1'
     *  Gain: '<S1>/Gain2'
     */
    Maglev_PD_B.Sum1_f = Maglev_PD_P.Gain2_Gain_m * Maglev_PD_B.SwitchControl +
      Maglev_PD_P.Constant1_Value;

    /* Sum: '<S2>/Sum1' incorporates:
     *  Constant: '<S2>/Constant1'
     *  Gain: '<S2>/Gain2'
     */
    Maglev_PD_B.Sum1_p = Maglev_PD_P.Gain2_Gain_n * Maglev_PD_B.AnalogInput +
      Maglev_PD_P.Constant1_Value_d;
    if (Maglev_PD_M->Timing.TaskCounters.TID[2] == 0) {
    }
  }

  UNUSED_PARAMETER(tid);
}