Monday, November 25, 2013

Continuous Measurements with a 34461A Digital Multimeter

I've heard this question being asked in the office and in the forums for a while now. How do I continuously sample with the 34461A? Continuously sampling is the term that we use to get the DMM to take readings without filling up it's reading memory. The 34461A has a 1000 reading limit for any single data file. If you are doing long term readings or taking fast readings this can fill up very quickly. But if you are willing to do a little bit of programming, you can bypass this limit and take as many readings as you need...at least until your computer's hard drive fills up.

The key with programming this DMM is SCPI programming. For those of you who aren't familiar with it, SCPI stands for Standard Commands for Programmable Instruments (SCPI). Wikipedia defines it as " (often pronounced "skippy") defines a standard for syntax and commands to use in controlling programmable test and measurement devices". To program using SCPI you need a programming language such as C, Labview, C#, Matlab,  or anything else that can allow you to send text messages to instruments.

The typical method of programming a DMM to take readings is to send the READ? command. This triggers the DMM and does a single reading. Agilent has provided some good examples for programming the Truevolt DMMs. These are available in C#, VB, Labview, and Matlab. You can find the link here: Truevolt DMM programming.

However to do continuous readings you need to use a different set of commands.

TRIGGER:COUNT - this command determines the number of triggers to send to the DMM.
INIT - this command tells the DMM to start its readings
DATA:REM? X, WAIT - This command tells the DMM to take an X number of readings from its reading buffer and send them to the PC. If the number of readings is not available then the WAIT parameter tells the DMM to wait until they are available before sending it over. This command and R? are the the most efficient reading commands for the DMM to process.

These commands are also supported on the 34410A and 34411A. I haven't tested but I think that the below code would work with those models as well. If it doesn't email me and I'll publish an update for those models.

I've pasted an example set of C# code below. If you are just interested in understanding how it works, here is a pseudo code explanation:

CONF:DCV Setup your reading Function
TRIG:COUNT 20000 Take 20000 readings
TRIG:SOUR IMM  Set the trigger sour to internal triggering
INIT  Start the readings
For (i = 0, i<1000, i++) start a for loop that runs 1000 times
    DATA:REM? 20, WAIT   Remove 20 readings at a time
Next i

The purpose of removing 20 readings at a time is to continuously empty the DMM's reading buffer. By removing a relatively small number of readings, this reduces any processing headroom that the DMM needs for data transfer. The benefit is that the DMM's reading speed and accuracy is not affected by the data transfer. The combination of reading 20 readings x 1000 loops gives us 20,000 readings.


Here's an example of the output from the code. This example shows the reading in the first column and the reading number in the second column. This proves that I just took 20,000 readings from my DMM and it took about 6 minutes 40 seconds to gather all those readings.



You can download the project containing the continuous measurements code here. As of the time publication of this, I do not have the code in any other language beside C#. However, you can easily use the SCPI commands in your language of preference.


The 34461A SCPI reference is contained in the Truevolt Operating and Service guide. The link is to the pdf document found on Agilent.com. The SCPI reference starts on page 101.


So without further ado, here is the code in C# to take continuous readings:


using System;

using System.Collections.Generic;

using System.Text;

using Ivi.Visa.Interop;



//'' """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

//''  © Agilent Technologies, Inc. 2013

//''

//'' You have a royalty-free right to use, modify, reproduce and distribute

//'' the Sample Application Files (and/or any modified version) in any way

//'' you find useful, provided that you agree that Agilent Technologies has no

//'' warranty,  obligations or liability for any Sample Application Files.

//''

//'' Agilent Technologies provides programming examples for illustration only,

//'' This sample program assumes that you are familiar with the programming

//'' language being demonstrated and the tools used to create and debug

//'' procedures. Agilent Technologies support engineers can help explain the

//'' functionality of Agilent Technologies software components and associated

//'' commands, but they will not modify these samples to provide added

//'' functionality or construct procedures to meet your specific needs.

//'' """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""





namespace ContinuousSampling

{

    class ContinousSampling

    {

        static void Main(string[] args)

