Forum Replies Created

Viewing 7 posts - 16 through 22 (of 22 total)
  • Author
    Posts
  • in reply to: Resetting HTBasic and NI-VISA to start up conditions #9423
    PatB
    Moderator

      Thanks Tony for the additional information.

      Could you provide more details around when communication seems to stop? For example:

      1. How long is “A short period of time”? Minutes, Hours, Days?
      2. When it stops working, is there an error displayed in the currently running program (If so, what error), and the program execution is stopped? Or is it always between runs that it goes from working, to not working?
      3. To expand on #2, is it always after re-launching HTBasic that it appears to stop working, or is it working and then subsequently not working, in the same instance of HTBasic?
      4. When you say unloading the driver and then re-loading it does not solve the issue, are you unloading it from inside Device Setup? When you re-load the driver, does it show it loaded correctly, but still doesn’t communicate? or does it simply fail to load?
      5. Have you tried using the HTBasic reset utility after communication stops, to clear the registry and then re-add and re-load the driver? Does that resolve the issue, without requiring a reboot?

      What I suspect is happening is that an error is occurring that is causing the current Visa Session not to work, but that the session is also not getting closed correctly, blocking new sessions from getting opened. What I don’t understand, is that unloading the driver should closes the session, so why does that not resolve your issue. Answers to my above questions will hopefully help me to narrow down what is happening so that we can propose a work around, or find a solution.

      Thanks,

      Pat

      in reply to: Resetting HTBasic and NI-VISA to start up conditions #9419
      PatB
      Moderator

        Hi Tony,

        What version of HTBasic are you using and what driver are you loading (GPIBNI or VISA)? Could you also show us what you are using in your LOAD BIN statement?

        Thanks,

        Pat

        in reply to: about call dll-C and CSharp #9370
        PatB
        Moderator

          Hi Dongxu,

          I setup a similar test where I created an unmanaged C++ dll and from it called into a managed C# dll. Loading the unmanaged C++ dll from HTBasic and calling the unmanaged function that calls into the managed dll, I was able to reproduce the same exception you are seeing. I have spent some time looking into it and finally found a solution. There were two steps I needed to take before i was able to call the unmanaged dll function from HTBasic successfully.

          First, make sure that your unmanaged DLL and Managed DLL are both targeting x86 since that is what HTBasic targets.

          Second, put the managed dll into the same folder that the HTBwin.exe file is in.

          Hopefully this will allow it to work for you.

          Thanks,

          Pat

          in reply to: VISA LabVIEW #9288
          PatB
          Moderator

            Here is a simple program that simply loads the VISA driver for the instrument at ASRL3::INSTR. It outputs *IDN to the instrument and then enters the response and stores it in a string variable. Finally it prints out the returned value in the string variable.

            
             LOAD BIN "VISA;DEV ASRL3::INSTR ISC 7"
            
                  OUTPUT 7;"*IDN?";
                  ENTER 7;S$
                  PRINT "The connected device is: ",S$
                  
                  END
            

            An alternative to loading the driver in code is to use the Device Setup under the tools menu.

            in reply to: HTBDDE dll #9276
            PatB
            Moderator

              Hi ZeRider,

              I wanted to see if I could reproduce the failure at line 16379. Using your program in HTBasic 2021 I could not get it to fail. It completed successfully every time. I did see that you were using HTBasic 10.0 and HTBasic 10.1 so I tried those versions and immediately get an error in each and they shutdown which is very odd. If I get the time I will look into it, although since it works fine in our latest release, my recommendation is to use it.

              Ralphs suggestion is a good one and will be much faster than going through Excel, but if you need to go through Excel for some reason, I would recommend using HTBasic 2021.

              Concerning how I entered my code in my post, I use the HTML CODE tags provided on the toolbar above and put my code between them.

              If you do get a copy of HTBasic 2021, I would be interested to know if HTBDDE works successfully for you, or you still hit the same issue.

              Thanks!

              in reply to: HTBDDE dll #9268
              PatB
              Moderator

                Hi ZeRider,

                I put together a sample program and a sample excel file to try and reproduce the issue you are seeing above. I am able to consistently read all 200 rows of 259 cells. The difference could be in the data being read in since I am not certain the format of your data. Here is a link to the excel file I am using:

                sample.xlsx

                And here is my sample program:

                my sample program:

                      CONFIGURE LONGFILENAMES ON
                
                      DLL UNLOAD ALL
                
                      LONG Hconvexcel! Excel conversation handle
                      LONG Retval  ! Return value for the DLL functions
                
                      DLL LOAD "HTBdde"
                      DLL GET "LONG HTBdde:Ddeconnect"
                      DLL GET "SHORT HTBdde:Ddeterminate"
                      DLL GET "LONG HTBdde:Ddetimeout"
                      DLL GET "SHORT HTBdde:Ddeexecute"
                      DLL GET "SHORT HTBdde:Ddepoke"
                      DLL GET "CHARPTR HTBdde:Dderequest"
                      DLL GET "SHORT HTBdde:Runexe"
                
                    ! Connect to the Excel System topic
                      Hconvexcel=FNDdeconnect("Excel","System")
                
                      IF Hconvexcel=0 THEN
                         ! If we couldn't connect, lauch Excel and try again
                          Retval=FNRunexe("C:\Program Files\Microsoft Office\root\Office16\Excel.exe",1)
                          WAIT 2
                          Hconvexcel=FNDdeconnect("Excel","System")
                
                         ! If we still couldn't connect, Exit
                          IF Hconvexcel=0 THEN
                              GOTO Exit
                          END IF
                      ELSE
                            ! Create a new workbook
                          Retval=FNDdeexecute(Hconvexcel,"[Open(""C:\Program Files (x86)\HTBasic 2021\DLL Toolkit\Samples\HTBDde\sample.xlsx"")]")
                
                          IF NOT Retval THEN
                              PRINT "didn't open"
                              GOTO Exit
                          END IF !
                      END IF
                
                     IF Hconvexcel=0 THEN
                          GOTO Exit
                      END IF
                
                      DIM C$[20]
                      DIM Return$[50]
                      DIM Data$(1:200,1:259)[20]
                      Row$="L"
                
                      Total=0
                      FOR Line=1 TO 200
                          FOR Column=1 TO 259
                              C$=""
                              C$=Row$&VAL$(Line)&"C"&VAL$(Column)
                              Return$=""
                              Return$=FNDderequest$(Hconvexcel,C$)
                              Total=Total+1
                              Data$(Line,Column)=Return$
                              DISP Total,C$,Data$(Line,Column)
                          NEXT Column
                      NEXT Line
                
                      PRINT "Finished"
                
                 Exit:!
                
                    ! Terminate the connection with Excel
                      IF (Hconvexcel) THEN
                          Retval=FNDdeterminate(Hconvexcel)!Terminate the excel DDE conversation
                      END IF
                
                    ! Unload the DDE DLL
                      DLL UNLOAD "HTBdde"
                
                      END
                
                in reply to: HTBasic and visa32.Ddll #9111
                PatB
                Moderator

                  The latest released version of HTBasic 2021 now contains a native VISA driver. This can be loaded in Device Setup and will allow you to communicate with instruments natively in HTBasic using standard ENTER and OUTPUT statements, greatly simplifying your programming.

                Viewing 7 posts - 16 through 22 (of 22 total)
                Scroll to Top
                HTB icon

                Please Sign In