Download Real-Time Workshop

Transcript
Writing S-Functions for Real-Time Workshop
10
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Classes of Problems Solved by S-Functions . . . . . . . . . . . . .
Types of S-Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Basic Files Required for Implementation . . . . . . . . . . . . . .
10-3
10-3
10-4
10-7
Writing Noninlined S-Functions . . . . . . . . . . . . . . . . . . . . .
10-8
Writing Wrapper S-Functions . . . . . . . . . . . . . . . . . . . . . . . 10-9
MEX S-Function Wrapper . . . . . . . . . . . . . . . . . . . . . . . . . . 10-9
TLC S-Function Wrapper . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-13
The Inlined Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-18
Writing Fully Inlined S-Functions . . . . . . . . . . . . . . . . . . . 10-19
Multiport S-Function Example . . . . . . . . . . . . . . . . . . . . . . . 10-20
Writing Fully Inlined S-Functions with the mdlRTW
Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
S-Function RTWdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
The Direct-Index Lookup Table Algorithm . . . . . . . . . . . . .
The Direct-Index Lookup Table Example . . . . . . . . . . . . . .
Writing S-Functions That Support Expression
Folding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Categories of Output Expressions . . . . . . . . . . . . . . . . . . . .
Acceptance or Denial of Requests for Input Expressions . .
Utilizing Expression Folding in Your TLC Block
Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10-21
10-22
10-22
10-24
10-46
10-47
10-52
10-56
Writing S-Functions That Specify Sample Time
Inheritance Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-62
Writing S-Functions That Support Code Reuse . . . . . . . 10-65
Writing S-Functions for Multirate Multitasking
Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-66
Rate Grouping Support in S-Functions . . . . . . . . . . . . . . . . 10-66
ix