Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
1 ratings:
 4 out of 5     Rate this Document

Why Am I Reading Negative Values From My Digital I/O Board?

Primary Software: Measurement Studio>>Visual C++ Support
Primary Software Version: 7.1
Primary Software Fixed Version: N/A
Secondary Software: Measurement Studio>>.NET Support
Hardware: Digital I/O (DIO)

Problem: When using Visual Basic or C functions to read from my digital I/O board, (e.g., PCI-653x), the returned value is negative. How is this possible?

Solution: Some functions*, such as DIG_Block_In, return the state of the DIO lines as a SIGNED integer (i16). The first bit in a signed data type indicates whether the value is positive (0) or negative (1). If the line that corresponds to the sign bit is high (logic 1), then the returned value will be a negative value.

To account for this, first convert the signed value to an unsigned value. For example...
If (DIO_value < 0) Then
DIO_value = 2^16 + DIO_value
End If

If you then convert this value to a binary representation, high and low lines will be indicated by values of 1 and 0 respectively.

*Refer to the "Traditional NI-DAQ Function Reference Help" in Start > Programs > National Instruments > NI-DAQ for a list of functions for DIO boards.

Related Links:

Attachments:





Report Date: 10/21/2004
Last Updated: 10/21/2004
Document ID: 3EKE2SPH

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit