Author Topic: AR488 Arduino-based GPIB adapter  (Read 13713 times)

ArthurDent and 2 Guests are viewing this topic.

Offline WaveyDipole

  • Frequent Contributor
  • **
  • Posts: 366
  • Country: gb
AR488 Arduino-based GPIB adapter
« on: February 07, 2019, 01:09:29 pm »
For the last 4 months or so, I have been working on an updated GPIB firmware for the Arduino. This was originally inspired by Emanuele Girlando's Arduino GPIB sketch which can be found here:

http://egirland.blogspot.com/2014/03/arduino-uno-as-usb-to-gpib-controller.html

My updated sketch implements the same pin assignment scheme, but the sketch is an almost complete re-write of Emanuele's original code with the remaining controller functions now implemented. SRQ and REN lines are now fully supported and device mode has also been added. The ++lon device mode command is currently the only unsupported command. Since I don't have a device that supports secondary addressing to test with, secondary addressing has not been implemented yet. This sketch has been released with Emanuele Girlando's permission and I would like to gratefully acknowledge his helpful observations. I would also like to thank Luke Mester for his invaluable and considerable help with testing.

The code can be found here:
https://github.com/Twilight-Logic/AR488

Problems with the firmware can be logged via the Issues feature on the GitHub page.
Any observations and suggestions for further improvement are welcome.

Offline sundance

  • Contributor
  • Posts: 39
  • Country: ch
Re: AR488 Arduino-based GPIB adapter
« Reply #1 on: February 07, 2019, 02:34:10 pm »
Thank you very much for your excellent work!
Last year I also decided to write my own GPIB controller software for the Arduino (when I bought an HP-3478A). It worked - although I didn't finish it yet. And it's always extremely interesting to see how others do it...

-sundance
 
The following users thanked this post: mlefe

Offline metrologist

  • Super Contributor
  • ***
  • Posts: 1760
  • Country: 00
Re: AR488 Arduino-based GPIB adapter
« Reply #2 on: February 07, 2019, 05:37:12 pm »
Spectacular. I was concerned because I recall Girlando did not want derivatives. You mention he reviewed and authorized this.

Inspired by the original work of Emanuele Girlando, licensed under a Creative
Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
Any code in common with the original work is reproduced here with the explicit
permission of Emanuele Girlando, who has kindly reviewed and tested this code.

Thanks also to Luke Mester for comparison testing against the Prologix interface.
AR488 is Licenced under the GNU Public licence.


I'm not that versed on the licensing though and it is not clear to me if your code is protected by Creative
Commons Attribution-NonCommercial-NoDerivatives 4.0 International License or the GNU Public licence, or if those are the same references as you mention both. Sorry to bring up licensing topic, but I am not sure now what is restricted to modify and if possible what, and thanks for the work to advance the code.
 

Offline sundance

  • Contributor
  • Posts: 39
  • Country: ch
Re: AR488 Arduino-based GPIB adapter
« Reply #3 on: February 07, 2019, 06:05:26 pm »
Quote
(...) but the sketch is an almost complete re-write of Emanuele's original code
That sounds more than just some adjustments/patches to Emanuele's code. And if you compare both WaveyDipole's to Emanuele's code there are not too many sections that are similar, except the obvious parts that cover hardware compatibility.
It's like with my own code: I took ideas from Emanuele and others (like here: http://www.rudiswiki.de/wiki/GPIBtoUSB_Nano3) who wrote GBIB software for the Arduino. But since I also wrote it from scratch, the final result is completely different. The only thing (concerning licence and patents) that worried me was the use of the (quasi standard) Prologix command syntax.
« Last Edit: February 07, 2019, 06:08:08 pm by sundance »
 

Offline kutte

  • Contributor
  • Posts: 28
  • Country: de
Re: AR488 Arduino-based GPIB adapter
« Reply #4 on: February 07, 2019, 06:16:14 pm »
thank you,
but does not compile. Errors are
AR488-0-45-10:758: error: invalid conversion from 'void (*)()' to 'void (*)(char*)' [-fpermissive]
plenty of them..
AR488-0-45-10:758: error: invalid conversion from 'void (*)()' to 'void (*)(char*)' [-fpermissive]
AR488-0-45-10.ino: In function 'bool gpibSendData(char*, uint8_t)':
AR488-0-45-10:1964: error: return-statement with no value, in function returning 'bool' [-fpermissive]
invalid conversion from 'void (*)()' to 'void (*)(char*)' [-fpermissive]
Kutte


 

