Download Developing Embedded Control System Platform using

Transcript
11.4. RESULTS
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
93
/∗ See s f u n t m p l d o c . c f o r more d e t a i l s on t h e macros b e l o w ∗/
ssSetNumSFcnParams ( S , 0 ) ;
/∗ Number o f e x p e c t e d p a r a m e t e r s ∗/
i f ( ssGetNumSFcnParams ( S ) != ssGetSFcnParamsCount ( S ) ) {
/∗ Return i f number o f e x p e c t e d != number o f a c t u a l p a r a m e t e r s ∗/
return ;
}
ssSetNumContStates ( S , 0 ) ;
ssSetNumDiscStates (S , 0) ;
if
( ! ssSetNumInputPorts ( S , 0 ) ) return ;
i f ( ! ssSetNumOutputPorts ( S , 8 ) ) return ;
f o r ( i =0; i <8; i ++){
ssSetOutputPortWidth ( S , i , 1 ) ;
}
ssSetNumSampleTimes ( S , 1 ) ;
ssSetNumRWork ( S , 0 ) ;
ssSetNumIWork ( S , 0 ) ;
ssSetNumPWork ( S , 0 ) ;
ssSetNumModes ( S , 0 ) ;
ssSetNumNonsampledZCs ( S , 0 ) ;
ssSetOptions (S , 0) ;
}
11.3.2
Target Block Files
Target block files are written in the TLC language and defines how code should be generated for the S-function. Two TLC functions are used, the InitializeConditions function
generates code that initialize the I/O-card, and the Outputs function generates code that
reads or writes to the I/O-card each time step. Since the TLC language is able to find out
which inputs and outputs of the blocks that are connected, code will only be generated
for the connected ports.
The target block files for the S-functions are in the appendix, from C.4.1 to C.4.4. Lines
start start with % are some kinds of TLC statements, like looping through all inputs or
outputs of a S-function. There are also some %< > tags in these files, that are TLC variables
or functions. All these will be replaced with some text in the generated code.
11.4
Results
Several Simulink diagrams were made to test how signals could be sent through the I/Ocard. With Real-Time Workshop generated code. This was done by connecting inputs
and outputs of the I/O-card together, so a signal that was sent to an output in Simulink
could be read by an input in Simulink.
11.4.1
Results of Analog Test
As mentioned in 10.4, the analog output channels of the I/O-card did not work as planned.
To be able to perform this test, a back up filter was made with regular resistors, capacitors