Parallel timer operation in App Designer
10 views (last 30 days)
Show older comments
Hi all,
Recently, I try to build a control and monitoring system through App Designer and I need multiple timers running at the same time (parallel). For example, I need a timer for CAN communication transceiving/ receiving data, a timer for MODBUS communication which also transceive/receive data, and a control optimization timer for heavy control optimization calculation. Ideally, I want them to operation parallelly where communication timers are triggered every 0.5s and the control timer is triggered every 5s, but I found the MATLAB is a single thread system, in which each timer is run in series. Therefore, I tried the parallel computing toolbox to make them run parallelly. Unfortunately, the MALTB command window shows that the app objs are not supported by the parallel computing toolbox. Does anyone know another way to achieve this purpose?
0 Comments
Answers (1)
Walter Roberson
on 6 Feb 2021
Parallel processes can run timers. They cannot share appdesigner objects with the other processes, but that just means that you have to be more selective about what you pass back and forth, and you cannot have the parallel processes directly change the properties of the app object and children, including not being able to affect user graphics directly.
What you can do is create parallel queues to do message passing between the parallel processes and the controller. For example the MODBUS controller can receive data and queue it back to the controller process, which can then send it to the process that needs to process the data.
There is naturally the question of how efficient those parallel queues are.
You might also be able to use memmap() to have multiple processes talk to the same file, which might be more efficient than memory passing.
There is also a File Exchange contribution for Shared Memory that is designed for Unix systems (Linux, Mac) but should not take much work to adapt to MS Windows.
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!