Offline maxwell3e10

  • Frequent Contributor
  • **
  • Posts: 394
  • Country: us
Re: AR488 Arduino-based GPIB adapter
« Reply #5 on: February 10, 2019, 12:36:17 am »
I tried it with an Atmega328p NANO board. It works OK if I don't use ++auto command.   If I use ++auto 1 command, everything gets slowed down, so even ++ver  response is delayed by the timeout. Also the ++rst command makes it hang.

To make EZGPIB recognize the adapter, it needs to have "GPIB-USB" string in the ++ver response.

 

Online texaspyro

  • Super Contributor
  • ***
  • Posts: 1267
Re: AR488 Arduino-based GPIB adapter
« Reply #6 on: February 10, 2019, 05:09:20 am »
To make EZGPIB recognize the adapter, it needs to have "GPIB-USB" string in the ++ver response.

Years ago I had to make a GPIB interface that emulated a Prologix adapter (at the time the Prologix code wrote to EEPROM every time certain commands were sent and this killed the EEPROM rather quickly if you talked to multiple devices).  To get my code to work with the program that was controlling it I had to output the ++ver (or was it a help command?) verbatim to what Prologix was sending.
 

Offline kutte

  • Contributor
  • Posts: 28
  • Country: de
Re: AR488 Arduino-based GPIB adapter
« Reply #7 on: February 10, 2019, 04:23:06 pm »
thank you,
but does not compile. Errors are
AR488-0-45-10:758: error: invalid conversion from 'void (*)()' to 'void (*)(char*)' [-fpermissive]
plenty of them..
AR488-0-45-10:758: error: invalid conversion from 'void (*)()' to 'void (*)(char*)' [-fpermissive]
AR488-0-45-10.ino: In function 'bool gpibSendData(char*, uint8_t)':
AR488-0-45-10:1964: error: return-statement with no value, in function returning 'bool' [-fpermissive]
invalid conversion from 'void (*)()' to 'void (*)(char*)' [-fpermissive]
Kutte

error handling seems to have been downgraded to warnings after updating Arduino IDE fro 1.6.5 to 1.8.19
Kutte
 

Offline WaveyDipole

  • Frequent Contributor
  • **
  • Posts: 366
  • Country: gb
Re: AR488 Arduino-based GPIB adapter
« Reply #8 on: February 10, 2019, 04:33:37 pm »
I tried it with an Atmega328p NANO board. It works OK if I don't use ++auto command.   If I use ++auto 1 command, everything gets slowed down, so even ++ver  response is delayed by the timeout. Also the ++rst command makes it hang.

To make EZGPIB recognize the adapter, it needs to have "GPIB-USB" string in the ++ver response.

The string can be changed with the ++setvstr command and saved with the ++savecfg command.

Thanks for the feedback regarding the NANO, including slowdown and ++rst hanging.
I will need to investigate these further.
« Last Edit: February 10, 2019, 10:31:44 pm by WaveyDipole »
 

Offline WaveyDipole

  • Frequent Contributor
  • **
  • Posts: 366
  • Country: gb
Re: AR488 Arduino-based GPIB adapter
« Reply #9 on: February 10, 2019, 10:17:42 pm »
thank you,
but does not compile. Errors are
AR488-0-45-10:758: error: invalid conversion from 'void (*)()' to 'void (*)(char*)' [-fpermissive]
plenty of them..
AR488-0-45-10:758: error: invalid conversion from 'void (*)()' to 'void (*)(char*)' [-fpermissive]

error handling seems to have been downgraded to warnings after updating Arduino IDE fro 1.6.5 to 1.8.19
Kutte

I am using Arduino IDE version 1.8.7 (Linux)/1.8.8 (Win) standalone (.zip package) downloaded directly from the Arduino.cc site for development and neither seems to generate these errors or warnings. I haven't tested it with v1.8.8/1.8.19 downloaded from the Win 10 store though. I will investigate further.
Issue logged: https://github.com/Twilight-Logic/AR488/issues/2

