Poll

Interested/Instrument/Interface

Yes,3458A,GPIB
17 (23.9%)
Yes,3458A,Prologix
10 (14.1%)
Yes,K2001/K2002,GPIB
11 (15.5%)
Yes, post type of instrument and type of interface (GPIB,Prologix,USB,LAN, RS232)
29 (40.8%)
Not interested, why?
4 (5.6%)

Total Members Voted: 44

Voting closed: December 13, 2016, 11:12:53 am

Author Topic: Raspberry Pi2/3 logging platform for Voltnuts  (Read 75514 times)

0 Members and 1 Guest are viewing this topic.

Offline z01z

  • Regular Contributor
  • *
  • Posts: 140
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #75 on: December 08, 2016, 11:30:19 am »
Reading back what I wrote, I'm sorry if this came through as a complaint, it wasn't aimed at you.
I can only be grateful for the idea and effort put into it. So thank you!
 

Offline z01z

  • Regular Contributor
  • *
  • Posts: 140
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #76 on: December 09, 2016, 06:55:46 pm »
I am waiting for the Agileng clone adapter implementation, i only have that one.   :popcorn:
For Agilent 82357B you'd need these additional commands

Code: [Select]
sudo apt-get install fxload
wget http://linux-gpib.sourceforge.net/firmware/gpib_firmware-2008-08-10.tar.gz
tar xvzf gpib_firmware-2008-08-10.tar.gz
sudo cp gpib_firmware-2008-08-10/agilent_82357a/measat_releaseX1.8.hex /usr/share/usb/agilent_82357a/

sudo cp /etc/gpib.conf /etc/gpib.conf.bak
sudo sed -i 's/ni_usb_b/agilent_82357a/g' /etc/gpib.conf
sudo sed -i 's/violet/agilent/g' /etc/gpib.conf
sudo sed -i '0,/set-bin = no/s//set-bin = yes/' /etc/gpib.conf

sudo modprobe agilent_82357a
sudo gpib_config

If "lsmod |grep agilent" shows these two lines:
pi@pi3:~ $ lsmod |grep agilent
agilent_82357a         18039  0
gpib_common            31540  1 agilent_82357a

Then this command makes loading the module permanent (otherwise the modprobe is needed after every reboot).
Code: [Select]
sudo sed -i -e "\$aagilent_82357a" /etc/modules
I hope I didn't miss anything.

You could also refer to TiN's guide.
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2284
  • Country: de
    • Frank Buss
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #77 on: December 10, 2016, 09:39:39 am »
I wrote a sample for my HM8012 and tested it with
, and created a github pull request, so that it can be integrated in the main github repository (and later in the SD card image). With the github repository, we could implement an update function, even over the web interface, to get the latest examples and framework code, without the need to update the whole SD card image and without overwriting your own code.

Maybe would be a good idea to add TiN's guide to the repository as well in a doc directory, so that it is all in one place and under version control, and all scripts and docs needed to create a new image from a fresh Raspbian image.
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 

Offline Assafl

  • Frequent Contributor
  • **
  • Posts: 580
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #78 on: December 10, 2016, 11:32:46 am »
RPi2/3 with HP82357B and a 34401A.

1. I followed TiN's excellent article and have the RPi2 working well with the HP82357B and the HP34401A replies with the proper ID text for a *IDN? command. Both direct GPIB calls as well as pyVISA work well.
2. My guess is that since the newer Keysight 6.5 digit models are backwards compatible with the 34401A - it may be a moot point to support all of these models using one script.

NB - if testVISA.py (pyVISA) fails to reply (not finding the interface) try to add the '@py' resource:
replace:
rm = pyvisa.ResourceManager()
with
rm = pyvisa.ResourceManager('@py')
 
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2284
  • Country: de
    • Frank Buss
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #79 on: December 10, 2016, 07:54:31 pm »
I think a Python measurement framework would be nice. Maybe we can use some parts of the project at http://sigrok.org that @lwatts666 mentioned?

An idea: a generic base class "Instrument". All instruments in common is the capability to measure something. An instrument has a fixed number of inputs (and maybe outputs?). Concrete instrument classes for a HP34401A, or a HM8012, are derived from the abstract base class and implement all the instrument specific initialization and communication. It might be possible to configure an input, e.g. select volt or ohm, and select a range or auto-range. For each input you can get an input reader, which reads this input and knows about more about the input, like the unit, e.g. V or A, or the instrument channel.Then a logger class. You can add inputs to it and it automatically reads all inputs and writes them with a timestamp to a file, in a selected interval.

Sounds difficult if you are not an object oriented programmer, but it makes it really easy to write your own custom measurement script for an advanced end user. Goal should be that you can write a script for an instrument, without knowing the GPIB commands or other details of the instrument, except some instrument specific configuration for selecting AC or DC etc. A logger program could look like this (I don't know much about Python, so this might not compile) :

Code: [Select]
try {
  # create a new instrument object. Opens the default port for this instrument
  # and initializes it to be used with the framework, e.g. ASCII output format, 9 digits etc.
  voltageMeter = new HP34401A();

  # application specific configuration of an input of the instrument.
  # optional parameter: channel=x, if there are more than one input
  voltageMeter.configure(command=HP34401A.DCV, value=10);

  # creates a new instrument object for a LM75A temperature sensor
  # uses the default I2C address 0x48 for A0-A2=0, if not specified in the constructor
  # the I2C address could be a generic parameter "port", which could be the GPIB address, or an I2C address,
  # and a factory function in the instrument which lists all available ports, to create a GUI for port selection later
  i2cTempSensor = new LM75A();

  # create a new logger object and add all inputs. The getInputtReader-function could have an optional channel parameter
  log = new Logging("/pub/logs/test.csv");
  log.add(voltageMeter.getInputReader());
  log.addInstrument(i2cTempSensor.getInputtReader());

  # start logging
  # this creates the log file, writes the CSV header and saves the current time for the exact measurement interval
  log.start();
  while (true) {
    # measures all configured inputs and writes it to the CSV file, with a leading timestamp
    log.measureInputs();

    # waits for the specified number of seconds, relative to the last call of this function, so that there is an the exact same interval between every measurement
    log.waitSeconds(10);
  }
  log.createWebpage("/pub/html/test.html");
} catch (exception) {
  print(exception);
}

So all you need to write for a volt/temperature combination logger, with website output, are about 10 lines of easy to understand code, which can be mixed with custom tasks, like switching relays after some time etc. The generated CSV file header should name the instrument and unit, and optionally the channel, or I2C address etc.:

(timestamp)(HP34401A, V)(LM75A, C)
10/12/2016-07:53:279.15222.3
10/12/2016-07:53:379.26422.2

The InputReader class has a function "measure", which returns a float for the measured value, and it has a function getUnit. Now the log object can have a function to create a standard webpage to display all configured instruments and inputs, with some nice diagram header and axis labeling. There could be also a getLastMeasure function in the InputReader class, which you can use in the measure loop to get the last value, if you want to compare it to something to do something, in addition to the log output.

One step further: There is a webpage, which lists all available instruments. You can add multiple instruments with a mouse click and individually configure each instrument and the measurement interval. The set of instruments with the configuration can be saved as a project. You can start a measurement and then a log file is named with the project name and a sequential number suffix. You can click on a log file to display, download and delete it.

An instrument can list the possible set of configuration parameters so that you can edit this in the web page when configuring an instrument. There could be some templates for an instrument with a set of configuration parameters, e.g. "measure DC voltage", "measure AC ampere", so that you don't have to lookup the meaning of all parameters. The templates are provided by the concrete instrument class. Each parameter has a description, so that it is self documenting, without needing to read a manual for an instrument.

For the webserver it might be a good idea to use the Python webserver http.server, because then it is easier to access the Python instrument classes and configuration. The Python webserver could also provide a JSON server interface, so that you can call your Raspberry Pi from other systems and create a set of distributed network connected measurement devices.

Shouldn't be too difficult to implement. An experienced Python developer with webserver and object oriented programming experience might be able to do it in one week full time. Too bad I don't have much time at the moment , but I can help with testing, bugfixing and framework design ideas, if someone wants to do it.
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 

Online ManateeMafia

  • Frequent Contributor
  • **
  • Posts: 719
  • Country: us
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #80 on: December 10, 2016, 09:14:38 pm »
@FrankBuss

Those are good suggestions and some of them are implemented in the python scripts used at xDevs . An example is here ... https://xdevs.com/doc/HP_Agilent_Keysight/3458A/test/dcv_ftp_b3.py
It comes in handy when you have two or more of the same meter. It can be difficult to initialize multiple meters without it becoming a long list of the same commands.

The 3458A and Keithley 2001/2 meters have been controlled this way for a while and once the code has been tested, only a couple lines of code are needed to create another instance. The same thing goes for the BME280. Adding more sensors will just require a similar bit of code .

I have not tried the http.server and I would like to see how easy it is to implement.
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2284
  • Country: de
    • Frank Buss
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #81 on: December 10, 2016, 10:14:56 pm »
I have not tried the http.server and I would like to see how easy it is to implement.

I just tried the webserver, now I can read the value of my benchtop multimeter which has only RS232, in a webpage and even from the internet, if I would add a NAT rule to my router  :)

