Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

NI 488.2 can support VS2013?

Solved!
Go to solution

I have add reference "NationalIstruments.NI4882", but can't coding 488.2 command. please see below picture.

 

NI4882.png

My OS is WIN 7 64 bit, VS2013, MAX v15.0.0f0, upgrate to new version.

 

Below is my code, can't to build, NI488 code can't complete compile.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Ivi.Visa.Interop; //VisaComLib
using NationalInstruments.NI4882;
using NationalInstruments.VisaNS;

namespace xxx
{
    class Program
    {
      private MessageBasedSession mbSession;

        static void Main(string[] args)            

        {
          int noncontroller;
          char[] buffer = new char[100];
          int panelHandle;
            //Open  session to the GPIB board
            noncontroller = ibfind ("gpib0");

            //Release system control
            ibrsc(noncontroller, 0);

            //Change GPIB primary address from 0 to 2
            ibpad(noncontroller, 2);

            while(true)
            {
                //Update status variable
                ibwait(noncontroller, 0);

                //Wait until non-controller is listener and ATN line is dropped.
                if ((ibsta&LACS)&&(!(ibsta&ATN)))
                {
                    ibrd(noncontroller, buffer, 100); // Read data bytes
                    buffer[ibcnt] = '\n'; //Add linefeed and 0 to string
                    buffer[ibcnt + 1] = 0;
                    Console.WriteLine("Buffer Value{0}", buffer);
                    //printf("%s", buffer); // Print buffer for C
                    return;
                }
            }
        }
    }
}

 

 

 

0 Kudos
Message 1 of 12
(9,190 Views)

If you the newest NI-488.2 installed, it should support .NET Framework 4.5.1

0 Kudos
Message 2 of 12
(9,175 Views)

Yes, can support .NET Framework 4.5.1, so only can use .NET to programming?

0 Kudos
Message 3 of 12
(9,153 Views)

@JackieLin wrote:

Yes, can support .NET Framework 4.5.1, so only can use .NET to programming?


I don't understand your question.

 

Visual Studio uses .NET

0 Kudos
Message 4 of 12
(9,136 Views)

I think loss NationalInstruments.Common,but add reference, can't include program, please see below picture.

 

NationalInstruments.Common verison is 15.0.40.49154

.Net Framework 4

 

 

 

0 Kudos
Message 5 of 12
(9,126 Views)

Confirm NI4882.dll is working, but can't use ibfind,ibwait..... command, i don't know why?

0 Kudos
Message 6 of 12
(9,116 Views)

Hi,

 

You set a reference to the GPIB .NET library, but you using the old Win32 function calls.

 

ibfind, ibread etc...

 

You need to use the NI488.2 Class library objects and methods

 

Check the examples located at the followng link

 

http://digital.ni.com/public.nsf/allkb/39F4B9264B94308C8625729D0067F9AF

 

Curt

0 Kudos
Message 7 of 12
(8,996 Views)

Thanks and understood, but use .NET library, any document can read, because for Win32 have NI-488.2 user manual for reference to programming, such as ibfind,ibwrt...etc, but .NET only example program, i don't know which command same ibfind?

0 Kudos
Message 8 of 12
(8,952 Views)
0 Kudos
Message 9 of 12
(8,949 Views)
Solution
Accepted by topic author JackieLin

Hi,

 

You need to create a Board object.

 

 

Address boardAddress;
        Board board;

        private void butOpen_Click(object sender, EventArgs e)
        {
            bool retval = false;

            try
            {

                boardAddress.PrimaryAddress = 0;
               
                board = new Board();  //defaults to 0 for GPIB board index number 'GPIB0'. Change to your board number idf required

                retval = board.FindListener(boardAddress);

                Debug.WriteLine("FindListener returned " + retval.ToString());

                board.IsSystemController = false;

                retval = board.IsSystemController;

                Debug.WriteLine("IsSystemController returned " + retval.ToString());


 
            }
            catch (Exception ex)
            {

                Debug.WriteLine(ex.Message.ToString());
   
            }
        }

 

Debug Output

 

FindListener returned True

IsSystemController returned False

 

 

 

Good luck!

 

Curt

Message 10 of 12
(8,942 Views)