Simulink RT - Lookup-Table for Strings

조회 수: 7 (최근 30일)
johnnynoc4sh
johnnynoc4sh 2020년 11월 25일
댓글: johnnynoc4sh 2020년 11월 27일
Hey folks,
I´m actually trying to communicate with some industrial devices via TCP. The protocol is ASCII-based SCPI command structure. For that application I would like to create a lookup-table which takes a numeric value as an input/index and replies with the corresponding string (for example '*IDN?). Since strings are kind of accepted in Simulink but aren´t well handable, do you have any hints how this can be done? The solution needs to be code-generatable since I use a Speedgoat-machine on which the program runs.
Best
Jonathan
PS: Since I work on a campus license, I can use any available toolbox.

채택된 답변

Dimitri MANKOV
Dimitri MANKOV 2020년 11월 27일
Hi Jonathan,
Which MATLAB release are you using? You could maybe try a construct based on String Constant and Multiport Switch blocks. String Constant blocks were introduced in Simulink in R2018a, and fully support code generation. For more information and examples about the usage of strings in Simulink, have a look here.
Best,
Dimitri
  댓글 수: 1
johnnynoc4sh
johnnynoc4sh 2020년 11월 27일
Thank you very much Dimitri for you support!
This is exactly what I tried in the first place. It kinda works, but isnt the most beautiful solution. But I found another option which might help other people out:
I use Stateflow charts which output the desired string. Remember to switch the chart action language from Matlab to C because strings are only supported for C action language.
Best

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Target Computer Setup에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by