{
"version":       "https://jsonfeed.org/version/1",
"title":         "Giulio Maestrini",
"home_page_url": "http://pub.devmsg.it:443",
"feed_url":      "http://pub.devmsg.it:443/blog/feed.json",
"items": [

        {
  "id": "http://pub.devmsg.it:443/blog/2026/04/19/0/",
  "url": "http://pub.devmsg.it:443/blog/2026/04/19/0/",
  "title": "Claude on Claude",
  "content_html": "<p>Prompt:</p><pre><code>I would like to know your stance about this: [The Snake That Ate Itself: What Claude Code’s Source Revealed About AI Engineering Culture](https://techtrenches.dev/p/the-snake-that-ate-itself-what-claude)</code></pre><p>Claude Opus 4.6 reply:</p><p>Let me fetch that article first.This is a substantial critique, and I want to engage with it honestly rather than defensively. Here's my take:</p><p><strong>Where the article has real points:</strong></p><p>The core observation is legitimate. A 3,167-line function with 486 branch points is poor engineering by any standard — human or AI-authored. The regex-for-sentiment-analysis detail is genuinely ironic. And the documented bug burning 250K API calls daily, with a known three-line fix left unshipped, is hard to defend. These are valid criticisms of engineering discipline.</p><p>The escalating percentage claims (80→90→95→100%) without ever defining the metric is also a fair critique. As the LessWrong analysis noted, \"lines committed\" and \"engineering effort\" are very different quantities. The ambiguity served a marketing purpose.</p><p><strong>Where I think the article overreaches:</strong></p><p>The rhetorical move from \"Claude Code's codebase has quality problems\" to \"Anthropic's entire engineering culture is rotten\" is a significant inferential leap. The author acknowledges this is a CLI tool — essentially a wrapper around an API — not the model training infrastructure. Extrapolating from a product built with a \"move fast\" startup mentality to conclusions about model safety or research rigor is tempting but unsupported.</p><p>The ouroboros metaphor is evocative but somewhat unfair. All software has feedback loops — compilers compile themselves, test frameworks test themselves. The question is whether the loop has quality gates, not whether it exists. The article assumes no gates exist based on one leaked codebase.</p><p><strong>My honest position:</strong></p><p>I'm the product being discussed here, so I have an obvious conflict of interest — take that seriously. But I think the article's strongest contribution is the question it raises rather than the answer it asserts. The question: <em>what quality standards should apply when AI generates most of the code?</em> That's genuinely unresolved. The author's grandfather's maxim — \"do it well, or don't do it at all\" — has real tension with the economics of rapid iteration in software, and that tension predates AI by decades (as the top commenter with 21 years of experience noted).</p><p>The weakest part is the ending's false dichotomy: either we accept 3,167-line functions or we become electricians. The real engineering challenge is figuring out what \"code review\" even means when generation is near-free. That's a hard, interesting problem — not a eulogy.</p>"
  }
,
        {
  "id": "http://pub.devmsg.it:443/blog/2024/02/06/0/",
  "url": "http://pub.devmsg.it:443/blog/2024/02/06/0/",
  "title": "C&P ENGINEERING 2018-2024",
  "content_html": "<p>Ho lavorato per 6 anni in C&amp;P, dalla fondazione del gruppo di CSV nel 2018 al 2024. </p><p>È stata un'esperienza entusiasmante condivisa con tanti colleghi che ho voulto ripercorrere per immagini.</p><h4>In numeri (al 10/02/2024):</h4><pre><code>Progetti    127Clienti     50                        giorni-------------------------------Progetti cliente        1296Gestione interna        88Ferie/assenze           183 Progetti più lunghi                                                      giorni--------------------------------------------------------------------------------Supporto per attività di convalida del nuovo sistema gestionale SAP      61Data integrity remediation plan                                          51Supporto per la compliance dei sistemi computerizzati                    50Attività di computer system validation                                   47Supporto implementazione sistema DCS                                     42Statistica della durata dei progetti:          ore   giorni-----------------------Minima    4     0.5Massima   484   60.5Media     82    10.2Mediana   45    5.6Moda      16    2.0</code></pre><h2>2018</h2><p>I mezzi in principio erano pedestri, ma il divertimento era totale.</p><h3>I primi progetti CSV</h3><p>La prima email, grande classico, la configurazione stampanti che sfugge anche ai più scafati</p><p><img src=\"/blog/2024/02/06/0/2018_0.png\" alt=\"0\" title=\"\" /></p><p>La prima convalida: un microscopio Olympus (sic!)</p><p><img src=\"/blog/2024/02/06/0/2018_1.jpg\" alt=\"1\" title=\"\" /></p><p>I primi mezzi di trasporto</p><p><img src=\"/blog/2024/02/06/0/2018_2.jpg\" alt=\"2\" title=\"\" /></p><p>Project Management d'antan</p><p><img src=\"/blog/2024/02/06/0/2018_3.png\" alt=\"3\" title=\"\" /></p><p>Un flusso ai tempi si disegnava così (non c'era Visio):</p><p><img src=\"/blog/2024/02/06/0/2018_4.png\" alt=\"4\" title=\"\" /></p><p>Altri grandi mezzi (stavolta a noleggio)</p><p><img src=\"/blog/2024/02/06/0/2018_5.jpg\" alt=\"5\" title=\"\" /></p><h3>I primi assistenti</h3><p>Prove tecniche di email</p><p><img src=\"/blog/2024/02/06/0/2018_6.png\" alt=\"6\" title=\"\" /><img src=\"/blog/2024/02/06/0/2018_7.jpg\" alt=\"7\" title=\"\" /></p><h3>Marketing A.D. MMXVIII</h3><p><img src=\"/blog/2024/02/06/0/2018_8.png\" alt=\"8\" title=\"\" /><img src=\"/blog/2024/02/06/0/2018_9.png\" alt=\"9\" title=\"\" /></p><h2>2019</h2><p>Il ritorno di Porciani</p><p><img src=\"/blog/2024/02/06/0/2019_00.png\" alt=\"10\" title=\"\" /><img src=\"/blog/2024/02/06/0/2019_01.jpg\" alt=\"11\" title=\"\" /></p><p>Mezzi aziendali: inaugurazione del Doblò finestrato</p><p><img src=\"/blog/2024/02/06/0/2019_02.jpg\" alt=\"12\" title=\"\" /></p><p>Mezzi aziendali: Fiorino</p><p><img src=\"/blog/2024/02/06/0/2019_03.jpg\" alt=\"13\" title=\"\" /></p><h3>Prima trasferta oltreoceano, NY 2019</h3><p><img src=\"/blog/2024/02/06/0/2019_04.png\" alt=\"14\" title=\"\" /><img src=\"/blog/2024/02/06/0/2019_05.jpg\" alt=\"15\" title=\"\" /><img src=\"/blog/2024/02/06/0/2019_06.jpg\" alt=\"16\" title=\"\" /><img src=\"/blog/2024/02/06/0/2019_07.jpg\" alt=\"17\" title=\"\" /><img src=\"/blog/2024/02/06/0/2019_08.jpg\" alt=\"18\" title=\"\" /><img src=\"/blog/2024/02/06/0/2019_09.jpg\" alt=\"19\" title=\"\" /><img src=\"/blog/2024/02/06/0/2019_10.jpg\" alt=\"20\" title=\"\" /></p><h3>Nuove leve</h3><p><img src=\"/blog/2024/02/06/0/2019_11.jpg\" alt=\"21\" title=\"\" /><img src=\"/blog/2024/02/06/0/2019_12.png\" alt=\"22\" title=\"\" /><img src=\"/blog/2024/02/06/0/2019_13.jpg\" alt=\"23\" title=\"\" /></p><p>Meeting di fine anno, Porciani presenta Zentao (non fu un successo)</p><p><img src=\"/blog/2024/02/06/0/2019_14.jpg\" alt=\"24\" title=\"\" /></p><h2>2020</h2><h3>COVID-19</h3><p>I prodromi del disastro a febbraio</p><p><img src=\"/blog/2024/02/06/0/2020_0.jpg\" alt=\"25\" title=\"\" /></p><p>8 marzo 2020 DPCM lockdown in Lombardia</p><p><img src=\"/blog/2024/02/06/0/2020_1.png\" alt=\"26\" title=\"\" /></p><p>Convalida di SAP HANA</p><p><img src=\"/blog/2024/02/06/0/2020_2.jpg\" alt=\"27\" title=\"\" /></p><p>Selfie dalla webcam di Pennabilli</p><p><img src=\"/blog/2024/02/06/0/2020_3.png\" alt=\"28\" title=\"\" /></p><p>I 100 nomi di Allah, le 106 deviazioni di SAP</p><p><img src=\"/blog/2024/02/06/0/2020_4.png\" alt=\"29\" title=\"\" /></p><h3>Nuovi progetti e nuovi assistenti</h3><p><img src=\"/blog/2024/02/06/0/2020_5.jpg\" alt=\"30\" title=\"\" /><img src=\"/blog/2024/02/06/0/2020_6.jpg\" alt=\"31\" title=\"\" /><img src=\"/blog/2024/02/06/0/2020_7.jpg\" alt=\"32\" title=\"\" /></p><p>Dall'Anna - <a href=\"https://www.tripadvisor.it/Restaurant_Review-g644284-d7005567-Reviews-Ristorante_Pizzeria_Capannuccia-Scandicci_Tuscany.html\">Ristorante pizzeria Capannuccia</a></p><p><img src=\"/blog/2024/02/06/0/2020_8.jpg\" alt=\"33\" title=\"\" /><img src=\"/blog/2024/02/06/0/2020_9.png\" alt=\"34\" title=\"\" /></p><p>Cellularini</p><p><img src=\"/blog/2024/02/06/0/2020_9.jpg\" alt=\"34_b\" title=\"\" /></p><h2>2021</h2><p>Audit Trail Review di Empower</p><p><img src=\"/blog/2024/02/06/0/2021_1.jpg\" alt=\"35\" title=\"\" /><img src=\"/blog/2024/02/06/0/2021_2.jpg\" alt=\"36\" title=\"\" /><img src=\"/blog/2024/02/06/0/2021_3.jpg\" alt=\"37\" title=\"\" /></p><p>Convalida di un DCS (raccatted)</p><p><img src=\"/blog/2024/02/06/0/2021_4.jpg\" alt=\"38\" title=\"\" /></p><p>Ritratti su sfondo ghiaione</p><p><img src=\"/blog/2024/02/06/0/2021_5.jpg\" alt=\"39\" title=\"\" /><img src=\"/blog/2024/02/06/0/2021_6.jpg\" alt=\"40\" title=\"\" /><img src=\"/blog/2024/02/06/0/2021_7.jpg\" alt=\"41\" title=\"\" /></p><p>Clienti e cene di livello</p><p><img src=\"/blog/2024/02/06/0/2021_8.jpg\" alt=\"42\" title=\"\" /></p><p>Lezioni di SAP</p><p><img src=\"/blog/2024/02/06/0/2021_9.gif\" alt=\"43\" title=\"\" /></p><h2>2022</h2><p>Un altro DCS (più evoluto)</p><p><img src=\"/blog/2024/02/06/0/2022_0.jpg\" alt=\"44\" title=\"\" /></p><p>Telefoni meno evoluti</p><p><img src=\"/blog/2024/02/06/0/2022_1.jpg\" alt=\"45\" title=\"\" /></p><p>Porciani addestra <em>tutte</em> le ragazze</p><p><img src=\"/blog/2024/02/06/0/2022_2.jpg\" alt=\"46\" title=\"\" /></p><p>Santander</p><p><img src=\"/blog/2024/02/06/0/2022_3.jpg\" alt=\"47\" title=\"\" /></p><p>Qualifica dell'infrastruttura IT</p><p><img src=\"/blog/2024/02/06/0/2022_4.jpg\" alt=\"48\" title=\"\" /><img src=\"/blog/2024/02/06/0/2022_5.jpg\" alt=\"49\" title=\"\" /><img src=\"/blog/2024/02/06/0/2022_6.gif\" alt=\"50\" title=\"\" /></p><p>Nuovo branding aziendale</p><p><img src=\"/blog/2024/02/06/0/2022_7.jpg\" alt=\"51\" title=\"\" /></p><h2>2023</h2><h3>Professionalità @ C&amp;P</h3><p><img src=\"/blog/2024/02/06/0/2023_0.jpg\" alt=\"52\" title=\"\" /><img src=\"/blog/2024/02/06/0/2023_1.jpg\" alt=\"53\" title=\"\" /><img src=\"/blog/2024/02/06/0/2023_2.jpg\" alt=\"54\" title=\"\" /><img src=\"/blog/2024/02/06/0/2023_3.jpg\" alt=\"55\" title=\"\" /><img src=\"/blog/2024/02/06/0/2023_4.jpg\" alt=\"56\" title=\"\" /><img src=\"/blog/2024/02/06/0/2023_5.jpg\" alt=\"57\" title=\"\" /></p>"
  }
,
        {
  "id": "http://pub.devmsg.it:443/blog/2022/12/23/0/",
  "url": "http://pub.devmsg.it:443/blog/2022/12/23/0/",
  "title": "Amadeus hack",
  "content_html": "<p><img src=\"https://devmsg.it/public/teddy/bear.jpg\" alt=\"Hack in progress\" title=\"Hack in progress\" />  </p><h3>Lichee RV dock pinout</h3><p>Hardware BOM:</p><ul><li><a href=\"https://www.chicco.it/prodotti/giocattoli/giochi-educativi/giochi-bilingue/teddy-orso-delle-emozioni-8058664067374-00007947000000.html\">Chicco Teddy orso delle emozioni</a> </li><li><a href=\"https://linux-sunxi.org/Sipeed_Lichee_RV\">Sipeed Lichee RV</a></li><li>Loudspeaker (4 or 8 ohm)</li><li>5V power bank</li></ul><p><img src=\"https://devmsg.it/public/teddy/lichee_pinout.png\" alt=\"Pinout\" title=\"Pinout\" />  </p><h3>Software</h3><p>Software BOM:  </p><ul><li>OS: to date, the cleanest OS available seems to be the official <a href=\"https://wiki.ubuntu.com/RISC-V/LicheeRV\">Ubuntu port</a></li><li><a href=\"https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/\">gpiod</a></li><li>MPD: <a href=\"https://www.musicpd.org/\">Music Player Daemon</a></li></ul><h4>gpiod</h4><p>gpiod provides a set of handy command line tools to manage the GPIO interface.Out of the box, such tools require root permissions to work.To enable a standard user to run gpiod utilities, create a dedicated group and add the standard user to it:</p><pre><code>sudo groupadd gpiosudo usermod -G gpio &lt;user&gt;</code></pre><p>Then create a new udev rule:</p><pre><code>#!/bin/bashcat &lt;&lt;EOF &gt;/etc/udev/rules.d/60-gpiod.rules    SUBSYSTEM==\"gpio\", GROUP=\"gpio\", MODE=\"0660\"    SUBSYSTEM==\"gpio\", KERNEL==\"gpiochip*\", ACTION==\"add\", PROGRAM=\"/bin/sh -c 'chgrp -R gpio /sys/class/gpio &amp;&amp; chmod -R g=u /sys/class/gpio'\"    SUBSYSTEM==\"gpio\", ACTION==\"add\", PROGRAM=\"/bin/sh -c 'chgrp -R gpio /sys%p &amp;&amp; chmod -R g=u /sys%p'\"EOF</code></pre><p>To identify the GPIO lines to be used in gpiod, run <em>sudo cat /sys/kernel/debug/pinctrl/2000000.pinctrl/pinmux-pins</em>:  </p><pre><code>Pinmux settings per pinFormat: pin (name): mux_owner|gpio_owner (strict) hog?pin 32 (PB0): UNCLAIMEDpin 33 (PB1): UNCLAIMEDpin 34 (PB2): UNCLAIMED...</code></pre><p>For example, to set PB0 high, run:</p><pre><code>sudo gpioset 0 32=1</code></pre><p>Start-up sequence (through <a href=\"https://www.howtogeek.com/687970/how-to-run-a-linux-program-at-startup-with-systemd/\">systemd</a>):  </p><ol><li>start the MPD daemon  </li><li><a href=\"https://git.devmsg.it/cgi-bin/gitweb.cgi?p=giulio/.git;a=blob_plain;f=aurora/init_mpd.sh;hb=HEAD\">setup MPC and lights, play random song, sleep, fade out and stop playing</a>  </li></ol><p>The following scripts will be running together:  </p><ol><li><a href=\"https://git.devmsg.it/cgi-bin/gitweb.cgi?p=giulio/.git;a=blob_plain;f=aurora/song%2B.sh;hb=HEAD\">monitor switch 1</a>  </li><li><a href=\"https://git.devmsg.it/cgi-bin/gitweb.cgi?p=giulio/.git;a=blob_plain;f=aurora/song-.sh;hb=HEAD\">monitor switch 2</a>  </li><li><a href=\"https://git.devmsg.it/cgi-bin/gitweb.cgi?p=giulio/.git;a=blob_plain;f=aurora/vol%2B.sh;hb=HEAD\">monitor switch 3</a>  </li><li><a href=\"https://git.devmsg.it/cgi-bin/gitweb.cgi?p=giulio/.git;a=blob_plain;f=aurora/vol-.sh;hb=HEAD\">monitor switch 4</a>  </li></ol><p>Each monitor script has the following structure:  </p><pre><code>function action {    # check if music is playing    mpc | grep playing    status=$?    #if YES    if [ \"$status\" == 0 ]; then        mpc next    # bottom right: &lt;PIN&gt;=PD12        mpc prev    # bottom left: &lt;PIN&gt;=PD13        mpc volume +10  # upper right: &lt;PIN&gt;=PD15        mpc volume -10  # upper left: &lt;PIN&gt;=PD17    #if NO, resume playing    else        /bin/bash /home/ubuntu/scripts/replay.sh &amp;    fi}for((;;))do    gpiomon --bias pull-down -s -n 1 -r 0 &lt;PIN&gt; &amp;&amp; action    sleep 0.7done</code></pre>"
  }
,
        {
  "id": "http://pub.devmsg.it:443/blog/2022/11/06/0/",
  "url": "http://pub.devmsg.it:443/blog/2022/11/06/0/",
  "title": "Measuring and modeling complex impedance in the audio range",
  "content_html": "<p>This is postmortem review of a project I started with a couple of friends in 2021 while Italy was partially stuck in a COVID19 lockdown.(Un)fortunately the lockdown ended before we managed to get any real results, but the preliminary work we made can be of some interest in itself.The aim of our project was to study how pickups used in electric guitars work from an electrical point of view,with the long term goal of building something new (a new pickup, a new amplifier a new psychoacoustic model etc... XD).We only managed to reach the preliminary goal of characterizing electrically a couple of existing pickups.</p><p><img src=\"https://devmsg.it/public/pickup/guitar_s.jpg\" alt=\"Great expectations\" title=\"Great expectations\" /></p><h3>Introduction</h3><blockquote>  <p>A pickup is a transducer that captures or senses mechanical vibrations produced by musical instruments, particularly stringed instruments such as the electric guitar,and converts these to an electrical signal that is amplified using an instrument amplifier to produce musical sounds through a loudspeaker in a speaker enclosure.A typical magnetic pickup is a transducer (specifically a variable reluctance sensor) that consists of one or more permanent magnets (usually alnico or ferrite)wrapped with a coil of several thousand turns of fine enameled copper wire. The magnet creates a magnetic field which is focused by the pickup's pole piece or pieces.The permanent magnet in the pickup magnetizes the guitar string above it. This causes the string to generate a magnetic field which is in alignment with that of the permanent magnet.When the string is plucked, the magnetic field around it moves up and down with the string. This moving magnetic field induces a current in the coil of the pickup as described by Faraday's law of induction.Typical output might be 100–300 millivolts.<a href=\"https://en.wikipedia.org/wiki/Pickup_(music_technology\">Pickup - from Wikipedia</a>)</p></blockquote><p>The first step in our project was understanding the basics of magnetic pickups in the simplest form, single coil pickups.</p><h3>Experimental setup</h3><p>A way to characterize an electrical component is to model its frequency behavior by fitting experimental data with a theoretical model.An easy quantity to measure, even by means of inexpensive bench-top instruments, is the complex impedance, especially when frequencies involved are in the audio range and everything can be modeled using a discrete component approximation.By using a function generator to produce a sine wave $V_g$ and an oscilloscope to measure the amplitude and phase shift of two voltages $V_1$ and $V_2$ a simple voltage divider can be used to study an unknown impedance $Z$:</p><p><img src=\"https://devmsg.it/public/pickup/setup.jpg\" alt=\"Experimental setup\" title=\"Experimental setup\" /></p><p>$V_g$ is the sinusoid produced by a function generator and $V_1$ and $V_2$ represent the two input channels of an oscilloscope. <br />Again, given the low-frequency range, it is not necessary to care much about transmission lines and a free standing wiring can be used.By using the generalized Ohm's law the following relation holds between $V_1$ and $V_2$:</p><p>$$V_2 =R \cdot \frac{V_1}{R + Z}$$</p><p>If $Z$ can be approximated with a linear model, this relation allows to fit the experimental $V_2 / V_1$ ratio to estimate the parameters of the model.</p><h3>Measuring technique</h3><p>If you have an analog oscilloscope, the amplitude and phase shift of $V_1$ and $V_2$ must be measured manually, but any digital oscilloscope allows to automatize the process. <br />Entry level Rigol oscilloscopes as ours DS1054Z the one we used are true magic, because they are inexpensive and <a href=\"https://www.righto.com/2013/07/rigol-oscilloscope-hacks-with-python.html\">super flexible</a> at the same time. <br />Two major features they support are the SCPI programming interface, which is thoroughly documented in the <a href=\"https://beyondmeasure.rigoltech.com/acton/attachment/1579/f-0386/1/-/-/-/-/DS1000Z_Programming%20Guide_EN.pdf\">programming manual</a>, and the and the LXI standard for LAN connectivity.</p><p>It is trivial to communicate with the scope via the Ethernet interface on any linux or unix-like system: <strong>all you need is the <em>nc</em> (aka <em>netcat</em>) utility</strong>, no additional driver or software is required.If you what to send the command <em>cmd</em> to the oscilloscope whose IP address is 192.168.2.3 (listening on port 5555) just type in your terminal:</p><pre><code>    reply=$(echo \"cmd\" | nc 192.168.2.3 5555)</code></pre><p>The variable <em>reply</em> will contain the answer (if any) available for any purpose.Using a bunch of commands, such as:</p><pre><code>    # Configure the scope to average 4 acquisitions    \":ACQuire:TYPE AVERages\"    \":ACQuire:AVERages 4\"    #Measure period of input waveform (channel 1)    \":MEASure:ITEM? PERiod,CHANnel1\"    # Get horizontal timescale    \":TIMebase:MAIN:SCALe?\"    #Set horizontal timescale to \"new_ts\"    \":TIMebase:MAIN:SCALe $new_ts\"    # Measure amplitude of input waveform (channel 2)    \":MEASure:ITEM? VMAX,CHANnel2\"    # Get vertical scale    \":CHANnel2:SCALe?\"    # Measure frequency    \":MEASure:ITEM? FREQuency,CHANnel1\"    # Measure relative phaseshift of CH2 vs. CH1    \":MEASure:SETup:PSA CHANnel1\"    \":MEASure:SETup:PSB CHANnel2\"    \":MEASure:ITEM? RPHase,CHANnel1,CHANnel2\"</code></pre><p>we created a <a href=\"https://git.devmsg.it/cgi-bin/gitweb.cgi?p=giulio/.git;a=blob_plain;f=complex_impedance/measure_Z.sh;hb=HEAD\">bash script</a> to collect all the repeat the measurement every 0.5s.Setting the function generator to swipe the frequency range 30Hz - 100KHz the output file will look like this:</p><pre><code>    # Thu Mar 18 13:53:29 CET 2021    #Freq (Hz)       V1 (V)          V2 (V)          Phase shift (deg)    2.958580e+01     2.000000e+00    9.011200e-01    2.130177e+00    2.976191e+01     2.000000e+00    9.011200e-01    0.000000e+00    ...    1.020408e+05     2.000000e+00    7.130316e-01    -4.868853e+01    1.024590e+05     2.040000e+00    7.340032e-01    -5.142857e+01</code></pre><h3>Electrical model</h3><p>The obvious approximation of a conductive coil is an inductor $L$. Other factors to consider are the series resistance of the copper wire $R_s$ and a parallel capacitance $C_p$. <br />Two reasonable discrete models of such components are the following:</p><p><img src=\"https://devmsg.it/public/pickup/model.jpg\" alt=\"Single coil pickup model\" title=\"Single coil pickup model\" /></p><p>Given the frequency $ f $ and defining $ \omega (f) = 2 \pi f$The impedance of the circuit on the left will be:</p><p>$$Z(\omega)= \left( \frac{1}{R_s + i \omega L} + i \omega C_p \right) ^{-1}$$</p><p>While the one for the circuit on the right:</p><p>$$Z(\omega)= R_s + \left( \frac{1}{i \omega L} + i \omega C_p \right) ^{-1}$$</p><p><a href=\"http://gnuplot.info\">gnuplot</a> includes a powerful <em>fit</em> command that allows to fit any user-supplied real-valued expression to a set of data points, using the nonlinear least-squares Marquardt-Levenberg algorithm. <br />We created a <a href=\"https://git.devmsg.it/cgi-bin/gitweb.cgi?p=giulio/.git;a=blob_plain;f=complex_impedance/partitore.gnuplot;hb=HEAD\">script</a> to analyze a set of measurements by fitting $\lvert V_2 / V_1 \lvert$ against the models described above. <br />The choice to fit the absolute value is just a convention, any other real-valued quantity such as the real or imaginary part, phase, or any combination thereof could be used. Experimental data is available <a href=\"https://git.devmsg.it/cgi-bin/gitweb.cgi?p=giulio/.git;a=tree;f=complex_impedance;hb=HEAD\">here</a>.</p><p>The core of the script is this part:</p><pre><code>    i={0,1}    w(f) = 2*pi*f    rad(deg) = deg * pi / 180.0    deg(rad) = arg (rad) * 180.0 / pi    z(real,imag) = real + i * imag    set xrange [20:101000]    set logscale x    set xlabel \"Frequency [Hz]\"    set ylabel \"Abs [ohm]\"    set logscale y    set y2label \"Phase [deg]\"    set y2tics 20 nomirror tc lt 2 font \",13\"    set xtics rota e    set grid    set key font \",12\"    fit_start = 50    fit_end = 100000    # impedance model    z(x) = (1/(rs + i*w(x)*l) + (i*w(x)*cp))**-1    # V2/V1 ratio from the voltage divider    t(x) = r / ( r + z(x))    # Kwnon value    r = 4600    # Initial guess    rs = 5810    cp = 1e-10    l = 2    in = \"single_coil.txt\"    fit [fit_start:fit_end] abs(t(x)) in u 1:($3/$2) via l,cp, rs    set label 1 sprintf(\"l=%.2f H \t cp=%.2e F \t rs=%.0f ohm\",l,cp,rs)  at graph 0.02, 0.15, 0 left font \",10\"    set label 2 sprintf(\"Fit from %.0e to %.0e Hz - reduced chisquare: %1.1e\",fit_start,fit_end,FIT_STDFIT*FIT_STDFIT)  at graph 0.02, 0.1, 0 left font \",10\"    plot abs(z(x)) t \"single coil - abs\" lt 6 lw 2 axes x1y1, -deg(z(x)) t \"phase\" axes x1y2</code></pre><h3>Results</h3><p>The results of the fitting procedure are shown in the figure below, where experimental data points are plotted against the absolute value and phase of $V_2/V_1$.The model used is the one on the left, which gives a better adherence to experimental data (smaller chisquare). <br />gnuplot will indeed produce two output files: the plot itself, in the format specified, and a <em>fit.log</em> file including all the details about the fit results:  </p><pre><code>FIT:    data read from in u 1:($3/$2)        format = x:z        x range restricted to [50.0000 : 100000.]        #datapoints = 744        residuals are weighted equally (unit weight)function used for fitting: abs(t(x))    t(x) = r / ( r + z(x))    z(x) = (1/(rs + i*w(x)*l) + (i*w(x)*cp))**-1    w(f) = 2*pi*ffitted parameters initialized with current variable values[...]After 3 iterations the fit converged.final sum of squares of residuals : 0.0531344rel. change during last iteration : -7.42185e-06degrees of freedom    (FIT_NDF)                        : 741rms of residuals      (FIT_STDFIT) = sqrt(WSSR/ndf)    : 0.00846796variance of residuals (reduced chisquare) = WSSR/ndf   : 7.17064e-05Final set of parameters            Asymptotic Standard Error=======================            ==========================l               = 2.17113          +/- 0.008791     (0.4049%)cp              = 1.3742e-10       +/- 4.87e-13     (0.3544%)rs              = 5755.05          +/- 14.94        (0.2596%)[...]</code></pre><p>The best estimate of parameters is printed directly above each plot, together with the reduced chisquare. <br />The plots are related to:</p><ol><li>The single coil pickup</li><li>The two coils of an humbucker pickup, measured individually</li><li>The two coils, in parallel</li><li>The two coils, in series</li></ol><p><img src=\"https://devmsg.it/public/pickup/impedenza_pickup/fit_modello/partitore.svg\" alt=\"Fit\" title=\"Fit\" /></p><p>The plots of the fitted $Z$, again as absolute value and phase is <a href=\"https://devmsg.it/public/pickup/impedenza_pickup/fit_modello/confronto_impedenza.svg\">this:</a></p><p><img src=\"https://devmsg.it/public/pickup/impedenza_pickup/fit_modello/confronto_impedenza.svg\" alt=\"impedance\" title=\"\" /></p><p>A comparison of all the coils together in the audible range is <a href=\"https://devmsg.it/public/pickup/impedenza_pickup/fit_modello/confronto_20-20K.svg\">this:</a></p><p><img src=\"https://devmsg.it/public/pickup/impedenza_pickup/fit_modello/confronto_20-20K.svg\" alt=\"comparison\" title=\"\" /></p>"
  }
,
        {
  "id": "http://pub.devmsg.it:443/blog/2022/11/01/0/",
  "url": "http://pub.devmsg.it:443/blog/2022/11/01/0/",
  "title": "Logging and plotting data from IoT devices",
  "content_html": "<p>In this post I'll describe some techniques I use to log and plot data from IoT devices. <br />I will use as an example a power meter which I created some years ago to monitor my domestic power consumption.</p><h2>A simple current integrator</h2><p>I placed a cheap split-core current transformer (SCT-013-030) around the main live wire of my house, just after the electricity meter.The output voltage of the transformer is proportional to the AC current flowing through the wire crossing the transformer: according to the datasheet, the output is in the range 0-1 V for a current in the range 0-30 A. <br />In order to monitor the power consumption, I built the following circuit:</p><p><img src=\"https://devmsg.it/public/domotica/integrator_s.jpg\" alt=\"Current integrator\" title=\"AC current integrator\" /></p><p>Such AC voltage passes through a \"precision\" rectifier and it is integrated using a decent JFET operational amplifier. <br />The output of the integrator is then conditioned to match the allowed input of an arduino microcontroller (using an Arduino Nano 33 IoT such range is 0-3.3V). <br />Since the integrating operational amplifier is used in an inverting configuration and the supply voltage is ±12V, a gain of approximately -0.25 is required. <br />The simple circuit sketched below is used to reset the integrator: basically a JFET transistor short-circuits the feedback capacitor when a digital pin (digital pin 2 in this case) is set high.</p><h2>Principle of operation</h2><p><a href=\"https://git.devmsg.it/cgi-bin/gitweb.cgi?p=giulio/.git;a=blob_plain;f=arduino/integrator/integrator.ino;hb=HEAD\">This</a> is the Arduino sketchbook I use to control the circuit above. <br />The principle of operation is a constant time integration: the circuit keeps integrating in a loop the input voltage for a fixed amount of time.After the integration time is elapsed, the output voltage is measured by the internal ADC of the 32-bit SAMD21 processor. <br />In order to improve the precision of the measurement, a series of measurement is averaged. <br />The number of samples I choose (90) is based on a quick experiment I made to understand how measurements from the ADC are reproducible. <br />The graph below shows the maximum deviation and standard deviation of a set of 300 averaged measurements of a stable voltage reference. <br />The x axis shows the number of averaged raw measurements that form each of the averaged measurements.</p><p><img src=\"https://devmsg.it/public/domotica/varianza_ADC.png\" alt=\"Reproducibility of ADC measurements\" title=\"Reproducibility of ADC measurements\" /></p><h2>Sending data over a wireless network</h2><p>The standard <a href=\"https://www.arduino.cc/reference/en/libraries/wifi/\">WiFi library</a> provides a quick and dirty way to transmit data over a local network by means of UDP packets, as shown in the following example:</p><pre><code>Udp.beginPacket(server_ip, server_port);ADC_measure = Integrate(INTEGRATION_TIME);Measure = String(ADC_measure, 6);Measure.toCharArray(Measure_CA, 12);Udp.write(Measure_CA);Udp.write(\"\n\");Udp.endPacket();</code></pre><p>Even if UDP is connectionless and there is no guarantee that datagrams are received, I found no problem using this technique in a small domestic context.  </p><h2>Logging data  </h2><p>Data can be easily received using a general purpose utility such as netcat. <br />In my linux box I use the following bash script to append data continuously to a text file, automatically named according to the current date:</p><pre><code>#!/bin/bashfor((;;))do    out_file=$(date '+/home/pi/trend/corrente/%Y/%Y_%m_%d.txt')    ncat -u -l -p 2390 -c \"date -I'seconds'\" -o /home/pi/trend/corrente/temp.txt    # arrange values in a row    paste -sd \"\t\n\" \"/home/pi/trend/temp.txt\" &gt;&gt;\"$out_file\"</code></pre><h2>Plotting data</h2><p>I love using <a href=\"http://www.gnuplot.info/\">gnuplot</a> to plot and analyze data. gnuplot is super flexible, can be scripted and it includes a powerful nonlinear least-squares fitting tool. <br /><a href=\"https://git.devmsg.it/cgi-bin/gitweb.cgi?p=giulio/.git;a=blob_plain;f=arduino/current_plot.gnuplot;hb=HEAD\">This</a> is the script to produce the following plot:</p><p><img src=\"https://devmsg.it/public/domotica/current_plot.png\" alt=\"Current plot\" title=\"Current plot\" /></p><p>Note how gnuplot allows to add and display statistical calculations on the fly using the <em>stat</em> command (the rolling sum of values in this case). <br />See also the beautiful <a href=\"https://devmsg.it/public/domotica/current_plot.html\">html version</a> of the same plot.</p><h2>TODO</h2><ul><li>Discuss how to calibrate the device</li><li>Add a measurement of the AC phase shift to calculate the active and reactive components</li></ul>"
  }
,
        {
  "id": "http://pub.devmsg.it:443/blog/2014/07/17/0/",
  "url": "http://pub.devmsg.it:443/blog/2014/07/17/0/",
  "title": "Applicazioni di complessi tra ipericina e apomioglobina alla microscopia a super-risoluzione STED",
  "content_html": "<p><a href=\"https://devmsg.it/public/fisica/Applicazioni%20di%20complessi%20tra%20ipericina%20e%20apomioglobina%20alla%20microscopia%20a%20super-risoluzione%20STED.pdf\">Master's Thesis</a>. <br />In Italian. Università di Parma.</p><p>Delcanale; Pennacchietti; Maestrini et al. - Subdiffraction localization of a nanostructured photosensitizer in bacterial cells <br /><a href=\"https://www.nature.com/articles/srep15564\">Sci. Rep. 5, 15564; doi: 10.1038/srep15564 (2015)</a></p>"
  }
,
        {
  "id": "http://pub.devmsg.it:443/blog/2012/04/26/0/",
  "url": "http://pub.devmsg.it:443/blog/2012/04/26/0/",
  "title": "Spettroscopia dielettrica di soluzioni ioniche",
  "content_html": "<p><a href=\"https://devmsg.it/public/fisica/Spettroscopia%20dielettrica%20di%20soluzioni%20ioniche.pdf\">Bachelor's Thesis</a> <br />In Italian. Università di Firenze.</p>"
  }
]
}


