|
Post by johnking on Jan 21, 2021 7:16:31 GMT -5
I use LB 4.51 to retrieve data from several measurement instruments via the RS-232 serial port.
One of my newer instruments (Keysight 33511B) has only LAN, USB and GPIB capabilities. So no serial port anymore .
I think I checked all posts and internet to find a way to use LB to send/retrieve via USB for example by using DLL, but no luck. There are some examples, but no luck with them.
But to be sure: am I correct that we cannot use Labview to send and retrieve data via USB ? Or did someone find a way to do it ? Or will version 5 give possibilities ?
My alternative is to use Labview, but for the tasks I need LB would be much easier.
|
|
|
Post by Carl Gundel on Jan 21, 2021 12:19:16 GMT -5
The way that this typically has been made to work with Liberty BASIC is to find some sort of USB adapter (perhaps to GPIB?) that has a device driver that makes it work like a serial port. Then using the OPEN "COM..." command in Liberty BASIC to control it. For example: prologix.biz/gpib-usb-controller.html
|
|
|
Post by Rod on Jan 21, 2021 13:32:13 GMT -5
I read they have a connections module but the place to ask would be on their forum. That said there has been a few posts about talking to gadgets over LAN. Michael Molinari posted some code a while back controlling a lamp. I am sure we have seen other posts. Not my forte.
|
|
|
Post by Chris Iverson on Jan 21, 2021 13:45:30 GMT -5
I wonder what "USB" means. Is it a fully custom made driver made specifically for that device, or is it a USB-to-Serial adapter like a lot of devices use? If it's a USB-to-Serial adapter, you might be able to interact with the COM port it creates yourself. If it's a custom USB device driver, there's not much you can do without knowing exactly how to interact with it, and if Keysight hasn't published any documentation on the interface, you might have no choice but to rely on their software to do the communication. USB communication is complicated: docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/windows-desktop-app-for-a-usb-deviceDespite the "serial" in the name, USB is not comparable to the old-school serial bus, where you just plug in some wires and get or send a stream of bits. USB is actually quite strict and regimented, and even the drivers/libraries that would let you seemingly communicate arbitrarily with devices(libusb or WinUSB) have to follow the strict guidelines of it. Heck, pretending to be an RS232 serial device is a feature that's built in to the USB protocol definition(part of the USB Communications class of devices, RS232 has its own subclass), and not just hacked into it by conversion hardware, simply because of how complicated USB communication can really be.
|
|
|
Post by Brandon Parker on Jan 21, 2021 21:41:27 GMT -5
Since the Keysight 33511B has a built-in web server, you might be able to peruse that and find a page that has all of the data you need. Then you could possibly use HTTPGet$() to pull that page with the data and parse the data out of the return from HTTPGET$().
{:0)
Brandon Parker
|
|
|
Post by johnking on Jan 23, 2021 7:56:58 GMT -5
A quick update: - The original Keysight USB-to-GPIB convertor does not make a virtual COM port, it makes a dedicated USB port. So that does not work. _ Maybe there are USB-to-GPIB convertors that make a virtual port. I would love to try one. But I hesitate to buy one without knowing it is going to work. - I have a Keithley PCI-488 PCI-to-GPIB card, but it won't install with any driver I try. Quickbasic has a GPIB library and can work with this card, but since I cannot get the PCI card to work, no luck so far. - The build-in-webserver provides possibilities to set up the instrument remotely, but does not allow to send commands or retrieve data, unless you use Matlab or Labview, or use the command screen within that server. So no luck so far . I think I have to move forward with LabView on this one.
|
|
|
Post by johnking on Jan 23, 2021 10:00:09 GMT -5
In the mean time I was able to get the PCI GPIB card working. I can send commands to the GPIB card via a test program and the Keysight 33511 is reacting to commands. So there is datatraffic flowing.
As far as I see, this should set the amplitude to 2 volt:
open "GPIB.32.DLL" for DLL as #gpib CALLDLL #gpib, "ibcmd", 16, "volt +2.0" 'set amplitude tot 2 volt
close #gpib
However, no error, but also no result
|
|
|
Post by Rod on Jan 23, 2021 12:53:27 GMT -5
ANy manual for the pci card, or web resource?
|
|
|
Post by johnking on Jan 23, 2021 13:33:25 GMT -5
|
|
|
Post by Brandon Parker on Jan 23, 2021 17:44:12 GMT -5
I do not believe GPIB.32.DLL is a standard Windows DLL. You likely have it due to working with the equipment and installing something previously.
Try this and see what you have returned from the function
Open "GPIB.32.DLL" For DLL As #gpib
Print sendGPIBCommand(16, "volt +2.0")
Close #gpib
Function sendGPIBCommand(ud, cmdString$) cmdString$ = cmdString$;chr$(0) cnt = Len(cmdString$) CallDLL #gpib, "ibcmd", ud As long, _ cmdString$ As ptr, _ cnt As long, _ sendGPIBCommand As long End Function
That is considering "volt +2.0" is a valid command. Do you have a command set for the device?
Also, your second link appears to not be working at least for me.
{:0)
Brandon Parker
|
|
|
Post by johnking on Jan 24, 2021 9:24:26 GMT -5
Good news! LB can send commands to the PCI GPIB card. Brandon pointed me in the right direction, but it needed some more effort. 1. My assumption that the GPIB DLL is a standard DLL is not correct, like Brandon said. You need to install the 2019 version of this DLL from the National Instruments website. 2.Install the complete 2019 package from the National Instrument labview site. Here is the link www.ni.com/nl-nl/support/downloads/drivers/download.ni-488-2.html#345631Use the default choices. The installation takes some time, let it finish. After installation you should have the GPIB-32.DLL and also the complete package, with all documentation. So now you also have the complete API and DLL manual 3. Locate the GPIB-32.DLL file on your PC. On my 32-bit PC it is in C:\windows\System32\GPIB-32.DLL. On my 64-bit PC it is in c:\windows\SysWOW64\GPIB-32.DLL 4. In LB I needed to point to the complete path on my 32-bit PC. On my 64-bit PC the complete path is not necessary. 5. With the code below the Keysight 33511 steps through 3 frequencies and 3 voltages. 6. I could not get to work using a function, the subroutine approach as in my code works however. 7. Now the code works on the PCI GPIB card I feel confident enough to order a USB-to-GPIB adapter. If more people are interested in the results, let me know. In that case I will publish further results. Open "c:\windows\System32\GPIB-32.DLL" For DLL As #gpib
gpibboard=0 gpibaddress=16 sad=0 tmo=10 eot=1 eos=0
CallDLL #gpib, "ibdev", gpibboard As long, _ 'initilalize the GPIB board and deviceadress gpibaddress As long, _ sad As long, _ tmo As long, _ eot As long, _ eos As long
cmdString$="volt +1.0" gosub [send] cmdString$="freq 1000" gosub [send]
input a$ cmdString$="volt +2.0" gosub [send] cmdString$="freq 2000" gosub [send]
input a$ cmdString$="volt +3.0" gosub [send] cmdString$="freq 3000" gosub [send]
Close #gpib
end
[send] cmdString$ = cmdString$;chr$(0) count = Len(cmdString$) CallDLL #gpib, "ibwrt", gpibaddress As long, _ cmdString$ As ptr, _ count As long, _ functionreturn As long return
|
|
jordi
Full Member
A simple solution is the smarter one.
Posts: 106
|
Post by jordi on Jan 25, 2021 13:56:08 GMT -5
Is it possible to communicate with external devices using a ch340g too? I suppose it can. It's what many Arduinos use.
|
|
|
Post by johnking on Jan 25, 2021 14:25:59 GMT -5
|
|
jordi
Full Member
A simple solution is the smarter one.
Posts: 106
|
Post by jordi on Jan 26, 2021 1:07:02 GMT -5
Yes like that one.
|
|
|
Post by Carl Gundel on Jan 26, 2021 12:17:31 GMT -5
|
|