Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

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?..
0 Kudos
Message 1 of 3
(4,575 Views)

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 
0 Kudos
Message 2 of 3
(4,571 Views)

Not anything related to NI. Contact Agilent.

0 Kudos
Message 3 of 3
(4,565 Views)