I/O mapping is the main feature of the Rapid Prototyping Code Generator. It allows you to map the textual elements of a Rational Statemate model into the input/output signals of I/O card.
The mapping process consists of the following steps:
3.The two first steps are usually made only at the beginning of the process. The other steps may be performed every time, when you want to change something in the model or in run time execution of the model.
Writing the I/O card description and driver code are correlated processes. In fact, the
.crd
file is input information for the driver functions, so the content of this file depends on the needs of the driver. For example, the port offset field contains some string. In the example (theonyx_mm_dio.crd
file shown in the following figure), every element of the#port list
paragraph corresponds with some port of the card. However, it is sometimes only necessary to take one bit of the real port and to map it to some condition. In this case, it is more comfortable to declare every pin as a separate virtual port and to use the#port offset
field to declare the two information elements: real port offset and pin number of the port. Then the driver can unpack this field and read the two values as specified. It might look like the following string:where 1 is the port offset, and 5 is the pin number.
Although such a driver tends to be a little more complicated, this approach sometimes makes sense because it allows for the simplification of the model.
I/O mapping itself is performed using the I/O Mapping dialog form shown above in the following figure. It contains the mapping matrix and the Polling Rate pop down menu. Note that there are four fields in every line of the matrix.
The name is selected by using the Choose window or by typing in the name directly from the keyboard.
The I/O card field may be filled out by placing the mouse cursor over the cell in the desired row and column and pressing the right mouse button. Then, a pop-down menu appears containing the current list of
.crd
files detected in the<workarea>/rprt
directory.When the card name is chosen, the user can choose the port name in the next field of the matrix. This is done in the same manner as the previous field. The pop-down menu presents the list of available ports.
When the port name is chosen, the I/O field is automatically filled out by the proper value for this port. Usually there is no need to change it, because this value is an inseparable part of the I/O card and is installed in the
init_driver
function or built-in.After the I/O mapping is done, it’s time to set the parameters of the INPUT tasks, (if input mapping exists).
You can define one or two tasks for the polling of I/O cards. The second task is needed only if there are more than a few I/O cards, all participating in the input mapping, and with different polling rates. In this case, the code generator separates all of the I/O cards into two groups: one group with high a polling rate and the other with a low polling rate. The mapped elements belonging to the first group are polled by the
HINPUT_TASK
, and the mapped elements from the second group are polled by theLINPUT_TASK
. The actual polling rate values can be set using the Target Task Settings window shown in the following figure.