5.13. Analog/Digital Interface

[Note]Note

The ADInterfaceMCC (Analog/Digital Interface) is an interface between the BCVTB and USB-data acquisition devices. This interface has been tested for one device (USB-1208LS) of the Measurement Computing Corporation and is only supported on Windows. This interface will work properly only if the drivers of the Data Acquisition device have been installed correctly and the device has been configured. Read the user guide available at http://www.mccdaq.com/PDFmanuals/USB-1208LS.pdf and the Data Acquisition software manual http://www.mccdaq.com/PDFs/Manuals/DAQ-Software-Quick-Start.pdf to learn how to install and to configure the USB-1208LS.

The BCVTB contains an actor, called ADInterfaceMCCReader, that can read from ADInterfaceMCC devices and an actor, called ADInterfaceMCCWriter, that can write to ADInterfaceMCC devices. Both actors use a configuration file that specifies the ADInterfaceMCC devices. The next sections describe how to write these configuration files, and how to set up a model that reads from and writes to ADInterfaceMCC devices.

The ADInterfaceMCCReader actor reads an xml configuration file to determine what data it needs to read from ADInterfaceMCC devices. The xml configuration file has the following syntax: It starts and ends with

<?xml version="1.0" encoding="utf-8"?>
     <ADInterfaceMCC>
     <!-- Child elements are not shown. -->
     </ADInterfaceMCC>

The above element ADInterfaceMCC has at least one child element of the form

<Object BoardNumber = "0" ChannelNumber = "0" ChannelGain = "2" ChannelOptions = "0"  ApplicationTag = "read"/>

The element name needs to be set to Object. The attribute BoardNumber is the board number associated with the board used to collect the data when it was installed with InstalCal. The attribute ChannelNumber is the A/D (Analog/Digital) channel number. The attribute ChannelGain is the A/D range code. If the board has a programmable gain, it will be set according to this argument value. The attribute ChannelOptions is reserved for future use by the hardware manufacturer and should be set to zero. The attribute ApplicationTag is a value that can be set to read or write depending on whether the interface should be used in the READ or WRITE mode. Table 5.9, “Attribute's values for the USB-1208LS Data Acquisition Device (READ mode).” gives a short overview about the values that the attributes could have in the configuration file.


The ADInterfaceMCCWriter actor reads an xml configuration file to determine what data it needs to write to ADInterfaceMCC devices. The xml configuration file has the following syntax: It starts and ends with

<?xml version="1.0" encoding="utf-8"?>
     <ADInterfaceMCC>
     <!-- Child elements are not shown. -->
     </ADInterfaceMCC>

The above element ADInterfaceMCC has at least one child element of the form

<Object BoardNumber = "0" ChannelNumber = "0" ChannelGain = "3" ChannelOptions = "0"  ApplicationTag = "write"/>

The element name needs to be set to Object. The attribute BoardNumber is the board number associated with the board used to collect the data when it was installed with InstalCal. The attribute ChannelNumber is the D/A (Digital/Analog) channel number. The maximum allowable channel depends on which type of D/A board is being used. The attribute ChannelGain is the D/A range code. If the device has a programmable gain, it will be set according to this argument value. If the specified range is not supported, the function will return a BADRANGE error. If the gain is fixed or manually selectable, you must make sure this argument matches the gain configured for the device. The attribute ChannelOptions is reserved for future use by the hardware manufacturer and should be set to zero. The attribute ApplicationTag is a value that can be set to read or write depending on whether the interface should be used in the READ or WRITE mode. Table 5.10, “Attribute's values for the USB-1208LS Data Acquisition Device (WRITE mode).” gives a short overview about the values that the attributes could have in the configuration file.


The ADInterfaceMCCReader and the ADInterfaceMCCWriter actor can be used in the same Ptolemy II model. In this section, we will explain how to configure a Ptolemy II model that writes to and reads from ADInterfaceMCCdevices. This example can be found in the directory bcvtb/examples/adInterfaceMCC-roomControl. A similar example can also be found in the directory bcvtb/examples/adInterfaceMCC-room.


Figure 5.45 shows a Ptolemy II system model that uses the ADInterfaceMCCReader and the ADInterfaceMCCWriter actors. To configure the ADInterfaceMCCReader, double-click on its icon and add the name of its configuration file that has been developed as described in Section 5.13.2, “Reading from ADInterfaceMCC” . There is also a check-box called continueWhenError. If activated and an error occurs, then Ptolemy II will continue the simulation and the actor will output at its ports the last known value and the error message, unless the error occurs in the first step, in which case the simulation stops. If deactivated and an error occurs, then the simulation will stop, the error message will be displayed on the screen and the user is required to confirm the error message by clicking on its OK button. Thus, select this box if the BCVTB should continue its operation when a run-time error occurs.

The ADInterfaceMCCReader has the following ports: There is one input port, which is a trigger port. If the SDF Director is used in the Ptolemy II system model, then this port need not be connected. The ADInterfaceMCCReader has the output ports shown in Table 5.11, “Output ports of the ADInterfaceMCCReader actor.”.


The configuration of the ADInterfaceMCCWriter actor is similar to the configuration of the ADInterfaceMCCReader. To configure the ADInterfaceMCCWriter, double-click on its icon and add the name of its configuration file that has been developed as described in Section 5.13.3, “Writing to ADInterfaceMCC” . There is also a check-box called continueWhenError. If activated and an error occurs, then Ptolemy II will continue the simulation and the actor will output the error message at its ports, unless the error occurs in the first step, in which case the simulation stops. If deactivated and an error occurs, then the simulation will stop, the error message will be displayed on the screen and the user is required to confirm the error message by clicking on its OK button. Thus, select this box if the BCVTB should continue its operation when a run-time error occurs.

Input into the actor are values that will be written to the ADInterfaceMCC device according to the order specified in the xml configuration file.

The ADInterfaceMCCWriter has one multiport input. This port is used to collect the data that need to be sent to the ADInterfaceMCCdevices. The ADInterfaceMCCWriter has the output ports shown in Table 5.12, “Output ports of the ADInterfaceMCCWriter actor.”.