{"id":2414,"date":"2020-03-20T12:22:00","date_gmt":"2020-03-20T16:22:00","guid":{"rendered":"http:\/\/www.nuclearphysicslab.com\/npl\/?page_id=2414"},"modified":"2020-07-07T18:52:44","modified_gmt":"2020-07-07T22:52:44","slug":"diy-matlab-mca","status":"publish","type":"page","link":"http:\/\/www.nuclearphysicslab.com\/npl\/npl-home\/spectroscopy\/software_and_hardware\/diy-matlab-mca\/","title":{"rendered":"DIY Matlab MCA"},"content":{"rendered":"\n<p class=\"has-text-align-center\"><em>Author: Jay Howson<br>Date: March-2020<\/em><\/p>\n\n\n\n<p>Note: This page is under construction. I have example files to add, more pictures to add, code to write, etc. I&#8217;ll get to it eventually I promise.  <\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_33_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">Quick Links<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><label for=\"item\" aria-label=\"Table of Content\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/label><input type=\"checkbox\" id=\"item\"><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1'><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/www.nuclearphysicslab.com\/npl\/npl-home\/spectroscopy\/software_and_hardware\/diy-matlab-mca\/#Intro\" title=\"Intro\">Intro<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/www.nuclearphysicslab.com\/npl\/npl-home\/spectroscopy\/software_and_hardware\/diy-matlab-mca\/#The_Possibilities\" title=\"The Possibilities \">The Possibilities <\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/www.nuclearphysicslab.com\/npl\/npl-home\/spectroscopy\/software_and_hardware\/diy-matlab-mca\/#Downloads\" title=\"Downloads\">Downloads<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/www.nuclearphysicslab.com\/npl\/npl-home\/spectroscopy\/software_and_hardware\/diy-matlab-mca\/#How_To\" title=\"How To\">How To<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"http:\/\/www.nuclearphysicslab.com\/npl\/npl-home\/spectroscopy\/software_and_hardware\/diy-matlab-mca\/#My_MCA\" title=\"My MCA\">My MCA<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"http:\/\/www.nuclearphysicslab.com\/npl\/npl-home\/spectroscopy\/software_and_hardware\/diy-matlab-mca\/#Future_Work\" title=\"Future Work\">Future Work<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Intro\"><\/span>Intro<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Once I had my<a href=\"http:\/\/www.nuclearphysicslab.com\/npl\/npl-home\/spectroscopy\/software_and_hardware\/diy-canberra-system\/\"> canberra spectroscopy<\/a> system working, I found myself wanting more out of the MCA software. Both the MEDm and IDL software were convenient, in that MEDm at least was pre-installed with the EPICS software. Both did what they were supposed to do. However there was also a lot they did not do.  The Canberra GENIE software was way to expensive for someone doing spectroscopy as a hobby to purchase. (it would be nice if Canberra offered a lite version of the software to amateurs)  <\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3><span class=\"ez-toc-section\" id=\"The_Possibilities\"><\/span>The Possibilities <span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>I knew that others had gotten labview to interface with EPICS, I wondered if MATLAB could do the same. Sure enough it could. <\/p>\n\n\n\n<p>Thru my work I have gained (over several years) a reasonable skill level at making GUI&#8217;s in matlab. I had yet to interface one to hardware but (not to toot my own horn) i&#8217;m pretty good at making a GUI with intelligent buttons and a decent user intuitiveness when it comes to data processing. I knew that matlab was a tool I could effectively and efficiently use to make a MCA environment which worked for me, and potentially others in the future. <\/p>\n\n\n\n<p>Another benefit was the ability to request a home-use license for Matlab thru my work place which has been highly convenient to me thus far. I will be very sad if &#8220;the man&#8221; ever takes that job perk away from me. <\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3><span class=\"ez-toc-section\" id=\"Downloads\"><\/span>Downloads<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The key to getting MATLAB and epics to play nice together, was a set of MATLAB scripts titled CA_MATLAB. I think there exists a new version at this point, but this is what I started with and I have not yet felt the need to try and upgrade. <\/p>\n\n\n\n<ul><li>You can read about the software here<ul><li><a href=\"https:\/\/github.com\/channelaccess\/ca_matlab\">https:\/\/github.com\/channelaccess\/ca_matlab<\/a> <\/li><\/ul><\/li><li>and download here<ul><li> <a href=\"https:\/\/github.com\/channelaccess\/ca_matlab\/releases\">https:\/\/github.com\/channelaccess\/ca_matlab\/releases<\/a> <\/li><\/ul><\/li><li>Note the version of Ca_Matlab i use was superceded by a new version which only works with 2019a or new matlab. Read more here<ul><li> <a href=\"https:\/\/github.com\/channelaccess\/ca\/blob\/master\/README_MATLAB.md\">https:\/\/github.com\/channelaccess\/ca\/blob\/master\/README_MATLAB.md<\/a> <\/li><\/ul><\/li><li>Example Files<ul><li>Coming Soon<\/li><\/ul><\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3><span class=\"ez-toc-section\" id=\"How_To\"><\/span>How To<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The author does a pretty good job at documenting how exactly to use it. <br>But I will write up my own micro tutorial here demonstrating how I use it. <\/p>\n\n\n\n<ul><li>Place the file you downloaded into the main directory that you use for matlab.  <ul><li>Such that a file titled &#8220;ca_matlab-1.0.0.jar&#8221; is in the 1st level down<\/li><li>I also stick it in my scripts folder, out of convenience<\/li><\/ul><\/li><li>You will need to add this file and its folder to your matlab path<ul><li>accomplished via a right click, &#8220;add to path&#8221; on the parent directory<\/li><\/ul><\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/camatlab_1st-1.png\"><img loading=\"lazy\" width=\"576\" height=\"408\" src=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/camatlab_1st-1.png\" alt=\"\" class=\"wp-image-2706\" srcset=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/camatlab_1st-1.png 576w, http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/camatlab_1st-1-381x270.png 381w\" sizes=\"(max-width: 576px) 100vw, 576px\" \/><\/a><\/figure>\n\n\n\n<p>I will let the author explain the why behind the code on this own site, linked above.  This code should be at the start of every script you try and make. <\/p>\n\n\n\n<p>Site Note: The code display plugin doesn&#8217;t seem to respect the fact that I changed Octave to say Matlab.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;octave&quot;,&quot;mime&quot;:&quot;text\/x-octave&quot;,&quot;theme&quot;:&quot;solarized&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;MATLAB&quot;,&quot;language&quot;:&quot;Octave&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;octave&quot;}\">import ch.psi.jcae.*\nif not(exist('java_classpath_set'))\n    javaaddpath('Scripts\\ca_matlab-1.0.0.jar')\n    java_classpath_set = 1;\nend\ncontext = Context();\nproperties = java.util.Properties();\nproperties.setProperty('EPICS_CA_MAX_ARRAY_BYTES',getenv('EPICS_CA_MAX_ARRAY_BYTES'));\ncontext = Context(properties);\n\n<\/pre><\/div>\n\n\n\n<p>Now, I have discovered a few tricks to make things work smoothly in a gui environment. As you many know, a MATLAB GUI script is effectively a giant list of individual functions linked to a &#8220;. fig&#8221; file called callbacks.   I like to use GUIDE, which creates both in tandem with one another auto creating callbacks when you add a graphical object.  You can read more about the in&#8217;s and out&#8217;s of making GUI&#8217;s elsewhere. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1635\" height=\"818\" src=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/MatlabGuide.png\" alt=\"\" class=\"wp-image-2760\" srcset=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/MatlabGuide.png 1635w, http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/MatlabGuide-768x384.png 768w, http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/MatlabGuide-1536x768.png 1536w, http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/MatlabGuide-540x270.png 540w\" sizes=\"(max-width: 1635px) 100vw, 1635px\" \/><figcaption>An example of what my MCA looks like in GUIDE<\/figcaption><\/figure>\n\n\n\n<p>Firstly, a context apparently needs to exist within every function. I didn&#8217;t want to have to go thru and repeat the above code for every single function, so I made context() a global variable<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;octave&quot;,&quot;mime&quot;:&quot;text\/x-octave&quot;,&quot;theme&quot;:&quot;solarized&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot; MATLAB &quot;,&quot;language&quot;:&quot;Octave&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;octave&quot;}\">import ch.psi.jcae.*\nif not(exist('java_classpath_set'))\n    javaaddpath('Scripts\\ca_matlab-1.0.0.jar')\n    java_classpath_set = 1;\nend\nglobal context();\ncontext = Context();\nproperties = java.util.Properties();\nproperties.setProperty('EPICS_CA_MAX_ARRAY_BYTES',getenv('EPICS_CA_MAX_ARRAY_BYTES'));\ncontext = Context(properties);\n<\/pre><\/div>\n\n\n\n<p>Line 9, has to do with the max amount of bytes you can read at any one time.  I was having issues reading all the data from EPICS into matlab. The fix is explained on the  <a href=\"http:\/\/www.nuclearphysicslab.com\/npl\/npl-home\/spectroscopy\/software_and_hardware\/diy-canberra-system\/\">Canberra spectroscopy<\/a> page. The important detail here is that the fix needs to be imported into the MATLAB environment as well. All Line 9 does is read the enviroment variable we created before, and assign its value to a property within the Context(). <\/p>\n\n\n\n<p>Now that we have initiated Ca_matlab we can try to issue or read some commands.  <br>Each parameter and setting the AIM 556 controls has a unique channel. Each Channel has a unique name. Finding these unique names is a chore, i used MEDm and looked at the code behind each button (a right click on a button in MEDm will tell you all sorts of information about that button)<\/p>\n\n\n\n<ul><li>First we create a channel<\/li><li>Then we read or write to the channel<\/li><li>Finally we close the channel<\/li><\/ul>\n\n\n\n<p> I&#8217;m unclear on what happens if you decide not to close a channel. I tried it and nothing bad seemed to happen, but i close all my channels anyway.<br><br>For example here is a snippet of code where i pull the number of channels my AIM is using and use that value to create a channel array. I assume you have the previously described code before this code in your script. <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;octave&quot;,&quot;mime&quot;:&quot;text\/x-octave&quot;,&quot;theme&quot;:&quot;solarized&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;Matlab&quot;,&quot;language&quot;:&quot;Octave&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;octave&quot;}\">mcaTest_aim_adc1NUSE   = Channels.create(context, ChannelDescriptor('double','mcaTest:aim_adc1.NUSE'));\naim_adc1NUSE = mcaTest_aim_adc1NUSE.get();\nchannelArray = [1:1:aim_adc1NUSE]';\nmcaTest_aim_adc1NUSE.close();<\/pre><\/div>\n\n\n\n<p>If you are inside of a function, or a callback for your GUI you need to bring your context into your function\/callback. We made the context a global, thus<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;octave&quot;,&quot;mime&quot;:&quot;text\/x-octave&quot;,&quot;theme&quot;:&quot;solarized&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot; MATLAB &quot;,&quot;language&quot;:&quot;Octave&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;octave&quot;}\">function Button(hObject, eventdata, handles)\n\timport ch.psi.jcae.*\n    global context\n\tmcaTest_aim_adc1NUSE   = Channels.create(context,ChannelDescriptor('double','mcaTest:aim_adc1.NUSE'));\n\taim_adc1NUSE = mcaTest_aim_adc1NUSE.get();\n\tchannelArray = [1:1:aim_adc1NUSE]';\n\tmcaTest_aim_adc1NUSE.close();<\/pre><\/div>\n\n\n\n<ul><li>the channel we accessed was &#8220;mcaTest:aim_adc1.NUSE&#8221;<ul><li>we access the mcaTest database in EPICS<\/li><li>we access the AIM&#8217;s 1st ADC slot <\/li><li>we accessed the NUSE variable, <ul><li>which is the number of channels in use on the AIM&#8217;s ADC1 slot<\/li><\/ul><\/li><\/ul><\/li><\/ul>\n\n\n\n<p>Of course doing all that every single time you want to access a channel is also annoying. So I made a function that I just needed to feed 2 variables. <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;octave&quot;,&quot;mime&quot;:&quot;text\/x-octave&quot;,&quot;theme&quot;:&quot;solarized&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot; MATLAB &quot;,&quot;language&quot;:&quot;Octave&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;octave&quot;}\">function output = EPICS_READ(PV,type)\n\t%Ex\n    %PV: database:pvVARIABLE \n\t%database = mcaTest\n\t%pv = hvps1\n\t%VARIABLE = STATUS\n\t%mcaTest:hvps1STATUS\n\t% \n\t%options for type are\n\t%double, integer, short, float, byte, boolean, string and the respective array forms double[], integer[], int[], short[], float[], byte[], boolean[], string[]\n\t%%%%%%%%%%%%%%%%%%%%%\n\t%https:\/\/github.com\/channelaccess\/ca_matlab\nglobal context\n    import ch.psi.jcae.*\n    channel = Channels.create(context, ChannelDescriptor(type, PV));\n    output = channel.get();\n    channel.close();\n<\/pre><\/div>\n\n\n\n<p>a write function is similar<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;octave&quot;,&quot;mime&quot;:&quot;text\/x-octave&quot;,&quot;theme&quot;:&quot;solarized&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot; MATLAB &quot;,&quot;language&quot;:&quot;Octave&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;octave&quot;}\">function EPICS_WRITE(PV,type,value)\n\t%Ex\n    %PV: database:pvVARIABLE \n\t%database = mcaTest\n\t%pv = hvps1\n\t%VARIABLE = STATUS\n\t%mcaTest:hvps1STATUS\n\t% \n\t%options for type are\n\t%double, integer, short, float, byte, boolean, string and the respective array forms double[], integer[], int[], short[], float[], byte[], boolean[], string[]\n\t%%%%%%%%%%%%%%%%%%%%%\n\t%https:\/\/github.com\/channelaccess\/ca_matlab\nglobal context\n    import ch.psi.jcae.*\n    channel = Channels.create(context, ChannelDescriptor(type, PV));\n    channel.put(value);\n    channel.close();\n<\/pre><\/div>\n\n\n\n<p>examples<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;octave&quot;,&quot;mime&quot;:&quot;text\/x-octave&quot;,&quot;theme&quot;:&quot;solarized&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot; MATLAB &quot;,&quot;language&quot;:&quot;Octave&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;octave&quot;}\">PZValue = EPICS_READ('mcaTest:amp1PZRBV','double');\n\t%read the pole Zero Value of my Canberra_9615 AMP\nEPICS_WRITE('mcaTest:adc1GAIN','double',aim_adc1GAIN-1);\n\t%The Canberra_9635 permits any of the below channel counts for its GAIN setting\n\t%256, 521, 1024, 2048, 4096, 8192, 16384\n\t% However the ADC is zero referenced, so you must subtract 1 before writing a GAIN value\nData = EPICS_READ('mcaTest_aim_adc1','integer[]');\n\t%This will read data from the AIM, note how i had to use the integer[] type.\n\t%This allows for arrays to be read<\/pre><\/div>\n\n\n\n<p><br>I find that if I am writing or reading multiple commands in a single function, its faster to go direct, rather than using the EPICS_READ or EPICS_WRITE commands. <\/p>\n\n\n\n<p> And that&#8217;s pretty much all there is to it.  <\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3><span class=\"ez-toc-section\" id=\"My_MCA\"><\/span>My MCA<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>After close to a year of work at this point, I think my MCA is coming along nicely. Granted I haven&#8217;t spent a solid year making it, but off and on work.<br>Every time I open up the code It gets better. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-Energy.png\"><img loading=\"lazy\" width=\"1518\" height=\"739\" src=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-Energy.png\" alt=\"\" class=\"wp-image-2368\" srcset=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-Energy.png 1518w, http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-Energy-768x374.png 768w, http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-Energy-555x270.png 555w\" sizes=\"(max-width: 1518px) 100vw, 1518px\" \/><\/a><figcaption>The basic display<\/figcaption><\/figure>\n\n\n\n<p>I should note, it is not my intention at this time to release my matlab MCA to the public. If you are a friend, we can talk. However, it has far to many bugs and I have no desire to offer program support to the masses. It is also fairly closely linked to my specific setup, if you don&#8217;t have my exact modules set, it wont run for you with out modification.  I encourage you to learn and try and make your own. This work has all been a learning experience for me and I am better for it. <\/p>\n\n\n\n<p>This far I have completed<\/p>\n\n\n\n<ul><li>Full control over modules with menus and buttons for each available function<ul><li><a href=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/canberra_556A_Acquisition-Interface-Module-Users-Manual.pdf\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Canberra_556A_Acquisition_Interface_Module<\/a><\/li><li><a href=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/canberra_9635_ICB_Analog_Digital_Converter.pdf\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Canberra_9635_ICB_Analog_Digital_Converter<\/a> <\/li><li><a href=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/canberra_9615_ICB_Amplifier.pdf\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Canberra_9615_ICB_Amplifier<\/a><\/li><li><a href=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/canberra_9641_HV_Power_Supply.pdf\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Canberra_9641_ICB_HV_Power_Supply<\/a><\/li><\/ul><ul><li><a href=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/canberra_9645_HV_Power_Supply.pdf\">Canberra_9645_ICB_HV_Power_Supply<\/a> <\/li><\/ul><\/li><li>Ability to save data with a footer which encompass all the settings<\/li><li>Ability to load data<\/li><li>Graphical Display of <ul><li>Current Read Data<\/li><li>Background files<\/li><li>Background subtracted (and interpolated) Read Data (in real time)<ul><li>It uses a ratio of live times to define a scaler. <\/li><\/ul><\/li><li>Comparative Data loaded into the GUI from saved files<ul><li>I can directly compare multiple saved files with data currently be collected<\/li><\/ul><\/li><li>Display data in channels or energy on the X-axis<\/li><li>Display log or linear on both axies<\/li><li>Other minor plot options<\/li><\/ul><\/li><li>Ability to input energy\/channel information and perform a polynomial fit to calibrate the energy curve to your detector<ul><li>My  <a href=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/38B57_1.5M-E1-X.pdf\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Scionix_Detector<\/a>  works best with a cubic fit<\/li><\/ul><ul><li>this energy data is preserved when you save a file, enabling you to always compare with other files when displayed in energy<\/li><\/ul><ul><li>display a comparative fit between the two data sets, calculated verses input<\/li><\/ul><\/li><li>Stop data collection <ul><li>after a fixed time, live time or real time<ul><li>adjust units to suit your needs<\/li><\/ul><\/li><\/ul><ul><li>after a fixed sum of counts within a channel window <\/li><\/ul><\/li><li>I&#8217;m sure there is some other stuff I have implemented by I am forgetting to mention<\/li><\/ul>\n\n\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-Settings.png\"><img loading=\"lazy\" width=\"1520\" height=\"745\" src=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-Settings.png\" alt=\"\" class=\"wp-image-2369\" srcset=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-Settings.png 1520w, http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-Settings-768x376.png 768w, http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-Settings-551x270.png 551w\" sizes=\"(max-width: 1520px) 100vw, 1520px\" \/><\/a><figcaption>All the various options and settings expanded at the same time<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-energy-fit-display.png\"><img loading=\"lazy\" width=\"1520\" height=\"745\" src=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-energy-fit-display.png\" alt=\"\" class=\"wp-image-2737\" srcset=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-energy-fit-display.png 1520w, http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-energy-fit-display-768x376.png 768w, http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/matlab-MCA-energy-fit-display-551x270.png 551w\" sizes=\"(max-width: 1520px) 100vw, 1520px\" \/><\/a><figcaption>The energy fit plot<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/FileSaveFooter.png\"><img loading=\"lazy\" width=\"783\" height=\"1002\" src=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/FileSaveFooter.png\" alt=\"\" class=\"wp-image-2744\" srcset=\"http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/FileSaveFooter.png 783w, http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/FileSaveFooter-768x983.png 768w, http:\/\/www.nuclearphysicslab.com\/npl\/wp-content\/uploads\/FileSaveFooter-211x270.png 211w\" sizes=\"(max-width: 783px) 100vw, 783px\" \/><\/a><figcaption>Example of a saved files footer<br>3 columns of data are Channel, Energy, and Count<\/figcaption><\/figure>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3><span class=\"ez-toc-section\" id=\"Future_Work\"><\/span>Future Work<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Planned features to be added include<\/p>\n\n\n\n<ul><li>Continuous never ending fixing of bugs as I find them <\/li><li>Load different fits, for use with different detectors <\/li><li>Additional plot display options<\/li><li>Ability to turn on or off modules at startup <ul><li>such that I can vary my NIM setup if I chose to<\/li><\/ul><\/li><li>Data Tagging<ul><li>Label peaks as you see them with custom text<\/li><\/ul><\/li><li>Graphical Saves<ul><li>Save the spectrum as an image<\/li><\/ul><\/li><li>Auto State restore<ul><li>To read a files footer and auto set set all the settings based on it<\/li><\/ul><\/li><li>Waterfall plots and time linked measurements<ul><li>To graphically display half lives for short lives things like radon or neutron activation products from fusor runs.  <\/li><\/ul><\/li><li>Isotope Energies Display (gamma for now)<ul><li>Displayed as vertical lines for each energy an isotope emits<\/li><li>With relative intensities displayed as calculated and normalized variable height vertical lines for each energy an isotope emits. <\/li><li>With optional daughter decay chain energies displayed as different color vertical lines at normalized variable heights <\/li><\/ul><\/li><li>Perhaps someday ill try my hand at isotope Identification, maybe<\/li><li>I&#8217;m sure there is some other stuff I have had ideas to implement but I am forgetting to mention<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Author: Jay HowsonDate: March-2020 Note: This page is under construction. I have example files to add, more pictures to add, code to write, etc. I&#8217;ll get to it eventually I promise. Intro Once I had my canberra spectroscopy system working, I found myself wanting more out of the MCA software. Both the MEDm and&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"http:\/\/www.nuclearphysicslab.com\/npl\/npl-home\/spectroscopy\/software_and_hardware\/diy-matlab-mca\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":2368,"parent":122,"menu_order":2,"comment_status":"open","ping_status":"closed","template":"","meta":{"advanced-sidebar-menu\/link-title":"","advanced-sidebar-menu\/exclude-page":false},"categories":[48,80,5,34,47],"tags":[],"_links":{"self":[{"href":"http:\/\/www.nuclearphysicslab.com\/npl\/wp-json\/wp\/v2\/pages\/2414"}],"collection":[{"href":"http:\/\/www.nuclearphysicslab.com\/npl\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.nuclearphysicslab.com\/npl\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.nuclearphysicslab.com\/npl\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.nuclearphysicslab.com\/npl\/wp-json\/wp\/v2\/comments?post=2414"}],"version-history":[{"count":47,"href":"http:\/\/www.nuclearphysicslab.com\/npl\/wp-json\/wp\/v2\/pages\/2414\/revisions"}],"predecessor-version":[{"id":3186,"href":"http:\/\/www.nuclearphysicslab.com\/npl\/wp-json\/wp\/v2\/pages\/2414\/revisions\/3186"}],"up":[{"embeddable":true,"href":"http:\/\/www.nuclearphysicslab.com\/npl\/wp-json\/wp\/v2\/pages\/122"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.nuclearphysicslab.com\/npl\/wp-json\/wp\/v2\/media\/2368"}],"wp:attachment":[{"href":"http:\/\/www.nuclearphysicslab.com\/npl\/wp-json\/wp\/v2\/media?parent=2414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.nuclearphysicslab.com\/npl\/wp-json\/wp\/v2\/categories?post=2414"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.nuclearphysicslab.com\/npl\/wp-json\/wp\/v2\/tags?post=2414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}