        {

        

            ContinousSampling DmmClass = new ContinousSampling(); //Create an instance of this class so we can call functions from Main



            //For more information on getting started using VISA COM I/O operations see the app note located at:

            //http://cp.literature.agilent.com/litweb/pdf/5989-6338EN.pdf



            Ivi.Visa.Interop.ResourceManager rm = new Ivi.Visa.Interop.ResourceManager(); //Open up a new resource manager

            Ivi.Visa.Interop.FormattedIO488 myDmm = new Ivi.Visa.Interop.FormattedIO488(); //Open a new Formatted IO 488 session

            try

            {

                string DutAddr = "GPIB0::22"; //String for GPIB

                //string DutAddr = ""TCPIP0::169.254.4.61";  //Example string for LAN

                //string DutAddr = "USB0::0x0957::0x1A07::MY53000101"; //Example string for USB

               



                myDmm.IO = (IMessage)rm.Open(DutAddr, AccessMode.NO_LOCK, 2000, ""); //Open up a handle to the DMM

                myDmm.IO.Timeout = 5000;



                //First start with a reset state

                myDmm.IO.Clear(); //Send a device clear first to stop any measurements in process

                myDmm.WriteString("*RST", true); //Reset the device

                myDmm.WriteString("*IDN?", true); //Get the IDN string               

                string IDN = myDmm.ReadString();

                Console.WriteLine(IDN); //report the DMM's identity



                //Configure the 34461 DCV Measurement state

                myDmm.WriteString("CONF:VOLT:DC 10", true);              //Configure DCV, 10V range

                myDmm.WriteString("VOLT:IMP:AUTO OFF", true);       //10M input impedance setting , "ON" sets >10Gohm

                myDmm.WriteString("SENS:VOLT:DC:ZERO:AUTO OFF", true);   // Autozero Off               

                myDmm.WriteString("VOLT:NPLC .02", true);               //Set Integration Time;Resolution to .02 PLC (333uSec)

                DmmClass.CheckDMMError(myDmm);                      //Check the DMM for errors





                //Configure trigger settings

                myDmm.WriteString("TRIG:SOUR IMM", true);                //Set trigger source to internal                               

                myDmm.WriteString("TRIG:DEL:AUTO OFF", true);            //Turn OFF Automatic trigger delay

                myDmm.WriteString("TRIG:DEL .019", true);                   // Set trigger delay to 19.6 msec (Delay + Integration time = 20msec               

                myDmm.WriteString("TRIG:COUN 50000", true);                  //Set trigger count to 50,000               

                DmmClass.CheckDMMError(myDmm);                      //Check the DMM for errors

                            

                //Trigger and make the readings

                myDmm.IO.Timeout = 10000;                             //Allow 10 seconds for DMM to make readings               



                //Here's the code to continously get the readings                               

                List<double> AllReadings = new List<double>();

                //Do a single init to start all the readings. The trigger count set above will ensure that we get our readings

                myDmm.WriteString("INIT", true);    



                DateTime time = DateTime.Now;  //Set a timer to measure the time difference to get all the readings

                int SampleCnt = 0;

                //Get 50,000 readings. We use DATA:REM to get a small chunk of readings at a time so transfer rates

                //won't affect measurements

                for (int i = 0; i<1000; i++)

                {

                   

                    myDmm.WriteString("DATA:REM? 50,WAIT",true);

                    Object[] DCVResult = (object[])myDmm.ReadList(IEEEASCIIType.ASCIIType_Any, ",;"); //Read the result into an array that is , separated

                    foreach (double Reading in DCVResult)

                    {                       

                        AllReadings.Add(Convert.ToDouble(Reading)); //Convert the readings and add it to the AllReadings List if you want a double arry                                             

                    }

                }

                TimeSpan Diff1 = DateTime.Now.Subtract(time); //Get the difference in time that it took to get 50K readings

               

                //Show the readings in a console

                foreach (double rdg in AllReadings)

                {

                    Console.WriteLine(rdg + "," + SampleCnt.ToString());

                    SampleCnt++;

                }

                Console.WriteLine("Total time for readings = " + Diff1); //Finally report the difference in time.

            }

            catch (Exception e)

            {

                Console.WriteLine("Error occured: " + e.Message);

            }

            finally

            {

                //Close out your resources

                try { myDmm.IO.Close(); }

                catch { }

                try { System.Runtime.InteropServices.Marshal.ReleaseComObject(myDmm); }

                catch { }

                try

                {

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(rm);

                }

                catch { }

                Console.WriteLine("Press any key to continue...");

                Console.ReadKey();



            }

        }

        /// <summary>

        /// Checks the error queue and throws an exception if error

        /// </summary>

        /// <param name="myDmm"></param>

