Forum Replies Created
-
AuthorPosts
-
Hey Pat,
Just wondering if this got fixed and if there is any way to get the updated code?
Thanks,
TonyG
Thanks Pat – Appreciate it.
TonyG
I’m using an original NI GPIB-ENET/1000 with the latest NI 488 & VISA drivers.
For clarity, the Basic code works if I use the GPIBNI driver but fails if I use the VISA driver.
That seems to indicate a HT Basic problem and not a problem with the NI Hardware.
I reimplemented this in C# using the NI VISA libraries and the code works as expected:
using Ivi.Visa; using NationalInstruments.Visa; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.ConstrainedExecution; using System.Text; using System.Threading; using System.Threading.Tasks; namespace SRQTest { internal class Program { public static GpibSession gpibSession; public static NationalInstruments.Visa.ResourceManager resManager; public static int gpibIntAddress = 14; // 34401A public static string gpibAddress = string.Format("GPIB0::{0}::INSTR", gpibIntAddress); public static SemaphoreSlim srqWait = new SemaphoreSlim(0, 1); // use a semaphore to wait for the SRQ events static void Main(string[] args) { // Setup the GPIB connection via the ResourceManager resManager = new NationalInstruments.Visa.ResourceManager(); // Create a GPIB session for the specified address gpibSession = (GpibSession)resManager.Open(gpibAddress); gpibSession.TimeoutMilliseconds = 8000; // Set the timeout to be 4s gpibSession.TerminationCharacterEnabled = true; gpibSession.Clear(); // Clear the session gpibSession.ServiceRequest += SRQHandler; SendCommand("*RST"); // Reset the DMM SendCommand("*CLS"); // Clear the DMM status registers SendCommand("*ESE 1"); // Enable "operation complete" bit to set "standard event" bit in status byte SendCommand("*SRE 32"); // Enable "standard event" bit in status byte to pull the IEEE-488 SRQ line var opcResult = QueryString("*OPC?"); // Assure synchronization Console.WriteLine($"OPC Result: {opcResult}"); // Print the result of the OPC query SendCommand("CONF:VOLT:DC 10"); // Set DMM to 10 volt DC range SendCommand("VOLT:DC:NPLC 10"); // Set the integration time to 10 PLCs SendCommand("TRIG:COUN 100"); // DMM will accept 100 triggers SendCommand("INIT"); // Place DMM in "wait-for-trigger" state SendCommand("*OPC"); // Set "operation complete" bit in standard event // Wait for the SRQ event srqWait.Wait(); // Wait for the SRQ event to be signaled // Read the data string response = QueryString("FETCH?"); Console.WriteLine($"1. Response: {response}"); // Clear the DMM status registers SendCommand("*CLS"); } public static void SRQHandler(object sender, Ivi.Visa.VisaEventArgs e) { // Read the Status Byte var gbs = (GpibSession)sender; StatusByteFlags sb = gbs.ReadStatusByte(); Console.WriteLine($"1. SRQHandler - Status Byte: {sb}"); gpibSession.DiscardEvents(EventType.ServiceRequest); SendCommand("*CLS"); srqWait.Release(); } static private void SendCommand(string command) { gpibSession.FormattedIO.WriteLine(command); } static private string ReadResponse() { return gpibSession.FormattedIO.ReadLine(); } static private string QueryString(string command) { SendCommand(command); return (ReadResponse()); } } }Looking at the NI IO Trace Utility, I can see that the HTBasic program differs in that it doesn’t add a 0A to the end of the *OPC? string – Adding END to the OUTPUT statement fixes that and I can continue on but I now run into a problem on line 270 with HT Basic giving an Error 170 “I/O operation not allowed”:
270 ENABLE INTR Hpib;Mask ! Enable SRQ to interrupt the programIf I swap to the GPIBNI driver then the program works successfully.
TonyG
March 3, 2025 at 11:30 am in reply to: Why does HTBasic keep issuing iblines, ibwait & ThreadIbsta? #9462Hey Pat – Just checking back in, I’ve never used the secondary address for a GPIB device so I’m hoping you might also be able to share an example that shows how to do it.
Look forward to hearing from you and thanks for looking into this.
TonyG
February 26, 2025 at 8:26 am in reply to: Why does HTBasic keep issuing iblines, ibwait & ThreadIbsta? #9458Thanks, Pat – I was using the GPIBNI driver – Switching to the VISA driver does make it work as the VISA Test Panel does – Thank you again.
Is there any documentation on best practice seeing that I need to load a VISA driver for each GPIB address? Or am I missing something?
What I mean is that if I have devices say 7 & 8 on GPIB0 (ISC 7) then I need to have 2 VISA drivers with ISC 11 (GPIB0 7) & 12 (GPIB0 8) – So instead of using OUTPUT 707 or OUTPUT 708, I now use OUTPUT 1100 or OUTPUT 1200.
Any insight?
Thanks, TonyG
February 25, 2025 at 5:44 pm in reply to: Why does HTBasic keep issuing iblines, ibwait & ThreadIbsta? #9456BTW Here is the XML export from NI I/O Trace utility of one pass through the loop:
<call type=”NI-488.2″ description=”iblines” process=”0x000017F4″ thread=”0x00006D90″>
<status type=”success” code=”0x00000164″ name=”CMPL REM CIC LACS”>Operation completed successfully.</status>
<input time=”13:19:37.6771″>
<parameter name=”Board Name”>GPIB0</parameter>
<parameter name=”ud”>31000</parameter>
<parameter name=”&controlLines”>0x5036FBE4</parameter>
</input>
<output time=”13:19:37.6771″>
<parameter name=”iberr”>0</parameter>
<parameter name=”ibcntl”>0 (0x0)</parameter>
<parameter name=”controlLines”>-1</parameter>
</output>
</call>
<call type=”NI-488.2″ description=”ibwait” process=”0x000017F4″ thread=”0x00006D90″>
<status type=”success” code=”0x00000164″ name=”CMPL REM CIC LACS”>Operation completed successfully.</status>
<input time=”13:19:37.6771″>
<parameter name=”Brd/Dev Name”>GPIB0</parameter>
<parameter name=”ud”>31000</parameter>
<parameter name=”mask”>0x0000</parameter>
</input>
<output time=”13:19:37.6781″>
<parameter name=”iberr”>0</parameter>
<parameter name=”ibcntl”>0 (0x0)</parameter>
</output>
</call>
<call type=”NI-488.2″ description=”ThreadIbsta” process=”0x000017F4″ thread=”0x00006D90″>
<status type=”success” code=”0x00000164″ name=”CMPL REM CIC LACS”>Operation completed successfully.</status>
<input time=”13:19:37.6781″ />
<output time=”13:19:37.6781″>
<parameter name=”iberr”>0</parameter>
<parameter name=”ibcntl”>0 (0x0)</parameter>
<parameter name=”Thread ibsta”>0x0164</parameter>
</output>
</call>Hey Pat,
Here you go:
1. I’ve found this to happen in the 10’s of minutes range.
2. Not sure about during execution but it is certainly during one HTBasic session. I’ve seen both timeout errors and simple “Enter” statements return without any values in the variables (i.e. if I’m doing an *IDN? then the Enter returns with a blank string). Stopping and restarting HTBasic doesn’t help, I have to reboot the machine.
3. No, it happens during one session of HTBasic use and then subsequent restarts of HTBasic have no impact on the issue. Only rebooting fixes it.
4. Yes. I’ve initially setup the instrument in the “Device Setup” dialog and when this happened I tried unloading and reloading the driver to no avail. This is when I tried loading the driver in code to see if that was different but I still had the same issue.
5. I have not tried that – I tried the “BASIC Reset” button in the toolbar but that had no impact.I won’t get to it tonight but I’ll crack open HTBasic again hopefully tomorrow and see if I can get it to fail (I fully expect now that you’ve asked it will operate perfectly until this post ages out) and then try the reset utility.
Thanks for the help.
TonyG
Hmm – I replied with the code and some images but I don’t see the reply so to quickly recap without the images in case that it causes the post to be sent to moderation/blocked.
The devices will work for a short period of time. I don’t have a repro case for the failure except that after some point it always stops communicating. The devices are being used over the VISA driver.
I’ve tried both loading the driver in the app and using the device setup dialog (I haven’t tried using an AUTOST as they’re supposed to be equivalent).
Code line is:
10 LOAD BIN “VISA;DEV TCPIP0::192.168.1.50::inst0::INSTR ISC 8”
HT Basic version is 21.1.017
All suggestions appreciated.
Thanks,
TonyG
-
This reply was modified 1 year, 3 months ago by
Tony Goodhew.
Thanks – My driver load is correct, the issue I’m having is that after some point HT Basic stops working with the NI Stack – The NI stack still works as I can use their test panel.
In fact the same code will work in HT Basic just after a complete reboot of the PC – Shutting down HT Basic and restarting doesn’t fix it – It seems that there is something left running that hoses the HT Basic connection.
TonyG
-
This reply was modified 1 year, 3 months ago by
-
AuthorPosts