EDIT: Tested with Arduino IDE 1.8.8/1.8.19.0 downloaded from the Win10 store and it seems these warnings do indeed appear in that version. I will investigate and see whether the code can be adjusted to avoid them. For further updates, please follow the linked issue on GitHub.

AR488-0-45-10.ino: In function 'bool gpibSendData(char*, uint8_t)':
AR488-0-45-10:1964: error: return-statement with no value, in function returning 'bool' [-fpermissive]
invalid conversion from 'void (*)()' to 'void (*)(char*)' [-fpermissive]
Kutte

I believe I know what the problem is and it will be fixed in the next update.
Issue logged: https://github.com/Twilight-Logic/AR488/issues/1
« Last Edit: February 12, 2019, 11:27:04 am by WaveyDipole »
 
The following users thanked this post: coromonadalix

Offline WaveyDipole

  • Frequent Contributor
  • **
  • Posts: 366
  • Country: gb
Re: AR488 Arduino-based GPIB adapter
« Reply #10 on: February 12, 2019, 12:01:45 pm »
Version 0.45.11 uploaded. This should address the compiler warnings in Arduino IDE v1.8.8/1.8.19.0.
 

Offline kutte

  • Contributor
  • Posts: 28
  • Country: de
Re: AR488 Arduino-based GPIB adapter
« Reply #11 on: February 13, 2019, 10:34:13 am »
Version 0.45.11 uploaded. This should address the compiler warnings in Arduino IDE v1.8.8/1.8.19.0.

thank you again, but a lot of warnings still exist:

Y:\USB_16GB\Voltage reference\GPIB\ar488-arduino\ar488\AR488.ino:153:0: warning: "SPE" redefined

 #define SPE 0x18

In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:272:0,
                 from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\pgmspace.h:90,
                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28,
                 from sketch\AR488.ino.cpp:1:
c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\iom328p.h:294:0: note: this is the location of the previous definition
 #define SPE 6
Y:\USB_16GB\Voltage reference\GPIB\ar488-arduino\ar488\AR488.ino:758:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

 Y:\USB_16GB\Voltage reference\GPIB\ar488-arduino\ar488\AR488.ino:758:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

Y:\USB_16GB\Voltage reference\GPIB\ar488-arduino\ar488\AR488.ino:758:1: warning: invalid conversion from 'void (*)()' to 'void (*)(char*)' [-fpermissive]

Y:\USB_16GB\Voltage reference\GPIB\ar488-arduino\ar488\AR488.ino:758:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

and many !!! more, Kutte
 

Online coromonadalix

  • Super Contributor
  • ***
  • Posts: 1930
  • Country: ca
Re: AR488 Arduino-based GPIB adapter
« Reply #12 on: February 13, 2019, 10:53:46 pm »
Witch arduino version do you have when you try to compile it  ???,  please  be more specific with your errors to help  WaveyDipole

On my 1.8.8 IDE   it compiled and sent just fine for an duemilanove and a uno,  for tests purposes ??
« Last Edit: February 13, 2019, 11:00:53 pm by coromonadalix »
 

Offline kutte

  • Contributor
  • Posts: 28
  • Country: de
Re: AR488 Arduino-based GPIB adapter
« Reply #13 on: February 14, 2019, 04:08:37 pm »
compiled with version 1.8.8 this time without any erros. Don't know what happend the last time, sorry for any confusion.
Kutte
 

Offline WaveyDipole

  • Frequent Contributor
  • **
  • Posts: 366
  • Country: gb
Re: AR488 Arduino-based GPIB adapter
« Reply #14 on: February 14, 2019, 05:53:51 pm »
kutte, thanks for the update. The warning is interesting since it indicates a definition as it indicates that 'SPE' is defined elsewhere in the Arduino IDE support files. I will need to have a think about how to deal with this - probably will have to change all of my #define names.

Glad you got it compiled without error in the meantime. Curious that the IDE should behave in such an inconsistent manner.
 

Offline Kean

  • Supporter
  • ****
  • Posts: 850
  • Country: au
  • Embedded systems & IT consultant
    • Kean Electronics
Re: AR488 Arduino-based GPIB adapter
« Reply #15 on: February 15, 2019, 10:58:28 am »
kutte, thanks for the update. The warning is interesting since it indicates a definition as it indicates that 'SPE' is defined elsewhere in the Arduino IDE support files. I will need to have a think about how to deal with this - probably will have to change all of my #define names.