        public void CheckDMMError(FormattedIO488 myDmm)

        {



            myDmm.WriteString("SYST:ERR?", true);

            string errStr = myDmm.ReadString();



            if (errStr.Contains("No error")) //If no error, then return

                return;

            //If there is an error, read out all of the errors and return them in an exception

            else

            {

                string errStr2 = "";

                do

                {

                    myDmm.WriteString("SYST:ERR?", true);

                    errStr2 = myDmm.ReadString();

                    if (!errStr2.Contains("No error")) errStr = errStr + "\n" + errStr2;



                } while (!errStr2.Contains("No error"));

                throw new Exception("Exception: Encountered system error(s)\n" + errStr);

            }



        }

    }
}

76 comments:

  1. Updated mid-April with links to SCPI documentation and a google drive download for the project.

    ReplyDelete
  2. Kassa

    Vi erbjuder Kvalité och snabb service och vet att det är mycket viktigt att få saker gjort snabbt , därför kan vi erbjuda service avtal Från 99:-/mån så du får snabbt på plats service (även distans avtal)och så ser vi till att du alltid håller ditt kassasystem uppdaterad med den nyaste programvaran!

    Kontakt información:

    Norra Ågatan 5 A Arboga Västmanland 732 31
    teléfono: 0589-10031
    Site: www.kassanetto.se

    ReplyDelete
  3. Kamera

    Vi erbjuder Kvalité och snabb service och vet att det är mycket viktigt att få saker gjort snabbt , därför kan vi erbjuda service avtal Från 99:-/mån så du får snabbt på plats service (även distans avtal)och så ser vi till att du alltid håller ditt kassasystem uppdaterad med den nyaste programvaran!

    Kontakt información:

    Norra Ågatan 5 A Arboga Västmanland 732 31
    teléfono: 0589-10031
    Site: www.kassanetto.se

    ReplyDelete
    Replies
    1. I appreciate you taking the time to correct some of my misconceptions and provide a different perspective.
      I will admit that LabVIEW does have some awesome hardware integration and definitely eases deployment.
      My post was mainly a outlet for too many hours of frustration trying to get LabVIEW to do things that
      I could have accomplished in much less time using a more traditional language.
      And while I still prefer text-based languages


      labview programming

      Delete
  4. http://bantalsilikon01.blogspot.com/2014/10/perumahan-baru-di-tangerang-graha-raya.html
    http://bantalsilikon01.blogspot.com/2014/11/bantal-silikon.html
    http://bantalsilikon01.blogspot.com/2014/10/rekomendasi-untuk-cloud-dedicated.html
    http://bantalsilikon01.blogspot.com/
    http://marinir-seo.blogspot.com/2014/10/marinir-seo.html
    http://marinirseo.blogspot.com/2014/10/perumahan-baru-di-tangerang-graha-raya.html
    http://kopiluwakliar01.blogspot.com/2014/10/perumahan-baru-di-tangerang-graha-raya.html

    lkmnprapto@gmail.com
    http://vvty.in
    http://marinir-seo-konsultan-12a.blogspot.com/2014/10/aaa.html
    http://asdf-14.blogspot.com/2014/10/hhh.html
    http://vvtiin.blogspot.com/2014/10/iii.html
    http://marinir-seo-8.blogspot.com/2014/10/jjj.html
    http://bantaljkt1.blogspot.com/2014/10/sss.html
    http://dfes12.blogspot.com/2014/10/rrr.html
    http://seo-guru01.blogspot.com/2014/10/qqq.html
    http://jksbindo.blogspot.com/2014/10/ppp.html
    http://jkt-49.blogspot.com/2014/10/ooo.html
    http://seokonsultan1.blogspot.com/2014/10/nnn.html
    http://guru-seo-malang.blogspot.com/2014/10/mmm.html
    http://seo-aaa.blogspot.com/2014/10/lll.html
    http://seo-konsultasi-mudah.blogspot.com/2014/10/kkk.html
    http://bantal-silikon15.blogspot.com/2014/10/ggg.html
    http://agen-seo16.blogspot.com/2014/10/fff.html
    http://agen-seo17.blogspot.com/2014/10/eee_30.html
    http://agen-seo18.blogspot.com/2014/10/ddd.html
    http://agen-seo19.blogspot.com/2014/10/ccc.html
    http://agen-seo20.blogspot.com/2014/10/bbb.html
    http://bumbu-pecel01.blogspot.com/2014/10/xxx.html

    bumbupecel1.blogspot.com
    http://bantalasdf.blogspot.com/2014/10/aaa.html
    http://seo-malang-19.blogspot.com/2014/10/bbb.html
    http://agenseomalang18.blogspot.com/2014/10/ccc.html
    http://marinirseo17.blogspot.com/2014/10/ddd.html
    http://bumbupecel16.blogspot.com/2014/10/eee.html
    http://domainhosting15.blogspot.com/2014/10/fff.html
    http://bumbupecel15.blogspot.com/2014/10/ggg.html
    http://marinirseo14.blogspot.com/2014/10/hhh.html
    http://bantalsilikon12a.blogspot.com/2014/10/iii.html
    http://marinirseo12.blogspot.com/2014/10/jjj.html
    http://bumbu-pecel-hz.blogspot.com/2014/10/kkk.html
    http://marinir-seo-001.blogspot.com/2014/10/lll.html
    http://bantal-silikon-murah.blogspot.com/2014/10/mmm.html
    http://vvty-ine.blogspot.com/2014/10/nnn.html
    http://give-a-power.blogspot.com/2014/10/ooo.html
    http://bumbupecel-12.blogspot.com/2014/10/ppp.html
    http://marinir-seo-konsultan.blogspot.com/2014/10/qqq.html
    http://guru-seo-praktisi-123.blogspot.com/2014/10/rrr.html
    http://guru-seminar-online01.blogspot.com/2014/10/sss.html
    http://kopiluwakmalang11.blogspot.com/2014/10/ttt.html

    ReplyDelete
  5. I want to comment out pieces of my code in LabVIEW like I can in other programming languages,
    such as C. This way I can try different tests to improve my program without deleting my existing code.


    labview programming

    ReplyDelete
  6. Eva Karea Featuring our unique CodeConnect technology, the easy-to-use AutoScanner Plus displays trouble codes and prioritizes troubleshooting with the Top Reported Fixes specific to a vehicle's make, model, year and engine.

    ReplyDelete
  7. Thanks for information Export Packers and Movers services India provider best price save time with moving & packing services.
    Pune Packers and Movers
    Mumbai Packers and Movers
    Hyderabad Packers and Movers
    Chennai Packers and Movers
    Bangalore Packers and Movers

    ReplyDelete
  8. How did you can avail the give your dream a shape with the help of make your move Adword India's No 1 online business experts.
    http://www.adword.co.in/

    ReplyDelete
  9. All Packers and Movers India relocation services provided this company services are available pricrs for Top3th.
    Packers and Movers Gurgaon
    Packers and Movers in Thane
    Packers and Movers in Navi Mumbai

    ReplyDelete
  10. If you are Packers and Movers in India free relocation services provide transport and moving & packing service
    Packers and Movers in Delhi
    Packers and Movers in Noida
    Packers and Movers in Faridabad
    Packers and Movers in Ghaziabad

    ReplyDelete
  11. Hi,

    Can I check with you, how'd I go about programming if I wanted to re-direct the console output into a richtexbox format ?

    ReplyDelete
  12. How to choose a multimeter read more choose a best multimeter best multimeter

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. Get a wide range of packing and moving companies at helloenquiry.in. We endeavour to furnish the best packers and movers companies in Vadodara at ease of Internet. Packers and Movers Vadodara

    ReplyDelete
  15. I am on a plan to get Fluke Digital Clamp Meter for my project. This was helpful. Thanks. Keep sharing and exploring.

    ReplyDelete
    Replies
    1. You you want to get Fluke digital clamp meter. Here is good resouce for your referrence.

      Delete
  16. The buzz words for personal statement is actually what we should do for our project. I haven't tested but I think that the below code would work with those models as well. If it doesn't email me and I'll publish an update for those models.

    ReplyDelete
  17. Trying to compile the example code and am getting errors on the line:

    Object[] DCVResult = (object[])myDmm.ReadList(IEEEASCIIType.ASCIIType_Any, ",;");

    Console Output:

    Agilent Technologies,34410A,MY47006101,2.21-2.21-0.09-46-9

    Error occured: Exception: Encountered system error(s)
    -108,"Parameter not allowed"

    -420,"Query UNTERMINATED"

    Press any key to continue...









    Any insight?

    ReplyDelete
  18. Based on provided example I developed Windows application (.NET, C#, WPF) that enables setting acquisition parameters (sample rate and time), file for storing data and voltage/current measurement range.
    I'm giving it for free, no restrictions: http://www.antonic.hr/Projects/DAQ/

    Davor

    ReplyDelete
  19. Hi, I've managed to get your program working. While printing the output into a console output, after which a conversion of values for let say millivolts. My question now is, can I set it to only read and throw back 1 value at a time?

    ReplyDelete
  20. Thanks on your marvelous posting! I really enjoyed reading it, you’re a great author.Please visit here:
    http://packersmoversbangalore.in/

    ReplyDelete
  21. When you've attached the leads as described, you can now connect the meter in series to the device you wish to measure. The Multimeter Guide

    ReplyDelete
  22. http://packersmoverskolkata.latest5th.in/
    http://packersandmoverskolkata.usupport.in/
    http://easyshifting.in/packers-and-movers-kolkata/
    http://shiftingwala.in/packers-and-movers-kolkata/

    ReplyDelete
  23. We pick our female Indian Pakistani escorts in Dubai (UAE) to a great degree consciously keeping the necessities of

    our customers in our mind. All our escort girls in UAE are selected not just in light of the fact that they are

    fabulous hot girls in Dubai however also in light of the fact that they are so passionate and energetic about sex

    in Dubai. We keep those Dubai escort girls who are sharp for sex and have charm and attraction in their state of

    mind.
    escorts in Dubai
    Dubai escorts
    call girls in Dubai

    ReplyDelete
  24. Escorts in Dubai! which is the all expected sensitive to offer the all things considered finest girls which customer expect to have for their enjoyment. They have a normal understanding that to be the most perfectly awesome they give the table an organization which is exceptional. That is the part you will see that our Indian escorts in Dubai will constantly go that extra mile to ensure that every single customer is left genuinely feeling extensively met after a meeting with them.
    Escorts in Dubai!
    indian Pakistani escorts in Dubai!

    ReplyDelete
  25. This comment has been removed by the author.

    ReplyDelete
  26. Just be ready for an ultimate time span because the hottest and glamorous Indian escorts are awaiting for your call.
    Pakistani Call Girls in Dubai

    ReplyDelete
  27. I have been surfing the internet for the past two hours looking for Professional article writing service and I have not come across such an informative site. I have learned a lot about the Continuous Measurements with a 34461A Digital Multimeter. I will, therefore, bookmark this site so that I can visit it occasionally to read new articles.

    ReplyDelete
  28. If you're an exploration of a good Escorts Agency in Dubai to hire a high category most beautifully stunning and sizzling Pakistani Escorts in Dubai, then you're at the proper and best place currently. we tend to ar absolutely approved to offer this exceptional Escort in Dubai that's reasonable, trained and separate. Our UAR Escorts Hub Agency is additionally famous for providing hottest and sexiest Indian Escorts in Dubai and hot call girls in dubai services. Contact us now and Book Your desire Escorts in Dubai.

    ReplyDelete
  29. male to male body massage in mumbai,delhi,pune

    https://plus.google.com/u/0/113599863563124207521
    https://twitter.com/bodymassagemal1
    https://www.facebook.com/Malebodymassage-266658327162688/
    https://www.pinterest.com/bodymassagemale02/
    https://myspace.com/malebodymassage1
    http://www.scoop.it/u/rahul-jhon
    http://www.pearltrees.com/malebodymassage1
    https://www.stumbleupon.com/stumbler/malebodymassage1
    https://batmalebodymassage.tumblr.com/
    https://www.reddit.com/r/entertainment/comments/6v9i7l/male_to_male_body_massage_in_mumbai/

    ReplyDelete
  30. The game is over even the smallest body part injuries. It takes much patience to finish the goal. Is this much challenging? Make your best efforts to survive in this glory and funny game. We can find a way to break through Even if we can't find heaven, I'll walk through hell with you.
    geometry dash
    happy wheels

    ReplyDelete
  31. thank you for sharing such a useful information. where we rarely find the true facts about it. find some information about jobs here hr jobs in hyderabad .

    ReplyDelete
  32. We can all agree that you have shared a nice post that is worthwhile reading. I have found ideas which have really transformed my life. Thank you for sharing. Whenever you feel that you would like to refresh yourself with the word of God or maybe biblical quotes, you can visit Redeemed Gospel Church -Thika Town

    ReplyDelete