Quantcast
Channel: Instrument Control (GPIB, Serial, VISA, IVI) topics
Viewing all articles
Browse latest Browse all 5566

GPIB Unable open Visa resource in C#

$
0
0

Hi,
I am programming in C# and using the RsInstrument_CSharp_Hello_Word_Example for open the communication
with GPIB interface.


I have a problem with a Visa this Resource GPIB0::16::INSTR
It's a RF- Relaise Matrix

I must only send this command: R1R2R3R4R5R6
When I check command with NiMax its all ok but the problem is in C#. The exception error is "viReadSTB() - Timeout occured"
my simple source is above.
I tried changed contructor flag but not found nothing soluting or option.
With a NI/IO trace I see that, I think that the problem is that when open the visa resource the matrix hardware not accept the standand control *CLS and STB
There is a way for avoid the extra control and open only the resource?
Thanks for help.

 

TRACE:

 

1. viOpenDefaultRM (0x00333438)
Process ID: 0x0000148C Thread ID: 0x00001050
Start Time: 12:52:14,3769 Call Duration 00:00:00.0270
Status: 0 (VI_SUCCESS)
2. viGetAttribute (0x00333438, 0xBFFF0174 (VI_ATTR_RSRC_MANF_NAME), "National Instruments")
Process ID: 0x0000148C Thread ID: 0x00001050
Start Time: 12:52:14,4049 Call Duration 00:00:00.0000
Status: 0 (VI_SUCCESS)
3. viOpen (0x00333438, "GPIB0::16::INSTR", 0 (0x0), 0 (0x0), 0x04A32048)
Process ID: 0x0000148C Thread ID: 0x00001050
Start Time: 12:52:14,4059 Call Duration 00:00:00.1200
Status: 0 (VI_SUCCESS)
4. viGetAttribute (GPIB0::16::INSTR (0x04A32048), 0x3FFF0171 (VI_ATTR_INTF_TYPE), 1 (0x1))
Process ID: 0x0000148C Thread ID: 0x00001050
Start Time: 12:52:14,5279 Call Duration 00:00:00.0000
Status: 0 (VI_SUCCESS)
5. viGetAttribute (GPIB0::16::INSTR (0x04A32048), 0xBFFF0001 (VI_ATTR_RSRC_CLASS), "INSTR")
Process ID: 0x0000148C Thread ID: 0x00001050
Start Time: 12:52:14,5279 Call Duration 00:00:00.0000
Status: 0 (VI_SUCCESS)
6. viSetAttribute (GPIB0::16::INSTR (0x04A32048), 0x3FFF001A (VI_ATTR_TMO_VALUE), 10000 (0x2710))
Process ID: 0x0000148C Thread ID: 0x00001050
Start Time: 12:52:14,5329 Call Duration 00:00:00.0020
Status: 0 (VI_SUCCESS)
7. viClear (GPIB0::16::INSTR (0x04A32048))
Process ID: 0x0000148C Thread ID: 0x00001050
Start Time: 12:52:14,5359 Call Duration 00:00:00.0010
Status: 0 (VI_SUCCESS)
8. viWrite (GPIB0::16::INSTR (0x04A32048), "*CLS", 4 (0x4), 4 (0x4))
Process ID: 0x0000148C Thread ID: 0x00001050
Start Time: 12:52:14,5379 Call Duration 00:00:00.0010
Status: 0 (VI_SUCCESS)
> 9. viReadSTB (GPIB0::16::INSTR (0x04A32048), 0 (0x0))
> Process ID: 0x0000148C Thread ID: 0x00001050
> Start Time: 12:52:14,5399 Call Duration 00:00:16.7799
> Status: 0xBFFF0015 (VI_ERROR_TMO)

 

----

SOURCE

--
using System;
using RohdeSchwarz.RsInstrument; // .NET component providing all the necessary VISA extended functionalities. Install as NuGet from www.nuget.org
using System.IO;


namespace RsInstrument_Hello_World_Example
{
class Program
{
static void Main(string[] args)
{

Console.ReadKey();


RsInstrument matrix;
try // Separate try-catch for initialization prevents accessing uninitialized object
{
var resMatrix = "GPIB0::16::INSTR"; // GPIB Connection

matrix = new RsInstrument(resMatrix, false,false);
}
catch (RsInstrumentException e)
{
Console.WriteLine($"Error initializing the instrument session:\n{e.Message}");
Console.Write("\nPress any key ...");
Console.ReadKey();
return;
}


//Invio comando settaggio matrice
matrix.WriteString("R1R2R3R4R5R6");


Console.Write("\nVISA OK Press any key ...");
Console.ReadKey();

matrix.Dispose();
}
}
}
----


Viewing all articles
Browse latest Browse all 5566

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>