Analog and Digital Data Acquisition using the DI-148/158 and ActiveX
On this Page
Download the AnalogDigitalAcq Sample Program
Enable, Assign and Display Additional Analog Channels/Digital Bits
Issue
You are unable to simultaneously display analog and digital data or toggle individual digital bits using a DI-148/158 and the ActiveX control library.
Resolution
To resolve these issues carefully follow the steps below.
Download the AnalogDigitalAcq Sample Program
Download the AnalogDigitalAcq Visual Basic sample program at: http://www.dataq.com/develop/vb6.php?file=113.
Enter a DeviceID
Before running the SimAnaDigAcq sample program you must enter a Device ID.
The DeviceID consists of the COM port number that your DI-148/158 is installed onto, the model number (148 or 158) and the baud rate. The format is as follows:

Figure 1 illustrates how/where to enter the DeviceID.
For further instruction on determining the appropriate DeviceID see "Device Drivers and Device IDs" under "Reference Materials" in the ActiveX help file. You can download the latest ActiveX help file at http://www.dataq.com/support/documentation/helpfiles/index.htm.
Enable, Assign and Display Additional Analog Channels/Digital Bits
- Add Additional Analog Channels (for the purpose of this example we'll add analog channel two):
- Begin by adding channel two to the ChannelList as shown in Figure 2. Note — channel two on your DI-148/158 corresponds to channel one in the ChannelList property (channel one on your DI-148/158 corresponds to zero).
- Choose the object view and double-click DQChart on the VB toolbar (Figure 3). Resize and relocate the chart as you wish.

Figure 3
Double-click DQChart in the toolbar to add a chart to the form - Set the DQChart Channel property to 2 in order to display channel two data (Figure 4).
- With the chart placed in the form and the Channel property set, add the DQChart to the chart list as shown in Figure 5.
- Edit the DataqSdk1.ADChannelCount property to reflect the total number of channels enabled (Figure 6).
- Add Additional Digital Bits (for the purpose of this example we'll add digital bit 3):
- Choose the object view and double-click DQChart on the VB toolbar (Figure 7). Resize and relocate the chart as you wish.

Figure 7
Double-click DQChart in the toolbar to add a chart to the form - Set the DQChart Channel property to 0 (zero) and the DQChart DigitalMask property to 2048 - PlotBit11 (Figure 8)

Figure 8
Set the DQChart DigitalMask property to 2048 — PlotBit11 - With the chart placed in the form and the Channel and DigitalMask properties set, add the DQChart to the chart list as shown in Figure 9.
- Choose the object view and double-click DQChart on the VB toolbar (Figure 7). Resize and relocate the chart as you wish.
- Set the Direction of the Digital Bits
Before individual bits can be toggled the direction of the digital bits must be set.
The DigitalDir constant is used to set the direction of the digital bits (as outputs). This is accomplished by setting the DataqSdk1.DigitalOutput property equal to the DigitalDir constant. Individual bits can be set as inputs on the same line (Figure 10). - Toggle Individual Bits (outputs only)
With the direction of the digital bits set individual bits can be toggled as shown in Figure 11. Each digital port assigned to DataqSdk1.DigitalOutput will output a 1 (high).
Applies To
The DI-148/158 and AnalogDigitalAcq sample program.





