# Archived: Convert Traditional NI-DAQ (Legacy) Binary Data to Voltage Values

NI does not actively maintain this document.

This content provides support for older products and technology, so you may notice outdated links or obsolete information about operating systems or other relevant products.

## Overview

Note: This page is about NI-DAQ also known as Traditional NI-DAQ (Legacy). NI-DAQmx replaced Traditional NI-DAQ (Legacy) in 2003. NI strongly recommends using NI-DAQmx for new designs and migrating existing Traditional NI-DAQ (Legacy) applications to NI-DAQmx. Please review the Getting Started with NI-DAQmx guide for more information on migration. Many Traditional NI-DAQ (Legacy) data acquisition functions return the actual binary codes returned by the A/D converter. This document explains how to convert the binary codes into voltage values.

## Overview

Many Traditional  NI-DAQ (Legacy) data acquisition functions -- such as AI_Read, DAQ_Start, and SCAN_Op -- return binary codes. The LabVIEW AI Read.vi (in output type 2) also returns binary information. Generally, a call to AI_VScale returns the voltage value corresponding with a binary code, but you may want to manually calculate the value. For example, suppose you're acquiring data in one program and saving it to a file. Then, you have a second program that has no other DAQ functionality than to read the data in the file. The second program does not have to load nidaq32.dll in order to call AI_VScale. Instead, you can have the program do a simple mathematical calculation to convert the binary codes into voltage values.

## The Information You Need

In order to convert from the binary code, you need the following information about the specific DAQ operation that acquired the data:

• The resolution of the board
• The gain
• The range
• The polarity

The codes, or individual binary values, are evenly distributed over the entire range of the A/D converter. The number of codes is dependent on the resolution of the board: Most of the National Instruments DAQ boards have 12-bit resolution, which means the boards have 4096 codes.

The range of the A/D converter for the National Instruments DAQ products is either -5 to +5 V, or 0 to 10 V, depending on the polarity setting. Notice that each range is 10 V in size. So, each of the 4096 codes is distributed over a 10 V range in either case.

However, you still need to factor in the pre-conversion gain, which effectively changes the range over which the codes are distributed. If, for example, a gain of 10 is applied, the effective range of the A/D converter is -0.5 to +0.5 V, and the codes are distributed over a 1 V range. Thus, each code is worth 1/10th as much voltage, resulting in higher accuracy.

## Conversion Formulas

In order to calculate the voltage represented by a specific code, you need to know the code width, or the amount of voltage that each code represents. You calculate the code width using the following formula: For a typical E Series board with a resolution of 12 bits, and a range of -5 to +5 V set at a gain of 1, the code width is 2.4 mV.

By multiplying the code returned from the DAQ operation by the code width, you can calculate how far in volts the code was from the bottom of the range. All that's left is to remember what the gain adjusted range bottom was, and subtract that from the voltage offset: For example, suppose a typical 12-bit E Series board returned a code of 3212 in bipolar mode (range = –5 to + 5 volts) with a gain of 5. The voltage value that corresponds is:
{"ft_lang_label":"__label__en","ft_lang_prob":0.91550475,"math_prob":0.8993464,"size":2771,"snap":"2020-45-2020-50","text_gpt3_token_len":623,"char_repetition_ratio":0.11926274,"word_repetition_ratio":0.0041067763,"special_character_ratio":0.2284374,"punctuation_ratio":0.10873441,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97147197,"pos_list":[0,1,2,3,4,5,6,7,8,9,10],"im_url_duplicate_count":[null,9,null,9,null,9,null,9,null,9,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-22T07:27:20Z\",\"WARC-Record-ID\":\"<urn:uuid:682272d0-7ada-4399-8dce-4566e132e972>\",\"Content-Length\":\"71286\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:3c2adc79-ed85-4022-8042-9104246dfa93>\",\"WARC-Concurrent-To\":\"<urn:uuid:92a9d46e-3a83-4352-aa45-d60bc62b8946>\",\"WARC-IP-Address\":\"104.16.35.15\",\"WARC-Target-URI\":\"https://www.ni.com/nl-be/support/documentation/supplemental/06/archived--convert-traditional-ni-daq--legacy--binary-data-to-vol.html\",\"WARC-Payload-Digest\":\"sha1:6IG6OTRTGNPWQBA5UGNF2QTYY2K6QLKO\",\"WARC-Block-Digest\":\"sha1:RGDOUKF3JHEK3OW375YJV7BCYZHUY3CY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107878921.41_warc_CC-MAIN-20201022053410-20201022083410-00522.warc.gz\"}"}