Yes, you may want to add a prefix in front of your shorthand definitions just to be on the safe side.

In particular SPE is also defined in various Arduino hardware includes as the "SPI Enable" bit in one of the AVR Special Function Registers.
See for example hardware/tools/avr/avr/include/avr/iom328p.h (included via hardware/tools/avr/avr/include/avr/io.h)

Thanks for this updated code by the way.  It is something I think I can use in the future for some HPIB CS/80 disk interfacing I want to do.
 

Offline WaveyDipole

  • Frequent Contributor
  • **
  • Posts: 366
  • Country: gb
Re: AR488 Arduino-based GPIB adapter
« Reply #16 on: February 23, 2019, 06:24:01 pm »
I tried it with an Atmega328p NANO board. It works OK if I don't use ++auto command.   If I use ++auto 1 command, everything gets slowed down, so even ++ver  response is delayed by the timeout. Also the ++rst command makes it hang.

To make EZGPIB recognize the adapter, it needs to have "GPIB-USB" string in the ++ver response.

Could you please provide the exact sequence of commands you used to reproduce the issue?
Also, what equipment are you driving please?

I am using quite a slow meter, so perhaps not noticing the issue.

Thanks.

 

Offline maxwell3e10

  • Frequent Contributor
  • **
  • Posts: 394
  • Country: us
Re: AR488 Arduino-based GPIB adapter
« Reply #17 on: February 23, 2019, 10:26:49 pm »
I was testing it with HP3457 meter. I use a serial terminal to issue ++addr 22 command and then start sending commands through it. If I set ++auto 1 and the meter is send command TRIG SGL, then there is a significant delay before it gives a reading. Also there is the same delay for ID? command or ++ver command.

On the other hand, if I set the meter to TRIG AUTO, the program gives a continuous stream of voltage readings in the ++auto 1 mode. This maybe is useful, but its not the behavior one would expect.  I think the problem maybe that the program issues a continuous stream of ++read commands in the ++auto 1 mode. My guess is that the buffer is getting delayed by ++read commands when no answer is supposed to come from the meter.
 

Offline WaveyDipole

  • Frequent Contributor
  • **
  • Posts: 366
  • Country: gb
Re: AR488 Arduino-based GPIB adapter
« Reply #18 on: February 24, 2019, 08:15:04 pm »
On the other hand, if I set the meter to TRIG AUTO, the program gives a continuous stream of voltage readings in the ++auto 1 mode. This maybe is useful, but its not the behavior one would expect.  I think the problem maybe that the program issues a continuous stream of ++read commands in the ++auto 1 mode. My guess is that the buffer is getting delayed by ++read commands when no answer is supposed to come from the meter.

Thank you for taking the time to feed back the details of the problem. The section on the auto command in the Prologix manual says that it "saves the user from having to issue read commands repeatedly", which sounds like a process that performs repeated read commands automatically. Having read that section again in conjunction with your observations, I am now wondering whether what was meant is that it should perform ONE read automatically after a command is issued, saving the user from having to issue a ++read after each command sent to the instrument? In that context the note regarding the "Query unterminated or -420 error" starts to make sense. However, the example still doesn't seem to fit in somehow so I'm still not sure. Moreover, how does one set parameters for this automatic read (e.g. ++read eoi)? It would be appreciated if you or someone else reading this could explain what behavior one would expect from the auto 1 command?

I will be happy to adjust the program to comply with the expected behavior.
« Last Edit: February 24, 2019, 08:22:29 pm by WaveyDipole »
 

Offline maxwell3e10

  • Frequent Contributor
  • **
  • Posts: 394
  • Country: us
Re: AR488 Arduino-based GPIB adapter
« Reply #19 on: February 24, 2019, 11:19:19 pm »
I don't have Prologix's original software, but the behavior I observed with Girlando's code is that in ++auto 1 mode just one ++read command is issued after each command sent to the device. This generally make sense, since most GPIB instruments (except some meters in auto mode) don't have new data available in the buffer for reading at all times, only in response to a specific command.

On the other hand, for the case when data are available, it maybe useful to keep the auto mode as you have implemented it, simulating "Talk only" GPIB mode. So perhaps it would make sense to keep the continuous reading option that you have already implemented with something like ++auto 2 setting.

