Have you ever had to write a bit of code to interpret a non-linear analog reading as picked up by an ADC? When all you have to work with for your transfer function is a graph in a semiconductor datasheet that was probably written thirty years ago and prints out the size of a postage stamp, that’s a rather annoying task. Wouldn’t it be nice if you had access to the numbers behind the graph!

You can’t knock on the office door of the engineer who created it back in the ’80s, he’s probably in retirement and playing golf or growing prize petunias by now. But you can digitize the graph to get yourself a lot closer to the action, and to help you in your quest there’s a handy online tool.

WebPlotDigitizer is not new, it’s been around for quite a few years now. But it’s still worth talking about, because it’s one of those tools to keep in reserve. If you’ve ever needed it, you’ll know what we mean.

So how does it work? Load an image with a graph in it, select some points on the X and Y axis, roughly trace the curve with a marker tool, and set it in motion. Let’s give it a go. We’re going to try digitizing the current gain plot from the 2N3904 datasheet (PDF) that we examined a few days ago.

So, open the WebPlotDigitizer app, load the graph image captured from the sheet as a JPEG. It asks what type of graph you’ve loaded, in this case a 2D X-Y plot. It asks you to identify four known points on the axes and supply their values. You also tell it if the axes are logarithmic at this point. Select “Automatic mode” on the right hand side, then click “Pen” and mark the graph trace, then select the colour of the trace. Click the “Run” button, and your data points appear. Hit the “View data” button, and there you have it. A few rogue points to remove perhaps, but it does a pretty good job.

If WebPlotDigitizer has engaged your interest, you’ll be pleased to know that it’s open-source, and you can find all its code on GitHub. There is also a handy video tutorial which you can see below the break.

Looking through the Hackaday archives, we’ve covered this subject a couple of times before. Engauge is another graph digitizer, and we’ve also covered a photographic digitizer for servo splines.

A tip of the hat to [JD].

Article contains link to older article that contains old comment with link to subject of current article. It is a spiral of madness I tell you! mahahahahahaaaaaaaaaa…. .

Looks nice. It’d be even better if it went to the next step of analysing the points to work out the equation. That’d have the added advantage of helping eliminate those “rogue points”.

You’d need to know a little bit a priori about the curve, but yes that should be doable. At least a polynomial curve quadratic fit.

I use webplotdigitizer a lot and do that mostly afterwards in Python, because in most cases I have to compare it with data I created myself or need an interpolation.

What is the easiest way to convert the data to a non-linear equation

Download it as *.csv, fire up a ipython Notebook (within Anaconda Python https://www.continuum.io/downloads ) or create a python script. Guess a function which fits your needs:

* Decaying function add: exp(x * a)

* Oscillating function add: sin(x * b + c)*cos(x * b + c)

* Offset add a constant term

* Or a polynomial: a + x * b + x^2 * c + …

Code Example with data from Weblotdigitizer:

http://pastebin.com/Xdr0bkgZ

Result:

Nice imgur links embedd images?

Eureqa does a fine job. You can specify the complexity you’re after and it provides multiple results to choose from.

Here’s a free open source program that does that ( Symbolic Regression ):

Video of it in action: https://www.youtube.com/watch?v=2kbCMWC_EgA

Program: http://dev.heuristiclab.com/

The program can export the equation as a matlab model, excel function/sheet, Latex math function (for publication) and even more!

I never understood why component makers don’t make use of a PDFs full functionality…

All those formulas could be interactive – just insert your application’s numbers and have the PDF spit out the required Rsense, number of coil-windings or whatever.

If the figures within the PDF are embedded as vector graphics you can at least extract the underlying data (vectors).

“Have you ever had to write a bit of code to interpret a non-linear analog reading as picked up by an ADC?”

The local vicar asked me that very question this morning over tea and muffins.