Technical FAQs

Ask a Question

How to access the 'DDT Type' IO variable in a Unity application using referenced variables.

Goals and Symptoms
How to access the 'DDT Type' IO variable in a Unity application using referenced variables.

Facts and Change
Unity 8.1 and above

Causes and Fixes
Referenced variable allows the user to access the IO 'DDT Type' variables (%I, %Q and %IW) and use them directly in the Unity application without having to convert each input and output point on a module to either a %MW or %M variables. The following is a procedure on how to create the referenced variable.
 
  • Open the Data Editor.
  • Click on the DDT Types tab.
  • Enter a reference name (i.e., MyMotor) -Assign it to the type <Struct>.

 
  • Add the name for new variable type (i.e., Feedback, Start, Stop, Status). The new variable is referred to as a referenced variable.
  • Click on the selction box next to the Type textbox to open the Variable Type Selection window.
  • Click on the REF_TO checkbox to select it.
  • Select the appropriate Type.
  • Click on OK.
  • Repeat the last five (5) steps for any other new variable type.

 
  • Select the 'R/W Rights.of Referenced Variable' checkbox as needed for the module IO type.
  • Click on the Variable tab.
  • Add the located variable name (i.e., MyMotor).
  • Select the new 'DDT Type' that you created earlier.
  • If you click on the + next to the variable name, it will show the reference variables that was created earlier.

 
  • Open the Project Settings and select the 'Force reference initialization' checkbox.
  • Click on Apply.
  • Click on OK.



If you try to build the application, it will fail.



To correct the problem you need to add a value to the referenced variable. This is what the 'Forced reference initialization' is looking for.
  • Double click on Value textbox.
  • Click on the button next to the textbox.

 
  • Drill down to the value for the I/O module channel.
  • Click on the Value item to highlight it.
  • Click on OK.
  • Repeat the last 4 steps for all the other referenced variables.
  • Save the changes.

 
  • Build the application.

 
  • To access the referenced variable in either logic or the animation table,
  • Browse for the referenced variable name
  • Click on the item to highlight it.

 
  • Add a ^ after the referenced variable name.


 
Was this helpful?
What can we do to improve the information ?