Home Questions Unable to use task-wide parameters in Stateflow

Unable to use task-wide parameters in Stateflow

DWQA QuestionsCategory: Custom Task DevelopmentUnable to use task-wide parameters in Stateflow
Margaret Schrayer asked 5 years ago
Hello, In order to simplify the process of setting parameters to be used by multiple trial protocols, I have made most of our trial parameters (including start target row, mean target velocity, target X position, etc.) into task-wide parameters. I am currently trying to devise a method for accessing the task wide parameters to use in the Stateflow chart and in other Simulink blocks, using their constant names to index them (the same way we would access Trial Protocol data obtained from the GUI Control block output). I am trying to modify the GUI Control block to output a structure analogous to the Trial Protocol output, with the Task Wide Parameters. Is there a simpler way to access task-wide parameters to use in the task program?
Margaret Schrayer replied 5 years ago

Update: issue resolved. Thanks!

1 Answers
Koloman Varady Staff answered 5 years ago
Hi Margaret, The GUI Control block already has set up the Task Wide Parameters as a 'Tag'. With a From block, you can select Task_Wide_Parameters to access the contents of the Task Wide Parameters and pass that into your Stateflow. Section 10.9 of the Create Task Programs for Dexterit-E 3.6 user guide has a list of the Tags we have already set up. Cheers, Koloman
Margaret Schrayer replied 5 years ago

Thank you for your response! Using that tag directly does not work: If I pass the contents to my Stateflow and try to index using the names of the constants (e.g. Task_Wide_Parameters[MEAN_VELOCITY] or Task_Wide_Parameters[START_TARGET_ROW]), a value of 0 is obtained at every index even if other values have been specified for those parameters. I have been trying to use the data from the tag and convert it to a format which will allow me to read the task wide parameters using those constant names.

Koloman Varady Staff replied 5 years ago

Hm, did you set First index = 1 for the input port?

Outside the Stateflow, you can use a Selector and use the constant names ie. [MEAN_VELOCITY START_TARGET_ROW] but that’s a bit awkward if the point is to use the indexing in Stateflow.

The Tag should work, it is a vector with the contents of the Task Wide Parameters. You could put a scope on it and then just try using numbers instead of constant names to debug. For example, you could see on the scope what the second task wide parameter is and then visually compare it to Task_Wide_Parameters(2) in Stateflow

Margaret Schrayer replied 5 years ago

Thank you for your response! Using that tag directly does not work: If I pass the contents to my Stateflow and try to index using the names of the constants (e.g. Task_Wide_Parameters[MEAN_VELOCITY] or Task_Wide_Parameters[START_TARGET_ROW]), a value of 0 is obtained at every index even if other values have been specified for those parameters. I have been trying to use the data from the tag and convert it to a format which will allow me to read the task wide parameters using those constant names.

Margaret Schrayer replied 5 years ago

Thanks, I will try that!