An even fancier implementation would be to look for "?" as the last character in the command sent to the meter. If there is a ?, then execute one ++read command, if not then don't execute the read command.  Otherwise, the ++auto 1 mode can still cause errors if a command doesn't generate a response from the device.
 

Online GregDunn

  • Frequent Contributor
  • **
  • Posts: 691
  • Country: us
Re: AR488 Arduino-based GPIB adapter
« Reply #20 on: February 27, 2019, 02:27:14 am »
I appreciate the effort in producing a GPIB compatible interface for Arduino.  My boards are on the way and should be here soon; meanwhile, I'm trying to assemble the resources so that I can put them to use.

I have downloaded the AR488 code and it compiles properly, so shipping it to the Uno board (standard FTDI interface, not the CH340G) should be straightforward.

Now, here's where I need some guidance: I have one PC, but it's in a different room from the workspace and would be very inconvenient.  I have several Macs, of which two are portable and can be set up on the bench.  I understand that EZGPIB and the GPIB Toolkit only run on Windows, but that having the FTDI drivers I can talk directly to the AR488 with GPIB commands via a terminal through USB, correct? 

Is it possible to script communications to the interface without the special software, using the terminal and a shell script?  I realize I'd be giving up some of the capabilities, but all I really need to do is read and write a few things from the target device (DMM data and in the case of my HP 3478A, cal data).  It doesn't have to be anything fancy, and I'm comfortable with *nix shell scripting.
 

Offline maxwell3e10

  • Frequent Contributor
  • **
  • Posts: 394
  • Country: us
Re: AR488 Arduino-based GPIB adapter
« Reply #21 on: February 27, 2019, 05:03:18 am »
Yes, all of these serial-interface GPIB don't require a special driver. A simple serial terminal program can be used interactively or any program (pythod, matlab) that can talk to the serial port.
 
The following users thanked this post: GregDunn

Online GregDunn

  • Frequent Contributor
  • **
  • Posts: 691
  • Country: us
Re: AR488 Arduino-based GPIB adapter
« Reply #22 on: February 28, 2019, 08:02:40 pm »
Well, that was anticlimactic.   :D  Plugged the Uno into a USB port, uploaded the sketch, connected via 'screen' and it just worked.  Unfortunately, there's a bug in 'screen' that prevents setting local echo, so I've been using CoolTerm to verify that the interface is communicating to the Mac.  (I really want to use *nix scripting to do this, rather than CoolTerm's Applescript.   :P  I may end up using another screen emulator)

Now, to wire up the GP-IB plug and try it out on my HP 3478A...
 

Offline Krampmeier

  • Regular Contributor
  • *
  • Posts: 78
  • Country: de
Re: AR488 Arduino-based GPIB adapter
« Reply #23 on: February 28, 2019, 08:11:12 pm »
Many thanks for creating and sharing this!
I built the adapter with a chinese Arduino Nano clone, using the latest "nightly" Arduino compiler. Got a lot of warnings (including the one about the duplicate definition of  'SPE' ), but no errors.

Communication with my HP 4192A impedance analyzer sees to work fine, but when I sent *IDN? to a Keithley 2001, the first 1 to 3 characters of the response were always wrong. Same with a Keithley 2010.

I just tried it again:
Quote
*idn?
++read
OEITHLEY INSTRUMENTS INC.,MODEL 2010,0632912,A15  /A02
fetch?
++read
m9.59916086E-01
:SENS:FUNC?
++read
bVOLT:DC"

Edit: I just noticed that the Keithley's display twitches when I send the ++read command. The instrument also clears the "REM" indicator, so it goes out of remote mode. Hmmm. Did I make a mistake in the wiring?

The behaviour with ++auto 1 does not make sense with the DMMs, as the DMM starts showing Errors when the adapter tries to read something when nothing is there. It does work with the 4192A. I agree with maxwell3e10 that there are two options for "auto read" which can make sense depending on the instrument.
« Last Edit: February 28, 2019, 09:07:48 pm by Krampmeier »
 

Online coromonadalix

  • Super Contributor
  • ***
  • Posts: 1930
  • Country: ca
Re: AR488 Arduino-based GPIB adapter
« Reply #24 on: February 28, 2019, 09:14:38 pm »
would be nice to have a final schematic / wiring to be sure we dont miss something ??
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf