ReadString visa-error timeout issue

ArnMan

Board Regular
Joined
Aug 30, 2017
Messages
69
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello,
I have a small vba program I am trying to modify, to access a Fluke 187 Multimeter through a com port (4) but am having a issue when it goes to run the ReadString() code.

I didnt make this module, I and trying to adapt it from GpiB to com port.
I can successfully open, and send a command to the meter, but when when you click the read from meter button, (Read *IDN?), it seems to pause for about 10 seconds, and then give me a "visa error = timeout expired before operation completed" error and stops.
I set the line of code in question in Red Bold letters so you can find it better, below in the code block.

I can use Putty and connect to the meter and run the ID command and it will spit out in putty Make,Model,Serial number information. I just need to bring that information from the meter to Excel.
I got this vba from the Keysight website

https://community.keysight.com/thread/21917

I am sure there is a better way to do this without other users needing to download any other code or software.


Code:
Option Explicit
    
    Dim ioMgr As VisaComLib.ResourceManager
    Dim instrAny As VisaComLib.FormattedIO488
    Dim instrQuery As String
    Dim instrAddress As String
Public Sub Intialize_Click()

On Error GoTo ioError
    
    instrAddress = Range("B4").Value
    
    Set ioMgr = New VisaComLib.ResourceManager
    Set instrAny = New VisaComLib.FormattedIO488
    Set instrAny.IO = ioMgr.Open("ASRL4::INSTR")
    Dim serInfc As VisaComLib.ISerial
    Set serInfc = instrAny.IO
    serInfc.BaudRate = 9600
    serInfc.FlowControl = ASRL_FLOW_NONE
    serInfc.Timeout = 10000
    instrAny.IO.SendEndEnabled = True
    instrAny.IO.TerminationCharacter = 10          ' could be 10 (line feed) or 13 (carriage return)
    instrAny.IO.TerminationCharacterEnabled = True
    instrAny.IO.Timeout = 10000
 
    Exit Sub

ioError:
    MsgBox "An IO error occured:" & vbCrLf & Err.Description

End Sub


Public Sub cmdSendIDN_Click()
    
    On Error GoTo ioError
          
    instrAny.WriteString ("ID")
    MsgBox "ID has been sent to Instrument"
    
    Exit Sub

ioError:
    MsgBox "An IO error occured:" & vbCrLf & Err.Description

End Sub