https://github.com/FrankBuss/RPi_LogNut/blob/master/pub/python/HM8012_Webserver.py

How it looks like (the real version reloads automatically every second) :



Of course, this is just a quick hack. You would not create the web pages in the Python code, but state of the art is probably to use some WebSocket API, serve local static files and then some JavaScript communicates over the WebSocket with JSON requests with the Python script.
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 
The following users thanked this post: plesa

Offline plesa

  • Frequent Contributor
  • **
  • Posts: 965
  • Country: se
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #82 on: December 10, 2016, 10:30:07 pm »
@z01z
Thanks, it is know description.Your tutorial and others does not work for some 82357B clones, or at least for one which I have.
I found some information on various forums, but without any solution.On Windows machine it works ok.
And you can create udev rule to avoid executing commands every time you connect adapter.

@Assafl
I did not see any reason for pyVisa.

@ManateeMafia,@FrankBuss
It will be too complex for beginner, but I like idea, unfortunately it is not in my programming skills.
Multiple loggng scripts (one 3458A logging voltage and secon script for BME280) and combining data on D3 seems to be way to go to make it universal for now.



 
 

Offline plesa

  • Frequent Contributor
  • **
  • Posts: 965
  • Country: se
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #83 on: December 10, 2016, 10:32:15 pm »
I have not tried the http.server and I would like to see how easy it is to implement.

I just tried the webserver, now I can read the value of my benchtop multimeter which has only RS232, in a webpage and even from the internet, if I would add a NAT rule to my router  :)

https://github.com/FrankBuss/RPi_LogNut/blob/master/pub/python/HM8012_Webserver.py

How it looks like (the real version reloads automatically every second) :



Of course, this is just a quick hack. You would not create the web pages in the Python code, but state of the art is probably to use some WebSocket API, serve local static files and then some JavaScript communicates over the WebSocket with JSON requests with the Python script.

I like it, so on additional page can be actual values.
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2284
  • Country: de
    • Frank Buss
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #84 on: December 10, 2016, 11:21:31 pm »
@ManateeMafia,@FrankBuss
It will be too complex for beginner, but I like idea, unfortunately it is not in my programming skills.
Multiple loggng scripts (one 3458A logging voltage and secon script for BME280) and combining data on D3 seems to be way to go to make it universal for now.
Using classes will make it easier for the beginner, otherwise the framework programmer did something wrong :) Looks like ManateeMafia has some OOP and Python knowledge, would be cool if he could implement some of my ideas. plesa, if you accept my pull request, if you agree with the slightly changed structure (the html directory in the pub directory now), the current source code will be in your github repository, and ManateeMafia can fork it and modify and add some more code. Or you could add me and ManateeMafia as members to your project (might need to convert your account to a organization, which I think is still free, if you don't have private repositories), makes changing things easier.
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2284
  • Country: de
    • Frank Buss
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #85 on: December 11, 2016, 12:28:15 am »
Running multiple scripts and having multiple output files could have some problems, like out of sync and it is more complicated for the web page. Maybe as a start a universal Python script would be a good idea, which reads some simple JSON project file. Then all a user has to do, is to write a JSON project file, no need to program anything (and the JSON file creation could be supported by a neat web interface). An example for measuring volt and temperature:

Code: [Select]

   "LogFile":"/pub/log/test.csv",
   "MeasureInterval":"10",
   "Instruments":[ 
      { 
         "class":"HP34401A",
         "InitCommands":[ 
            { 
               "Command":"DCV",
               "Value":"10"
            },
            { 
               "Command":"LFILTER",
               "Value":"ON"
            }
         ],
         "Unit":"V"
      },
      { 
         "class":"LM75A",
         "Unit":"C"
      }
   ]
}

(I'm not sure if it makes sense to allow to specify multiple input channels, as proposed earlier, maybe better to just instantiate multiple instrument objects, even for the same physical instrument, and each instrument has just one channel.)

The Python script reads this file, creates all instrument classes and configures them, and writes the log file. The script could be even created now by merging all existing Python scripts in one big script, and evaluating the JSON input with it, but would be much better to create some clean classes. The same JSON file can be used from a general webpage, which creates the diagram with it. Special format specifiers, like colors etc., could be added to the JSON file.

This would be not as flexible as hand written Python, e.g. with custom actions when some limits are triggered, and custom HTML code, but I guess would work well for many measurement applications.
« Last Edit: December 11, 2016, 12:30:12 am by FrankBuss »
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1363
  • Country: dk
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #86 on: December 11, 2016, 07:06:44 pm »
@z01z
Thanks, it is know description.Your tutorial and others does not work for some 82357B clones, or at least for one which I have.
I found some information on various forums, but without any solution.On Windows machine it works ok.
And you can create udev rule to avoid executing commands every time you connect adapter.

@Plesa
Chang from Beiming told me that he had to do his own firmware for the adapters he made.
As they were not "Clones" they had other hw layout, and would not run with the agilent firmware.

Maybe that's the same with your clone , i know the "Gold clone" only works @Win.

@Assafl
I did not see any reason for pyVisa.

This is the first time i hear about pyVisa working on a non NI adapter.
Have i missed something ?

/Bingo

 

Offline Assafl

  • Frequent Contributor
  • **
  • Posts: 580
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #87 on: December 11, 2016, 08:20:46 pm »
TiN's documentation ends with a pyvisa example.
 

Offline plesa

  • Frequent Contributor
  • **
  • Posts: 965
  • Country: se
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #88 on: December 11, 2016, 08:25:21 pm »
Chang from Beiming told me that he had to do his own firmware for the adapters he made.
As they were not "Clones" they had other hw layout, and would not run with the agilent firmware.

Maybe that's the same with your clone , i know the "Gold clone" only works @Win.

@Assafl
I did not see any reason for pyVisa.

This is the first time i hear about pyVisa working on a non NI adapter.
Have i missed something ?

/Bingo

Clone is 1:1 HW copy of Agilent/Keysight one, it is not cubic version based on NI/NAT and Cypress chip which I also have but after few connection to PC it lost boot code for some reasons.
I suppose it is only question of linux-gpib settings and firmware. I used measat_releaseX1.8.hex.
TiN makes it work, maybe the clones are different. Till it is solved 82357B clones are out of game.Only genuine NI-GPIB HS, E5810 and Prologix will be supported. 
 

Offline Sbampato12

  • Regular Contributor
  • *
  • Posts: 211
  • Country: br
    • Sbampato.com
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #89 on: December 12, 2016, 12:56:10 pm »
I'm in.
Lately I'm in a hurry with some projects, but whenever possible I could contribute. I have some gears, and a NI PCI GPIB card in my computer.

I will order a new Rasp, since mine is the first one.... ???

Some gears are LAN, some have serial and a lot have GPIB and I can test, and help code something.
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1363
  • Country: dk
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #90 on: December 12, 2016, 01:32:51 pm »
I suppose it is only question of linux-gpib settings and firmware. I used measat_releaseX1.8.hex.
TiN makes it work, maybe the clones are different. Till it is solved 82357B clones are out of game.Only genuine NI-GPIB HS, E5810 and Prologix will be supported.

Seems like a strange decision , unless you meant 82357B clones , and still supports the original 82357B.
My Agilent clone & Beimings are running excellent w. linux-gpib.

How do you experience the problem ?

/Bingo
« Last Edit: December 12, 2016, 01:44:26 pm by bingo600 »
 

Offline Assafl

  • Frequent Contributor
  • **
  • Posts: 580
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #91 on: December 12, 2016, 08:42:16 pm »
I suppose it is only question of linux-gpib settings and firmware. I used measat_releaseX1.8.hex.
TiN makes it work, maybe the clones are different. Till it is solved 82357B clones are out of game.Only genuine NI-GPIB HS, E5810 and Prologix will be supported.

Seems like a strange decision , unless you meant 82357B clones , and still supports the original 82357B.
My Agilent clone & Beimings are running excellent w. linux-gpib.

How do you experience the problem ?

/Bingo

I don't know if that is what plesa is referring to - I am getting for ibtest with Genuine Agilent 82357B (and similar errors for Python):

gpib status is:
ibsta = 0xc100  < ERR TIMO CMPL >
iberr= 14
EBUS 14: Bus error
ibcnt = 0

I was able to see something happen with pyVisa - but can't even recreate that. 
 

Offline z01z

  • Regular Contributor
  • *
  • Posts: 140
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #92 on: December 13, 2016, 12:54:31 pm »
I also have a supposedly original 82357B, which only works in Windows. In linux the same error (EBUS 14: Bus error) happens for me as for Assafl.

Finally managed to dump what is sent from Windows, it is a bit different from what is in the gpib_firmware file.
In the measat_releaseX1.8.hex this is present (from line 75):
:100F200001010380320904000003000000000705EE
:100F3000820200020007050602000200070588037E
:100F400008000100090227000101048032090400A1

And this is sent from Windows (in the same format, with manually calculated checksum):
:100F200001010380FA090400000300000000070526
:100F3000820200020007050602000200070588037E
:100F4000080001000902270001010480FA090400D9

This is the only difference I could see, the same two bytes are different, the rest is the same.

I'm going to change the firmware accordingly and try it, but probably won't be able to do it not before the end of week. I'll report back with the results.
 

Offline plesa

  • Frequent Contributor
  • **
  • Posts: 965
  • Country: se
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #93 on: December 14, 2016, 08:18:37 am »
Thanks z01z.
Which file in Windows is firmware?
I just started clean Gentoo installation on RPi3 to check if issue persist.
On older kernel/linux-gpib this error has been solved by changing kernel parameter (timing), but it was for PCI and ISA boards.
Document with error messages
http://digital.ni.com/public.nsf/allkb/2FA525A8585A92E9862566EE002A3755
 

Offline z01z

  • Regular Contributor
  • *
  • Posts: 140
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #94 on: December 14, 2016, 09:15:51 am »
Sadly changing these bytes had no effect, the error still happened.

As for the driver, look for agt357run.inf. There's a separate driver for boot (agt82357.sys) and for run (agt357run.sys).
So you think this is a timing issue? I took some USB captures for both, I'll have a look at them. Downloading the firmware seems to work though, so I suppose it's how commands sent afterwards.
« Last Edit: December 14, 2016, 11:21:45 am by z01z »
 

Offline Assafl

  • Frequent Contributor
  • **
  • Posts: 580
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #95 on: December 14, 2016, 03:05:32 pm »
Concur changing the 2 words did not change the behavior for me as well.
 

Offline pelule

  • Frequent Contributor
  • **
  • Posts: 509
  • Country: de
  • What is business? It’s other people’s money
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #96 on: December 15, 2016, 06:13:51 pm »
Quote
GPIB interface:
Agilent 82357B ( official)  - we needs volunteer for testing
Agilent 82357B ( clone)  - I have dead clone only :(
I have the 1st version of Raspberry Pi - as never used this would a nice usage to log on my 3458A.
I also own an Agilent 82357B (not sure how to detect if official or a clone).
My very special feature request: allow to switch of the 3458A display.
BR
PeLuLe
You will learn something new every single day
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2284
  • Country: de
    • Frank Buss
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #97 on: December 15, 2016, 06:28:13 pm »
I've tested the image on an old Raspberry Pi 1, model B, and works without problem on this hardware.
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 

Offline plesa

  • Frequent Contributor
  • **
  • Posts: 965
  • Country: se
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #98 on: December 15, 2016, 06:34:02 pm »
I've tested the image on an old Raspberry Pi 1, model B, and works without problem on this hardware.

Thanks Frank!

Quote
GPIB interface:
Agilent 82357B ( official)  - we needs volunteer for testing
Agilent 82357B ( clone)  - I have dead clone only :(
I have the 1st version of Raspberry Pi - as never used this would a nice usage to log on my 3458A.
I also own an Agilent 82357B (not sure how to detect if official or a clone).
My very special feature request: allow to switch of the 3458A display.
BR
PeLuLe


Yes, it is done. I needs to solve 82357B support to release new version of image.
 

Offline pelule

  • Frequent Contributor
  • **
  • Posts: 509
  • Country: de
  • What is business? It’s other people’s money
Re: Raspberry Pi2/3 logging platform for Voltnuts
« Reply #99 on: December 15, 2016, 07:35:54 pm »
Is my undersatnding correct:
Raspberry is same time also logging at the environment (temperature. humidity, pressure) using the BME280 sensore (I2C)?
If yes - would great, as I have two of BME280 waiting for activity.

BR
PeLuLe
You will learn something new every single day
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf