Author Topic: Using a Raspberry PI with linux-gpib - and a Beiming or Agilent USB-GPIB adapter  (Read 78254 times)

0 Members and 1 Guest are viewing this topic.

Offline davorin

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Do you know who works on PHP support? Think it is still on version PHP-4.x the last time I've tried...

 

Offline bingo600Topic starter

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Do you know who works on PHP support? Think it is still on version PHP-4.x the last time I've tried...

I don't know.
For quite some time linux-gpib was just being "maintained" meaning there would come no new features, only bugfixes.

I don't know if that has changed, now where FMH is back in the team.

But Dave P has just released SVN 1643, that fixed my problem when making 1633 on a 32-bit Debian machine.
I'm running 1634 SVN now on a Beiming USB GPIB adapter.
Thank you for that Dave  :-+

/Bingo


 

Offline davorin

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Just checked out the latest SVN version and isntalled it...and of course did a reboot (o;

Still the same..won't do "remote select"...

Code: [Select]
libgpib: ibsre error
Traceback (most recent call last):
  File "crtu.py", line 6, in <module>
    v.remote_enable(1)
  File "/usr/local/lib/python2.7/dist-packages/Gpib.py", line 80, in remote_enable
    gpib.remote_enable(self.id,val)
gpib.GpibError: remote_enable() failed: One or more arguments to the function call were invalid.
 

Offline bingo600Topic starter

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
@davorin

What's the full source (or remote select example) ?
What adapter are you using ?

I have both a Beiming and an Agilent here

/Bingo
 

Offline davorin

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
That's just a simple Python script:

Code: [Select]
from Gpib import *

v = Gpib(0,20)

v.clear()
v.remote_enable(1)

v.write("*IDN?")

print v.read(200)


There isn't much documentation regarding "remote select" though....

It's a F82357 Beiming adapter...same with a S82357 adapter....well...hardware is exactly the same...just the firmware makes it a F or S model...

 

Offline bingo600Topic starter

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Are you sure that's the way to do it ??


from the py implementation in language
Code: [Select]

static char gpib_remote_enable__doc__[] =
"remote_enable -- set remote enable (board)\n"
"remote_enable(handle, enable)";

static PyObject* gpib_remote_enable(PyObject *self, PyObject *args)
{
int device;
int val;
int sta;

if (!PyArg_ParseTuple(args, "ii:remote_enable", &device,&val))
return NULL;

Py_BEGIN_ALLOW_THREADS
sta = ibsre(device,val);
Py_END_ALLOW_THREADS

if( sta & ERR){
_SetGpibError("remote_enable");
return NULL;
}

return PyInt_FromLong(sta);
}



From the doc (attached)  pg. 47

Quote
ibsre

Description
If enable is nonzero, then the board specified by the board descriptor ud asserts the REN line. If
enable is zero, the REN line is unasserted. The board must be the system controller.
Return value
The value of ibsta is returned.


I think the systemcontroller is your adapter (beiming) , usually addr 0.


Btw: I use gpib.find , to open the devices with
It has the advantage of using the gpib.conf file , and the names/settings from that one is automaticly set when the device is found/opened (ie. eos/eot values etc)


Code: [Select]
RQS=0x0800 #
SPOLL=0x0400        #


BOARD=gpib.find("agilent_82357b") # The GPIB Controller Board
PM6680=gpib.find("PM6680B")             # defined in /etc/gpib.conf - Phillips PM6680

gpib_conf(BOARD,gpib.IbcAUTOPOLL,1) # Enable Auto Spoll, for RQS detection
gpib_conf(BOARD,gpib.IbcSPollBit,1) # Enable Serial Spoll bit usage.
gpib_conf(PM6680,gpib.IbcSPollTime,gpib.T30s) # Enable Serial Spoll timeout , must match


gpib_timeout(PM6680,gpib.T30s)

print query(PM6680,"*IDN?")



/Bingo
« Last Edit: June 18, 2015, 07:29:57 pm by bingo600 »
 

Offline davorin

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Hmm...you might be right....that I have to specify the Beiming adapter to set rsel...not the end device...as the line is common to all devices....

 

Offline davorin

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Okay..this snippet doesn't show this error anymore...it just times out during reading back from the device...

Code: [Select]
#!/usr/bin/python

import Gpib

a = Gpib.Gpib('crtu')
b = Gpib.Gpib('agilent')

b.remote_enable(1)

a.write("*IDN?")

print a.read(200)

Guess now it's time to hook up some DSO to see what happens (o;

 

Offline bingo600Topic starter

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Okay..this snippet doesn't show this error anymore...it just times out during reading back from the device...

Code: [Select]
#!/usr/bin/python

import Gpib

a = Gpib.Gpib('crtu')
b = Gpib.Gpib('agilent')

b.remote_enable(1)

a.write("*IDN?")

print a.read(200)

Guess now it's time to hook up some DSO to see what happens (o;

EOI or EOS/EOT definition problems ?

/Bingo
 

Offline davorin

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Hmm...tried some combinations now...still no luck...

But the REN line is asserted correctly....dunno what this "extra_bytes_read=1" means in the dmesg output...
 

Offline davorin

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Odd....it gives the 3 seconds timeout both during write and during read....

BTW: is /etc/gpib.conf always reloaded when doing "sudo gpib_config" ?
 

Offline davorin

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Tried now all configurations possible in gpib.conf......so meaning 2 * 16 different configurations with either eos 0x0a or 0x0d...

Just won't answer...but answers quickly as soon I plug it into the WIn8.1 machine with Agilent I/O installed...

 

Offline bingo600Topic starter

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Odd....it gives the 3 seconds timeout both during write and during read....

BTW: is /etc/gpib.conf always reloaded when doing "sudo gpib_config" ?

I have no idea

Have you tried to "scope" the EOI line on a working windows, and then on linux ?

Ohh and the doc says that the Agilent USB's can only do 8-bit (binary) compare  (might be actual for eos/eot)

/Bingo
/Bingo
« Last Edit: June 20, 2015, 07:57:41 am by bingo600 »
 

Offline bang007

  • Newbie
  • Posts: 4
Hi guys,

First thanks to bingo600 for this documentation. I can now communicate with my tektronix TDS 3052 with my RPi B+ via GPIB :-+.
Every thing is ok except the hardcopy.
I  try to write a script in python to save the screenshoot in a png file but I get some errors. If any body can have a look on this. I am new in Python.
Many thanks for your help.

Code: [Select]
import visa

rm=visa.ResourceManager('@py')
scope = rm.open_resource('GPIB::6::0')

scope.write('HARDCOPY:FILENAME "test.png"')
scope.write('HARDCOPY:FORMAT PNG')
scope.write('HARDCOPY:LAYOUT LANDSCAPE')
scope.write('HARDCOPY:PORT GPIB')
scope.write('HARDCOPY START')

raw_data=scope.read()

fid=open('/home/pi/test.png','wb')
fid.write(raw_data)
fid.close()

And I got this error
Quote
File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pyvisa/resources/messagebased.py", line 312, in read
    message = self.read_raw().decode(enco)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 1031: ordinal not in range(128)
« Last Edit: June 24, 2015, 10:00:53 am by bang007 »
 

Offline bingo600Topic starter

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Hi guys,

First thanks to bingo600 for this documentation. I can now communicate with my tektronix TDS 3052 with my RPi B+ via GPIB :-+.
Every thing is ok except the hardcopy.
I  try to write a script in python to save the screenshoot in a png file but I get some errors. If any body can have a look on this. I am new in Python.
Many thanks for your help.

Code: [Select]
import visa

rm=visa.ResourceManager('@py')
scope = rm.open_resource('GPIB::6::0')

scope.write('HARDCOPY:FILENAME "test.png"')
scope.write('HARDCOPY:FORMAT PNG')
scope.write('HARDCOPY:LAYOUT LANDSCAPE')
scope.write('HARDCOPY:PORT GPIB')
scope.write('HARDCOPY START')

raw_data=scope.read()

fid=open('/home/pi/test.png','wb')
fid.write(raw_data)
fid.close()

And I got this error
Quote
File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pyvisa/resources/messagebased.py", line 312, in read
    message = self.read_raw().decode(enco)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 1031: ordinal not in range(128)

Have a look here
https://www.eevblog.com/forum/testgear/new-rigol-ds1054z-oscilloscope/msg675845/#msg675845

This is the one for reading Rigols , and raw reads work

Snip that read from the rigol one , and use for the TEK

/Bingo
 

Offline bang007

  • Newbie
  • Posts: 4
Thanks bingo600
I will try it and give  a feedback later  :-BROKE
 

Offline bang007

  • Newbie
  • Posts: 4

I still have a problem with the encodage. I use python 2.7 and pyVisa 1.7.
When I make a read_raw(), I have no error but my png image is empty (black background).
I've also tried  scope.read(encoding='UTF-8') but I got this error   :-//

Quote
File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pyvisa/resources/messagebased.py", line 312, in read
    message = self.read_raw().decode(enco)
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in position 3: invalid start byte

 

Offline bingo600Topic starter

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk

I still have a problem with the encodage. I use python 2.7 and pyVisa 1.7.
When I make a read_raw(), I have no error but my png image is empty (black background).
I've also tried  scope.read(encoding='UTF-8') but I got this error   :-//

Quote
File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pyvisa/resources/messagebased.py", line 312, in read
    message = self.read_raw().decode(enco)
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in position 3: invalid start byte

I think you have to ask a python expert in another message.
They prob. dont read gpib stuff

/Bingo
 

Offline TiN

  • Super Contributor
  • ***
  • Posts: 4543
  • Country: ua
    • xDevs.com
Revive, revive!  :-+

Many thanks, Bingo600 for your thread for GPIB-linux.

Spend some time and got my RaspberryPi talking well on GPIB using NI GPIB-USB-HS.

Step-by-step guide (click on photo) :

« Last Edit: August 15, 2015, 06:44:37 pm by TiN »
YouTube | Metrology IRC Chat room | Let's share T&M documentation? Upload! No upload limits for firmwares, photos, files.
 

Offline bingo600Topic starter

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
@TIN  :-+

Well done, now you can produce some nice Linux/Python scripts for measuring deviations on our DMM's.
Then us with Linux can play along.

/Bingo
 

Offline TiN

  • Super Contributor
  • ***
  • Posts: 4543
  • Country: ua
    • xDevs.com
Well, sorry for necroposting, but I think this one is bit important.

I got HP/Agilent 4142B mainframe which sports HP-IB interface and since this thing does not have any controls on it's FP, only way to use it talk via GPIB.
Oki-doki I thought, no problems, my RPI+linux-gpib is ready.

But bleeeep... Failed at first attempt. ibtest was working well and nice, instrument was accepting commands and reading feedback, just like it should be.

First I ran ibtest program to check if Raspberry Pi with linux-gpib package can talk with the instrument and read data back.

Code: [Select]
enter a string to send to your device: *IDN?
sending string: *IDN?
trying to read 40 bytes from device...
received string: 'HEWLETT PACKARD,4142B,0,4.30'

But attempt of using same thing in the usual Python binding thru linux-gpib rendered no good results, 4142B just entering TALK mode and does not feedback or execute any commands.

My python test app:

Code: [Select]
cat ./test.py
# xDevs.com Python test GPIB app
# http://xdevs.com/fix/a4142b/
import sys
import Gpib

inst = Gpib.Gpib(0,14) # 4142B GPIB Address = 27
inst.clear()
inst.write("*RST")
inst.write("*TST? 2")
str = inst.read(40)
print str

This should reset the instrument and issue command to perform self-test on module in slot 2. Nop, nothing, just TLK LED lit up and nothing happening. App give timeout error on inst.read command afterwards.

How I fixed it? Just add \n in write strings, and it works well now!

Code: [Select]
...
inst.write("*IDN?\n")
str = inst.read(40)
print str

Code: [Select]
root@pi2:/repo/3458# python ./test.py
HEWLETT PACKARD,4142B,0,4.30

Hope this helps someone.
YouTube | Metrology IRC Chat room | Let's share T&M documentation? Upload! No upload limits for firmwares, photos, files.
 

Offline bingo600Topic starter

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
@TIN

This is often needed on old HP equipment (the \n).
I seem to remember my 5384 needs it too.

/Bingo
 

Offline TiN

  • Super Contributor
  • ***
  • Posts: 4543
  • Country: ua
    • xDevs.com
Well, HP 3458A obviously fine without \n, as well as all my Keithley folks...  So it was new to me.
YouTube | Metrology IRC Chat room | Let's share T&M documentation? Upload! No upload limits for firmwares, photos, files.
 

Offline bingo600Topic starter

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Often the need for \n , is if/when EOI is not used by the instrument or adapter (or not set up correctly)
Then the instruments trigger on \n as a last resort.

/Bingo
 

Offline bingo600Topic starter

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
@TiN

Nice find  :-+ - About how to get kernel source & headers for the newer kernels (jessie) , in your NI GPIB section
https://xdevs.com/guide/ni_gpib_rpi/

I just build and installed the Agilent modules for my Raspi V3 & old Raspi V1 (jessie)
uname -a
Linux raspi-4 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linux


I haven't tested them on the adapter yet , but i can load (modprobe) the modules
sudo modprobe agilent_82357a


/Bingo
« Last Edit: April 16, 2016, 08:03:48 pm by bingo600 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf