Dangerous Prototypes

In development => Project logs => Topic started by: scasagrande on January 13, 2014, 12:33:45 am

Title: GPIBUSB Adapter rev3
Post by: scasagrande on January 13, 2014, 12:33:45 am
Hello everyone! I've noticed that in the past I've gotten a few links to my GPIBUSB adapter project from this forum, so I figured I would make a dedicated thread for it.

A few years ago when I was in my final year of undergrad I was working at a fresh university lab (which I later spent my masters at). While setting up some equipment, I had to connect a bunch of T&M equipment to a PC via GPIB. However, I quickly discovered what a pain in the arse it is to get GPIB working. Specifically, I found that the Linux GPIB drivers do not contain MATLAB bindings. Well, if they did we couldn't get it to work. Getting it to work with Python was no problem with pyvisa, but this project had the requirement that we used MATLAB. Eventually we just installed Windows instead (which caused later issues with SSH but that's another topic).

A few months later I was thinking about that situation and set off to make my own solution. I decided to make a board that used a virtual serial port to avoid all these issues. This way any modern software could talk to a GPIB connected device.

This past weekend I finally finished up the third major revision of my GPIBUSB adapter board. Major hardware changes include swapping the pull-up resistors for the proper GPIB line drivers, as well as swapping the FT232RL for the newer FT230X. There is a number of software improvements from improved reliability to additional commands.

