In the spirit of continual learning and, as a follow on to my previous blog, Line Regulation Measurement Coding in Python, I thought I would continue discussing coding for measurements by providing an overview of my Python script for load regulation. The coding is quite similar to what I used for the line regulation measurement I discussed in that last blog. In the case of the line regulation, the measurements are performed with the maximum load and the input voltage varied while observing the change in the output voltage. In the case of the load regulation measurement, the output load current is varied while observing the change in output voltage. This is done by first connecting the LDO output to a very high impedance such as a 1 MΩ or higher resistance and measuring the output voltage. Next the LDO output is connected to a load resistance value resulting in the maximum load current. For more details on the basics of the measurement you can go to my blog entitled, Measuring LDO Load Regulation for a Novice.
I’ll once again add the disclaimer here that by no means am I an expert coder but, I believe I know enough to be dangerous. Before we dive into some of the coding that I did when measuring LDO load regulation, let’s take a closer look at a few things including the required equipment and test setup. We must first know what equipment we are using so we can execute the right commands. For the purposes of creating this particular Python script I used a Keithley 2230 DC source meter and a Keysight 34461A digital multimeter which are both shown below.
Keithley 2230 DC Source Meter
Keysight (Agilent) 34461A Digital Multimeter
Something I neglected to mention in my previous blog is that I am using the CH3 output for this test. The Keithley 2230 DC source meter has three outputs. CH1 and CH2 outputs are 0 – 30 V outputs while CH3 is a 0 – 6 V output. Since I only require 5.6V for this particular test I selected the CH3 output. Another interesting item I should point out is that the Keysight 34461A software commands align with the previous generation Keysight model 34410A. This is particularly handy if you’ve been familiar with writing code to control the older unit and have upgraded to the newer unit. This is just happens to be the case for me with the script that I have written here. I had previously written code for the older unit but found that the commands work just the same on the newer unit.
The Keithley is used to provide the DC input voltage for the regulator as well as provide monitoring of the input current to the LDO. The Keysight digital multimeter is used to provide the measured output voltage from the LDO. The supply current reading is not necessarily required to perform this measurement, but it can be added to monitor the input current as an indicator of proper device operation. The current limit on the power supply should be set to provide a safeguard against drawing too much current. Of course, if all goes as planned the current limit should never get tripped, but Mr. Murphy is known to pay us a visit more often than we like as we discussed in detail in my blogs, How About Murphy’s Law? and Mr. Murphy, You’re Not Welcome in Space.
As was done for the line regulation measurement, the current limit on the output of the Keithley DC source meter was set to about 5-10% above the maximum rated current of the LDO. This allows a little margin for any extra current in the setup and ensures that the output doesn’t current limit unnecessarily. Recall that load regulation is the measurement of the output voltage variation when the output load current is varied. When measuring the load regulation of the LDO output, voltage is measured with a very high resistance (RL ) that is 1 MΩ or higher if possible and then load resistance (RL ) installed such that there is maximum current draw from the LDO. In this case the two different output resistances were measured and the current is measured indirectly by measuring the output voltage and dividing by the load resistance.
Load Regulation Measurement Setup
The basic objective for the script is to record the output voltage under different load conditions. Since the measurement is automated we can do things like vary the input voltage as well during the test. This can be useful to see the behavior of the LDO under the different conditions although it is not necessary to do so. Since the measurement is automated it is relatively easy to add this to the code. As I did for the line regulation script, I have broken the code down into three main sections and a few subsections. The three main sections are: 1 – Library setup, 2 – Filename and variable setup, and 3 – Main function. The Main function section is further subdivided into three sections: A – Script checking, B – Loop to record values to a file, and C – Creates file header and writes file.
Recall that the first section of the program is the place in the code where the various libraries that are required are called so that they can be used in the script. Just as before there are some built-in Python libraries as well as some libraries that have been generated by my wonderful colleagues at Analog Devices. Personally, I am very fond of this feature within Python. I am also very thankful that my colleagues generated these libraries for others to use. As the old saying goes “There is no sense in re-inventing the wheel.” In addition to these libraries, I am using a library that enables me to be able to easily write to a CSV file to collect the data. I also have a few other libraries as well such as the MessageBox which will display text in a message box pop up window wherever it is called in the program. Notice in this case I have a line in the Script checking section commented out (the # symbol at the beginning of a line comments the ensuing code on that line). I used this for debugging the code. This is a handy tool for us since it can help during the debugging phase to see how far the code progresses before it runs into an error.
Python Script for Measuring LDO Line Regulation
After the Library setup section there is the Filename and variable setup. In this section a filename is specified where the output data from the script can be stored. In addition, variables are defined here that are used in the main function of the program. This section is where I have set the column labels in for the output file. Once again I set a board number (to serialize data), defined the output under test (this is helpful if there is more than one output on a given device), and set a label for the test condition. I believe it is better to set up variables for description of the test being performed so that there are no questions later on the specifics of the data. It is better to have a little too much information than to not have enough information.
In the Main function section of the script the actual measurements are performed and the data is written to a file. In this section there is also some script checking that was used to help debug the code. In this portion of the script the CSV file is set up and the addresses of the Keithley DC source meter and Keysight multimeter are defined. The for loop in this section defines the conditions for which the input DC voltage is swept while measuring the output voltage on the Keysight multimeter. It is with this for loop that the range and the step size (increment) for the load regulation test can be defined. Once again, it is not necessary to sweep the input voltage; it simply adds some interesting information to the output data. At the beginning of the main function, the Keithley DC source meter is enabled and at the end it is disabled. Using the MessageBox function that is called in the Library setup section, the program will generate a pop up message upon completion of the script that states the user defined message that is set within the code.
It is my hope that this blog and my previous blog, on coding for line regulation, have helped provide a better understanding for some simple Python coding. It is quite handy to have at least a little skill in coding for various functions in our roles as engineers. I am demonstrating its use for automating measurements in the lab, but that is just one of the many ways that the skill can be put to good use. Another for example is data parsing and manipulation. It comes with the trade as an engineer that we have lots of data to analyze. It can be advantageous to be able to write some code to parse data in some cases rather than trying to crunch that data manually. What have you used coding for in your role as an engineer? What do you wish you could use coding to help with in your functions as an engineer? Please feel free to comment with your experiences.