Public Sub cmdReadIDN_Click()
    
    On Error GoTo ioError
               
   [COLOR=#ff0000][B] instrQuery = instrAny.ReadString()[/B][/COLOR]
    
    MsgBox instrQuery, , "Instrument response to ID"
        
    Exit Sub

ioError:
    MsgBox "An IO error occured:" & vbCrLf & Err.Description
        
        
End Sub

Public Sub instrclose_Click()
    
    On Error GoTo ioError
          
    instrAny.IO.Close
    MsgBox "Connection Closed"
    
    Exit Sub

ioError:
    MsgBox "An IO error occured:" & vbCrLf & Err.Description

End Sub

Any help would be greatly greatly appreciated.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Yes, that is true, IDN is used for Agilient and fluke calibrators and big bench multimeters, but for the Fluke 187, is just a hand held multimeter ID is the command to get the make model and serial number. The meter uses 2 char commands, ID, QM and a couple of others. I can use those commands in Putty to get certain information.
 
Upvote 0
You need to log what Putty actually sends and add it to the VBA string.
putty - Session->Logging. Select all session output and specify a log file.

Serial needs terminating characters I think.

It may be ('ID\n') being sent
 
Last edited:
Upvote 0
Hello,
here I the result of my putty.log
I ran 2 commands ID and QM
Code:
=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2019.08.19 10:40:46 =~=~=~=~=~=~=~=~=~=~=~=
ID
0
FLUKE 187, V2.02,0000000000
QM
0
QM,+0.0037 V AC
that is all it had, and everything is all in 1 line.

Here is a pdf showing remote specifications commands for the 187

http://www.pewa.de/DATENBLATT/DBL_FL_FL187-9-89IV_BEFEHLSSATZ_ENGLISCH.PDF
 
Upvote 0
Hi,

according to the manual you linked to: Command Syntax: ID< CR >
According to the code: instrAny.IO.TerminationCharacter = 10 which is linefeed


I don't know if that line of code actually sets the value but try changing it to 13.

If that doesn't work try commenting it out and sending \r as part of the write string.


That's about my limit....
 
Last edited:
Upvote 0
I tried that and it didn't work.

But, however I do have a Keysight 3458A on my desk, already hooked to my computer. I took that IDN, the original unmodified, except for gpib address, and ran it.
I got the same response. Timeout on Readstring.
I was thinking it was just the com port.
Could it be something not being referenced? It'll talk to it but not read from it.
 
Upvote 0
Ok here is a update of what I have found out and done
The original above code will read from a Fluke5520A Calibrator and Fluke PM6681 Frequency Counter, Using *IDN? and return a response. It will send commands to my Keysight 3458A DMM just fine, but not read anything from it.

I was trying to access a Fluke 187 Handheld dmm but with no luck.
So I found a Fluke 789 handheld dmm and the code worked perfectly. I ran it over and over and it works, for a couple of days in a row.
Then I had to return the meter.
I have been given another Fluke 789 that I can use and perfect my excel vba scrip with.
Problem is, although I can use Putty to connect, my, was working vba script, isn't connecting to the new 789.

When I use Putty to send a command I will see a small PCicon in the 789 display. It pops up for a few seconds, then goes away. But whenI send commands from excel that little display icon does not show up, hencegiving me the Visa timeout error.
It’s just not opening up the com port or something.

Here is the vba that I was using yesterday that was workingwith the first Fluke 789.

So any other places to look or things to change would be surely appreciated.

Code:
Sub Fluke789Reading()[/COLOR][/SIZE][/FONT]

[FONT=Calibri][SIZE=3][COLOR=#000000]    Dim nameArray As Variant, full As String, reading As String, command As String, mode As String, unitrange As String
    Dim fluke798 As Range
    
    Dim ioMgr As VisaComLib.ResourceManager
    Dim instrument As VisaComLib.FormattedIO488
    Dim sndBuffer As String
    Dim rcvBuffer As String
    Dim myCommStr As String
    Dim myStatus As Integer
    
   
    Set ioMgr = New VisaComLib.ResourceManager
    Set instrument = New VisaComLib.FormattedIO488
    
    'Set instrument.IO = ioMgr.Open(myCommStr)
    Set instrument.IO = ioMgr.Open("ASRL3::INSTR")
    
    ' Set serial interface-specific attributes...
    Dim serInfc As VisaComLib.ISerial
    Set serInfc = instrument.IO
    serInfc.BaudRate = 9600
    serInfc.FlowControl = ASRL_FLOW_NONE
    serInfc.Timeout = 10000
    instrument.IO.SendEndEnabled = True
    instrument.IO.TerminationCharacter = 13          ' could be 10 (line feed) or 13 (carriage return)
    instrument.IO.TerminationCharacterEnabled = True
    instrument.IO.Timeout = 10000
    
    instrument.WriteString "QM"
    
    
    rcvBuffer = instrument.ReadString()
        If rcvBuffer = 0 Then
    rcvBuffer = instrument.ReadString()
        End If
  
    If Len(rcvBuffer) > 0 Then                   'if not empty[/COLOR][/SIZE][/FONT]

[FONT=Calibri][SIZE=3][COLOR=#000000]        nameArray = Split(rcvBuffer, ",")        'attempt to split on comma[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]        If UBound(nameArray) < 1 Then       'if comma doesn't exist (1 element in array)[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]            nameArray = Split(rcvBuffer)         'attempt to split by space (" ")[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]            If UBound(nameArray) > 0 Then   'if at least one space exists
                reading = nameArray(0)        'FIRST_1 FIRST_2 LAST doesn't work
                command = nameArray(1)         'multiple last names won't work either
                mode = nameArray(2)
                unitrange = nameArray(3)
                unitpercent = nameArray(4)
                unitloop = nameArray(5)
                unitohm = nameArray(6)
            
            Else
                reading = rcvBuffer                'one word only
            End If
        Else                                'comma exists so last name is first in array
            command = Trim(nameArray(0))      'remove first space after comma
            reading = Trim(nameArray(1))
            mode = Trim(nameArray(2))
            
        If UBound(nameArray) = 3 Then
            
            unitrange = Trim(nameArray(3))
        Else
            'unitrange = Trim(nameArray(3))
        End If
        If UBound(nameArray) = 4 Then
            
            unitpercent = Trim(nameArray(4))
        Else
            'unitpercent = Trim(nameArray(4))
        End If
        If UBound(nameArray) = 5 Then
            
            unitloop = Trim(nameArray(5))
        Else
            'unitloop = Trim(nameArray(5))
        End If
        If UBound(nameArray) = 6 Then
            
            unitohm = Trim(nameArray(6))
        Else
            'unitohm = Trim(nameArray(6))
        End If
            
        End If
    End If
    
   ActiveCell = reading
   
[FONT=Calibri][SIZE=3][COLOR=#000000]End Sub

[/COLOR][/SIZE][/FONT]
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top