(http://http://i.imgur.com/RocuIEp.png) (http://http://imgur.com/RocuIEp)

(http://http://i.imgur.com/kMQgJkFl.jpg) (http://http://imgur.com/kMQgJkF)

In order to help abstract the user away from having to deal with adapter-specific commands (eg: setting the target GPIB address, etc) my friend and I started a Python library project called InstrumentKit (http://https://www.github.com/Galvant/InstrumentKit). Here, we took things another step further and abstracted hardware-channel specific instructions away. InstrumentKit allows you to communicate with equipment via Python while maintaining a consistent API across instruments and keeping you away from having to deal with the specifics associated with the physical connection. This means serial, tcpip, nix filelikes (eg /dev/usbtmc0), my adapter, etc are all opened with a single command (or a single line in a YAML config file). But that's all I'll say about that for now and I'll make another post at a later time with more details.

This project (along with everything else I do) is open source hardware. Sources can be found in a few repositories at my Github page (http://https://www.github.com/Galvant). Do note that a few docs need some updates but the main files are there. You can also find the adapter on my website at Galvant Industries (http://http://www.galvant.ca).

I have a few ideas for improvements in the next version, but let me know what you all think!

Oh, and I'll try to get a video of it in action in a few days.

[edit Jan 18] I uploaded a video of it in action here: http://http://www.youtube.com/watch?v=VzGDldTVSOg
Title: Re: GPIBUSB Adapter rev3
Post by: Sleepwalker3 on January 13, 2014, 02:19:52 pm
Sounds good. Perhaps in rev 4 you might consider adding the option of using a real RS232 port? Some people (like me) still use RS232 regularly and it might be handy if the PC and instrument are a decent distance away. Could be left unpopulated if not used and just some links or jumpers to select the FTDI or RS232 side (something common like a MAX232, MAX3232, etc.) Just a thought anyway. If I ever get around to connecting up some of the HP gear, I'll certainly use your unit, as it seems you've been a lot more active with it than other units I've seen and it seems a more established unit now, well done.
You should post something on some of the HP gear forums, I'm sure there would be plenty of interested people there.
Title: Re: GPIBUSB Adapter rev3
Post by: scasagrande on January 13, 2014, 03:47:41 pm
Thanks for the suggestions! I've been thinking about that on and off for the past little bit. I'll have to see if I can squeeze that in. The main problem will probably be the DE-9 connector which would take up a decent amount of space. I've also toyed with the idea of making a more modular adapter for people that want some added flexibility.

For example, the main board could just be the primary logic, and then daughter boards for GPIB and serial ports, as well as separate boards for RS232, USB, or you could just use the exposed tx rx header pins for something else. This would more than likely not plug directly into the back of an instrument's GPIB port (due to the size, and thus requiring a GPIB cable) but having 1 device to talk to GPIB and a few serial port connected devices has its advantages.
Title: Re: GPIBUSB Adapter rev3
Post by: Sleepwalker3 on January 13, 2014, 11:34:34 pm
There is a trick you can do to add a DB9 with very little space and no holes, I'll try to get you an example when I get a chance. Essentially you make rectangular pads with no holes and use a standard DBxx solder bucket type - not the PCB type. You will find most will have a firm fit onto a 1.6mm PCB, so you basically slide the PCB between the two rows of pins, the solder it on either side. I use the technique on prototype boards a bit. It doesn't use much PCB space at all, allows you to mount the DB to a panel if you like, or just leave it hanging, it's quite solid. Also there's no holes to drill and the normal solder bucket style units are usually cheaper than the PCB ones. One thing you may want to consider in having the GPIB on a cable that runs to your board, rather than the plug on the board. With the unit plugged directly into the GPIB, it will stick out the back and likely make the test equipment have to sit out further. If you had the GPIB plug as an IDC onto a ribbon, it could be a short patch cable to the interface with perhaps an IDC DB25 on the far end. The interface could be made with other options, as you'd have more room without the GPIB right angle PCB connector taking up space. It could sit in a box beside or on top of the test gear or anywhere else convenient.  Anyway, they're all just ideas, your unit looks very useful as-is and most people will probably want to use USB anyway.
Title: Re: GPIBUSB Adapter rev3
Post by: electroniceel on January 14, 2014, 12:13:03 am
Does your adapter work with MATLAB or LabView? On Windows and Linux?

Can I use the regular intrument drivers which come with LabView/MATLAB or are provided by a device manufacturer? E.g. for my Agilent 34401A bench multimeter.
Title: Re: GPIBUSB Adapter rev3
Post by: scasagrande on January 14, 2014, 02:11:20 am
@Sleepwalker3
That would be great! If you can find some docs or pictures be sure to forward them onto me :)

@electroniceel
I have not personally used it with MATLAB or LabView, but both of them can communicate with serial ports so I don't see why not. However, it is not a drop in replacement for the more expensive NI/Agilent adapters. It is not VISA-compatible and thus will not work with stock software from manufacturers. If you're willing to use Python, InstrumentKit is aiming to make things as simple as possible. For example, here is how I download the binary waveform from channel 1 on my TekTDS224:

>>> import numpy as np
>>> import instruments as ik
>>> scope = ik.tektronix.TekTDS224.open_gpibusb('/dev/ttyUSB0', 1)
>>> [x, y] = scope.channel[0].read_waveform()

There is still lots to do, but the core is there.

My adapter does work with both Windows and Linux, which was one of my original design constraints. The detailed list of which versions of Windows and which Linux kernels that my adapter supports is the same as that of the FTDI chip (FT230X). You can see that here http://www.ftdichip.com/Drivers/VCP.htm (http://http://www.ftdichip.com/Drivers/VCP.htm).
Title: Re: GPIBUSB Adapter rev3
Post by: electroniceel on January 15, 2014, 08:32:04 pm
Thanks for your answer.

Just a rough idea, maybe not feasible: a lot of current instruments offer LXI in addition to the older GPIB. So there are VISA drivers for LXI and entering IP-Adresses or DNS-Names as device addresses is supported in e.g. Labview and Matlab. So if a GPIB-Adapter had an Ethernet port and offered some basic LXI-subset and translated that to GPIB, you could use it with stock drivers.

Or would that only work if the driver from the instrument manufacturer actually supports LXI? Because that would usually not be the case for oldish devices from long before the advent of LXI.
Title: Re: GPIBUSB Adapter rev3
Post by: scasagrande on January 15, 2014, 10:51:10 pm
I believe that would still require VISA compatibility which is something I'm not interested in supporting at this time. But an ethernet to GPIB adapter that follows the same rules as my USB one is something I would like to do someday.
Title: Re: GPIBUSB Adapter rev3
Post by: scasagrande on January 18, 2014, 04:37:20 pm
I uploaded a new video last night that goes over how to use my adapter in two different software environments. First is Ubuntu 13.10 + Python + InstrumentKit and the second is Win7 + Terminite.

http://http://www.youtube.com/watch?v=VzGDldTVSOg
Title: Re: GPIBUSB Adapter rev3
Post by: scasagrande on March 15, 2014, 10:07:04 pm
After many days, I just finished off firmware version 5 for my adapter. This is probably my biggest update yet. A lot of people asked for compatibility with the Prologix commands so that's what I focused on. Here is an overview of the new firmware:

- Nearly all Prologix command set support. The adapter should now work with some pre-existing software tools and examples on the internet that were originally intended. Some will require a few changes for baud rate and flow control settings.
- Improved termination character handling
- SRQ support (but no parallel polling, only serial)
- Improved stability
- Device mode (first version so there may be fixes in the future)
- Most settings can be stored in EEPROM
- Basic FIFO buffer for data sent from the PC

The next update will probably focus on optimization. As usual, everything is open source and can be found at https://www.github.com/Galvant/gpibusb-firmware (https://www.github.com/Galvant/gpibusb-firmware)
Title: Re: GPIBUSB Adapter rev3
Post by: mountaindude on March 25, 2014, 08:53:26 am
So I am pretty much a GPIB noob... sorry if I ask something totally obvious.

Would I be able to control my GPIB / HPIB equipped tools with this board?
Such as a HP 3478 bench meter, Fluke 8842 bench meter, HP 6632A power supply (to name the ones most commonly used around here).

Would it work from a Mac? Guess it should, as long as a terminal program capable of fast serial is used, right?
Title: Re: GPIBUSB Adapter rev3
Post by: scasagrande on March 28, 2014, 03:20:59 am
[quote author="mountaindude"]So I am pretty much a GPIB noob... sorry if I ask something totally obvious.

Would I be able to control my GPIB / HPIB equipped tools with this board?
Such as a HP 3478 bench meter, Fluke 8842 bench meter, HP 6632A power supply (to name the ones most commonly used around here).

Would it work from a Mac? Guess it should, as long as a terminal program capable of fast serial is used, right?[/quote]

Hey sorry I missed your post. Yes as long as those instruments have GPIB/HPIB ports on the back (and they are functioning!) this project will let you control them.

I have never *personally* used it with OSX, but I know that FTDI does have an OSX driver so it should work just fine. If you are going to use a terminal program be sure that it sends your entire string at once, rather than sending each character as you type them out.
Title: Re: GPIBUSB Adapter rev3
Post by: scasagrande on April 15, 2014, 11:02:21 pm
I just uploaded a new build to the dev branch on GitHub which speeds up command recognition. Before this build I had the micro do comparisons on input vs each stored "valid" string in memory until a match was found. This resulted in a lot of unneeded character checks.

With the update, only the characters that differentiates each command are checked. So, while this technically reduces how strict the language set is, it speeds this section of the code execute up enough that large numbers of internal commands being sent no longer require the occasional delay to prevent the buffer from being filled.

Next I want to investigate speeding up the port manipulation and see if that improves performance at all. If it does make a difference, both of these changes will be packaged together in a final firmware v6.
Title: Re: GPIBUSB Adapter rev3
Post by: bantambasher135 on May 09, 2014, 02:56:59 pm
This is amazing! In my lab we have five different PARC potentiostats, but only three setups. Problem is, we only have three GPIB adapter cards. I am going to build two more and put big stickers on them with your name.
Title: Re: GPIBUSB Adapter rev3
Post by: scasagrande on May 09, 2014, 03:12:11 pm
Thanks! You can always pick them up on my website www.galvant.ca (http://www.galvant.ca) if you want to financially support my work and future firmware development. I understand that's not an option for everyone so if you choose to build it yourself, be sure to send me a picture!
Title: Re: GPIBUSB Adapter rev3
Post by: scasagrande on July 07, 2014, 10:59:57 pm
Hey everyone, got another update for this project to share.

After working closely with a few individuals it was discovered that some of the pre-existing GPIB software (such as KE5FX's tools) has some hardcoded serial port settings, one of which being the use of hardware flow control. After getting builds of the software tools with these disabled, some buffer problems were found using the default settings, under Windows, without the flow control. Running the software with WINE on Linux did not produce these issues. With some small tweaks to either the software or to Windows USB settings would fix the issue but that's not very intuitive. A better long term solution would be to wire up the hardware flow control lines in the next hardware revision for use in a future firmware update.

That's what I've done with the revision 4 PCB. In addition, I grounded a few unused digital lines on the micro to be able to, starting with rev4+, check what the hardware revision is in software. I also added two LEDs to the FT230X to allow it to signal on TX and RX.

(http://http://i.imgur.com/0nrNySOl.png) (http://http://imgur.com/0nrNySO)
Title: Re: GPIBUSB Adapter rev3
Post by: etroy on November 21, 2015, 05:36:02 pm
Does anyone know of a design for a GPIB to USB converter? (I know that is what this is called, but it is really a USB to GPIB converter which are plentiful, but, as noted, expensive.) I want a GPIB to USB converter so that I can use a conventional USB printer with a GPIB instrument such as a spectrum analyzer, logic analyzer, etc. Years ago, you could buy inkjet and laserjet printers that had IEEE-488 interfaces to use with such instruments, but today those printers are almost impossible to find. So, something that went from GPIB to USB would be very useful for allowing people with IEEE-488 test equipment to use modern USB printers.
I've looked, but so far I have not found any such products or designs.
Ed
Title: Re: GPIBUSB Adapter rev3
Post by: JanDonker9 on February 18, 2019, 08:38:19 pm
I tried to build something like this myself, so I figured I could use the code, but I don't have the non-free compiler that was used to build it. So I started translating it to SDCC, which gave me some funny warnings about unreachable code. And then I realised that these are in fact bugs. Binary "OR" is not the same as logical "OR".