How do I connect one model's RTDB variable to another model's RTDB variable?
Question
How do I connect one model's RTDB variable to another model's RTDB variable?
Answer
To connect one model's RTDB variable to another model's RTDB variable, i.e to share RTDB variables between two models the variables must have the same name.
- For the variables to have the same we must first turn off (uncheck) the Hierarchical RTDB Variable Names checkbox in the SimWB -> Preferences -> RTDB tab. Also, in the same tab turn on (check) the option Append RTDB variables as AIO or DIO. Please refer to the preferences tab documentation for additional information.
- Create and upload the RTDB from model1. Say variable A is the output of model1 and is also the input for model2. Variable A will be created in the RTDB with point type AO.
- Create and append the RTDB from model2. Since variable A already exists in the RTDB with type AO and its append with another variable A with type AI, the new point type with be AIO which indicates that the RTDB variable is treated as both input and output.
- Once we have created and appended the RTDBs from all the models we can start the code generation process for the models.
- Generate code for model1.
- Generate code for mode2.
- Create a test with both models. Make sure you understand the data dependencies between the models. Ideally since the same variable is shared between the 2 models create the test such that model2 runs only after model1 is completed and the variable A is written to by model1.
Note: When you use an AIO variable this way, you cannot modify the value of the variable in the RT-viewer. If you do, the upstream model (model1) overwrites your change in the next-time step.