NAME

PDL::IO::MDIF - Read and manipulate Measurement Data Interchange Format (MDIF, *.mdf) files.

DESCRIPTION

A simple interface for reading and writing RF MDIF files (also known as MDF or .mdf files). MDIF files contain multiple Touchstone files in a text format; consult the "SEE ALSO" section for more about the MDIFs format and using them to optimize circuits. For example, a single MDIF file could contain the Touchstone RF data for each available value in a line of capacitors (ie, from 10pF to 1000pF) provided by a particular manufacturer.

MDIF files contain Touchstone-formatted data representing multiple components, so PDL::IO::Touchstone is used internally for processing the Touchstone data.

A notable difference between Touchstone files and MDIF files is that MDIF supports variable parameters within the MDIF file itself. For example, an MDIF file containing a set of capacitor data of different values might define the following:

VAR pF = 1000
VAR Vmax = 250

These variables are provided in the return value of rmdif as shown below.

SYNOPSIS

use PDL::IO::MDIF;

# Read input matrix into an arrayref:
$mdif_data = rmdif('input-file.mdf', { units => 'MHz' });

# Write output file:
wmdif('output-file.mdf', $mdif_data);

IO Functions

rmdif($filename, $options) - Read MDIF file

$options is a hashref passed to PDL:IO::Touchstone's rsnp function. The function rmdf is an alias for rmdif.

# Read input matrix into an arrayref:
$mdif_data = rmdif('input-file.mdf');

It returns an arrayref of hashrefs, as follows:

[ 
	# Component 1
	{
		var1 => "val1",
		var2 => -123, 
		...
		_data => [ @rsnp_data ],
		_comments => [ 'comment line 1', 'comment line 2', ... ]
	},

	# Component 2:
	{
		pF => 1000,  # component value in pF
		Vmax => 250, # component maximum voltage
		...
		_data => [ @rsnp_data ]
	},

	...
]
  • MDIF Variable (parameter) Names

    The example variables and values above (var1, pF, etc) are arbitrary; they are specific to the MDIF file being read.

  • _data Structure

    The _data hash element is an array refernce to exactly that which was returned by PDL::IO::Touchstone's rsnp() function. It is prefixed with an underscore to prevent name collisions with the MDIF file being loaded.

    This may deviate from the typical PDL structures in the sense that frequency and S-parameter data is not combined into one big PDL. There are a number of reasons for this, but notably, the frequencies and RF port count in each component contained in the MDF are not required to be identical.

    Since they are not guaranteed to be consistent the best we can do is generate a structure containing all of the data and let the user parse what they need. Interpolation using things like PDL::IO::Touchstone's m_interpolate function is possible if the frequencies differ, but we don't want to modify the source data, and that wouldn't address the RF port count issue.

  • _comments Structure

    Comments are simply an arrayref of strings, one for each comment line. When written by wsnp, each comment will be written before that component's section on the resulting .mdf text file.

wmdif($filename, $mdif_data) - Write MDIF file

The wmdif function writes the MDIF data in $mdif_data to $filename. The function wmdf is an alias for wmdif.

Internally wmdif uses PDL::IO::Touchstone's wsnp_fh function to write Touchstone data for each component into the MDIF file. To generate an MDIF file from multiple Touchstone files you can read each Touchstone file and merge them as follows:

my @cap_100pF = rsnp('100pF.s2p');
my @cap_200pF = rsnp('200pF.s2p');
my @cap_300pF = rsnp('300pF.s2p');

wmdif("my_caps.mdf", [
		{ pF => 100, _data => \@cap_100pF },
		{ pF => 200, _data => \@cap_200pF },
		{ pF => 300, _data => \@cap_300pF },
	]);

Note that pF is just an arbitrary variable that will be stored in the MDIF file for reference when you load it in your EDA software.

You may transform the content of $mdif_data in any way that is suitable to your application before writing the file provided the resulting data is valid. For example, if you convert S paramters to Z parameters using s_to_z then be sure to set $param_type to Y before writing the MDIF output. See PDL::IO::Touchstone for details.

SEE ALSO

MDIF file format from AWR: https://awrcorp.com/download/faq/english/docs/users_guide/data_file_formats.html#i489154
MDIF file format from Keysight https://edadocs.software.keysight.com/display/ads2009/Working+with+Data+Files#WorkingwithDataFiles-1135104
RF::Component - An object-oriented encapsulation of PDL::IO::Touchstone.
PDL::IO::Touchstone - A PDL IO module to load Touchstone (*.sNp, s2p, ...) files.
Touchstone specification: https://ibis.org/connector/touchstone_spec11.pdf
Building MDIF/MDF files from multiple S2P files: https://youtu.be/q1ixcb_mgeM, https://github.com/KJ7NLL/mdf/
Optimizing amplifer impedance match circuits with MDIF files: https://youtu.be/nx2jy7EHzxw

AUTHOR

Originally written at eWheeler, Inc. dba Linux Global Eric Wheeler to transform .s2p files and build MDIF files to optimize with Microwave Office for amplifer impedance matches.

COPYRIGHT

Copyright (C) 2022 eWheeler, Inc. https://www.linuxglobal.com/

This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this module. If not, see <http://www.gnu.org/licenses/>.