NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
Ironcoder
Posts: 4
0 Kudos

Reading DINT Format[Need Help!!!]

Hi, I am trying to read measurements from agilent 3458a multimeter and i wanted to know if anyone has idea how to read in DINT format what conversions are needed. If there is any code availble that would be great!.. currently i read in like this : byte[] ac = DMM1.IO.Read(4); // Reading single value. double a = System.BitConverter.ToDouble(ac, 0); i multiply this value with the scale factor but the values are coming out wrong. Any suggestions?..
Member
Ironcoder
Posts: 4
0 Kudos

Re: Reading DINT Format[Need Help!!!]

So i found this procedure in vb by Agilent that is suppose to do the thing

but the problem here is that with IO.Read(4) , the bytes i recieve in a byte array aren't coming right , first byte is always wrong , rest of them are fine but with reverse order. for e.g if i get 10, 70, 2, 0 when i read a single reading  from instrument. if i divide the reading from instrument by scale factor , it's give the  DINT value and if i convert that to byte array , it gives 110(first byte changed),0,2,70(rest order swaped)..what's going on here? ..even using this is not helping ..Am i doing something wrong in the configuration?..

Private Sub cmdMeasureNorm_Click() 
    Dim readByte() As Byte 
    Dim rdg() As Long 
    Dim reading() As Double 
    Dim i As Integer 
    Dim iscale As String 
    Dim numReadings As Integer 
 
    numReadings = txtReadings.Text 
 
    ReDim reading(numReadings) 
    ReDim rdg(numReadings) 
 
    timeResult.Text = "" 
    txtResults.Text = "" 
    timeResult.Refresh 
    txtResults.Refresh 
    StartTimer 
 
    With DMM 
        .WriteString "PRESET NORM"                         'TARM AUTO, TRIG SYN, DCV AUTORANGE 
        'DINT good for 5-1/2 or more digits 
        .WriteString "OFORMAT DINT"                        'FAST AND ACCURATE - 4-BYTE INTEGERS 
        .WriteString "NRDGS 15, SYN"                       '15 READINGS PER TRIGGER, SYN SAMPLE EVENT 
 
        For i = 1 To numReadings 
            readByte = .IO.Read(4)                         'SYN EVENT, 4-bytes per DINT value 
            'build 4-byte long values 
            If readByte(0) > 127 Then                      'negative 
                rdg(i) = CLng(-2147483648#) + (readByte(0) - CLng(128)) * CLng(16777216) _ 
                        + readByte(1) * CLng(65536) _ 
                        + readByte(2) * CLng(256) + readByte(3) 
            Else                                           'positive 
                rdg(i) = readByte(0) * CLng(16777216) + readByte(1) * CLng(65536) _ 
                        + readByte(2) * CLng(256) + readByte(3) 
            End If 
        Next i 
 
        'get instrument scale value and multiply 
        'with all long values to get instrument measurement 
        .WriteString "ISCALE?"                             'scale factor for DINT format 
        iscale = .ReadString 
 
        For i = 1 To numReadings 
            reading(i) = Round((rdg(i) * Val(iscale)), 6) 
        Next i 
 
        timeResult.Text = EndTimer                         'readings in hand 
        timeResult.Refresh 
 
        'output to textbox 
        For i = 1 To numReadings 
            txtResults.SelText = i & ": " & Str$(reading(i)) & " volts DC" & vbCrLf 
        Next i 
    End With 
End Sub 
Active Participant nyc
Active Participant
Posts: 1,606
0 Kudos

Re: Reading DINT Format[Need Help!!!]

Not anything related to NI. Contact Agilent.

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page