22.3.1.2. RecurDyn Host Mode

For the synchronous simulation of control design tool and RecurDyn, following five steps are required as shown in Figure 22.45.

../_images/image0425.png

Figure 22.45 Four-step process

Communication Sequence

  1. Make the shared memory and call the Simulink by the RecurDyn, wait the control output (2) of the Simulink.

  2. Send the control output from the Simulink, wait the plant output (4) of the RecurDyn.

  3. Receive plant inputs (=control output) from the shared memory.

  4. Send plant outputs from RecurDyn.

  5. Receive the Sensor input (=Plant output) from the shared memory.

    ../_images/image0435.png

    Figure 22.46 Communication Sequence

22.3.1.2.1. Step I (In RecurDyn)

Step to open the RecurDyn model

  1. The model is provided in the RecurDyn installation directory <install dir>\Help\Examples\Simulink_CoSim\.

  2. Create a new working directory.

  3. Copy the RecurDyn model(mouse.rdyn) and Simulink model(simouse.mdl) from the directory paste to the newly created working directory.

  4. Run RecurDyn.

  5. Open the RecurDyn model. And then, the mouse model appears in the working window.

    ../_images/image1553.png

    Figure 22.47 Mouse model

Step to verify the mechanical system model

Prior to applying a control system to this model, make sure that the mouse model runs without any errors.

  1. Select Dynamic/Kinematic icon of the Simulation group in the Analysis tab.

    ../_images/image0634.png

    Figure 22.48 Dynamic/Kinematic Analysis dialog box

  2. Enter End time and Step.

  3. Click Simulate.

If the simulation stops abnormally, fix the model and try the simulation again.

22.3.1.2.2. Step II (In RecurDyn)

Step to identify general GPlant inputs

The input of interest is the single rotational axial force is applied to the wheel Revolute Joint to move the mouse.

  1. Click the GPlant_Input icon of the Control group in the Communicator tab. The General GPlant Input List dialog box appears as shown in Figure 22.49. For more information, click here.

    ../_images/image1563.png

    Figure 22.49 General GPlant Input List dialog box

  2. Add a GPlant input as the name of the actuator.

  3. Add an expression function as a following figure.

    ../_images/image1572.png

    Figure 22.50 Expression dialog box

  4. Open the dialog box of Rotational Axial force by double clicking RotationalAxial1 in the Database window. And then input the expression function defined in the upper step.

    ../_images/image1584.png

    Figure 22.51 Rotational Axial force dialog box

Step to identify general GPlant outputs

The output of interest is the displacement and velocity between the ball and the Mouse body pointer. This distance is in the X direction.

  1. Click the. GPlant_Output icon of the Control group in the Communicator tab. The General Plant Output List dialog box appears as shown in Figure 22.52. For more information, click here.

    ../_images/image1592.png

    Figure 22.52 General Plant Output dialog box

  2. Add GPlant outputs as expression functions. At this dialog, the defined expression functions are as following figures.

    ../_images/image1603.png
    ../_images/image1613.png

    Figure 22.53 Expression dialog box

Step to set interface information

  1. Save the RecurDyn model in the normal fashion.

  2. Click the GCoSim icon of the Control group in the Communicator tab. The General CoSim dialog box appears. For more information, click here.

    ../_images/image1622.png

    Figure 22.54 General CoSim dialog box

  3. Click Add button.

  4. Define the name of General CoSim as GCoSim1.

  5. Select the type of General CoSim as Simulink.

  6. Click the PIN (…) button. The General GPlant Input List (GCoSim1) dialog box appears.

    ../_images/image1633.png

    Figure 22.55 General GPlant Input List (GCoSim1) dialog box

  7. Click Add button. Automatically “Control_torque” is input. And click OK button.

  8. Likewise Clink the POUT (…) button. The General GPlant Output List (GCoSim1) dialog box appears.

    ../_images/image1643.png

    Figure 22.56 General GPlant Output List (GCoSim1) dialog box

  9. Click Add button twice. Automatically “displacement” and “velocity” are input. And Click OK button.

  10. Click CoSim(…) button. The Simulink (GCoSim1) dialog box appears.

    ../_images/image0445.png

    Figure 22.57 Simulink (GCoSim1) dialog box

  11. Select the Host Program as RecurDyn.

  12. Export the M file to create a Plant Block after defining the names.

  13. Click OK.

  14. Save the RecurDyn model and terminate the RecurDyn program.

22.3.1.2.3. Step III (In MATLAB)

Step to build Simulink model with RecurDyn Plant Block

  1. Run the MATLAB program.

  2. Change the working directory to the directory that includes the M file and RecurDyn model.

    ../_images/image166_1.png

    Figure 22.58 Changing the working directory

  3. In the MATLAB command window, enter the name of M file.

    ../_images/image167_1.png

    Figure 22.59 Reserved variables from M file

  4. In the MATLAB command window, enter GRDHost.

    ../_images/image168_1.png

    Figure 22.60 Entered GRDHost

  5. And then, a new Simulink window with RecurDyn Plant Block appears.

    ../_images/image169_1.png

    Figure 22.61 RecurDyn Plant Block

  6. Open the Simulink model (simouse.mdl).

  7. Drag and drop RecurDyn Plant Block on the opened Simulink model window.

  8. Construct the control algorithm as shown in Figure 22.62.

  9. Save the Simulink model.

    ../_images/image170_1.png

    Figure 22.62 Steps to design control algorithm

  10. Terminate MATLAB program.

22.3.1.2.4. Step IV (In RecurDyn)

Step to set parameters for batch job of simulink

  1. Enter the executable file name and the installation directory of the MATLAB program.

  2. Enter the name of Simulink model that is built for the co-simulation with RecurDyn.

  3. Enter the name of M file to run Simulink model to be used for the batch job of Simulink model and click Export.

    ../_images/image0453.png

    Figure 22.63 Steps to run co-simulation

Note

The exported data includes the simulation time of Analysis dialog box. So, check the end time before export m file.

22.3.1.2.5. Step V (In RecurDyn)

Step to do the co-simulation

  1. Run the dynamic analysis of RecurDyn. RecurDyn automatically executes MATLAB program.

Step to see the Animation Result

  1. In RecurDyn, play the animation.

    ../_images/image1741.png

    Figure 22.64 Show the animation

Step to see the Plot Result

  1. To plot the output data, click the Result icon of Plot group in Analysis tab.

  2. Expand the Plant Input item in the database window on the right side. Expand the Control_torque. Double-click on Value in the section and adjust the label and axes to get the plot below.

    ../_images/image1752.png

    Figure 22.65 Plot of Value - Control_torque

  3. Expand the Plant Output item. Expand the displacement and velocity and double-click on each Value.

    ../_images/image1762.png

    Figure 22.66 Plot of Value - displacement and Value-velocity