<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6338993703407602171</id><updated>2026-10-29T01:32:55.225-07:00</updated><category term="PIC32"/><category term="PIC32MX250F128B"/><category term="PIC"/><category term="PIC32MX"/><category term="32-bit"/><category term="XC32"/><category term="inverter"/><category term="mppt"/><category term="sine wave"/><category term="C32"/><category term="Cornell"/><category term="ICSP"/><category term="IR2110"/><category term="buck"/><category term="capacitor"/><category term="half bridge"/><category term="power supply"/><category term="rp2040"/><category term="transformer"/><category term="AT91"/><category term="AT91SAM3X8E"/><category term="Bruce"/><category term="DAC"/><category term="DC-AC"/><category term="DMA"/><category term="ECE"/><category term="Intel"/><category term="LCD"/><category term="Land"/><category term="MOSFET"/><category term="PIC micro"/><category term="PIC16"/><category term="PWM"/><category term="SG3525"/><category term="SG3525 circuit"/><category term="SMPS"/><category term="SPI"/><category term="SPWM"/><category term="TFT"/><category term="bias"/><category term="bootstrap"/><category term="bridge"/><category term="deadtime"/><category term="ferrite core"/><category term="full bridge"/><category term="gate drive"/><category term="gate driver"/><category term="high side"/><category term="high side drive"/><category term="inductor"/><category term="microcontroller"/><category term="phase angle"/><category term="phase angle control"/><category term="pi"/><category term="pico"/><category term="programmer"/><category term="pure sine"/><category term="push-pull"/><category term="raspberry"/><category term="ripple"/><category term="synchronous buck"/><category term="thyristor"/><category term="triac"/><category term="12-bit"/><category term="16F676"/><category term="16F684"/><category term="16F877A"/><category term="250F128B"/><category term="30v"/><category term="32-qam"/><category term="4670"/><category term="4999"/><category term="5a"/><category term="AC"/><category term="AC-DC"/><category term="ANSEL"/><category term="AT91SAM"/><category term="ATMEGA8"/><category term="AVR"/><category term="Adafruit"/><category term="Arduino"/><category term="Arduino Due"/><category term="Bruce Land"/><category term="CPU overhead"/><category term="Comparator"/><category term="DC-DC"/><category term="DC/AC"/><category term="DDS"/><category term="DMAC"/><category term="DMM"/><category term="Device"/><category term="Edison"/><category term="ExpressPCB"/><category term="ExpressSCH"/><category term="Galileo"/><category term="ILI9340"/><category term="IO"/><category term="IPS"/><category term="IR"/><category term="ISR"/><category term="JTAG"/><category term="Keypad"/><category term="Linux"/><category term="MCP4822"/><category term="MDDFS"/><category term="Microchip"/><category term="Mouse"/><category term="N-channel"/><category term="NEC"/><category term="PCB"/><category term="PIC16F684"/><category term="PIC16F873A"/><category term="PIC16F877A"/><category term="PIC32 hack"/><category term="PICKIT3"/><category term="PORT"/><category term="PV"/><category term="Protoboard"/><category term="Protothreads"/><category term="RC5"/><category term="RC6"/><category term="Reference Voltage"/><category term="SD"/><category term="SG 3525"/><category term="SIRC"/><category term="SRS"/><category term="TRIS"/><category term="UPS"/><category term="USB"/><category term="Voltmeter"/><category term="Yocto"/><category term="ac control"/><category term="ac power control"/><category term="amplifier"/><category term="amplitude"/><category term="analog"/><category term="atmega"/><category term="auto transformer"/><category term="automatic voltage stabilizer"/><category term="autotransformer"/><category term="avs"/><category term="battery charger"/><category term="boost"/><category term="boundary conduction"/><category term="bps305"/><category term="charge controller"/><category term="complementary"/><category term="control"/><category term="current control"/><category term="current sense"/><category term="derating"/><category term="development board"/><category term="development system"/><category term="dial"/><category term="digilent"/><category term="digital communication"/><category term="discovery"/><category term="display"/><category term="division"/><category term="driver"/><category term="dsPIC"/><category term="dsPIC33"/><category term="efficiency"/><category term="electrolytic"/><category term="embedded"/><category term="emulation"/><category term="encoder"/><category term="esl"/><category term="event2"/><category term="ferrite"/><category term="ferrite transformer"/><category term="frequency"/><category term="graphics"/><category term="hex"/><category term="hi cut"/><category term="high cut"/><category term="high low"/><category term="high-side"/><category term="hy3005"/><category term="impedance"/><category term="impedance analyzer"/><category term="independent study"/><category term="interrupt"/><category term="isolated drive"/><category term="keycap"/><category term="lavolta"/><category term="lm317"/><category term="lm358"/><category term="loader"/><category term="low cut"/><category term="low side"/><category term="matlab"/><category term="microSD"/><category term="modulation"/><category term="multiplexing"/><category term="ofdm"/><category term="offline"/><category term="offload"/><category term="opamp"/><category term="orthogonal"/><category term="oscilloscope"/><category term="owon"/><category term="parasitics"/><category term="passive"/><category term="pcm"/><category term="photovoltaic"/><category term="pic16f72"/><category term="power control"/><category term="power electronics"/><category term="programming"/><category term="pulse width modulation"/><category term="qam"/><category term="qam-32"/><category term="qam-5"/><category term="qamdemod"/><category term="qammod"/><category term="quadrature"/><category term="raspberry pi"/><category term="register"/><category term="reverse recovery"/><category term="rpi"/><category term="sawtooth"/><category term="schematic"/><category term="sds6062"/><category term="sds6062v"/><category term="separate power supply"/><category term="seven segment"/><category term="shadow"/><category term="solar"/><category term="solar panel"/><category term="stabilizer"/><category term="switch mode"/><category term="threading"/><category term="tl081"/><category term="tl082"/><category term="totem-pole"/><category term="touch screen"/><category term="trainer board"/><category term="variac"/><category term="verroboard"/><category term="voltage"/><category term="voltage stabilizer"/><title type='text'>Tahmid&#39;s blog</title><subtitle type='html'>Embedded Systems and Power Electronics</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>81</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-6685728658004954214</id><published>2025-08-05T12:45:00.000-07:00</published><updated>2025-08-05T23:06:28.843-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bias"/><category scheme="http://www.blogger.com/atom/ns#" term="buck"/><category scheme="http://www.blogger.com/atom/ns#" term="capacitor"/><category scheme="http://www.blogger.com/atom/ns#" term="derating"/><category scheme="http://www.blogger.com/atom/ns#" term="inductor"/><category scheme="http://www.blogger.com/atom/ns#" term="ripple"/><category scheme="http://www.blogger.com/atom/ns#" term="voltage"/><title type='text'>Why is my buck output ripple higher than expected: ceramic capacitor derating vs voltage</title><content type='html'>&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgPwH8eZwrJ6mDHfEiMqj4VgywTM_8BwM28Tptav-G9mbjIzcVN9gQorQHTkt372xZpbtyPb6n1bb3HxwCMO9A3DB8sH1GvxnFL7oPzrrFYblgv955cqE8DpKbjnN8It1IzZBH4Slz8R8hkIKHubMadSMQ2wlWSYUwmXzbEkI0shaXAVi262kWPvbEQLtXR&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1125&quot; data-original-width=&quot;1000&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgPwH8eZwrJ6mDHfEiMqj4VgywTM_8BwM28Tptav-G9mbjIzcVN9gQorQHTkt372xZpbtyPb6n1bb3HxwCMO9A3DB8sH1GvxnFL7oPzrrFYblgv955cqE8DpKbjnN8It1IzZBH4Slz8R8hkIKHubMadSMQ2wlWSYUwmXzbEkI0shaXAVi262kWPvbEQLtXR=w568-h640&quot; width=&quot;568&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 0a - The &lt;a href=&quot;https://tahmidmc.blogspot.com/2025/03/power-testbench-and-upcoming-power.html&quot;&gt;test hardware&lt;/a&gt;&amp;nbsp;comprising a buck converter operating at 50kHz and 50% duty cycle. The PWM signals are generated from an on-board RP2040. The buck inductor (not shown) is soldered on the reverse side of the PCB.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiSkbnBQpBnrEMd9i_WXxJi4_SxHxXOYevcI46ad0GDZ-0wMPJ2w1lZpg9XbZFIOKJFZuI4-TKjtHxNMuEDpE0hSWnxvINY8xR6v17DHjHVXU0_FOa3Z3NYgqyshaKAMGUmEdNXGN4Ni3tyuzhK_7P2NpnCWjAJDmyQbm38P446MPTNw9kCKFSo36YLlmxy&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1185&quot; data-original-width=&quot;1000&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiSkbnBQpBnrEMd9i_WXxJi4_SxHxXOYevcI46ad0GDZ-0wMPJ2w1lZpg9XbZFIOKJFZuI4-TKjtHxNMuEDpE0hSWnxvINY8xR6v17DHjHVXU0_FOa3Z3NYgqyshaKAMGUmEdNXGN4Ni3tyuzhK_7P2NpnCWjAJDmyQbm38P446MPTNw9kCKFSo36YLlmxy=w541-h640&quot; width=&quot;541&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 0b - Back side of the test PCB, where the input electrolytic caps and output inductor are soldered.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEihsEkYUHWhPiVRuY6WTjWOJrwNrZxGZhCwRm5KoI6sP4DTWVr5zhjZVNAOAOYk5tUAJbnzNIYM6VIfvmJfw4vqYd7ZPxkKQOvJAhw5dI_gOS3oyR6ywhcmdQhyFKKqTqfLyCKC1tFnVjxNrgEjD9w9-E1we_pWESNtRkBdr1cs1hHKJyxsuybLUOixfKLe&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;329&quot; data-original-width=&quot;766&quot; height=&quot;137&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEihsEkYUHWhPiVRuY6WTjWOJrwNrZxGZhCwRm5KoI6sP4DTWVr5zhjZVNAOAOYk5tUAJbnzNIYM6VIfvmJfw4vqYd7ZPxkKQOvJAhw5dI_gOS3oyR6ywhcmdQhyFKKqTqfLyCKC1tFnVjxNrgEjD9w9-E1we_pWESNtRkBdr1cs1hHKJyxsuybLUOixfKLe&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 1 - Buck converter&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;In a typical buck converter shown in Fig. 1, the output ripple voltage is an important design specification. Sensitive loads may specify a maximum ripple voltage. The max allowable voltage for the load is also limited by the ripple, especially for loads with tight specifications such as many processors.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The output ripple voltage is given by&lt;p&gt;&lt;/p&gt;&lt;p&gt;\[ \Delta V_\mathrm{out} = \frac{V_\mathrm{in}D(1-D)}{8LCf_\mathrm{sw}^2} \]&lt;/p&gt;&lt;p&gt;The derivation is given at the end of this post for those interested. The different parameters are:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;\( \Delta V_\mathrm{out} \) = peak-to-peak output ripple voltage&lt;/li&gt;&lt;li&gt;\( V_\mathrm{in} \) = input voltage&lt;/li&gt;&lt;li&gt;\( D \) = duty cycle&lt;/li&gt;&lt;li&gt;\( L \) = inductance&lt;/li&gt;&lt;li&gt;\( C \) = output capacitance&lt;/li&gt;&lt;li&gt;\( f_\mathrm{sw} \) = switching frequency&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;We can look at the output ripple using the &lt;a href=&quot;https://tahmidmc.blogspot.com/2025/03/power-testbench-and-upcoming-power.html&quot;&gt;power testbench&lt;/a&gt;. The converter is run at 50kHz and 50% duty cycle, with varying input voltages. The output capacitor of the converter is the parallel combination of 4x 0805 10µF caps (&lt;a href=&quot;https://www.murata.com/en-us/products/productdetail?partno=GRM21BR61H106KE43%23&quot;&gt;GRM21BR61H106KE43&lt;/a&gt;) and 1x 1206 10µF cap (&lt;a href=&quot;https://product.tdk.com/en/search/capacitor/ceramic/mlcc/info?part_no=CGA5L3X5R1H106K160AB&quot;&gt;CGA5L3X5R1H106K160AB&lt;/a&gt;). The inductor is rated at 5.6µH, specifically the &lt;a href=&quot;https://www.digikey.com/en/products/detail/würth-elektronik/7443557560/3083181&quot;&gt;Wurth&amp;nbsp;732-3799-1-ND&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Based on this, you would expect the output ripple at 10V input to be given by:&lt;/p&gt;&lt;p&gt;\[ \Delta V_\mathrm{out} = \frac{V_\mathrm{in}D(1-D)}{8LCf_\mathrm{sw}^2} = \frac{10V \cdot 0.5 \cdot 0.5}{8\cdot 5.6\mu H \cdot 50\mu F \cdot (50\;kHz)^2} =0.45\;V \]&lt;/p&gt;&lt;p&gt;The ripple waveform is obtained with a scope that is AC coupled and can be seen below in Fig. 2. From the scope shot, it appears that the voltage ripple is about 0.75V, which is a fair bit higher than the expected ripple. So what gives?&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjoTbvQ9M93fGAs3oiRUXDNaL0gmfrsnV00BC9NVWt-xky3ypN-SE1VgCw7YD37i55V9JfzBnuz_Bt9JG0CvSQis1UYzBTnlaHRRRVn5q5H70HHTnCzLNCZl6agfeQ1UUBqHIBEcBfEWYWFbSJ45xOFjrRKYsLLZHv2vxsvooQXIAT-E5sHfWvTvswIMe-0&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;480&quot; data-original-width=&quot;800&quot; height=&quot;384&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjoTbvQ9M93fGAs3oiRUXDNaL0gmfrsnV00BC9NVWt-xky3ypN-SE1VgCw7YD37i55V9JfzBnuz_Bt9JG0CvSQis1UYzBTnlaHRRRVn5q5H70HHTnCzLNCZl6agfeQ1UUBqHIBEcBfEWYWFbSJ45xOFjrRKYsLLZHv2vxsvooQXIAT-E5sHfWvTvswIMe-0=w640-h384&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 2 - Output ripple, AC coupled, 500mV/division, Vin=10V, Vout=5V&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;The culprit here is voltage derating of ceramic capacitors. Much like how I&#39;ve previously written about &lt;a href=&quot;https://tahmidmc.blogspot.com/2024/03/electrolytic-caps-over-frequency-why-is.html&quot;&gt;electrolytic capacitors derating with frequency&lt;/a&gt;, ceramic capacitors (particularly class II dielectrics) can derate substantially with voltage. This has to do with the reduced permittivity of the dielectric, reducing the capacitors&#39; ability to store energy at higher voltage biases. This is often given in manufacturer technical documentation. For our caps, the derating charts are reproduced below.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiAKb8jB5rB5bXg5S9YJFzMtAgAc8vCxcGDkxKfwvAvHTb1lT8rUTzGFIS7TCAdN8mJw05EzNCd2x1zcAt4QvtIg7ijCVvdJir0QbATBRWnC63wC2eXrASbPTQgPQk8srwUP6BFHW92phxk8qO7OjIaaHV_4UBglI8Pmr7CVdj0MF1wIlFLNTHo69FHgTBI&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;422&quot; data-original-width=&quot;575&quot; height=&quot;235&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiAKb8jB5rB5bXg5S9YJFzMtAgAc8vCxcGDkxKfwvAvHTb1lT8rUTzGFIS7TCAdN8mJw05EzNCd2x1zcAt4QvtIg7ijCVvdJir0QbATBRWnC63wC2eXrASbPTQgPQk8srwUP6BFHW92phxk8qO7OjIaaHV_4UBglI8Pmr7CVdj0MF1wIlFLNTHo69FHgTBI&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 3a -&amp;nbsp;&lt;a href=&quot;https://www.murata.com/en-us/products/productdetail?partno=GRM21BR61H106KE43%23&quot; style=&quot;text-align: left;&quot;&gt;GRM21BR61H106KE43&lt;/a&gt;&amp;nbsp;DC bias characteristics, credit: Murata&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjdevjFeI71LYc_hSqAi4k71u_NRh5tLNu4oKwiqWKmd3YH0cqo9Yt28P1Q0HFNwb7dBUIcRNKGhS28CPRxh9Zls7TUJUCdPoXpLyvDtdY3j6nklly7wBRrvMPlyQZC0qeQc8Qkn2VQQNtsEMx7gwvMXoG74Z3MkAZfRQMHP9zz42rOkKYxX5l-jmpEkINM&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;656&quot; data-original-width=&quot;682&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjdevjFeI71LYc_hSqAi4k71u_NRh5tLNu4oKwiqWKmd3YH0cqo9Yt28P1Q0HFNwb7dBUIcRNKGhS28CPRxh9Zls7TUJUCdPoXpLyvDtdY3j6nklly7wBRrvMPlyQZC0qeQc8Qkn2VQQNtsEMx7gwvMXoG74Z3MkAZfRQMHP9zz42rOkKYxX5l-jmpEkINM&quot; width=&quot;250&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 3b -&amp;nbsp;&lt;a href=&quot;https://www.murata.com/en-us/products/productdetail?partno=GRM21BR61H106KE43%23&quot; style=&quot;text-align: left;&quot;&gt;GRM21BR61H106KE43&lt;/a&gt;&amp;nbsp;5V DC bias corresponds to a 6.4µF capacitance&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi0NbPsZkKLInb4D7Uv9rHsTYvVYgHu5uwX5HSIehkvi5AjmWHfhtd2TuWjTIplOA8SQ5Vxritj7sJ9dWMYDKXKkox3_WUC0kC_ccxp4sZwPw97cNgisoP3hwYrbv6WZdKt1pXaIO8Cl_GLvkFzGzK2Iodu3oxTaVESr3rxmn9k4EdTAYGC_kmBPDCq_AK3&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;908&quot; data-original-width=&quot;1160&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi0NbPsZkKLInb4D7Uv9rHsTYvVYgHu5uwX5HSIehkvi5AjmWHfhtd2TuWjTIplOA8SQ5Vxritj7sJ9dWMYDKXKkox3_WUC0kC_ccxp4sZwPw97cNgisoP3hwYrbv6WZdKt1pXaIO8Cl_GLvkFzGzK2Iodu3oxTaVESr3rxmn9k4EdTAYGC_kmBPDCq_AK3&quot; width=&quot;307&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 4a -&amp;nbsp;&lt;a href=&quot;https://product.tdk.com/en/search/capacitor/ceramic/mlcc/info?part_no=CGA5L3X5R1H106K160AB&quot; style=&quot;text-align: left;&quot;&gt;CGA5L3X5R1H106K160AB&lt;/a&gt;&amp;nbsp;DC bias characteristics, credit: TDK&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhC7ip1yQvSH6FUpXtfZIjJ_zas4BlV6Ge5aLK3YW6J_NSJAA91AxyYL-vaaB2C9I2qrCxRyqoPJyBBCcuHXsJgPD5Me2e8wVCdZtsMXmR5EMXx29wCHs-4vLq5-ijRPKCxoDC1b40qGz4nArcQfWxfrDEiuqc_ess3q9WfMJlVVXaN2o6FLKXiLSOkcUfz&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;818&quot; data-original-width=&quot;1140&quot; height=&quot;230&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhC7ip1yQvSH6FUpXtfZIjJ_zas4BlV6Ge5aLK3YW6J_NSJAA91AxyYL-vaaB2C9I2qrCxRyqoPJyBBCcuHXsJgPD5Me2e8wVCdZtsMXmR5EMXx29wCHs-4vLq5-ijRPKCxoDC1b40qGz4nArcQfWxfrDEiuqc_ess3q9WfMJlVVXaN2o6FLKXiLSOkcUfz&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;Fig. 4b -&amp;nbsp;&lt;a href=&quot;https://product.tdk.com/en/search/capacitor/ceramic/mlcc/info?part_no=CGA5L3X5R1H106K160AB&quot; style=&quot;text-align: left;&quot;&gt;CGA5L3X5R1H106K160AB&lt;/a&gt;&amp;nbsp;5V DC bias corresponds to a 9.1µF capacitance; you will often notice that larger packages correspond to reduced derating and hence have larger capacitances for the same initial capacitance and voltage rating&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Considering the derating from Figs. 3-4, the total output capacitance is 34µF. With this new value plugged in, the expected output ripple is about&amp;nbsp;&lt;/div&gt;&lt;br /&gt;\[ \Delta V_\mathrm{out} = \frac{V_\mathrm{in}D(1-D)}{8LCf_\mathrm{sw}^2} = \frac{10V \cdot 0.5 \cdot 0.5}{8\cdot 5.6\mu H \cdot 34.7\mu F \cdot (50\;kHz)^2} =0.64\;V \]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is much closer to the observed value with a 14.5% error, something that is fairly within the tolerance of different components.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If we now look at the results with 20V input (corresponding to 10V output), we would expect an output ripple of double that for the 10V input, corresponding to 1.3V; if the caps didn&#39;t further derate. However, we can find again from the manufacturer data that the total output capacitance is 19.7µF, down from 34µF, which would correspond to a greater increase in the ripple. This is shown in Figs. 5a and 5b.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg9YoLMe91qfEo5mJocXRyo-fZzsino7Y7WFPNlMQBy7-TDZcuvupwkrSgdFk-k7bmrAsZzDXvH8OJ2KfKgiWRI2yjNuI4QHABNXkjRGOac9pJlbsDUdStl_Uu8iOZ-UOs2s20oeY6qoLYgB4tNAXTJFU5OdsiFXkT1pnlSOb8sdpS1H6ezPL7roV-0hSLM&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;648&quot; data-original-width=&quot;672&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg9YoLMe91qfEo5mJocXRyo-fZzsino7Y7WFPNlMQBy7-TDZcuvupwkrSgdFk-k7bmrAsZzDXvH8OJ2KfKgiWRI2yjNuI4QHABNXkjRGOac9pJlbsDUdStl_Uu8iOZ-UOs2s20oeY6qoLYgB4tNAXTJFU5OdsiFXkT1pnlSOb8sdpS1H6ezPL7roV-0hSLM&quot; width=&quot;249&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;text-align: left;&quot;&gt;Fig. 5a -&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://www.murata.com/en-us/products/productdetail?partno=GRM21BR61H106KE43%23&quot; style=&quot;text-align: left;&quot;&gt;GRM21BR61H106KE43&lt;/a&gt;&amp;nbsp;10V DC bias corresponds to a 3.2µF capacitance&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgzAg3jH_A_xC8vSQEcniQEDSrghJwMbGB9TveS8P9W2YOL_dNn-WSOlNf3i0WJrXGO_acEgJlfL-iO8i5Q5lfhN-PIx3REcSYTjFDNKf1ERO8VbkCMdM62focLDwAEI5i-G_Xyhna3oMb21v03GSUwnq8n3DJNwTfrfIGbQoPOZlmz9TYW8_e09mgu3Xk_&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;802&quot; data-original-width=&quot;1110&quot; height=&quot;231&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgzAg3jH_A_xC8vSQEcniQEDSrghJwMbGB9TveS8P9W2YOL_dNn-WSOlNf3i0WJrXGO_acEgJlfL-iO8i5Q5lfhN-PIx3REcSYTjFDNKf1ERO8VbkCMdM62focLDwAEI5i-G_Xyhna3oMb21v03GSUwnq8n3DJNwTfrfIGbQoPOZlmz9TYW8_e09mgu3Xk_&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;text-align: left;&quot;&gt;Fig. 5b -&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://product.tdk.com/en/search/capacitor/ceramic/mlcc/info?part_no=CGA5L3X5R1H106K160AB&quot; style=&quot;text-align: left;&quot;&gt;CGA5L3X5R1H106K160AB&lt;/a&gt;&amp;nbsp;10V DC bias corresponds to a 6.9µF capacitance&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjwfrVpcS-AaSMpThaG-mp7hfuqYL6HpSzXNY4vTdKqIE8n_NrRKRPNpmdh4YKVRquIRPBSf4c3zANxmxlvTWwOj6Asw8zwpyrHh-0nU6dpMRU3rzlh-zVmSfbyELAXaTVxAHD6GYicvo0b1dDsJWUHTffeWFpJqh5b5AZ5ARzvIZL4AZ7JdqsQDuCEDWEG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;480&quot; data-original-width=&quot;800&quot; height=&quot;384&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjwfrVpcS-AaSMpThaG-mp7hfuqYL6HpSzXNY4vTdKqIE8n_NrRKRPNpmdh4YKVRquIRPBSf4c3zANxmxlvTWwOj6Asw8zwpyrHh-0nU6dpMRU3rzlh-zVmSfbyELAXaTVxAHD6GYicvo0b1dDsJWUHTffeWFpJqh5b5AZ5ARzvIZL4AZ7JdqsQDuCEDWEG=w640-h384&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 6 - Output ripple, AC coupled, 500mV/division, Vin=20V, Vout=10V&lt;/div&gt;&lt;/span&gt;&lt;span style=&quot;text-align: center;&quot;&gt;&lt;div&gt;&lt;span style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;The output ripple observed with 20V input is shown in Fig. 6. The measured ripple corresponds to 2.7V, which further highlights the substantial capacitance drop with 10V bias for the output ceramic capacitors!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;text-align: center;&quot;&gt;The expected ripple with ideal caps is given by&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;text-align: left;&quot;&gt;\[ \Delta V_\mathrm{out} = \frac{V_\mathrm{in}D(1-D)}{8LCf_\mathrm{sw}^2} = \frac{20V \cdot 0.5 \cdot 0.5}{8\cdot 5.6\mu H \cdot 50\mu F \cdot (50\;kHz)^2} = 0.9\;V \]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;However, with derated capacitance, the expected ripple is&amp;nbsp;&lt;/div&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;\[ \Delta V_\mathrm{out} = \frac{V_\mathrm{in}D(1-D)}{8LCf_\mathrm{sw}^2} = \frac{20V \cdot 0.5 \cdot 0.5}{8\cdot 5.6\mu H \cdot 19.7\mu F \cdot (50\;kHz)^2} = 2.3\;V \]&lt;div&gt;This is much closer to the observed ripple value.&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;text-align: center;&quot;&gt;For proper filtering, it is crucial to consider the DC bias impact on the ceramic capacitors and the corresponding derating, in addition to component tolerance! Otherwise, the filtering will be insufficient and the ripple will be much higher than expected, as shown here. This could result in poor circuit performance or even component damage!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;text-align: center;&quot;&gt;Note that the circuit parameters here were chosen to have large output ripple to illustrate the concern described in this article. In almost any application, this circuit has a very high ripple percentage. Even with the components as present, the frequency can be increased substantially to reduce the ripple. Alternately, the output inductor or capacitance can be increased.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;h3 style=&quot;clear: both; text-align: left;&quot;&gt;Ripple Derivation&lt;/h3&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjDkdS8LGwVxPhoHd0mCqXsJbPHJ2ihNag0zX9l81NehB-5uSW0avKusXnVSviUHFENtU66czPcZ2GV9M9NMrTIZYOiO34VLAytNeX9inqbShrHKk4AEuXoWl2I-sg1esvWTuUqfNQl5-DqruM31j3u8drRZjeZz5nwbaBOFwFOn6-ob7GnOTee76oo3u6X&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;329&quot; data-original-width=&quot;766&quot; height=&quot;137&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjDkdS8LGwVxPhoHd0mCqXsJbPHJ2ihNag0zX9l81NehB-5uSW0avKusXnVSviUHFENtU66czPcZ2GV9M9NMrTIZYOiO34VLAytNeX9inqbShrHKk4AEuXoWl2I-sg1esvWTuUqfNQl5-DqruM31j3u8drRZjeZz5nwbaBOFwFOn6-ob7GnOTee76oo3u6X&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. D1 - Buck Converter&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiEu3XAN8TI0Zq3r8djv4mNvmdr3lN_6YdIlm7huSi0gs_EL5dlZryBuvLy-nJe8C5YdTxzR2OMM6JjNoqww4ksTF-HvLnIfXkvfQR0j_cr_KmUl_eOmf3M7T7LjWSVSZI9ZLt3qaAco8ED1p5SDDKyhdIf5EhbNNmUWOxldw3qkvc5nsK-TZ1cwjhOhzZl&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;391&quot; data-original-width=&quot;766&quot; height=&quot;163&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiEu3XAN8TI0Zq3r8djv4mNvmdr3lN_6YdIlm7huSi0gs_EL5dlZryBuvLy-nJe8C5YdTxzR2OMM6JjNoqww4ksTF-HvLnIfXkvfQR0j_cr_KmUl_eOmf3M7T7LjWSVSZI9ZLt3qaAco8ED1p5SDDKyhdIf5EhbNNmUWOxldw3qkvc5nsK-TZ1cwjhOhzZl&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. D2 - Buck Converter when QH is on&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjRR-pQu_p4TvXKOaLbQ7B-te0-SuiI2otkMgdUp0KQkjqRhF7_35Gd5O1baZuBAtNgorB95IAfzEKcWw4_cZ0UXHcbPbmUWrePzXKEHsAVmDVZ5X4WgfnmztiL7DTeHysk-wzl21Cwi3tAhHVMtjvEnrjnlciEYny8CURK_YXlyc8WLC3cX3xoGrq9eASP&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;389&quot; data-original-width=&quot;766&quot; height=&quot;163&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjRR-pQu_p4TvXKOaLbQ7B-te0-SuiI2otkMgdUp0KQkjqRhF7_35Gd5O1baZuBAtNgorB95IAfzEKcWw4_cZ0UXHcbPbmUWrePzXKEHsAVmDVZ5X4WgfnmztiL7DTeHysk-wzl21Cwi3tAhHVMtjvEnrjnlciEYny8CURK_YXlyc8WLC3cX3xoGrq9eASP&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Fig. D3 - Buck Converter when QL is on&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: left;&quot;&gt;To find the output ripple in a buck converter, we start from the inductor current, which can be determined from the inductor voltage in either QH on or QL on state. We can identify that \( i_\mathrm{L} \) increases when QH is on since \( v_\mathrm{L} \) is positive then. And similarly, \( i_\mathrm{L} \) decreases when QL is on since \( v_\mathrm{L} \) is negative.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;QH is on for a fraction of the switching period given by the duty cycle D. For a buck converter, the output voltage is given by \( V_\mathrm{out} = D V_\mathrm{in} \). The inductor voltage relationship \( v_\mathrm{L} = L \frac{di_\mathrm{L}}{dt} \) can be rewritten for constant voltage \( v_\mathrm{L} = L \frac{\Delta i_\mathrm{L}}{\Delta t} = L \frac{\Delta i_\mathrm{L}}{D T_\mathrm{sw}} \) where \(T_\mathrm{sw}\) is the switching period.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;The peak-to-peak inductor current ripple is thus given by&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;\[ \Delta i_\mathrm{L,pp} =&amp;nbsp; \frac{V_\mathrm{in}-V_\mathrm{out}}{L}\cdot \frac{D}{f_\mathrm{sw}} = \frac{V_\mathrm{in}(1-D)D}{Lf_\mathrm{sw}} \]&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;We know from Fig. D1 that \( i_\mathrm{L} = i_\mathrm{C} + i_\mathrm{out} \). We can find the impedance of the output capacitor and determine the current split between it and the output load. We can assume (and confirm mathematically) that the impedance of the output cap at high frequencies (such as in a typical buck converter) is much lower than the load resistance. Thus, we can assume that the inductor ripple current is going through the output cap, as shown in Fig. D4, and that the DC amount is going through the load resistor.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhNNhIUGidCPb_y53gBPfPFQq8FcjcMsJO6Xx2JzaGjr1LD2mGe4Zb_hl31zK6Z7gADPQEPW2tH5iCurSKVBIS3MUOlne0dJLCMuzGs22jsD7dtclnc62l-8CTbhSIFIWTSF0mTFWNYR920wMQWASluqMPcLhc88q1svrtjvY0tqmTGoujpWM8GXDiN1afW&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;544&quot; data-original-width=&quot;897&quot; height=&quot;194&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhNNhIUGidCPb_y53gBPfPFQq8FcjcMsJO6Xx2JzaGjr1LD2mGe4Zb_hl31zK6Z7gADPQEPW2tH5iCurSKVBIS3MUOlne0dJLCMuzGs22jsD7dtclnc62l-8CTbhSIFIWTSF0mTFWNYR920wMQWASluqMPcLhc88q1svrtjvY0tqmTGoujpWM8GXDiN1afW&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. D4 - Current going through the output capacitor&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;When the ripple current is positive (for half of \( T_\mathrm{sw} \) ), the output capacitor is charged and when the ripple current is negative, the output capacitor is discharged. The peak-to-peak capacitor voltage ripple can be found from the positive inductor current charging the cap, where Q is the charge \( \int i_\mathrm{C}\;dt = \frac{1}{2} \frac{\Delta i_\mathrm{L,pp}}{2} \frac{T_\mathrm{sw}}{2} = \frac{1}{8} \Delta \frac{i_\mathrm{L,pp}}{f_\mathrm{sw}} \)&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;\[&amp;nbsp; \Delta V_\mathrm{out} = \frac{Q}{C} = \frac{1}{8Cf_\mathrm{sw}} \Delta {i_\mathrm{L,pp}} = \frac{1}{8Cf_\mathrm{sw}} \frac{V_\mathrm{in}(1-D)D}{Lf_\mathrm{sw}} = \boxed{ \frac{V_\mathrm{in}D(1-D)}{8LCf_\mathrm{sw}^2} } \]&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;As a final check, we can go back to checking the magnitude of the output capacitance compared to the load resistance (10Ω output resistor was used) with the circuit in Fig. 0.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;\[ |Z_\mathrm{C}| = \frac{1}{2 \pi f_\mathrm{sw} C} = \frac{1}{2 \pi 50\;kHz \; 19.7\mu F} = 0.16 \Omega \ll 10 \Omega \]&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/6685728658004954214/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2025/08/why-is-my-buck-output-ripple-higher.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/6685728658004954214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/6685728658004954214'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2025/08/why-is-my-buck-output-ripple-higher.html' title='Why is my buck output ripple higher than expected: ceramic capacitor derating vs voltage'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEgPwH8eZwrJ6mDHfEiMqj4VgywTM_8BwM28Tptav-G9mbjIzcVN9gQorQHTkt372xZpbtyPb6n1bb3HxwCMO9A3DB8sH1GvxnFL7oPzrrFYblgv955cqE8DpKbjnN8It1IzZBH4Slz8R8hkIKHubMadSMQ2wlWSYUwmXzbEkI0shaXAVi262kWPvbEQLtXR=s72-w568-h640-c" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-2446763440439587270</id><published>2025-05-01T01:07:00.000-07:00</published><updated>2025-07-09T19:22:10.779-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bias"/><category scheme="http://www.blogger.com/atom/ns#" term="charge controller"/><category scheme="http://www.blogger.com/atom/ns#" term="emulation"/><category scheme="http://www.blogger.com/atom/ns#" term="mppt"/><category scheme="http://www.blogger.com/atom/ns#" term="photovoltaic"/><category scheme="http://www.blogger.com/atom/ns#" term="power supply"/><category scheme="http://www.blogger.com/atom/ns#" term="PV"/><title type='text'>Using a PV panel indoors by biasing with an external power supply</title><content type='html'>&lt;p&gt;My introduction to working with solar panels goes back a long time. In fact, in 2012, I posted &lt;a href=&quot;https://tahmidmc.blogspot.com/2012/09/research-and-design-of-solar-products.html&quot;&gt;this article&lt;/a&gt;&amp;nbsp;when I was working on some charge controllers and inverters. One consistent challenge when doing such work is always having a consistent reliable PV panel outdoors in bright (ideally not-too-hot) sunlight. This becomes difficult with varying weather conditions and limits development.&lt;/p&gt;&lt;p&gt;Recently I learned about how you can very easily use an external power supply (capable of operating in constant current mode) to use the PV panel indoors and emulate its outdoor behavior! This ends up being great for testing charge controllers and MPPT algorithms!&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgTxigaa0TbErgwiitnxR1qgKNMSaZP-WAs2m6wXGnIzGRTodux3rQmCnk8jh89RRiF1ZPujRZ0y_hRLXznkPBoI71Sl7evOqhqp5V6UoAGgurb4N0MyBaPiSIdXaHOBnShbnyqHKajYOt14UBEROXYs2qLOohAGfKNwAp0M5PUtkE7G24waL85Kw8izrdF&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;2129&quot; data-original-width=&quot;4000&quot; height=&quot;341&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgTxigaa0TbErgwiitnxR1qgKNMSaZP-WAs2m6wXGnIzGRTodux3rQmCnk8jh89RRiF1ZPujRZ0y_hRLXznkPBoI71Sl7evOqhqp5V6UoAGgurb4N0MyBaPiSIdXaHOBnShbnyqHKajYOt14UBEROXYs2qLOohAGfKNwAp0M5PUtkE7G24waL85Kw8izrdF=w640-h341&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;Fig. 1 - Setup for characterizing PV panel behavior indoors&lt;br /&gt;Panel: SLP010-12U&lt;br /&gt;Power supply: Rigol DP832&lt;br /&gt;Eload: Rigol DL3031&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Fig. 1 shows the test setup used for obtaining PV panel IV curves indoors. The only equipment required for emulating the PV panel itself is the power supply. The electronic load is used to vary the voltage imposed on the panel to obtain the IV curve. You can even see the panel facing down so that light is not incident onto it!&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi1EV-vleJ8Kc2HY2WrC03PtaBD728aJ44w74eu42YW6t7fehZ3-X4wJ9jP5FgHh1mkt14NCGzT7N0M4Ym5mx4GZcotRSpAW7stma9aEtEDK_RNl4XskNI_OH1yUotRFhrOSkAj6n8Ywq7hQRHUG0yx4asz7I8DFcJOes1m8DbKLimU5AUflMZIUCpC-dMN&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;437&quot; data-original-width=&quot;975&quot; height=&quot;143&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi1EV-vleJ8Kc2HY2WrC03PtaBD728aJ44w74eu42YW6t7fehZ3-X4wJ9jP5FgHh1mkt14NCGzT7N0M4Ym5mx4GZcotRSpAW7stma9aEtEDK_RNl4XskNI_OH1yUotRFhrOSkAj6n8Ywq7hQRHUG0yx4asz7I8DFcJOes1m8DbKLimU5AUflMZIUCpC-dMN&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 2 - Simple PV panel model&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;We can start by recognizing that a PV panel may be simply modeled as shown in Fig. 2. Iph represents the photocurrent generated by the panel under sunlight. When the panel is indoors, Iph is a miniscule value under typical indoor lighting conditions. What we &lt;i&gt;can&lt;/i&gt; do is, instead, use an external power supply to bias the panel with a constant current source. This is represented by Iext in Fig. 3.&amp;nbsp;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjdMNOiePT5QIzCQzWn4CoqU0tvjv9kImtaPhFqa-4v93gMF1Po2RAvODWrf2OVv6fIMxQH4jkrN6WD29xqVTtEHEvk82qy3ZkztiwMGvc_-dLVCatH-JkRVa4u6Jcx8eujuZVy6GrpJI70M9o_lb80mnfMi1--zfq8hZKMLBYKQdC7VW4gsSYGWjogMGIg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;466&quot; data-original-width=&quot;1400&quot; height=&quot;134&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjdMNOiePT5QIzCQzWn4CoqU0tvjv9kImtaPhFqa-4v93gMF1Po2RAvODWrf2OVv6fIMxQH4jkrN6WD29xqVTtEHEvk82qy3ZkztiwMGvc_-dLVCatH-JkRVa4u6Jcx8eujuZVy6GrpJI70M9o_lb80mnfMi1--zfq8hZKMLBYKQdC7VW4gsSYGWjogMGIg=w400-h134&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 3 - External power supply used to emulate photocurrent in PV panel&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;This is as simple as configuring the power supply&#39;s voltage at (or higher than) the panel&#39;s open-circuit voltage (Voc), and setting the current limit at the panel&#39;s short-circuit current (Isc). For the panel I picked, these correspond to 21.6V and 0.68A (at 100% luminosity).&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;The short-circuit current limit for the PSU can be varied to provide Iext emulating varying luminosities! For example, using 50% of the panel&#39;s short-circuit current, a condition of approximately 50% luminosity may be emulated!&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;This may be taken even further by adding a series voltage source to emulate voltage shifts in the IV curve.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Tests with 10W panel:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;To generate the IV curves in a repeatable fashion, I wrote a Python script that imposes different panel voltages by issuing the corresponding SCPI commands to the electronic load. The curve is then plotted in real-time, as shown in Vid. 1 below. The GUI was built by modifying the one from a previous blog post:&amp;nbsp;&lt;a href=&quot;https://tahmidmc.blogspot.com/2023/11/smartsinepy-and-example-of-gui.html&quot; style=&quot;text-align: center;&quot;&gt;SmartSinePy, and an example of GUI development with PySide6 ~ Tahmid&#39;s blog&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/zJJz1tcFG04&quot; width=&quot;320&quot; youtube-src-id=&quot;zJJz1tcFG04&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Vid. 1 - Characterizing panel IV curve at 100% emulated luminosity&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;To illustrate the operation at 50% emulated luminosity, the power supply current is set to 0.34A instead of 0.68A. The corresponding curve is generated as shown in Vid. 2.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/55gHbkG7Xrk&quot; width=&quot;320&quot; youtube-src-id=&quot;55gHbkG7Xrk&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;Vid. 2 - Characterizing panel IV curve at 50% emulated luminosity&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;These obtained curves are also shown below in Fig. 4 and Fig. 5.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhawYIeHR-GgwPSMkDc9vzxVJ39un3Ub30LsdDmpttKUr5_GNmMe4Coqt2tNHlFJLZnNPtKhQZ9oXCf_gFpzj9dG99iyITStyqjpZBWwhvhVu9MRp4LsDQ8DKFXj8xzKj1UvTEiDqAoxxuzhBjMP9_PmreqYIQNBge0FADSUrzUUl-q1FiDJT3bkFvfWFOM&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;733&quot; data-original-width=&quot;1046&quot; height=&quot;448&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhawYIeHR-GgwPSMkDc9vzxVJ39un3Ub30LsdDmpttKUr5_GNmMe4Coqt2tNHlFJLZnNPtKhQZ9oXCf_gFpzj9dG99iyITStyqjpZBWwhvhVu9MRp4LsDQ8DKFXj8xzKj1UvTEiDqAoxxuzhBjMP9_PmreqYIQNBge0FADSUrzUUl-q1FiDJT3bkFvfWFOM=w640-h448&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 4 - Obtained IV curve at 100% emulated luminosity&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjIHBHZlgIgox6TAe2OQnHF3vkb5ykOZtDMorI_lyjLiWYbumeE1w8j6cHweyMib-g58p4GT3IXEaP3jHlH4fD6lROjrR_74pF2urT-aI1WCxkRAMDYjojKwCAZO7knlOJfK50N_aAtFxJRu_novzCDg6xvEVyipRMKEe2DmVUa-xruhoEUuS26AXLLdMd9&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;738&quot; data-original-width=&quot;1062&quot; height=&quot;445&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjIHBHZlgIgox6TAe2OQnHF3vkb5ykOZtDMorI_lyjLiWYbumeE1w8j6cHweyMib-g58p4GT3IXEaP3jHlH4fD6lROjrR_74pF2urT-aI1WCxkRAMDYjojKwCAZO7knlOJfK50N_aAtFxJRu_novzCDg6xvEVyipRMKEe2DmVUa-xruhoEUuS26AXLLdMd9=w640-h445&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 5 - Obtained IV curves at 100% (top, same as Fig. 4) and 50% (bottom) emulated luminosities&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHYQsWxyPMX2hjuBqAzyyKVjC6evL7kKRUbMsWVebPrbahwKjJXw5-aoEk2fpIL-tn3KjlH5vTCnJrRaHJxmssaTiYjek_alwRNs9Iqs0uBQjUa29PDIYPfcXKbbW5H9VefJjq8RxZ87IaCXpZMRldguZCs34S_1890U4FavNaCxpfItxwM850gwPzilSL/s639/ivcurve.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;563&quot; data-original-width=&quot;639&quot; height=&quot;282&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHYQsWxyPMX2hjuBqAzyyKVjC6evL7kKRUbMsWVebPrbahwKjJXw5-aoEk2fpIL-tn3KjlH5vTCnJrRaHJxmssaTiYjek_alwRNs9Iqs0uBQjUa29PDIYPfcXKbbW5H9VefJjq8RxZ87IaCXpZMRldguZCs34S_1890U4FavNaCxpfItxwM850gwPzilSL/s320/ivcurve.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 6 - IV curves provided in the panel datasheet&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Fig. 6 shows the IV curves of the panel from its datasheet, showing close agreement between the curves obtained indoors with the 25°C curve! Slight tweaking of the open-circuit voltage and short-circuit current to match the 25°C curve can give slightly better match!&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;More significantly, this now allows testing with the PV panel indoors without worrying about weather conditions! Of course, all final tests for any charge controller or MPPT algorithm should be run outdoors with the panel under varying weather conditions, but this emulation method can significantly improve development time. I will soon share a demonstration of an MPPT controller developed using this setup!&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Characterization of a 100W panel:&lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;The same technique can be used for different panels and power levels. Fig. 6 shows one such IV curve obtained using the techniques outlined here but with a more capable power supply and electronic load. The power supply was set to 24.3V (panel open-circuit voltage) and 5.21A (panel short-circuit current at 100% luminosity).&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj_rxIdrWHTc6iwQLmEVy2Anb0lPT1w6w1XPC7-0FbT0HcWktZkvsoXbGwkUeT56_2D9eOnfLtoTsMxUpJYaMeS-vEKi0WxEoY0rZKbP-qSGnHzE_O4SFXJJUubuJZdengPhL9MUS7BNmV6GxZ0Yl1f-1oTTeTXPjSbevkaQOV4KXeIqcAeDHFit9Zc7RTm&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;600&quot; data-original-width=&quot;1000&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj_rxIdrWHTc6iwQLmEVy2Anb0lPT1w6w1XPC7-0FbT0HcWktZkvsoXbGwkUeT56_2D9eOnfLtoTsMxUpJYaMeS-vEKi0WxEoY0rZKbP-qSGnHzE_O4SFXJJUubuJZdengPhL9MUS7BNmV6GxZ0Yl1f-1oTTeTXPjSbevkaQOV4KXeIqcAeDHFit9Zc7RTm=w400-h240&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 6 - Obtained IV curve for a 100W panel&lt;/div&gt;&lt;p&gt;This simple technique can significantly improve development and testing times for projects using PV panels! For more details about this emulation technique and further enhancements, refer to the following papers which provide much greater detail:&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;p&gt;1. S. Qin, K. A. Kim and R. C. N. Pilawa-Podgurski, &quot;Laboratory emulation of a photovoltaic module for controllable insolation and realistic dynamic performance,&quot; 2013 IEEE Power and Energy Conference at Illinois (PECI), Urbana, IL, USA, 2013, pp. 23-29, doi: 10.1109/PECI.2013.6506029.&lt;br /&gt;&lt;a href=&quot;https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=6506029&quot;&gt;https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=6506029&lt;/a&gt;&lt;/p&gt;&lt;p&gt;2. T. -L. Huang, F. S. Bagci and K. A. Kim, &quot;Indoor Panel-Based Photovoltaic Emulation Method Implementation and Evaluation,&quot; 2024 IEEE Workshop on Control and Modeling for Power Electronics (COMPEL), Lahore, Pakistan, 2024, pp. 1-7, doi: 10.1109/COMPEL57542.2024.10613957.&lt;br /&gt;&lt;a href=&quot;https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=10613957&quot;&gt;https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=10613957&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/2446763440439587270/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2025/05/using-pv-panel-indoors-by-biasing-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/2446763440439587270'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/2446763440439587270'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2025/05/using-pv-panel-indoors-by-biasing-with.html' title='Using a PV panel indoors by biasing with an external power supply'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEgTxigaa0TbErgwiitnxR1qgKNMSaZP-WAs2m6wXGnIzGRTodux3rQmCnk8jh89RRiF1ZPujRZ0y_hRLXznkPBoI71Sl7evOqhqp5V6UoAGgurb4N0MyBaPiSIdXaHOBnShbnyqHKajYOt14UBEROXYs2qLOohAGfKNwAp0M5PUtkE7G24waL85Kw8izrdF=s72-w640-h341-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-616791476635608122</id><published>2025-03-30T20:47:00.000-07:00</published><updated>2025-08-05T12:51:01.835-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="boost"/><category scheme="http://www.blogger.com/atom/ns#" term="bootstrap"/><category scheme="http://www.blogger.com/atom/ns#" term="boundary conduction"/><category scheme="http://www.blogger.com/atom/ns#" term="buck"/><category scheme="http://www.blogger.com/atom/ns#" term="capacitor"/><category scheme="http://www.blogger.com/atom/ns#" term="deadtime"/><category scheme="http://www.blogger.com/atom/ns#" term="efficiency"/><category scheme="http://www.blogger.com/atom/ns#" term="gate drive"/><category scheme="http://www.blogger.com/atom/ns#" term="inductor"/><category scheme="http://www.blogger.com/atom/ns#" term="mppt"/><category scheme="http://www.blogger.com/atom/ns#" term="power electronics"/><category scheme="http://www.blogger.com/atom/ns#" term="raspberry pi"/><category scheme="http://www.blogger.com/atom/ns#" term="reverse recovery"/><category scheme="http://www.blogger.com/atom/ns#" term="ripple"/><category scheme="http://www.blogger.com/atom/ns#" term="rp2040"/><category scheme="http://www.blogger.com/atom/ns#" term="solar panel"/><category scheme="http://www.blogger.com/atom/ns#" term="synchronous buck"/><title type='text'>Power Testbench and Upcoming Power Electronics Tutorials</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;While I have written many articles on this blog about power electronics related topics, I am hoping to share more fundamentally structured tutorials and articles, based on power electronics fundamentals that have been reinforced during my time in graduate school. To that end, I have designed a testbench to cover topics ranging from basics to slightly more involved ones. I have completed the design of a power electronics test bench, sent out the PCB files to be fabbed at OSHPark, and ordered parts from Digikey.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;Here are some ideas I have for topics to cover, and I&#39;d love to get feedback on other topics of interest!&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;ul&gt;&lt;li&gt;Basic demonstration of buck and boost conversion&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tahmidmc.blogspot.com/2025/08/why-is-my-buck-output-ripple-higher.html&quot;&gt;Estimation of capacitor ripple&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Bidirectional blocking circuit&lt;/li&gt;&lt;li&gt;Isolated vs bootstrapped gate drive&lt;/li&gt;&lt;li&gt;Sizing inductor and operating with large ripple current&lt;/li&gt;&lt;li&gt;Boundary conduction mode operation&lt;/li&gt;&lt;li&gt;Efficiency characterization&lt;/li&gt;&lt;li&gt;Impact of deadtime on efficiency&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tahmidmc.blogspot.com/2025/05/using-pv-panel-indoors-by-biasing-with.html&quot; target=&quot;_blank&quot;&gt;PV panel behavior emulation with lab power supply&lt;/a&gt;&lt;/li&gt;&lt;li&gt;MPPT operation with PV panel&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;p&gt;Here are a couple 3D renders of the testbench hardware from Altium:&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgwABHXUBkAelH2yTF34GeQSO9Cd8TTH7ojsQae7mAJnH0tn8HkqzJCBWlFlc7EWLzi08HuZOu3ZJdt4UjRS9X_PRX8_55mgsyA9IJutg7Ep7FwirIlCNPZWRCB-ecikQjzXLPd1h22cBcVEMw10xyFITj59VFMSK59OwcULSIzDcDcwnhcYV4a7mCSwUEe&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;2250&quot; data-original-width=&quot;3737&quot; height=&quot;193&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgwABHXUBkAelH2yTF34GeQSO9Cd8TTH7ojsQae7mAJnH0tn8HkqzJCBWlFlc7EWLzi08HuZOu3ZJdt4UjRS9X_PRX8_55mgsyA9IJutg7Ep7FwirIlCNPZWRCB-ecikQjzXLPd1h22cBcVEMw10xyFITj59VFMSK59OwcULSIzDcDcwnhcYV4a7mCSwUEe&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Top side render&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhOsLhwAwfnijqEMVc7vsJD56-qF9-G7GxyWsh13MEU-bqacvY70H1ZAYcS9VyFUh5HEtN-YQqQNp4DL8RR3sv2Ldc7ylshCW0pU-5LgnH8NboV1S085GkRc1H7IOB5ZUOlll5rYa5lZWSxC0G7UF9fJcOZGVAHWKgKfkP90NPJb_JsJon5Ku-CZADHhB0m&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;2250&quot; data-original-width=&quot;3737&quot; height=&quot;193&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhOsLhwAwfnijqEMVc7vsJD56-qF9-G7GxyWsh13MEU-bqacvY70H1ZAYcS9VyFUh5HEtN-YQqQNp4DL8RR3sv2Ldc7ylshCW0pU-5LgnH8NboV1S085GkRc1H7IOB5ZUOlll5rYa5lZWSxC0G7UF9fJcOZGVAHWKgKfkP90NPJb_JsJon5Ku-CZADHhB0m&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Bottom side render&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;I will go over more details of the design and will be sharing the Altium design files and bringup progress when the board is back! I am hoping to use this design and framework to provide more structured tutorials on power electronics, building on past articles on this blog.</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/616791476635608122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2025/03/power-testbench-and-upcoming-power.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/616791476635608122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/616791476635608122'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2025/03/power-testbench-and-upcoming-power.html' title='Power Testbench and Upcoming Power Electronics Tutorials'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEgwABHXUBkAelH2yTF34GeQSO9Cd8TTH7ojsQae7mAJnH0tn8HkqzJCBWlFlc7EWLzi08HuZOu3ZJdt4UjRS9X_PRX8_55mgsyA9IJutg7Ep7FwirIlCNPZWRCB-ecikQjzXLPd1h22cBcVEMw10xyFITj59VFMSK59OwcULSIzDcDcwnhcYV4a7mCSwUEe=s72-c" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-2815128950779630847</id><published>2025-01-01T01:15:00.000-08:00</published><updated>2025-01-01T01:30:38.050-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="dial"/><category scheme="http://www.blogger.com/atom/ns#" term="encoder"/><category scheme="http://www.blogger.com/atom/ns#" term="keycap"/><category scheme="http://www.blogger.com/atom/ns#" term="oscilloscope"/><category scheme="http://www.blogger.com/atom/ns#" term="owon"/><category scheme="http://www.blogger.com/atom/ns#" term="sds6062"/><category scheme="http://www.blogger.com/atom/ns#" term="sds6062v"/><title type='text'>Sprucing up an old scope: fixing the dials on the Owon SDS6062V</title><content type='html'>&lt;p&gt;I got the Owon SDS6062V scope back in 2014 when it seemed a great deal compared to brands like Tektronix and much better than cheaper analog or portable digital scopes. These days, I&#39;ve been using the Rigol DS1202 for hobby projects which is a better part, in my opinion. Of course, none of these are as nice as the Keysight MSOX scopes at work.&lt;/p&gt;&lt;p&gt;I&#39;ve demonstrated the Owon scope in previous projects such as&amp;nbsp;&lt;a href=&quot;https://tahmidmc.blogspot.com/2024/07/generating-complementary-pwm-with.html&quot;&gt;Generating complementary PWM with adjustable deadtime for the RP2040&lt;/a&gt; and&amp;nbsp;&lt;a href=&quot;https://tahmidmc.blogspot.com/2015/01/audio-player-using-pic32-microsd-card.html&quot;&gt;Stereo audio player using the PIC32, MCP4822, microSD card and the MDDFS library&lt;/a&gt;&amp;nbsp;(back in 2015!). The dials on the front panel seem to all be &quot;broken&quot;. When turning the dials, the response is erratic. For example, when turning the time division dial clockwise, sometimes the time division goes up, sometimes down, sometimes it jumps all the way down to the minimum or will jump up and back down. The same is true for all the other dials. Searching online revealed that this seems to be a common issue with the scope, with the encoders having worn out with age. Some sources suggested using filter caps on the output of the encoders (dials). However, this didn&#39;t help with mine. So I decided to just replace the encoders themselves.&lt;/p&gt;&lt;p&gt;The instructions for taking the scope apart and getting to the front panel PCB that houses the encoders is very well documented in the service manual. I uploaded a copy of the Owon service manual on Drive:&amp;nbsp;&lt;a href=&quot;https://drive.google.com/file/d/1YcCo0mDuPbWMsR25b2_2ccgDLu6vavSv/view?usp=sharing&quot;&gt;Owon Service Manual (Drive mirror)&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjmLX54EfXQT6ef9RMcRLVaGMS6ry2qDWHwulXmsKiW2wcceETE5cL4wspvmxvoQ9P6UsKujMRVJE-v9f-Ui5TGqiDTWxamqxzcZFmwVsgbQ-W47GmGeQrv-RI9QpNb-_MaY1csqdSKZ6BgJjDkXfZpLRG0ttPuo7IQ-O5w1-QlN_mu9RDYnnFLli7cYwel&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1100&quot; data-original-width=&quot;1500&quot; height=&quot;235&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjmLX54EfXQT6ef9RMcRLVaGMS6ry2qDWHwulXmsKiW2wcceETE5cL4wspvmxvoQ9P6UsKujMRVJE-v9f-Ui5TGqiDTWxamqxzcZFmwVsgbQ-W47GmGeQrv-RI9QpNb-_MaY1csqdSKZ6BgJjDkXfZpLRG0ttPuo7IQ-O5w1-QlN_mu9RDYnnFLli7cYwel&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 1 - Owon SDS-6062V oscilloscope with original dials and caps&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg2Xzn0SIqz5a0TuQHYOIveqQdM_sWMRHDYTvGxt76Vw14NWOOyS6jYXluaoXrFm8CaRcll66K110sgjLfOD2I_RKXFfuquxb4b1UKOJ5k-r0d449LE4EmulVUBxBAQpU1LlGTkzIgbZxvIaIxOWNwl-Hv93pIS1zJLgzuG4TU8JquTKXwHEqcUQj8P3N_5&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;346&quot; data-original-width=&quot;722&quot; height=&quot;153&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg2Xzn0SIqz5a0TuQHYOIveqQdM_sWMRHDYTvGxt76Vw14NWOOyS6jYXluaoXrFm8CaRcll66K110sgjLfOD2I_RKXFfuquxb4b1UKOJ5k-r0d449LE4EmulVUBxBAQpU1LlGTkzIgbZxvIaIxOWNwl-Hv93pIS1zJLgzuG4TU8JquTKXwHEqcUQj8P3N_5&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 2 - Scope with the encoders replaced&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhf4d5q9JoByohl70XHLwKA9GP8V5EN1Zo6bC4-bqBjBGd0-0mXMXIladwPnABrcoYX69CItSemRwePVkgXZ4Jl7T2mdKToIREuznYxGa1TmFhiQT7P8Xt4mYj8B0OYAR_6JvTFqHT5S--mCND2IopBZeM8joIrev7HEW8JKsb3Aq6pK4IQacG6rcE64F21&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;478&quot; data-original-width=&quot;521&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhf4d5q9JoByohl70XHLwKA9GP8V5EN1Zo6bC4-bqBjBGd0-0mXMXIladwPnABrcoYX69CItSemRwePVkgXZ4Jl7T2mdKToIREuznYxGa1TmFhiQT7P8Xt4mYj8B0OYAR_6JvTFqHT5S--mCND2IopBZeM8joIrev7HEW8JKsb3Aq6pK4IQacG6rcE64F21&quot; width=&quot;262&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 3 - The front panel PCB with the encoders soldered&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;After accessing the front panel PCB, I desoldered all the encoders. I could not find part numbers for these encoders and just went ahead and bought a standard 10-pack of encoders (&lt;a href=&quot;https://www.amazon.com/dp/B09KNC1J6H/ref=pe_386300_440135490_TE_simp_item_image&quot;&gt;Amazon link&lt;/a&gt;). Fig. 4 shows that the ordered parts are quite a bit taller than the ones on the scope. However, with the different encoder caps as shown in Fig. 5, the height difference is substantially removed. When I was looking online for which encoders to order, I found several sources suggesting ordering &quot;standard encoders&quot; without part numbers. So my hope here is that if someone is trying to change the encoders on their scope, they have a reference part to order if they&#39;re lost.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjoAhzJE6gndY5M3KiCZhpUtx4korafE2G8vg4VrybCjOHTSscmq9mUQx5GWAYWysXtRwIjLx1gtpN4dd0yu1Z943xmu4fbB5CdG8j2vwAsH3V854a749vEe62vrzTtERGNSq8QMqExAKH_TXOEo1JXyt9LgqbmBfEKLaXMDd1G4FTlY6dHqkibRt_tcOEO&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;454&quot; data-original-width=&quot;550&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjoAhzJE6gndY5M3KiCZhpUtx4korafE2G8vg4VrybCjOHTSscmq9mUQx5GWAYWysXtRwIjLx1gtpN4dd0yu1Z943xmu4fbB5CdG8j2vwAsH3V854a749vEe62vrzTtERGNSq8QMqExAKH_TXOEo1JXyt9LgqbmBfEKLaXMDd1G4FTlY6dHqkibRt_tcOEO&quot; width=&quot;291&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 4 - Encoders for the scope. Left = encoders removed from the scope PCB. Right = encoders ordered from Amazon.&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEir-6gXhph2XiTz521luVijGuOyO07921EKm1io3RSY2bE93aUxFhym_DUW6mQJCWRsdw2_WM_xeuM7J66yAsGCUYCsruaW7X3O_FPnBIWMwfgm5GFDSu6AafgruhbaxzhTgF1v3KQCJ5Bfdlq03M53Afph_loKBgSTDHaNwwe1v1KoMU_QPdyGv9BAuKdh&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;451&quot; data-original-width=&quot;554&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEir-6gXhph2XiTz521luVijGuOyO07921EKm1io3RSY2bE93aUxFhym_DUW6mQJCWRsdw2_WM_xeuM7J66yAsGCUYCsruaW7X3O_FPnBIWMwfgm5GFDSu6AafgruhbaxzhTgF1v3KQCJ5Bfdlq03M53Afph_loKBgSTDHaNwwe1v1KoMU_QPdyGv9BAuKdh&quot; width=&quot;295&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 5 - Encoders with their corresponding caps mounted. Left = encoders removed from the scope PCB. Right = encoders ordered from Amazon.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Once the new encoders are soldered into the panel, the scope dials now worked as expected. The replacement encoders I used all have steps in them. The scope&#39;s horizontal position encoders did not have steps. I didn&#39;t mind this at all and actually quite like the additional tactile feedback.&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;I am also a big fan of the look of the new encoder caps! The spruced up scope is shown in Fig. 2. This was a simple fix, but I wanted to document the service manual and the encoders here for someone else to find useful! This breathes new life into this trusty scope and hopefully it can continue functioning!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here are some fun shots of the interior of the scope!&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrnOIw_U399PdqS-Wdu2m7hTQRp21qDGL3_-XZ5PKCZselNj-oWHgiZHk4w_mBBBERasuDxrpx-E9bT-Htr5BYk0dWaafBPHPMW6MndjCIJexEoxuOkJmS8UJPiB75nbFHYnmvLKg73UutMUdZwopf9Vcy1LM7Z7awwi7zjGKJ9P34qMaTjNBv0xu5ZHWF/s577/pic1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;577&quot; data-original-width=&quot;433&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrnOIw_U399PdqS-Wdu2m7hTQRp21qDGL3_-XZ5PKCZselNj-oWHgiZHk4w_mBBBERasuDxrpx-E9bT-Htr5BYk0dWaafBPHPMW6MndjCIJexEoxuOkJmS8UJPiB75nbFHYnmvLKg73UutMUdZwopf9Vcy1LM7Z7awwi7zjGKJ9P34qMaTjNBv0xu5ZHWF/s320/pic1.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHY55NE5KtmL87CbkaEvPqDriF2HahPWuGvQCbgsb6MhqqNgfolhQvSzapmmn8o2BSQuvY29XwLD3Jdhe6VHOfb0ajRq19qMbWuJvgmX9NXPjrf-jFXCAzIuyrUb_oK5b5qgZZ295Kz1hWFC-tnpHaZh_7HvQIGJ6zzRHEiUAUs4XTv3HyBupLVkO15EBW/s550/pic2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;454&quot; data-original-width=&quot;550&quot; height=&quot;264&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHY55NE5KtmL87CbkaEvPqDriF2HahPWuGvQCbgsb6MhqqNgfolhQvSzapmmn8o2BSQuvY29XwLD3Jdhe6VHOfb0ajRq19qMbWuJvgmX9NXPjrf-jFXCAzIuyrUb_oK5b5qgZZ295Kz1hWFC-tnpHaZh_7HvQIGJ6zzRHEiUAUs4XTv3HyBupLVkO15EBW/s320/pic2.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl7LpkhCZtEtkjXHsBhaCBKzYNZkJTqdAO0FX2nFxPNStMgTLrwW0huGavhlGTjI4TcvnukHUQ9zEs5aLlEU-IaUlTLryU3GH8fhkl2HtrZE0WZaYP0Md85cHv5BNWKJAiZ5FpdwXjpauDDsBqFY1UG__7AxnMpOM7WkxOySmssho7BAQ4v9UqIihaWUCl/s443/pic3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;443&quot; data-original-width=&quot;433&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl7LpkhCZtEtkjXHsBhaCBKzYNZkJTqdAO0FX2nFxPNStMgTLrwW0huGavhlGTjI4TcvnukHUQ9zEs5aLlEU-IaUlTLryU3GH8fhkl2HtrZE0WZaYP0Md85cHv5BNWKJAiZ5FpdwXjpauDDsBqFY1UG__7AxnMpOM7WkxOySmssho7BAQ4v9UqIihaWUCl/s320/pic3.png&quot; width=&quot;313&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWxqJhOz86x5p6HN1PfVNoKJzHIihD8Es0Xel9z0_6smDAsSgXlhlPTpanFQI51TnKmSQSBPJaZpB4xfFdN0-A1f-HrfjIpazBSai8vgHL1h0TX4dFH-s2NPlQSDw3z-JPQzdLzP4qkgsIL0tp3sjvfmgJu-aK7CGujXct4sL_1ce8GGe-P4dDtV26Jm_f/s577/pic4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;577&quot; data-original-width=&quot;433&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWxqJhOz86x5p6HN1PfVNoKJzHIihD8Es0Xel9z0_6smDAsSgXlhlPTpanFQI51TnKmSQSBPJaZpB4xfFdN0-A1f-HrfjIpazBSai8vgHL1h0TX4dFH-s2NPlQSDw3z-JPQzdLzP4qkgsIL0tp3sjvfmgJu-aK7CGujXct4sL_1ce8GGe-P4dDtV26Jm_f/s320/pic4.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3vX3ErSJ71lRzpekSbwjIGvyQCSxqSA1L4HLNaqolORv5lW7bk9bsIe5YWpzUboc7MALTcVIbqzf4eQQBa1mgOx61Hi-6FiV3EKLDFsDoFsxRZsZ3Los2He4sjVikuCNKT4GwjGXA1E4NlkmWR-1Mz7QBFMAGxPsj4d7QSy5sHKkgaFCM1KuzWk59UnDs/s577/pic5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;577&quot; data-original-width=&quot;433&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3vX3ErSJ71lRzpekSbwjIGvyQCSxqSA1L4HLNaqolORv5lW7bk9bsIe5YWpzUboc7MALTcVIbqzf4eQQBa1mgOx61Hi-6FiV3EKLDFsDoFsxRZsZ3Los2He4sjVikuCNKT4GwjGXA1E4NlkmWR-1Mz7QBFMAGxPsj4d7QSy5sHKkgaFCM1KuzWk59UnDs/s320/pic5.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLAW5ObAlqNMJ0As09c5EvZ0TswCYX2VnjzXOPKzjO1YkeVLcZhchlX5TzMwUGLgXueMxndOmGETyhT9xbS453Nhh8wGZQMeUBnoS1kK37zoBW6VLVd0NaK4gBemGvbkoijlLSMHXlS2OGEdcxVOLg-eOlVGhq2T90W1kG-AqsVfZtuCIyn5rra0JY6Q5H/s577/pic6.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;577&quot; data-original-width=&quot;433&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLAW5ObAlqNMJ0As09c5EvZ0TswCYX2VnjzXOPKzjO1YkeVLcZhchlX5TzMwUGLgXueMxndOmGETyhT9xbS453Nhh8wGZQMeUBnoS1kK37zoBW6VLVd0NaK4gBemGvbkoijlLSMHXlS2OGEdcxVOLg-eOlVGhq2T90W1kG-AqsVfZtuCIyn5rra0JY6Q5H/s320/pic6.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/2815128950779630847/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2025/01/sprucing-up-old-scope-fixing-dials-on.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/2815128950779630847'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/2815128950779630847'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2025/01/sprucing-up-old-scope-fixing-dials-on.html' title='Sprucing up an old scope: fixing the dials on the Owon SDS6062V'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEjmLX54EfXQT6ef9RMcRLVaGMS6ry2qDWHwulXmsKiW2wcceETE5cL4wspvmxvoQ9P6UsKujMRVJE-v9f-Ui5TGqiDTWxamqxzcZFmwVsgbQ-W47GmGeQrv-RI9QpNb-_MaY1csqdSKZ6BgJjDkXfZpLRG0ttPuo7IQ-O5w1-QlN_mu9RDYnnFLli7cYwel=s72-c" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-3613728892470780450</id><published>2024-12-31T13:16:00.000-08:00</published><updated>2025-01-07T02:02:18.245-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="30v"/><category scheme="http://www.blogger.com/atom/ns#" term="5a"/><category scheme="http://www.blogger.com/atom/ns#" term="bps305"/><category scheme="http://www.blogger.com/atom/ns#" term="hy3005"/><category scheme="http://www.blogger.com/atom/ns#" term="lavolta"/><category scheme="http://www.blogger.com/atom/ns#" term="lm317"/><category scheme="http://www.blogger.com/atom/ns#" term="power supply"/><category scheme="http://www.blogger.com/atom/ns#" term="transformer"/><title type='text'>Insights from repairing a 30V 5A power supply (BPS-305)</title><content type='html'>&lt;p&gt;When I started working on a project (hopefully more on that soon), I reached out for an old 30V 5A power supply (Lavolta BPS-305). I rotated the voltage dial to try to get to 24V and observed that the voltage would not go past 15V, even though it is rated for 30V. Even though this supply was a few years old, I had not personally used it before. So, it wasn&#39;t clear whether it was a previously-functioning supply that stopped working, or whether it was always broken.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhHIxCPX7HVUN9t2aII7OOO_P-c0uqJSqQnn2gogoAbUK_U_4YNvs6-CwCfl1wZHa2hS8BYP9HKl_sU2b5UcmYWxeuBn6vSP-NlpZTe5aVATZ6Puiy9Mcdm8ugBEXIR09QwA76zSCrSj0UE7y6ip6KcCJCi4sMwFLj7p468Z-xhIoYg1eGcNSH8XU03mJBP&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;887&quot; data-original-width=&quot;1000&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhHIxCPX7HVUN9t2aII7OOO_P-c0uqJSqQnn2gogoAbUK_U_4YNvs6-CwCfl1wZHa2hS8BYP9HKl_sU2b5UcmYWxeuBn6vSP-NlpZTe5aVATZ6Puiy9Mcdm8ugBEXIR09QwA76zSCrSj0UE7y6ip6KcCJCi4sMwFLj7p468Z-xhIoYg1eGcNSH8XU03mJBP&quot; width=&quot;271&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 1 - Lavolta BPS-305 power supply&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Upon some more poking and prodding, I identified that the power supply had several issues:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Output voltage only goes up to about 15V instead of 30V max.&lt;/li&gt;&lt;li&gt;Output voltage is not stable and fluctuates at steady state, appearing unregulated. See video below.&lt;/li&gt;&lt;li&gt;Output voltage flickers when relays switch around ~7V and ~14V and the relays keep flickering unless the voltage is moved far away from the transition points.&lt;/li&gt;&lt;li&gt;Output current measurement (when HI/LO button is pressed down to LO) is off by a factor of 2.&lt;/li&gt;&lt;li&gt;Output current measurement (when HI/LO button is pressed up to HI) displays zero.&lt;/li&gt;&lt;/ol&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/hrSGBCKPYPc&quot; width=&quot;320&quot; youtube-src-id=&quot;hrSGBCKPYPc&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Output voltage unstable at &quot;steady state&quot; - moving between 10.2V to 11.1V with a fixed output load&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Hopeful that I can repair the supply, I opened it up. Noticing a relatively simple one-layer PCB, I set out to find a schematic or other reference for the supply. This is where I realized that many many (low-cost) 30V 5A power supplies are based on the same couple designs. I&#39;ll link to a few useful resources here that I came across during my search:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=YHQo9Ym4fT4&quot;&gt;0174: PS 305 Power Supply 30V 5A Repair by Engineering Secrets&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://aa0cn.neocities.org/ps-305dm&quot;&gt;Repair of a Dr. Meter PS-305DM Power Supply&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.pieraisa.it/php/myHwProjects.html&quot;&gt;#16&amp;nbsp;PS-305D Repairing&lt;/a&gt;&amp;nbsp;and &lt;a href=&quot;https://www.youtube.com/watch?v=GBvFfP52eLw&quot;&gt;corresponding youtube&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=r0mVWG77GyU&quot;&gt;How to repair or design a 3005D Electronics Laboratory Variable Power Supply &amp;amp; formulas for 30V 5A&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;The resources linked above contain many of the schematics for the supplies. I&#39;ve added Drive mirror links to several of these schematics, in addition to the Lavolta PSU manual, here:&amp;nbsp;&lt;a href=&quot;https://drive.google.com/drive/folders/1G1oorJG2v6LsT8LSzIfBv23qdOBqhMGH?usp=drive_link&quot;&gt;https://drive.google.com/drive/folders/1G1oorJG2v6LsT8LSzIfBv23qdOBqhMGH?usp=drive_link&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Instead of going through all my investigations, I&#39;ll highlight a few standouts here.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Broken potentiometers&lt;/h2&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;After lots of investigating, the key offenders were 2 broken potentiometers. Referring to the file&amp;nbsp;&lt;i&gt;PS305D Schematic Main&lt;/i&gt; in the Drive link, these are VR104 and VR102. These are shown below in Fig. 2.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhYm94tcsycJUoZ6kTsHZY69__PvomRsaHLlJxGO1NAec-FgIaNulNKpIbr3ixa1nsFwLhT75cGQ_DeeL9_mChcWXEZQbrFF_P0gfqrQOtjETAhBGX2wWEKavP-B-avRPMwvU9YSHoijHmRcYrViKnzZPFFlF2ES02GnHbaALJC6yVzcBbGI-6U3iLh3CRp&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;590&quot; data-original-width=&quot;924&quot; height=&quot;204&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhYm94tcsycJUoZ6kTsHZY69__PvomRsaHLlJxGO1NAec-FgIaNulNKpIbr3ixa1nsFwLhT75cGQ_DeeL9_mChcWXEZQbrFF_P0gfqrQOtjETAhBGX2wWEKavP-B-avRPMwvU9YSHoijHmRcYrViKnzZPFFlF2ES02GnHbaALJC6yVzcBbGI-6U3iLh3CRp&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 2 - The culprits. VR104 is marked 502 (5kΩ) and VR102 is marked 501 (500Ω). Both parts measure open at component ends.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;VR104 is used for output voltage feedback. Once this part was replaced with a functioning 5kΩ pot, the output voltage was now stable and would go all the way up to 30V. The pot is trimmed until the max output voltage is 30V.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;VR102 sets the max output current when the HI/LO button is released (HI -&amp;gt; 5A current limit). There was no current limit being set in this setting with the faulty part. Since I did not have a 500Ω pot on hand, I replaced VR102 with a 5kΩ pot in parallel with a 470Ω resistor. This allows tuning the resistance as shown in Fig. 3. Fig. 4 shows the parallel 470Ω resistor soldered on the back side of the board. Once these parts were provisioned, the 5kΩ pot was trimmed until the max output current was set to 5A. The red dot in Fig. 3 indicates the final trimmed resistance.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEio4DgRD0oZA7nz0Z30eUWkyBLAXpi1RSeM1awb8QhL-Dkikom2-4OLAeVHYA5vilZRUN78rUOvA5YpYphjUFMnKo76Z0y7Uj7gMNlUGfwYfkpiZ35sWdDoTTXQacK4cSeGuha1x1iA7H02-yPWl6Oal_DtMaqTTJVDvKn3WIUkgSRTr5x1qH6ntFIvthKe&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1645&quot; data-original-width=&quot;2040&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEio4DgRD0oZA7nz0Z30eUWkyBLAXpi1RSeM1awb8QhL-Dkikom2-4OLAeVHYA5vilZRUN78rUOvA5YpYphjUFMnKo76Z0y7Uj7gMNlUGfwYfkpiZ35sWdDoTTXQacK4cSeGuha1x1iA7H02-yPWl6Oal_DtMaqTTJVDvKn3WIUkgSRTr5x1qH6ntFIvthKe&quot; width=&quot;298&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;Fig. 3 - combined resistance of 5kΩ pot in parallel with 470Ω resistance as the pot is trimmed.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj6MIzf15S3XjyWEeAUCpT2vNqZ5a55N3_Rl6-e7MCO76g-mHPuQ3m9gQLyQTqQXoPHRX1N2kPKKKpFS7wl8BeqHROVo3Zt93Uz_Lam9ICAwG6DIKqSALKwkqgaTdMlgjM2UQWGJpYpmFOrAY7tjS_seiUVtjQO4gqzNDl-NqHSISqtUz5__EsWVIj9sMOy&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1026&quot; data-original-width=&quot;1036&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj6MIzf15S3XjyWEeAUCpT2vNqZ5a55N3_Rl6-e7MCO76g-mHPuQ3m9gQLyQTqQXoPHRX1N2kPKKKpFS7wl8BeqHROVo3Zt93Uz_Lam9ICAwG6DIKqSALKwkqgaTdMlgjM2UQWGJpYpmFOrAY7tjS_seiUVtjQO4gqzNDl-NqHSISqtUz5__EsWVIj9sMOy&quot; width=&quot;242&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 4 - soldered 470Ω resistor in parallel with VR102&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhqDy3aNgw7XgQmvMX-LuVoH14PaXdB3UqCkETZBEjlJfupvSsHMGF0g5bEHq-DwfAqhB2eCYAX40kGaeytViFL_5LLnJULvxzE63QAJ6n-HX4auWxVvYtOzT35cPYSj3UUzLaGsW4jCM6eGlrhkcoogJpidQ8gHttEr2_1zWmgvYuGmziAhq0rBuFNate2&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;942&quot; data-original-width=&quot;1166&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhqDy3aNgw7XgQmvMX-LuVoH14PaXdB3UqCkETZBEjlJfupvSsHMGF0g5bEHq-DwfAqhB2eCYAX40kGaeytViFL_5LLnJULvxzE63QAJ6n-HX4auWxVvYtOzT35cPYSj3UUzLaGsW4jCM6eGlrhkcoogJpidQ8gHttEr2_1zWmgvYuGmziAhq0rBuFNate2&quot; width=&quot;297&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;FIg. 5 - the two blue potentiometers replace the broken ones in Fig. 2&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Tuning the current display&lt;/h2&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEizR4KifAkANS9hn_6BBFsvjY5560RrPetuz1ZRK06mAG6onxaV7npaRzGJj4FUlhE4t-SVcMO_6n5wYtoFRx4Fzp1MA9WZDWdLaKc4KRtbXdZXOMT6zth19LiBcP0H03Vami1LTCG2t1mBgKeJ_9i6LBL58TbohyInNX4vSAFkJLOJ-9kIs8XWq1baAAO_&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;874&quot; data-original-width=&quot;1520&quot; height=&quot;184&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEizR4KifAkANS9hn_6BBFsvjY5560RrPetuz1ZRK06mAG6onxaV7npaRzGJj4FUlhE4t-SVcMO_6n5wYtoFRx4Fzp1MA9WZDWdLaKc4KRtbXdZXOMT6zth19LiBcP0H03Vami1LTCG2t1mBgKeJ_9i6LBL58TbohyInNX4vSAFkJLOJ-9kIs8XWq1baAAO_&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 6 - Output current reading 6.89A when the real measured value is 5A&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh520iHr2F91hEKD2Wjk0Up6mhGXz3ENN_ySfYkNYZJGtSz4T6jSWuL5nQ7YXwVued6JPNFk10zx92w8F73-y-7PwNh8NKGbrhsPARyJ-4g1nV0WOHvAFewG48gAym8tVYy1yUxfzo8tOtLmRYyIkQcVMlCLAgf4SdhnVaBHj-xH5xdLrB9ORJ2Z9Yp0Gm4/s928/dmm.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;616&quot; data-original-width=&quot;928&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh520iHr2F91hEKD2Wjk0Up6mhGXz3ENN_ySfYkNYZJGtSz4T6jSWuL5nQ7YXwVued6JPNFk10zx92w8F73-y-7PwNh8NKGbrhsPARyJ-4g1nV0WOHvAFewG48gAym8tVYy1yUxfzo8tOtLmRYyIkQcVMlCLAgf4SdhnVaBHj-xH5xdLrB9ORJ2Z9Yp0Gm4/s320/dmm.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 7 - DMM on the PSU; the trim pots are the blue components near each chip. Left display is for current and the corresponding trimpot is VR211. Right display is for voltage and the corresponding trimpot is VR201.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;When the HI/LO button is pushed down to the LO position, the PSU&#39;s output current limit is set to 2.5A tuned by VR101. When the HI/LO button is at the HI position, the output limit is set by VR102 (and the parallel 470Ω resistor) as described previously. However, there was a fair bit of error on this reading, as shown in Fig. 6. By adjusting VR305 (see&amp;nbsp;&lt;i&gt;PS305D Schematic Controls&lt;/i&gt; in the Drive link) in conjunction with the reference voltage set by the blue trimpot VR211 (see &lt;i&gt;PS305D Schematic Display&lt;/i&gt; in the Drive link) in Fig. 7, the output current can be tuned. Since VR211 affects the reference voltage for the current meter, adjusting it affects both the HI and LO current readings. The procedure then was to set the switch to HI and then tune VR211; once that is corrected, switch to LO and then tune VR305.&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;Relay-selectable transformer secondary winding&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqw_yE9BcSGCi-e3h6MxaRDaQyKmqkYqBM72SdCTm5FCiXAPx87vE9jOv9Jqb2IXSpr3O8UCJatn9gTGnQ7771-N1GR_HyJD87ZjwxEK5QBKW4nfkORBVC9v50EjiwQLYgFEv-hacbJ4QfVHbt0yOoNYBAeJekFrVRrOv6hwt5pM_OxiRPVxe5ITHm09nU/s1654/secondary_relay.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1158&quot; data-original-width=&quot;1654&quot; height=&quot;224&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqw_yE9BcSGCi-e3h6MxaRDaQyKmqkYqBM72SdCTm5FCiXAPx87vE9jOv9Jqb2IXSpr3O8UCJatn9gTGnQ7771-N1GR_HyJD87ZjwxEK5QBKW4nfkORBVC9v50EjiwQLYgFEv-hacbJ4QfVHbt0yOoNYBAeJekFrVRrOv6hwt5pM_OxiRPVxe5ITHm09nU/s320/secondary_relay.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 8 - secondary selection scheme with relay&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Because the regulation stage in the power supply is based on a linear regulator, the difference between the input and output power is dissipated as heat. Since the power supply has a large selectable output range, this would result in very high power dissipation in the regulator at lower input voltages. To overcome this drawback and reduce the power dissipation, the power supply utilizes a selector circuit on the secondary as shown in Fig. 8.&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;As an example, let&#39;s consider that the output power is desired to be 3.3V. Suppose the input voltage post-rectifier is 40V (which is the case between S3-S0 for the BPS-305). At an output current of 3A, the power dissipated in the regulator would be roughly: Pout-Pin = Vout*Iout - Vin*Iin ~ (Vout-Vin)*Iout = 110.1W.&amp;nbsp; All this for only 13.2W of output power. At lower output voltages and higher output currents, this gets even worse!&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;By using the scheme shown in Fig. 8, the voltage at the input of the regulator is selected based on the desired output voltage to reduce power dissipation. With the example above, now suppose that for 3.3V, the input to the regulator is 14.8V, the power dissipation is reduced to 34.5W now! That&#39;s 75W less than the previous example!&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;For my unit, the voltage bins transitions happen for output voltages 8V, 15V, 21V and 30V. This is a good design decision rather than having a fixed 40V input for the regulator.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;/div&gt;&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;Output testing&lt;/h2&gt;&lt;/div&gt;For testing the output, different resistor combinations were used as the load. In addition, a constant current circuit was used even as the output voltage is varied. A simple circuit can be designed using the jellybean LM317 part. The &lt;a href=&quot;https://www.ti.com/lit/ds/symlink/lm317.pdf&quot;&gt;datasheet&lt;/a&gt; shows an example circuit in Section 9.3.3 (Precision Current-Limiter Circuit).&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNR_O3GYBXV7_loZwf7C6bCLhwg-3qHDlJRuqfHMcYdZmexrzx0LHpgaWllGOi6bajAclLekSIzwTi32oxF8Im1EU264jNOcJUfjqDqItTD-94lsg73CjZl5n_P3jCQ4PBwu-nBfbIV8bRiCJfNqH753wqQJwgK4NWISmWmgkJjkLyvAw1VRHNgt3mNCZ3/s900/lm317.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;251&quot; data-original-width=&quot;900&quot; height=&quot;111&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNR_O3GYBXV7_loZwf7C6bCLhwg-3qHDlJRuqfHMcYdZmexrzx0LHpgaWllGOi6bajAclLekSIzwTi32oxF8Im1EU264jNOcJUfjqDqItTD-94lsg73CjZl5n_P3jCQ4PBwu-nBfbIV8bRiCJfNqH753wqQJwgK4NWISmWmgkJjkLyvAw1VRHNgt3mNCZ3/w400-h111/lm317.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Fig. 9 - constant current circuit using LM317&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;The output (ADJUST pin) is tied to GND for testing. Using R1 = 4.7Ω provides a ~250mA constant current load. Similarly, R1 is swapped out for lower values for higher currents. It is important to have a heatsink mounted on the LM317, especially at higher voltages. This constant current value was also used to validate the output current display across PSU output voltages.&lt;/div&gt;
		&lt;h2 style=&quot;text-align: left;&quot;&gt;Other observations&lt;/h2&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;The logic GND for the electronics are shorted to the positive output instead of the negative output. Even though the circuits in the PSU closely reflect those of&amp;nbsp;&lt;i&gt;PS305D Schematic Main/Display/Controls&lt;/i&gt;, this grounding scheme is reflected in&amp;nbsp;&lt;i&gt;hy_3005_dc_power_supply.&lt;/i&gt;&lt;/li&gt;&lt;li&gt;Many of these 30V 5A power supplies seem to be based on a couple base designs with slight tweaks in implementation.&lt;/li&gt;&lt;li&gt;The build quality appears shoddy. Many components were haphazardly soldered - many caps weren&#39;t fully seated. The fan wires run adjacent to (and touch) the (potentially very hot) heatsink for the transistors. However, none of these appear to impact functionality, at least in the short term.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/3613728892470780450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2024/12/insights-from-repairing-30v-5a-power.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/3613728892470780450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/3613728892470780450'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2024/12/insights-from-repairing-30v-5a-power.html' title='Insights from repairing a 30V 5A power supply (BPS-305)'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEhHIxCPX7HVUN9t2aII7OOO_P-c0uqJSqQnn2gogoAbUK_U_4YNvs6-CwCfl1wZHa2hS8BYP9HKl_sU2b5UcmYWxeuBn6vSP-NlpZTe5aVATZ6Puiy9Mcdm8ugBEXIR09QwA76zSCrSj0UE7y6ip6KcCJCi4sMwFLj7p468Z-xhIoYg1eGcNSH8XU03mJBP=s72-c" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-1263189371667291499</id><published>2024-07-10T04:37:00.000-07:00</published><updated>2024-07-10T13:54:20.537-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="amplifier"/><category scheme="http://www.blogger.com/atom/ns#" term="current control"/><category scheme="http://www.blogger.com/atom/ns#" term="current sense"/><category scheme="http://www.blogger.com/atom/ns#" term="inverter"/><category scheme="http://www.blogger.com/atom/ns#" term="lm358"/><category scheme="http://www.blogger.com/atom/ns#" term="mppt"/><category scheme="http://www.blogger.com/atom/ns#" term="opamp"/><category scheme="http://www.blogger.com/atom/ns#" term="pcm"/><category scheme="http://www.blogger.com/atom/ns#" term="solar"/><category scheme="http://www.blogger.com/atom/ns#" term="tl081"/><category scheme="http://www.blogger.com/atom/ns#" term="tl082"/><title type='text'>A low-cost high-side current sense amplifier: design considering non-idealities</title><content type='html'>&lt;div style=&quot;text-align: left;&quot;&gt;Current-sensing is commonly used in power electronics and embedded systems, both for system monitoring, as well as to take decisions. Examples of common use cases for the latter are:&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Monitoring inductor current for current-mode control in power converters&lt;/li&gt;&lt;li&gt;Monitoring converter current for overcurrent protection&lt;/li&gt;&lt;li&gt;Reading battery charge current to inform the charging process&lt;/li&gt;&lt;li&gt;Reading output current to compute output power to inform how to proceed in an MPPT charge controller&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;Use cases 1 and 2 require high-speed current measurements since they need to operate at either the converter&#39;s control frequency or based on a desired response time. Use cases 3 and 4, however, only require measuring &quot;DC&quot; current and so don&#39;t require high-speed current sense. The high-speed aspect ties to notions of slew rate and bandwidth for the amplifier. Other non-idealities, which I will describe here, affect even the DC behavior of the amplifier.&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;High-Side vs Low-Side Current Sensing&lt;/h2&gt;&lt;p&gt;&lt;a href=&quot;https://www.allaboutcircuits.com/technical-articles/resistive-current-sensing-low-side-versus-high-side-sensing/&quot;&gt;This article&lt;/a&gt; gives a good overview of the differences between high-side and low-side current sensing. Shown below are what they look like.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj77uX08_TlFbc_D-6og6zrtk3AUtCx5N0ne064D4rGxil1AqCJa4R4SXSxC4rjg6qMgX9oncaZefEd0bHTaf8Ocb4q_htU_Nb6jfBrKW_CEZis-U4rhaZl-O_u_BlaQyeowAxYKo36fjo5L6IBo1y8oldVI5V65y604nCd-EDsoA8EHty6rlHwUFPa2HSY&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;526&quot; data-original-width=&quot;1744&quot; height=&quot;121&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj77uX08_TlFbc_D-6og6zrtk3AUtCx5N0ne064D4rGxil1AqCJa4R4SXSxC4rjg6qMgX9oncaZefEd0bHTaf8Ocb4q_htU_Nb6jfBrKW_CEZis-U4rhaZl-O_u_BlaQyeowAxYKo36fjo5L6IBo1y8oldVI5V65y604nCd-EDsoA8EHty6rlHwUFPa2HSY=w400-h121&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;(a): High-side current sense&lt;br /&gt;(b): Low-side current sense&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;clear: both; text-align: left;&quot;&gt;Sense Resistor Selection&lt;/h3&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;In both cases, the sense element is the series resistor Rs. By monitoring the voltage drop across Rs, you can compute the corresponding current from Ohm&#39;s Law: V=IR.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Tradeoffs for resistor selection include considerations for power and minimum sense voltage.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Power dissipation in the resistor is given by I&lt;sub&gt;rms&lt;/sub&gt;&lt;sup&gt;2&lt;/sup&gt;R&lt;sub&gt;s&lt;/sub&gt;. A larger resistor will correspond to larger power dissipation for the same current.&lt;/li&gt;&lt;li&gt;Using a small resistor corresponds to a smaller sense voltage. When using a small sense resistor, you will use a current sense amplifier (CSA) to amplify the small sensed voltage to feed the corresponding circuit, which is often an ADC. A smaller resistor will correspond to requiring a larger gain in the amplifier or a greater ADC resolution.&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;High-side vs low-side&lt;/h3&gt;&lt;div&gt;High-side current sense refers to placing the sense resistor in the &quot;power&quot; side without disrupting the power return or ground, enabling&amp;nbsp; the use of a common ground overall circuit scheme. Low-side current sense refers to placing the sense resistor in the &quot;ground&quot; side, thereby disrupting the power return/ground. If common-ground is not desired for your application, you can use the low-side sense scheme.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In this article, we&#39;re looking at applications where you prefer high-side current sense!&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;h2&gt;Non-idealities Considerations and Circuit Design&lt;/h2&gt;&lt;div&gt;In this application, I&#39;m focusing on using a standard ultra-cheap op-amp instead of a dedicated current sense amplifier (such as &lt;a href=&quot;https://www.ti.com/lit/ds/symlink/ina180.pdf&quot;&gt;INA180&lt;/a&gt;).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The op-amp I&#39;m picking for this is the TL082 which I have on hand. The amplifier design is based on a standard differential amplifier configuration as shown &lt;a href=&quot;https://www.electronics-tutorials.ws/opamp/opamp_5.html&quot;&gt;in this article&lt;/a&gt;. The datasheet for the TL082 can be found on the TI website &lt;a href=&quot;https://www.ti.com/lit/ds/symlink/tl082-n.pdf&quot;&gt;[1]&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;https://www.ti.com/lit/ds/symlink/tl082.pdf&quot;&gt;[2]&lt;/a&gt;. &lt;a href=&quot;https://www.lcsc.com/products/Operational-Amplifier_516.html?keyword=tl082&quot;&gt;LCSC&lt;/a&gt;&amp;nbsp;shows the ultra-low cost of &amp;lt; $0.20 at volume!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The schematic for the current-sense amplifier (CSA) is shown below.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjBf8TtozBldzwwfQiC136lCuH-jZNrhOENxGgxic-6jKsKnfAZXMusqSVQDIl8Axjr8hppkN7YMIXQb47X197zrkBjqHBiomX7Nz_O8inv4ltFDPTt3j-zl6naov7bogl9GFvkScWaOXu8jMYthygkfjn_rv4vRTmfBwB-MIpmkBvcXm_1nSn45IFiLUWr&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1188&quot; data-original-width=&quot;1634&quot; height=&quot;466&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjBf8TtozBldzwwfQiC136lCuH-jZNrhOENxGgxic-6jKsKnfAZXMusqSVQDIl8Axjr8hppkN7YMIXQb47X197zrkBjqHBiomX7Nz_O8inv4ltFDPTt3j-zl6naov7bogl9GFvkScWaOXu8jMYthygkfjn_rv4vRTmfBwB-MIpmkBvcXm_1nSn45IFiLUWr=w640-h466&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;CSA implementation circuit (click to enlarge schematic)&lt;br /&gt;R1=R2=2.2k&lt;span style=&quot;text-align: left;&quot;&gt;Ω, R3=R4=5.6kΩ, Rs=0.5Ω, C1=C2=4.7uF, C3=0.1uF&lt;br /&gt;VSNS+ = 12V&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;i style=&quot;text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDKU28KioI0FhWKGJr6ylrt6GfGI1plIHLNHrbciOCW6ehTD0TBQgQPayHoc5ATW8Zu4OvcQVS6V9whnb1MBMdTabYirGSx9OCvP7kQazHXcAUbJaP6ncSdfEQ0uoK-mgzBeNLrevyNB3PkHVfJ0vq6N2CSlH22r9VqfSe1avf_0tItJ3tMWPD5JNWLtzW/s434/vout.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;74&quot; data-original-width=&quot;434&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDKU28KioI0FhWKGJr6ylrt6GfGI1plIHLNHrbciOCW6ehTD0TBQgQPayHoc5ATW8Zu4OvcQVS6V9whnb1MBMdTabYirGSx9OCvP7kQazHXcAUbJaP6ncSdfEQ0uoK-mgzBeNLrevyNB3PkHVfJ0vq6N2CSlH22r9VqfSe1avf_0tItJ3tMWPD5JNWLtzW/s16000/vout.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;There are 3 parts to the output to consider:&lt;/div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;VREF biases the output to 5V. Errors in the 5V reference will propagate to the output.&lt;/li&gt;&lt;li&gt;The diffamp gain is given by R3/R1 assuming R1=R2 and R3=R4. The input to the diffamp is given by the voltage across the sense resistor, which is the product of the current through it and its resistance.&lt;/li&gt;&lt;li&gt;The slope of the output voltage against current is negative due to the diffamp having negative gain. This is by design. See below.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We need to consider the amplifier non-idealities when designing the part. The ones we are considering, along with their impacts is shown below.&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Input offset voltage&lt;/li&gt;&lt;ul&gt;&lt;li&gt;This is a mismatch in the input voltage of the op-amp, due to the input-side design of the op-amp itself. This gets amplified and shows up as an error on the output. The TL082 is specced at 5mV typically. With our amplifier&#39;s gain of 5.6/2.2=2.54, this means that this offset shows up at the output as ~12.7mV. Given that our system&#39;s current gain magnitude is 1.27V/A, this corresponds to a 10mA error in current reading.&lt;/li&gt;&lt;li&gt;Note that the offset can be positive or negative.&lt;/li&gt;&lt;li&gt;Additionally, the offset varies over part tolerances and temperature, going up to as much as 20mV, which will correspond to closer to 40mA of error.&lt;/li&gt;&lt;li&gt;Whether this is a problem or not depends on your application and desired current sense accuracy. You can perform an offset calibration to try to get rid of the steady-state error and only have to worry about the smaller temperature-dependent offset error. Alternately, you can use an opamp such as the TL081 which has additional pins to allow for offset nulling.&lt;/li&gt;&lt;li&gt;Better opamps with lower offset can be used if the offset is an issue and cannot be solved by calibration.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Input bias and offset current&lt;/li&gt;&lt;ul&gt;&lt;li&gt;A large input bias current will correspond to voltages dropped across R1 and R2, which will correspond to errors in the sensed voltage. The TL082 has bias currents in the 50pA-8nA range. Since this shows up on both inputs on this amplifier, the impact will depend on the mismatch between the input resistors. This will not be an issue in this particular application. In a low-side current-sense amplifier, the bias will show up differentially since one side will likely be grounded, so you will need to be more careful there.&lt;/li&gt;&lt;li&gt;A large input offset current will correspond to mismatch in this voltage dropped across the input resistors, which will get amplified and show up as an error on the output. The TL082 has an input offset current spec between 25pA-4nA. The impact of this is the same as for the input offset voltage. Given that the input offset voltage spec is worse than this corresponding offset, this can be ignored for this application.&lt;/li&gt;&lt;li&gt;The design will tend to get more sensitive to bias/offset current if you use larger input resistors, so you should be careful about that.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Input common-mode voltage range&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Rail-to-rail opamps allow the input voltages to go as high as the supply voltage and as low as the supply return. However, the TL082 is not a rail-to-rail opamp, so you need to be careful about making sure that the input voltage is within the desired spec. The datasheet outlines that the input voltage can go as high as the supply rail but can only go as low as 4V above supply return. That means that in our single-rail application, the input voltage cannot go below 4V.&lt;/li&gt;&lt;li&gt;Note that this limit also means that you should not use the TL082 to buffer voltages below 4V!&lt;/li&gt;&lt;li&gt;With the 5.6k and 2.2k resistors, as well as the 5V VREF, this is not a concern in our application! However, this is something to keep in mind!&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Output voltage range&lt;/li&gt;&lt;ul&gt;&lt;li&gt;You can notice that I flipped the + and - inputs on the op-amp relative to a non-inverting configuration. This gives negative gain, but why did I do this? By using VREF=5V, this then means that as current goes up, the output voltage will go down but will nominally be 5V. If I used VREF=0V and used a non-inverting configuration, that would result in the desired 0A output to be 0V. However, the TL082 cannot drive its output to within 200mV of the supply rail or return (or even worse if you have too low an output resistance!).&lt;/li&gt;&lt;li&gt;This means that if the output sits at 200mV with no input, we cannot resolve currents below 158mA. However, if we sit at 5V, we don&#39;t have this issue since 5V is far out from either supply rail or GND!&lt;/li&gt;&lt;li&gt;With a large enough current, the output still can&#39;t swing low enough, so the max current we can resolve is about (5V-0.2V)/1.27[V/A]=3.8A. Note that this would result in a large power in the sense resistor, so this is another constraint to consider!&lt;/li&gt;&lt;/ul&gt;&lt;/ol&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Some additional considerations:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;VSNS+ is bounded between 4V and 14.75V. The lower bound maintains the op-amp&#39;s input common mode voltage range. The upper bound is given by the op-amp&#39;s supply voltage (=12V here). VSNS+ can go higher than 12V as long as the input to the op-amp pins is maintained to be at most 12V. The op-amp voltage at its non-inverting input is given by the equation below. With the circuit components implemented, this sets the upper bound of VSNS+ to 14.75V.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj3QoQy46mQDxiCEDGbGa74s1MWJGKa2QzUcy7nWH6Wzd7uW2js8_mxdjp0BBDWdZqxSNhydkvSadsISNb2XIRkpglx7d-IB8jmiyTL2CVIe4MPHNx0m_M1oORMMRjR7S5yJdoZDq_19ZqGHV1_iWmUzTHOiLh1PLWbJ5IrpNWGeYv_UDNetnmBOJyx8mNd&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;120&quot; data-original-width=&quot;588&quot; height=&quot;65&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj3QoQy46mQDxiCEDGbGa74s1MWJGKa2QzUcy7nWH6Wzd7uW2js8_mxdjp0BBDWdZqxSNhydkvSadsISNb2XIRkpglx7d-IB8jmiyTL2CVIe4MPHNx0m_M1oORMMRjR7S5yJdoZDq_19ZqGHV1_iWmUzTHOiLh1PLWbJ5IrpNWGeYv_UDNetnmBOJyx8mNd&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Errors in the reference voltage VREF (=5V here) will propagate to the output. These can be accounted for with an initial calibration step. For best performance, use a voltage ref chip such as the&amp;nbsp;&lt;a href=&quot;https://www.ti.com/lit/ds/symlink/lm4040.pdf&quot;&gt;LM4040&lt;/a&gt;. This will give better accuracy for the voltage reference.&lt;/li&gt;&lt;li&gt;You can set the VREF to a higher voltage and increase the gain.&lt;/li&gt;&lt;li&gt;You can use a voltage divider at the output to rescale the output to a lower range.&lt;/li&gt;&lt;li&gt;You should add a low-pass &lt;a href=&quot;https://www.analog.com/en/resources/technical-articles/guide-to-antialiasing-filter-basics.html&quot;&gt;anti-aliasing filter&lt;/a&gt; between the current-sense amplifier&#39;s output and the next-stage ADC.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Measurements&lt;/h2&gt;&lt;div&gt;With steady state currents, the following output voltages were measured.&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;0.33A : 4.70V measured vs 4.58V expected : +2.6% error&lt;/li&gt;&lt;li&gt;0.94A : 3.73V measured vs 3.81V expected : -2.0% error&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The input offset contributes output error - with no input, you can measure the output and find the offset. The component tolerances also contribute additional error.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For the purposes of this demonstrative application, this is deemed sufficient! In a wide range of applications, this could also be sufficient, especially in cases where the application is very cost-sensitive! I wanted to share some of the non-ideality considerations through this application and would love to hear if this has helped you understand them!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/1263189371667291499/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2024/07/a-low-cost-high-side-current-sense.html#comment-form' title='16 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/1263189371667291499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/1263189371667291499'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2024/07/a-low-cost-high-side-current-sense.html' title='A low-cost high-side current sense amplifier: design considering non-idealities'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEj77uX08_TlFbc_D-6og6zrtk3AUtCx5N0ne064D4rGxil1AqCJa4R4SXSxC4rjg6qMgX9oncaZefEd0bHTaf8Ocb4q_htU_Nb6jfBrKW_CEZis-U4rhaZl-O_u_BlaQyeowAxYKo36fjo5L6IBo1y8oldVI5V65y604nCd-EDsoA8EHty6rlHwUFPa2HSY=s72-w400-h121-c" height="72" width="72"/><thr:total>16</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-5453513681641699740</id><published>2024-07-03T04:55:00.000-07:00</published><updated>2024-07-04T01:45:48.166-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="buck"/><category scheme="http://www.blogger.com/atom/ns#" term="complementary"/><category scheme="http://www.blogger.com/atom/ns#" term="deadtime"/><category scheme="http://www.blogger.com/atom/ns#" term="gate drive"/><category scheme="http://www.blogger.com/atom/ns#" term="gate driver"/><category scheme="http://www.blogger.com/atom/ns#" term="mppt"/><category scheme="http://www.blogger.com/atom/ns#" term="pi"/><category scheme="http://www.blogger.com/atom/ns#" term="pico"/><category scheme="http://www.blogger.com/atom/ns#" term="PWM"/><category scheme="http://www.blogger.com/atom/ns#" term="raspberry"/><category scheme="http://www.blogger.com/atom/ns#" term="rp2040"/><category scheme="http://www.blogger.com/atom/ns#" term="synchronous buck"/><title type='text'>Generating complementary PWM with adjustable deadtime for the RP2040</title><content type='html'>&lt;p&gt;I have previously discussed the benefits of using the Raspberry Pi Pico, leveraging the easy-to-program Micropython along with the capable hardware peripherals:&amp;nbsp;&lt;a href=&quot;https://tahmidmc.blogspot.com/2023/08/2023-updates-phd-pi-pico.html&quot;&gt;&lt;i&gt;2023 Updates: PhD; Pi Pico&lt;/i&gt;&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href=&quot;https://tahmidmc.blogspot.com/2024/01/quick-and-dirty-pic16f72-programmer.html&quot;&gt;&lt;i&gt;Quick and dirty PIC16F72 programmer with the Pico&lt;/i&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Several articles in the blog have previously described applications of PWM in embedded systems, such as&amp;nbsp;&lt;a href=&quot;https://tahmidmc.blogspot.com/2015/01/audio-player-using-pic32-microsd-card.html&quot;&gt;&lt;i&gt;Stereo audio player using the PIC32, MCP4822, microSD card and the MDDFS library&lt;/i&gt;&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;https://tahmidmc.blogspot.com/2012/11/dc-motor-control-with-pic16f877a.html&quot;&gt;&lt;i&gt;DC motor control with PIC16F877A - Practical example of PIC PWM&lt;/i&gt;&lt;/a&gt;&amp;nbsp;and &lt;a href=&quot;https://tahmidmc.blogspot.com/2012/10/generation-of-sine-wave-using-spwm-in_10.html&quot;&gt;&lt;i&gt;Generation of sine wave using SPWM in PIC16F684&lt;/i&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhd2ieBXP7ncLG3Kf7Nz6zPOzBuvZALWG2JJ1V6gPiZty33-jB5t7oS-uE7XlbqqISYNmcpb7R1FhMA3TlltNe94MwIpWn223aBor43ZC9OJMyhxP_3zS4ibpbsum9yLiEe9b2Rc7ulcCLKypc7FlA9GnVRjR7TnPbUY5aDOl6LS_-Nb2wtDEOUO9uMfPED&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;600&quot; data-original-width=&quot;800&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhd2ieBXP7ncLG3Kf7Nz6zPOzBuvZALWG2JJ1V6gPiZty33-jB5t7oS-uE7XlbqqISYNmcpb7R1FhMA3TlltNe94MwIpWn223aBor43ZC9OJMyhxP_3zS4ibpbsum9yLiEe9b2Rc7ulcCLKypc7FlA9GnVRjR7TnPbUY5aDOl6LS_-Nb2wtDEOUO9uMfPED&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;Complementary PWM signals with 500ns deadtime&lt;/p&gt;&lt;p&gt;The underlying RP2040 in the Pi Pico provides an easy-to-use and still powerful and flexible set of PWM peripherals that can enable a wide range of applications. A common requirement in power electronics is the generation of complementary PWM signals. For example, the complementary PWM signals are used in a synchronous buck converter, shown below, to drive the switches S1 and S2.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgAnPaYydRP30rYLCe1PBeIAJS6TBj_cJDC82qlCnv8ZrwXQgEeh4Bg3AM8UruJ4XPn3hVd8P6qraT0q1Mx6vXJ-KRz21OytXW-PU9-a_VgqqLdnn_gYXWlgJED-rOqAJQloZZdl894VRpVFmceIKqPNt-cDFU9kI6rC5SWUPvJL8AAI-Hb7q7lp0TmqdHv&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;143&quot; data-original-width=&quot;300&quot; height=&quot;153&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgAnPaYydRP30rYLCe1PBeIAJS6TBj_cJDC82qlCnv8ZrwXQgEeh4Bg3AM8UruJ4XPn3hVd8P6qraT0q1Mx6vXJ-KRz21OytXW-PU9-a_VgqqLdnn_gYXWlgJED-rOqAJQloZZdl894VRpVFmceIKqPNt-cDFU9kI6rC5SWUPvJL8AAI-Hb7q7lp0TmqdHv&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;b&gt;Synchronous Buck Converter&lt;/b&gt;&lt;br /&gt;Image source:&amp;nbsp;https://commons.wikimedia.org/wiki/File:300px-Synch_buck.PNG&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;To prevent shoot-through, a deadtime is employed. Shoot-through is the event when both S1 and S2 are turned on, causing a large current through them due to shorting across the supply voltage. Even if the generated PWM signals are non-overlapping (ie S1 and S2 are never turned on together), delays in the circuitry - through the gate drivers and the power switches themselves - can still result in shoot-through conditions. In a severe case, the shoot-through can cause damage to the switches, blowing them out. In a more moderate case, small overlap times can result in reduced efficiency due to wasted power, but not necessarily damage to the switches. To combat this issue, a deadtime is inserted between the S1 and S2 driving signals. This is an amount of time when both switch control signals are zero allowing for system transients to settle out. How large it should be depends on the circuit parameters and behavior.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In many cases, gate drivers can have built-in features to insert dead-times, such as the &lt;a href=&quot;https://www.ti.com/lit/ds/symlink/lm5106.pdf&quot;&gt;LM5106&lt;/a&gt;. However, the ability to generate this in the microcontroller itself gives greater flexibility in the selection of gate driver. Further, it allows tuning the time easily in software rather than needing to change hardware components to change deadtimes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Fortunately, the Pi Pico makes it fairly straightforward to do this!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The details of the PWM peripheral are outlined in the &lt;a href=&quot;https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf&quot;&gt;RP2040 datasheet&lt;/a&gt; section 4.5. You can find the code sample here:&amp;nbsp;&lt;a href=&quot;https://github.com/SyedTahmidMahbub/comppwm_rp2040&quot;&gt;https://github.com/SyedTahmidMahbub/comppwm_rp2040&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The corresponding source code is copied below for convenience:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;script src=&quot;https://gist.github.com/SyedTahmidMahbub/877538df2843ec5d4bf3ce5b8d730299.js&quot;&gt;&lt;/script&gt;&lt;/div&gt;&lt;div&gt;The RP2040 has 8x PWM slices, each with 2 channels. The complementary PWM waveforms are produced on these 2 channels (A and B) on a given slice. The slice to GPIO mapping is shown below.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLhZh__vyjrMGld4nsbb1drHDk9AOBUHGt-6wzngHglHu21Ei1f1x2XtSt0Uv2zYg9JAGjTpy9-LXZPilCDTHpZlvG3Rdcz8kyN3RQidyWX2_biUgNe8g6RaqIIzjCY7kUjXO50xsoLofuMdaXRqybz1KhSoqOSkbsP5GBL_5TU9ocrO00ZmIl2jJKqEud/s1702/slices.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;376&quot; data-original-width=&quot;1702&quot; height=&quot;142&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLhZh__vyjrMGld4nsbb1drHDk9AOBUHGt-6wzngHglHu21Ei1f1x2XtSt0Uv2zYg9JAGjTpy9-LXZPilCDTHpZlvG3Rdcz8kyN3RQidyWX2_biUgNe8g6RaqIIzjCY7kUjXO50xsoLofuMdaXRqybz1KhSoqOSkbsP5GBL_5TU9ocrO00ZmIl2jJKqEud/w640-h142/slices.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;PWM slice+channel mapping to GPIO pins&lt;br /&gt;Image source: RP2040 datasheet section 4.5.2&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The key aspects of the code are:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Use Micropython to init PWM for the associated GPIO pins (A and B).&lt;/li&gt;&lt;li&gt;Alter RP2040 registers to configure for complementary PWM. This consists of two settings being changed.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Invert channel B relative to channel A.&lt;/li&gt;&lt;li&gt;Use center-aligned (phase-correct) PWM instead of edge-aligned. This ensures that the deadtime is applied to both rising and falling edges of channel A. If edge-aligned PWM was used, the channels would be set high together and the deadtime would only be applied on the falling edge of channel A.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;The deadtime is applied to channel B such that channel A&#39;s duty cycle corresponds to the desired/set duty cycle.&lt;/li&gt;&lt;li&gt;The duty cycles corresponding to both channels A and B are updated with one register write.&lt;/li&gt;&lt;li&gt;The frequency of the output PWM using center-aligned/phase-correct mode is half that when using the default edge-aligned mode.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;An example of phase-correct/center-aligned PWM operation is shown in the figure below, taken from the RP2040 datasheet.&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5_GBBzV9XxvX5Di67N7yV_nyNk6Y7ayCXklrPU3WoEYZ6FfDWuBeI9DMQ_NsQLyYS1jBVshLyjX3agRRETUUUOuFDdVptmCcNza8SDPmycMnuXRhMpiN75wPUCLvjeanmuCpIjd75xAdYl71UpGp5aUGZIpBBVy8dvdBrcLirwUVHQ08ditcVX4g975fP/s1266/ds_phasecorrect.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;696&quot; data-original-width=&quot;1266&quot; height=&quot;352&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5_GBBzV9XxvX5Di67N7yV_nyNk6Y7ayCXklrPU3WoEYZ6FfDWuBeI9DMQ_NsQLyYS1jBVshLyjX3agRRETUUUOuFDdVptmCcNza8SDPmycMnuXRhMpiN75wPUCLvjeanmuCpIjd75xAdYl71UpGp5aUGZIpBBVy8dvdBrcLirwUVHQ08ditcVX4g975fP/w640-h352/ds_phasecorrect.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Image source: RP2040 datasheet section 4.5.2.1&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;To generate the complementary signal on channel B, the duty cycle is computed as the sum of the pulse count corresponding to the desired duty cycle and the desired deadtime ticks. With a 125MHz clock for the RP2040 and default clock/divider settings, this corresponds to 8ns per tick. The inversion of channel B then ensures the production of the desired complementary setting.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Shown below are waveforms for GP16 (PWM 0A) and GP17 (PWM0B) for 100kHz PWM, 25% duty cycle and a 504ns deadtime. The deadtime can be verified by recognizing that it corresponds to one horizontal division, which is set to 500ns.&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhd2ieBXP7ncLG3Kf7Nz6zPOzBuvZALWG2JJ1V6gPiZty33-jB5t7oS-uE7XlbqqISYNmcpb7R1FhMA3TlltNe94MwIpWn223aBor43ZC9OJMyhxP_3zS4ibpbsum9yLiEe9b2Rc7ulcCLKypc7FlA9GnVRjR7TnPbUY5aDOl6LS_-Nb2wtDEOUO9uMfPED&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;600&quot; data-original-width=&quot;800&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhd2ieBXP7ncLG3Kf7Nz6zPOzBuvZALWG2JJ1V6gPiZty33-jB5t7oS-uE7XlbqqISYNmcpb7R1FhMA3TlltNe94MwIpWn223aBor43ZC9OJMyhxP_3zS4ibpbsum9yLiEe9b2Rc7ulcCLKypc7FlA9GnVRjR7TnPbUY5aDOl6LS_-Nb2wtDEOUO9uMfPED&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Complementary PWM signals with 500ns deadtime&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Taking a zoomed out view of the waveform highlights the 100kHz frequency and illustrates the complementary PWM generation over multiple cycles, as shown below.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiSkvpB-ULI5Uveii9oLhjOd4c377lOb9UgcUc--Uysy96oH1U00_BQt66bpV-zlXRJJ6qoKoahq1K2LBp5nlR11QecFiYAcrrHw3974uN9sQsiNMXnCMiBA1TnsKiva6fIYGvVIW2CdCXjV5tnfRE5tYIgEkrGywXu0w-io4ltBUXziQ7ekuth2XvmzDrp&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;600&quot; data-original-width=&quot;800&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiSkvpB-ULI5Uveii9oLhjOd4c377lOb9UgcUc--Uysy96oH1U00_BQt66bpV-zlXRJJ6qoKoahq1K2LBp5nlR11QecFiYAcrrHw3974uN9sQsiNMXnCMiBA1TnsKiva6fIYGvVIW2CdCXjV5tnfRE5tYIgEkrGywXu0w-io4ltBUXziQ7ekuth2XvmzDrp&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;3 cycles of 100kHz PWM complementary signals&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;A natural use case for this generated complementary PWM signal is to control a synchronous buck converter to achieve high efficiency step down operation. Since Micropython will limit the design of a fast control loop, applications where the high frequency PWM is coupled with a low-bandwidth controller make for a natural home for this use case. A solar MPPT battery charger would make for an ideal usage scenario. Alternately, if the same configuration technique is applied in C, fast control loops can then be designed and implemented.&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/5453513681641699740/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2024/07/generating-complementary-pwm-with.html#comment-form' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/5453513681641699740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/5453513681641699740'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2024/07/generating-complementary-pwm-with.html' title='Generating complementary PWM with adjustable deadtime for the RP2040'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEhd2ieBXP7ncLG3Kf7Nz6zPOzBuvZALWG2JJ1V6gPiZty33-jB5t7oS-uE7XlbqqISYNmcpb7R1FhMA3TlltNe94MwIpWn223aBor43ZC9OJMyhxP_3zS4ibpbsum9yLiEe9b2Rc7ulcCLKypc7FlA9GnVRjR7TnPbUY5aDOl6LS_-Nb2wtDEOUO9uMfPED=s72-c" height="72" width="72"/><thr:total>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-6851983155579322345</id><published>2024-03-23T17:56:00.000-07:00</published><updated>2024-03-25T22:42:10.505-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="analog"/><category scheme="http://www.blogger.com/atom/ns#" term="capacitor"/><category scheme="http://www.blogger.com/atom/ns#" term="digilent"/><category scheme="http://www.blogger.com/atom/ns#" term="discovery"/><category scheme="http://www.blogger.com/atom/ns#" term="electrolytic"/><category scheme="http://www.blogger.com/atom/ns#" term="esl"/><category scheme="http://www.blogger.com/atom/ns#" term="impedance"/><category scheme="http://www.blogger.com/atom/ns#" term="impedance analyzer"/><category scheme="http://www.blogger.com/atom/ns#" term="parasitics"/><category scheme="http://www.blogger.com/atom/ns#" term="passive"/><title type='text'>Electrolytic caps over frequency: why is my 470uF actually 20uF?</title><content type='html'>&lt;p&gt;While using an LCR meter to measure a 470uF cap in lab, the meter read the expected values at low frequency (100 Hz). But when measured at 100 kHz, the meter read 19uF. While I expected a capacitance drop due to parasitic inductance, I was still surprised at this sharp of a drop. I decided to dig further.&lt;/p&gt;&lt;p&gt;Simplistically, we can model a real capacitor as the following circuit:&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj9cOcOlFc92smBzxeggfnktRg_tWncXEbl99MJ1eDnFPfT3LuCoEDw5ks-JF68INJwmTle3AysGeBibNtqyqWtJJJpMk32ToSCDHDENxn839fuscoWSlGpltJRYNkN1hx0INBo8dRMTnY2Fx6MT3VsJwmqe-ubhYn7BpFXzWFztcu3tc8EyvL9tWjK6BMN&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;572&quot; data-original-width=&quot;1184&quot; height=&quot;155&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj9cOcOlFc92smBzxeggfnktRg_tWncXEbl99MJ1eDnFPfT3LuCoEDw5ks-JF68INJwmTle3AysGeBibNtqyqWtJJJpMk32ToSCDHDENxn839fuscoWSlGpltJRYNkN1hx0INBo8dRMTnY2Fx6MT3VsJwmqe-ubhYn7BpFXzWFztcu3tc8EyvL9tWjK6BMN&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Simplistic capacitor model including parasitic elements&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;C is the main capacitor and the other terms represent parasitic elements: Rs and Ls are the series resistances and inductances, whereas Rp is the parallel (leakage) resistance.&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;When using ceramic capacitors, datasheets often provided impedance charts over frequency and clearly highlight the self-resonant frequency. Let&#39;s consider the&amp;nbsp;&lt;a href=&quot;https://product.tdk.com/en/search/capacitor/ceramic/mlcc/info?part_no=C3216X5R1V226M160AC&quot; target=&quot;_blank&quot;&gt;C3216X5R1V226M160AC&lt;/a&gt;. The impedance chart for the part is shown below. The drop in the impedance magnitude below ~1MHz follows the expected shape of a capacitor. Past ~1MHz, the inductance starts rising again, following the expected shape of an inductor. The minimum point is the self-resonant frequency (SRF) where the capacitance and inductance reactances &quot;cancel&quot; and the impedance is driven by the series resistor. Since the impedance rises again past the self-resonant frequency, the effective capacitance is lower.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhTkCbAF-EpIuCxa03ATKptIbKPlgShPO11Xfv9LlrAcIWwIJX7H_uWPF9bWr1PmACzxQqmUTp2oDOrovBnPuoJ2mkDtwE5gwMcq-KcUkJzbFBmzwY2NQ_qnTlC7Xqr6GFFnJmKUd89gKwwQNpepYaLRvDSubAKTNaekNMB146MphQmTT4MdxC-kHfA_WmU&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;379&quot; data-original-width=&quot;584&quot; height=&quot;260&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhTkCbAF-EpIuCxa03ATKptIbKPlgShPO11Xfv9LlrAcIWwIJX7H_uWPF9bWr1PmACzxQqmUTp2oDOrovBnPuoJ2mkDtwE5gwMcq-KcUkJzbFBmzwY2NQ_qnTlC7Xqr6GFFnJmKUd89gKwwQNpepYaLRvDSubAKTNaekNMB146MphQmTT4MdxC-kHfA_WmU=w400-h260&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;C3216X5R1V226M160AC impedance vs frequency&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Let&#39;s consider a point past the SRF now:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhdMPksqkbrzJo1g9dGxZci5kwXVxHfx6xCnSw5AFtZjy7SbsXACgNe59C7HKxu-BqTbVVHOWkM6VqDEprQMzi2TKQS98ha3CeXq7CUUZKUMnJBgOCqmpIuKjl1y8Gmx3PWgHBtLiV7t_0XBHwHvjpCiD4MoNWrhhdPG9-q1Fu_OxDNP-cBoVnCeDMEGvqF&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;375&quot; data-original-width=&quot;581&quot; height=&quot;259&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhdMPksqkbrzJo1g9dGxZci5kwXVxHfx6xCnSw5AFtZjy7SbsXACgNe59C7HKxu-BqTbVVHOWkM6VqDEprQMzi2TKQS98ha3CeXq7CUUZKUMnJBgOCqmpIuKjl1y8Gmx3PWgHBtLiV7t_0XBHwHvjpCiD4MoNWrhhdPG9-q1Fu_OxDNP-cBoVnCeDMEGvqF=w400-h259&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;C3216X5R1V226M160AC impedance highlighted at 8.684MHz&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;The cap is nominally 22uF. At 8.648MHz, the expected impedance would be given by:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgl65z2zXaI-lxYc2mTU8hJ002GtTPSYGyI-6wIUFTbOObF1A0iMQhc3DGj97z8YuvZFXpawSNQssWAS4vbtAhAEmYhKXYsD3AYbPiKDU2njNHeERrdY6FRNGZPEp7z3NojKvuCa7lhdh3qL25k-jO_h4J4omie3Ay5AUm_onad3BkuJKTwL5vTGj_QKM2z&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;61&quot; data-original-width=&quot;258&quot; height=&quot;76&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgl65z2zXaI-lxYc2mTU8hJ002GtTPSYGyI-6wIUFTbOObF1A0iMQhc3DGj97z8YuvZFXpawSNQssWAS4vbtAhAEmYhKXYsD3AYbPiKDU2njNHeERrdY6FRNGZPEp7z3NojKvuCa7lhdh3qL25k-jO_h4J4omie3Ay5AUm_onad3BkuJKTwL5vTGj_QKM2z&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Expected impedance would therefore be 0.84 mΩ. However, the chart indicates that the impedance is 56 mΩ. Based on that, the effective capacitance can be back-worked to be 0.33uF for this 22uF cap!&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Now you could say that, this frequency is pretty high and way past the SRF so of course the cap isn&#39;t behaving as we expect it to. However, this ties directly to the electrolytic cap I was trying to use too.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;When looking at the electrolytic part&#39;s datasheet, I noticed no equivalent SRF or impedance information. Electrolytic capacitors are known to have lower SRF than ceramic capacitors, but how bad is it actually?&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As an aside, what causes the parasitic inductance and why is it better than the ceramic caps? A good reference to understand this is&amp;nbsp;&lt;a href=&quot;https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=1042783&quot;&gt;Improved Spice Models of Aluminum Electrolytic Capacitors for Inverter Applications&lt;/a&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In summary, consider the construction of a typical electrolytic capacitor where the contact foils are rolled within the package. The images below are taken from the paper linked above.&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjl3UzF3Z8XkXAZ0LTc7_xRPI6ql7VRhOV_OuXcrkqbMtPvYQeBVJNsSx91P6zTfrrCgRAQQGhbZ2rP2ic1OFnxKohs5yBEW2BhtuKSyZxapwSw0tvkuJIXx5wDrCinpdRz6gYAm1wuZqtlQQCU65Bns51ba-YFsmZd6xzZJSAgnImNnidK6ufGwb2xeblK&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;339&quot; data-original-width=&quot;386&quot; height=&quot;352&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjl3UzF3Z8XkXAZ0LTc7_xRPI6ql7VRhOV_OuXcrkqbMtPvYQeBVJNsSx91P6zTfrrCgRAQQGhbZ2rP2ic1OFnxKohs5yBEW2BhtuKSyZxapwSw0tvkuJIXx5wDrCinpdRz6gYAm1wuZqtlQQCU65Bns51ba-YFsmZd6xzZJSAgnImNnidK6ufGwb2xeblK=w400-h352&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhxsBDy0OQz5tfPGGMs5Bk_2k_j0hIBVojps8cpF9Aml1FiR34rpYWDpjo5Cn2f9tM9p6k0_lcTPgU8VrDNScu5X9A4QcWAKhuYhizNi1CvAQaAxthqOqanhLu8eCh3v9iM0sozz--oxNH85MvPrTeo9M7jPVcERGHR5XbYr6TYPC_CyBmGKrwT3B0Hb6cb&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;343&quot; data-original-width=&quot;388&quot; height=&quot;354&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhxsBDy0OQz5tfPGGMs5Bk_2k_j0hIBVojps8cpF9Aml1FiR34rpYWDpjo5Cn2f9tM9p6k0_lcTPgU8VrDNScu5X9A4QcWAKhuYhizNi1CvAQaAxthqOqanhLu8eCh3v9iM0sozz--oxNH85MvPrTeo9M7jPVcERGHR5XbYr6TYPC_CyBmGKrwT3B0Hb6cb=w400-h354&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;The current flow through the structure can be modelled as an RC ladder network with distributed resistances and capacitances. This translates to capacitances further down the ladder network (such as C5 shown below) have larger series resistances and the associated time constants are large compared to the period of the voltage across the cap. This results in a drop in capacitance with frequency, greater than that of just the contact and packaging inductances.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg_-nFRzHlXCdaSPGvWjLIit0n6aTEtC9jfZ5cOh2m8H7pvqf13M3l7Y7VEFnWefqtfvWOWx_rOe__cpS4ebSQORWBYpxAcD-32whCYsBZGB9PqICzLGCS4Hah8ZLybZ9-VBcgInM-2CY9JEbZi3Xi9HfOdWOeG7rJMZ9_goV1f3J5i3wjzgRbxgQqhewPH&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;298&quot; data-original-width=&quot;825&quot; height=&quot;232&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg_-nFRzHlXCdaSPGvWjLIit0n6aTEtC9jfZ5cOh2m8H7pvqf13M3l7Y7VEFnWefqtfvWOWx_rOe__cpS4ebSQORWBYpxAcD-32whCYsBZGB9PqICzLGCS4Hah8ZLybZ9-VBcgInM-2CY9JEbZi3Xi9HfOdWOeG7rJMZ9_goV1f3J5i3wjzgRbxgQqhewPH=w640-h232&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;A side note of interest is that the opposing current directions through the foils can help cancel the parasitic inductances, asides from small mismatches in foil alignment, depending on device assembly.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Is there an easy way to verify this for the cap I have? And can I trust the 19uF reading from the LCR meter? That&#39;s why I proceeded to do. (The reason for the distrust was more due to the meter misbehaving in lab for other measurements but is good to check against.)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I have a &lt;a href=&quot;https://digilent.com/reference/test-and-measurement/analog-discovery-2/start&quot;&gt;Digilent Analog Discovery 2&lt;/a&gt; at home, which I have found to be very handy! I recently learned I can use it as an &lt;a href=&quot;https://digilent.com/reference/test-and-measurement/guides/waveforms-impedance-analyzer&quot;&gt;impedance analyzer&lt;/a&gt;!&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgbPFuDRybjqjBb514sVzG0j9uCsUkrcphZ0EhMh-50JpTJzNlA97_rRzsLXhEc4H9RZ_GUV9VCzE8iqfvS3jq4orcVlhs5Jmf97CrjkXbATwXb6e5BCgxxvUDvjAP9IcLiGSLLSt25ovHXhzMOkA75EMiyBV4F1ykkV5EeiQsswvhl77lCFMTlC9XcXoZL&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;437&quot; data-original-width=&quot;507&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgbPFuDRybjqjBb514sVzG0j9uCsUkrcphZ0EhMh-50JpTJzNlA97_rRzsLXhEc4H9RZ_GUV9VCzE8iqfvS3jq4orcVlhs5Jmf97CrjkXbATwXb6e5BCgxxvUDvjAP9IcLiGSLLSt25ovHXhzMOkA75EMiyBV4F1ykkV5EeiQsswvhl77lCFMTlC9XcXoZL&quot; width=&quot;278&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Digilent Analog Discovery 2&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The following is the required setup to get impedance measurements.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjcY3313f5yfRP5K0tcHhyB1lmSVKhOCgZt0V5D3IW0JZn_jnaQNFXgJqwec1F2bB0U2KBqpxSChjXB8rMkg92jlphHL_pjjcdsKPjw6cPvIEoMkKGAjYm2cp69r1P2A5HV5zWXqRYywTwkNXFT20mkoe179VY6b3c34MgHsuDIlEOaRaUtLpTn4BM3erBe&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;301&quot; data-original-width=&quot;600&quot; height=&quot;161&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjcY3313f5yfRP5K0tcHhyB1lmSVKhOCgZt0V5D3IW0JZn_jnaQNFXgJqwec1F2bB0U2KBqpxSChjXB8rMkg92jlphHL_pjjcdsKPjw6cPvIEoMkKGAjYm2cp69r1P2A5HV5zWXqRYywTwkNXFT20mkoe179VY6b3c34MgHsuDIlEOaRaUtLpTn4BM3erBe&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Impedance measurement setup: &quot;Load&quot; is the cap under test&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Using this setup, I am now able to get some quick impedance measurements for my cap. A key aspect of this is to perform the short compensation to ensure that measurement parasitics are taken into account. Without performing this compensation at first, I saw very different results due to the ~50nH of additional parasitic inductance through my measurement setup.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;The reactance measurement is shown below:&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi2hVKChXG6fMuA-3QKmrkLwwtudqFr0cIJyyRrdOIQB8dDhqOg_w8wRIa7H0Eq5mkd10SSN0w0XjBNhnlrgN7Th8S-G8Q0xfKx2zwmFsn2nl1_XYBMKmf5arFpSMboVN0F_xuD19QBnE_cQo8XG8YyYBuiTzD7ZdbuggmMKKnyuh1Q46_EOqgJKXFngSPL&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;704&quot; data-original-width=&quot;975&quot; height=&quot;462&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi2hVKChXG6fMuA-3QKmrkLwwtudqFr0cIJyyRrdOIQB8dDhqOg_w8wRIa7H0Eq5mkd10SSN0w0XjBNhnlrgN7Th8S-G8Q0xfKx2zwmFsn2nl1_XYBMKmf5arFpSMboVN0F_xuD19QBnE_cQo8XG8YyYBuiTzD7ZdbuggmMKKnyuh1Q46_EOqgJKXFngSPL=w640-h462&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Reactance measurement from 1kHz to 1MHz&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;I exported the reactance measurements, and then found the values of C0 and L0. C0 is the capacitance at the lowest measurement frequency and L0 is the inductance at the highest measurement frequency. This allows me to simply model the capacitor as a constant C0 in series with constant L0 (and also a constant series resistor but that isn&#39;t factored into this reactance measurement).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For these measurements, the values of C0 and L0 are 407.6 uF and 34.5 nH. C0 is within 20% of the 470uF capacitance, as per the part&#39;s spec. Overlaying the reactance due to C0 and L0 on the measured reactances yields the following plot.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjuggUhd4Ucl5-9XXN_LPMg8oo3IXlvpGMKMpvTZwZzCpITuWUXTuNOI9UgVhNwNKbsbSsbuPwfTzahkjQxUUsH-Pz-qhGQCLOm1uJX9QnQTK4sLYcKrlagXndW9hK6MMr3KSQF0IU5FkckjbE4wLykpfXgv3gDkUCSyQD4iDL1dNYNd4V8fynSAakhfpy1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;597&quot; data-original-width=&quot;791&quot; height=&quot;483&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjuggUhd4Ucl5-9XXN_LPMg8oo3IXlvpGMKMpvTZwZzCpITuWUXTuNOI9UgVhNwNKbsbSsbuPwfTzahkjQxUUsH-Pz-qhGQCLOm1uJX9QnQTK4sLYcKrlagXndW9hK6MMr3KSQF0IU5FkckjbE4wLykpfXgv3gDkUCSyQD4iDL1dNYNd4V8fynSAakhfpy1=w640-h483&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Parasitic L, C fit on reactance measurements&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;This shows that barring the area around the SRF, the reactance is very well modelled by the constant C0 and L0. Considering the reactance, then, the equivalent capacitance can be computed as shown below.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiEIRYyvKzXWD5TA2ChybBn2_FuOnAwzjI7iyWjxfGFSfeU0q4qqagpdhpWEPimTYeclmjybMjJETkxiQUVaNGbz2X4JClYcxwgwrbFtvHPdrfv0fm7Wlq-BXoUKleeNkvIpw61RsBe8sit0Jpkj6bhmkY9hKJ4g7bsndY-vJXZ2MnwfWSfq8htRWad8Rbb&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;575&quot; data-original-width=&quot;770&quot; height=&quot;478&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiEIRYyvKzXWD5TA2ChybBn2_FuOnAwzjI7iyWjxfGFSfeU0q4qqagpdhpWEPimTYeclmjybMjJETkxiQUVaNGbz2X4JClYcxwgwrbFtvHPdrfv0fm7Wlq-BXoUKleeNkvIpw61RsBe8sit0Jpkj6bhmkY9hKJ4g7bsndY-vJXZ2MnwfWSfq8htRWad8Rbb=w640-h478&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&quot;Effective&quot; capacitance fit on reactance measurements&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;At 100 kHz, the capacitance is about 80 uF and at 200 kHz, the capacitance is about 20 uF! That is a HUGE drop from the 470 uF rating of the part (and measured 408 uF at low frequency). The self resonant frequency is about 40 kHz, which is very low compared to the ceramic cap shown previously. Of course, this is a different part in a different larger package and so that is not a fair comparison.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Back to where I was trying to use this! This is the input cap for a buck converter operating in the 80-200 kHz range. &lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;With such a substantial drop in effective capacitance, the input current ripple will be substantially higher than that predicted/computed with a 408uF cap!&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;In this particular converter, the 408uF cap would lead to about 23 mVpp ripple. However, with a 20uF cap, this goes up to 463 mVpp. Interestingly, operating this converter at a slower 100 kHz with the same cap (80uF @ 100kHz) could result in a lower ripple!&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Be careful which parts you use! And make sure you consider the frequency-dependent behavior! Once you&#39;re above the SRF, the capacitance value drops precipitously. If possible, operate below the SRF or make sure you understand what the impact will be if you don&#39;t. There&#39;s also the consideration of ESR but with electrolytic caps, that tends to decrease with resistance - which is why you&#39;ll see ripple current specs get better at higher frequencies for electrolytic caps.&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/6851983155579322345/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2024/03/electrolytic-caps-over-frequency-why-is.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/6851983155579322345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/6851983155579322345'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2024/03/electrolytic-caps-over-frequency-why-is.html' title='Electrolytic caps over frequency: why is my 470uF actually 20uF?'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEj9cOcOlFc92smBzxeggfnktRg_tWncXEbl99MJ1eDnFPfT3LuCoEDw5ks-JF68INJwmTle3AysGeBibNtqyqWtJJJpMk32ToSCDHDENxn839fuscoWSlGpltJRYNkN1hx0INBo8dRMTnY2Fx6MT3VsJwmqe-ubhYn7BpFXzWFztcu3tc8EyvL9tWjK6BMN=s72-c" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-5494292203617115445</id><published>2024-01-02T01:40:00.000-08:00</published><updated>2024-01-02T11:45:15.140-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ICSP"/><category scheme="http://www.blogger.com/atom/ns#" term="pi"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC16"/><category scheme="http://www.blogger.com/atom/ns#" term="pic16f72"/><category scheme="http://www.blogger.com/atom/ns#" term="pico"/><category scheme="http://www.blogger.com/atom/ns#" term="programmer"/><category scheme="http://www.blogger.com/atom/ns#" term="raspberry"/><category scheme="http://www.blogger.com/atom/ns#" term="rp2040"/><category scheme="http://www.blogger.com/atom/ns#" term="rpi"/><title type='text'>Quick and dirty PIC16F72 programmer with the Pico</title><content type='html'>&lt;p&gt;Accompanying Github repo:&amp;nbsp;&lt;a href=&quot;https://github.com/SyedTahmidMahbub/q-dpico_picprog72&quot;&gt;https://github.com/SyedTahmidMahbub/q-dpico_picprog72&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Having come to Dhaka over winter break, I was able to scrounge through the 10+ year-old collection of electronics stuff my parents had in storage from when I would experiment with electronics during the initial days of this blog. Among the many parts, I stumbled upon a large number of PIC16F72 MCU&#39;s - the defacto 8-bit cheap MCU of choice for many (commercial) projects. However, I couldn&#39;t seem to find the corresponding PICKIT2/3 programmer from back then - or one of the clones I had made - within the storage cabinets. At the same time, I had been working on some projects with the Pi Pico (as mentioned in the blog previously:&amp;nbsp;&lt;a href=&quot;https://tahmidmc.blogspot.com/2023/08/2023-updates-phd-pi-pico.html&quot;&gt;https://tahmidmc.blogspot.com/2023/08/2023-updates-phd-pi-pico.html&lt;/a&gt;). This seemed like the perfect use case for the Pico - a very quick and dirty programmer to flash the PIC16F72. With its 2MB onboard flash, a very easy-to-program Micropython interface and the PIC16F72&#39;s fairly timing insensitive ICSP protocol (&lt;a href=&quot;http://ww1.microchip.com/downloads/en/devicedoc/39588a.pdf&quot;&gt;http://ww1.microchip.com/downloads/en/devicedoc/39588a.pdf&lt;/a&gt;), I set out to build a programmer to flash some test code onto the PIC16F72. I made use of whatever parts I could scrounge from the parts bin to put the project together.&lt;/p&gt;&lt;p&gt;As expected, Micropython on the Pi Pico enabled a super-quick development time. To echo what I had previously quoted from the Raspberry Pi foundation:&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0.3px; background-color: white; color: #333333; font-family: &amp;quot;Roboto Slab&amp;quot;, serif; font-size: 16px;&quot;&gt;&lt;i&gt;Computing is just so cheap compared to what it has been historically. That then enables things that are maybe not super efficient, not super tight timing like Micropython but who cares at that point? A lot of people will come in and say things like &#39;in this benchmark, I found that MicroPython is 100x slower than C&#39; but if your C code is 100x faster than you need, then it doesn&#39;t matter. You just write the code you need and you focus on the parts that add value to your project and then you move on to your next project.&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0.3px; background-color: white; color: #333333; font-family: &amp;quot;Roboto Slab&amp;quot;, serif; font-size: 16px;&quot;&gt;And this is the perfect use case! It&#39;s not the highest performance result but it gets the job done and the project development was super quick!&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;-webkit-text-stroke-width: 0.3px; background-color: white; color: #333333; font-family: &amp;quot;Roboto Slab&amp;quot;, serif; font-size: 16px;&quot;&gt;The details for the PIC16F72 programming are covered in Microchip&#39;s documentation:&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://ww1.microchip.com/downloads/en/devicedoc/39588a.pdf&quot;&gt;http://ww1.microchip.com/downloads/en/devicedoc/39588a.pdf&lt;/a&gt;&lt;/p&gt;&lt;p&gt;A description of Microchip&#39;s HEX file format is provided here:&amp;nbsp;&lt;a href=&quot;https://microchipdeveloper.com/xwiki/bin/view/software-tools/ipe/sqtp-file-format-specification/intel-hex/&quot;&gt;https://microchipdeveloper.com/xwiki/bin/view/software-tools/ipe/sqtp-file-format-specification/intel-hex/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The hardware elements of the project have a few key aspects:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;A higher voltage power supply is required for programming. This is between 12.75V and 13.25V VPP. To achieve this, a boost converter is used to raise the 5V USB rail to about 13V. I didn&#39;t have any inductors on hand except one unmarked part I found, that measured around 1.8mH. The boost converter operates in discontinuous conduction mode with the minimal VPP required current. Because of the 3.3V IO level of the Pico, I used an NPN transistor instead of a logic level MOSFET I had on hand due to the MOSFET&#39;s relatively high threshold voltage.&lt;/li&gt;&lt;li&gt;A VPP level shifter is required to drive the VPP pin up to 13V or hold it low. A PC817 optocoupler is used for this.&lt;/li&gt;&lt;li&gt;Level shifters are not needed for the PGD and PGC programming lines since the 3.3V from the Pico is high enough (&amp;gt;2V) for the PIC to register, even though the PIC is powered off 5V.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;One useful and interesting aspect of the project is that no separate programming interface is required to transfer the PIC&#39;s HEX file from the PC to the Pico. Since the PIC16F72&#39;s flash storage is so small compared to the Pico&#39;s onboard storage, and using the Micropython setup on the Pico exposes a filesystem, I can just copy the HEX file contents onto a file on the Pico using the Thonny editor. And then hit run in Thonny to program the PIC!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The software is effectively the following:&lt;/div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Configure the IOs for their corresponding functions.&lt;/li&gt;&lt;li&gt;Configure PWM for the boost converter, running at 50kHz.&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Adjust the duty cycle until the output is near 13.2V.&lt;/li&gt;&lt;li&gt;The output voltage is sensed by an ADC channel.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Hold this duty cycle for the output voltage - at this point, the feedback loop is stopped.&lt;/li&gt;&lt;li&gt;Detect the target PIC.&lt;/li&gt;&lt;li&gt;If detected, issue a bulk erase and then check that the part is blank.&lt;/li&gt;&lt;li&gt;Upon success, flash the words read from the HEX file.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;To modify for another similar (small) PIC, adjust the constants at the beginning of the code:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;CODE_START_ADDR&lt;/li&gt;&lt;li&gt;CODE_END_ADDR&lt;/li&gt;&lt;li&gt;CONFIG_START_ADDR&lt;/li&gt;&lt;li&gt;CONFIG_END_ADDR&lt;/li&gt;&lt;li&gt;DEVID_PIC16F72&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;If you use a different inductor for the boost, you can play around with the switching frequency and loop time too.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The schematic for the setup is shown below:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdYm_fBMScNt_6co0a93l-oFoxhSs3nIk_mB3uKXGQhuqNJQaFF_1DqOITwYclgngHCe5p0tGQ4BPTe54R6ry8yc6bxU4OguDlLmR0FVu4WYgLPS7ZjV6_rXB60n2grKY6uZAAxAnCQNaZ_OnSFNAxYhVh4EfTeDRdqPJn1u5hPWJTk358W17wjfJUqcxn/s1650/schematic2.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1084&quot; data-original-width=&quot;1650&quot; height=&quot;420&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdYm_fBMScNt_6co0a93l-oFoxhSs3nIk_mB3uKXGQhuqNJQaFF_1DqOITwYclgngHCe5p0tGQ4BPTe54R6ry8yc6bxU4OguDlLmR0FVu4WYgLPS7ZjV6_rXB60n2grKY6uZAAxAnCQNaZ_OnSFNAxYhVh4EfTeDRdqPJn1u5hPWJTk358W17wjfJUqcxn/w640-h420/schematic2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;The code can be found &lt;a href=&quot;https://github.com/SyedTahmidMahbub/q-dpico_picprog72/blob/main/prog72.py&quot;&gt;here&lt;/a&gt; on this github repo:&amp;nbsp;&lt;a href=&quot;https://github.com/SyedTahmidMahbub/q-dpico_picprog72&quot;&gt;https://github.com/SyedTahmidMahbub/q-dpico_picprog72&lt;/a&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The repo also has 2 test hex files test.hex and testbig.hex where the latter has a large array in flash to program over a larger amount of the flash storage.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Shown below is an example output from Thonny when I set the target voltage to 13.15V and flashed the testbig.hex file:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHEIl_kVdr0ynCsX3DLiz5_gM9VAeE5ja2tgiHt0N70G8fHJZG8hlinj6qS3vrBYeTbZ6XAru7CeCDXpLD7mjx_TEv6HpS4Ux-w2GyALlfSwfVyz2dpthTxxECL3ftur1FONklAoENwlOJlj2Z2ImM0MAdjDQH1uul_Rca-YwdELPSciBpow1vVEiEHIsw/s1036/output.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;312&quot; data-original-width=&quot;1036&quot; height=&quot;120&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHEIl_kVdr0ynCsX3DLiz5_gM9VAeE5ja2tgiHt0N70G8fHJZG8hlinj6qS3vrBYeTbZ6XAru7CeCDXpLD7mjx_TEv6HpS4Ux-w2GyALlfSwfVyz2dpthTxxECL3ftur1FONklAoENwlOJlj2Z2ImM0MAdjDQH1uul_Rca-YwdELPSciBpow1vVEiEHIsw/w400-h120/output.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;The code and project are by no means optimized for speed or performance. They are, however, optimized for development time! The project could easily be adapted to support other MCUs, and to create an ultra-cheap programmer - something I had previously done with the PIC16F1459 but the Pico enables greater versatility. Due to the onboard stoarage, the Pico could also program a PIC with no interface to a computer for isolated industrial flashing settings.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Finally, a quick photo to truly highlight the quick and dirty build:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMuyrgEzEkGt7eYFw3v_EwK5hU0XOBhzc9VA9cWTsWeJ-1rA33P0bY50_6pOfcI6p5i0hVQt61qrBKlVX2SIvJtWxzTXSBp__kFs9q_opCSufPmh-ey4UTXT3iPIrCYiw8PXnxSAW8csed8X1wnKVw_GHXGhxTkA4_OnQQ2DE-nTwVGLWVK2qMJIssRatS/s2572/qdpicopicprog.jpeg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;2572&quot; data-original-width=&quot;2519&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMuyrgEzEkGt7eYFw3v_EwK5hU0XOBhzc9VA9cWTsWeJ-1rA33P0bY50_6pOfcI6p5i0hVQt61qrBKlVX2SIvJtWxzTXSBp__kFs9q_opCSufPmh-ey4UTXT3iPIrCYiw8PXnxSAW8csed8X1wnKVw_GHXGhxTkA4_OnQQ2DE-nTwVGLWVK2qMJIssRatS/w391-h400/qdpicopicprog.jpeg&quot; width=&quot;391&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/5494292203617115445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2024/01/quick-and-dirty-pic16f72-programmer.html#comment-form' title='18 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/5494292203617115445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/5494292203617115445'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2024/01/quick-and-dirty-pic16f72-programmer.html' title='Quick and dirty PIC16F72 programmer with the Pico'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdYm_fBMScNt_6co0a93l-oFoxhSs3nIk_mB3uKXGQhuqNJQaFF_1DqOITwYclgngHCe5p0tGQ4BPTe54R6ry8yc6bxU4OguDlLmR0FVu4WYgLPS7ZjV6_rXB60n2grKY6uZAAxAnCQNaZ_OnSFNAxYhVh4EfTeDRdqPJn1u5hPWJTk358W17wjfJUqcxn/s72-w640-h420-c/schematic2.png" height="72" width="72"/><thr:total>18</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-4774257802758782063</id><published>2023-12-21T19:50:00.000-08:00</published><updated>2024-03-24T03:14:22.419-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bootstrap"/><category scheme="http://www.blogger.com/atom/ns#" term="gate driver"/><category scheme="http://www.blogger.com/atom/ns#" term="half bridge"/><category scheme="http://www.blogger.com/atom/ns#" term="high side"/><category scheme="http://www.blogger.com/atom/ns#" term="high side drive"/><category scheme="http://www.blogger.com/atom/ns#" term="IR2110"/><category scheme="http://www.blogger.com/atom/ns#" term="MOSFET"/><title type='text'>Sizing IR2110 high-side bootstrap capacitor</title><content type='html'>&lt;p&gt;I have previously discussed the IR2110 gate driver on this blog:&amp;nbsp;&lt;a href=&quot;https://tahmidmc.blogspot.com/2013/01/using-high-low-side-driver-ir2110-with.html&quot;&gt;https://tahmidmc.blogspot.com/2013/01/using-high-low-side-driver-ir2110-with.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;A crucial part of the high-side gate driver is the sizing of the bootstrap cap. A common sizing strategy is to &quot;use a large cap&quot; and use a larger one for small frequencies. Here, I present a simple method to model the discharge of the cap in a simple LTSpice simulation to inform the capacitor sizing. Shown below is the simulation setup along with the functional block diagram of the IR2110.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTZ-tfTVwGidrjLdTcnCCKnM38BTxy88Fquqqylknbycy1zikFO9BjfM9d-JhohBzMKKcTnleZyi6dq__gOrfnIXyecF4arfYJF0B049DnPx1O6SJyCE47K_bzA9rP-d-9PuERkfdnIamzcPkENTdoin00QUd4DdsR1s1RiCFIn3JPLRr_soRdTigNkFKi/s1410/sch.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1362&quot; data-original-width=&quot;1410&quot; height=&quot;618&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTZ-tfTVwGidrjLdTcnCCKnM38BTxy88Fquqqylknbycy1zikFO9BjfM9d-JhohBzMKKcTnleZyi6dq__gOrfnIXyecF4arfYJF0B049DnPx1O6SJyCE47K_bzA9rP-d-9PuERkfdnIamzcPkENTdoin00QUd4DdsR1s1RiCFIn3JPLRr_soRdTigNkFKi/w640-h618/sch.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;The LTSpice file can be found at:&amp;nbsp;&lt;a href=&quot;https://github.com/SyedTahmidMahbub/boostrapcap_ir2110/blob/main/ir2110_capsizing.asc&quot;&gt;https://github.com/SyedTahmidMahbub/boostrapcap_ir2110/blob/main/ir2110_capsizing.asc&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4LqdgtPRXVVnccTj-LWiCILOLsxIUCN6YcJSPbF8XfLuk8IJGW0wbFTPUf5SazD0UsNbiWPRjYNbWOI9acDCQDRYnHTkLEig_L2-0eHn_-36ArqkCYsh1_Z60Jyl4GMbYipXlnN7stCp116y0mMTF4J-1guoyuKF1LLJ8g2K7EoazqvcQ_aqzo-2jJrec/s1554/ir2110.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;794&quot; data-original-width=&quot;1554&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4LqdgtPRXVVnccTj-LWiCILOLsxIUCN6YcJSPbF8XfLuk8IJGW0wbFTPUf5SazD0UsNbiWPRjYNbWOI9acDCQDRYnHTkLEig_L2-0eHn_-36ArqkCYsh1_Z60Jyl4GMbYipXlnN7stCp116y0mMTF4J-1guoyuKF1LLJ8g2K7EoazqvcQ_aqzo-2jJrec/w640-h328/ir2110.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;A few key points regarding the setup:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;S1 and S2 represent the high side gate drive FETs in the IR2110 that drive the HO pin.&lt;/li&gt;&lt;li&gt;S3 and S4 represent the low side gate drive FETs in the IR2110 that drive the LO pin.&lt;/li&gt;&lt;li&gt;Ibs represents the quiescent VBS current and the offset supply leakage current: Ibs = ILK + IQBS. From datasheet, that evaluates to a max of 50µA + 230µA = 280µA.&lt;/li&gt;&lt;li&gt;GDH and GDL have their threshold voltages set at +0.5V (refH) and -0.5V (refL) respectively. These, along with yH and yL generate the drive pulses for S1-S4 and correspondingly M1-M2.&lt;/li&gt;&lt;li&gt;C1 is the bootstrap cap here, specified at 1µF.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;The logic for generating the drive signals for S1-S4 is shown in the diagrams below. Click on the images to expand.&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg36dGY0OUPWeYKdEeEHzA2-TaMK0tb9imxqm9sGRW7WwrKjVxt-ysuZAS8YHgfLIl8yuH3ow8U37C1MAdHO4ZCwfMqRKXtRxVZ2dQjXpMhzJi2_7ctn4uwtDVCXtPQYo03Hao9OYxCdUTPJeBbqtdHlasXIkzuQ5yyB2D-ieXTy-ILIpCUixccSiQDSNXP/s1920/signals.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1440&quot; data-original-width=&quot;1920&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg36dGY0OUPWeYKdEeEHzA2-TaMK0tb9imxqm9sGRW7WwrKjVxt-ysuZAS8YHgfLIl8yuH3ow8U37C1MAdHO4ZCwfMqRKXtRxVZ2dQjXpMhzJi2_7ctn4uwtDVCXtPQYo03Hao9OYxCdUTPJeBbqtdHlasXIkzuQ5yyB2D-ieXTy-ILIpCUixccSiQDSNXP/w200-h150/signals.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitiAGx0WtI3Jvk4P1fN-_PA9HOiX3lG1K3B_BEVMIQBhvUULy42kiEOK8DGhYiKYcFbFT_35st5B7Cercere6xwfbtxQfwsqF9LkAUxzM9-xtrq64hPldeqklhmU06YV0KF9DuP3eKy8i5RFqj4Nnd-T3X-7diRpq-rKeoNCK9_OVt4-oYWrrQu8-iyP_e/s1920/switches.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1440&quot; data-original-width=&quot;1920&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitiAGx0WtI3Jvk4P1fN-_PA9HOiX3lG1K3B_BEVMIQBhvUULy42kiEOK8DGhYiKYcFbFT_35st5B7Cercere6xwfbtxQfwsqF9LkAUxzM9-xtrq64hPldeqklhmU06YV0KF9DuP3eKy8i5RFqj4Nnd-T3X-7diRpq-rKeoNCK9_OVt4-oYWrrQu8-iyP_e/w200-h150/switches.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNfyBIsQf7SMmdeG5qx9aA0uhisK5o8mlhb4tp_geHtQubbed9P4dQ1jJBxLtIcbOJip16SNzEmKElnDQWGHo5uapdytc18j0sDNJvDrbP4_B5ry02vIxfbhmrIMb34H5gIN2T19YblXXdGc4FgK4cWXycbu_hajB8VlL6oQ9utspbg699XN9BXcUWw_JW/s1920/fets.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1440&quot; data-original-width=&quot;1920&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNfyBIsQf7SMmdeG5qx9aA0uhisK5o8mlhb4tp_geHtQubbed9P4dQ1jJBxLtIcbOJip16SNzEmKElnDQWGHo5uapdytc18j0sDNJvDrbP4_B5ry02vIxfbhmrIMb34H5gIN2T19YblXXdGc4FgK4cWXycbu_hajB8VlL6oQ9utspbg699XN9BXcUWw_JW/w200-h150/fets.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: right;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Now, let&#39;s go on to the key discussion regarding the cap sizing.&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Once the cap is charged, there are a few discharge paths:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Charge transferred to the gate of the MOSFET being driven&lt;/li&gt;&lt;li&gt;Current draw due to the gate-source resistor&lt;/li&gt;&lt;li&gt;Leakage paths - the largest one modeled here is Ibs&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;For the charge transfer, consider the gate charge of the MOSFET being driven. This can be gathered from the datasheet of the MOSFET. For the IRFZ44N in this simulation, this is around 40nC-50nC as can be seen from Fig 6 in the IRFZ44N datasheet:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWNhyphenhyphenIn85HuWSd5ELbAlfP9uvEIbPc847alVaNLrtExtCPtlDrScifCxHR1i-rJ9rFwqELNi2b7q57_AuUq2Ga-USRJFk9nY3w5EBY_sDWM7ipNVX3l71jKHha3eto4AfUL80gcjjjnN40TMSKgOs5K7pXcPLN5bPkwu0W3AMb8PDpLhy2M0Pu86rwpiRY/s588/qg.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;588&quot; data-original-width=&quot;496&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWNhyphenhyphenIn85HuWSd5ELbAlfP9uvEIbPc847alVaNLrtExtCPtlDrScifCxHR1i-rJ9rFwqELNi2b7q57_AuUq2Ga-USRJFk9nY3w5EBY_sDWM7ipNVX3l71jKHha3eto4AfUL80gcjjjnN40TMSKgOs5K7pXcPLN5bPkwu0W3AMb8PDpLhy2M0Pu86rwpiRY/s320/qg.png&quot; width=&quot;270&quot; /&gt;&lt;/a&gt;&lt;/div&gt;The voltage droop due to charging the MOSFET gate (Qg) can be estimated as:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguv5QYluxVsSczjq5nIfpv3sc0J0gdr-NSaSGSIv-DT22lH9vBZgWK6tx8Dehy6e7cJRBSwnkopmV47RwMXPfsDs4y6H-N65O7XiZRosh0B5WXE9AqR-SyEwMjd9HP-rsqdZ4ZfuKFmIIh56h1ivT-uLfDoFLHr5hf9ir-OddaxNq7MGWpobqHQHBCHj9S/s224/eq1.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;122&quot; data-original-width=&quot;224&quot; height=&quot;109&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguv5QYluxVsSczjq5nIfpv3sc0J0gdr-NSaSGSIv-DT22lH9vBZgWK6tx8Dehy6e7cJRBSwnkopmV47RwMXPfsDs4y6H-N65O7XiZRosh0B5WXE9AqR-SyEwMjd9HP-rsqdZ4ZfuKFmIIh56h1ivT-uLfDoFLHr5hf9ir-OddaxNq7MGWpobqHQHBCHj9S/w200-h109/eq1.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;The voltage droop due to driving current through the gate-source resistor can be estimated as:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-kqZ5QbzI0oIBp5sRdpBqW2TmANdfhR1EGtgoPM8Wg2ez3ctEecTeDvjcqkZWgOy45V18aY7QiTlw0qnwmyymeCtEOf2pNR2DY6U8cQN4ovW_X3IHuz0CvqXJNVOxS3Db5cO3SwR5TEnvpL4OO70hjDM8WogYtsYgNvuvT8R8e7ug-5MbaAUbqqQy2gJa/s1228/eq2.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;142&quot; data-original-width=&quot;1228&quot; height=&quot;74&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-kqZ5QbzI0oIBp5sRdpBqW2TmANdfhR1EGtgoPM8Wg2ez3ctEecTeDvjcqkZWgOy45V18aY7QiTlw0qnwmyymeCtEOf2pNR2DY6U8cQN4ovW_X3IHuz0CvqXJNVOxS3Db5cO3SwR5TEnvpL4OO70hjDM8WogYtsYgNvuvT8R8e7ug-5MbaAUbqqQy2gJa/w640-h74/eq2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;VD1 is the forward drop for the bootstrap diode D1. Ton is the on-time given by the product of the duty cycle and period.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Below is the voltage across the boostrap cap from the sim:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjULcCqZN8MizKhVV4Xz3drZOrGatRKej7Zc-kjIJMaTE5EG1wEn4K89or8CwfC2dlcCJEgGgeXLYplW-PN9xjr-25IxV9lo78pyllkeTNr2ekV90ekrWY-firtbNZLcf5TLEK70mvWpDtY9NluRYTgSQJAJh8a7TQk6q_VzYu7qgOxNYyWTQrgUpGpYqWA/s1473/vgs_h.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;555&quot; data-original-width=&quot;1473&quot; height=&quot;242&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjULcCqZN8MizKhVV4Xz3drZOrGatRKej7Zc-kjIJMaTE5EG1wEn4K89or8CwfC2dlcCJEgGgeXLYplW-PN9xjr-25IxV9lo78pyllkeTNr2ekV90ekrWY-firtbNZLcf5TLEK70mvWpDtY9NluRYTgSQJAJh8a7TQk6q_VzYu7qgOxNYyWTQrgUpGpYqWA/w640-h242/vgs_h.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Observations from this waveform:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Between 440µs and 500µs, M2 is on, which charges the bootstrap cap C1 through D1. A larger charge resistance (D1 on-state resistance) or a larger bootstrap cap C1 would increase this charging time.&lt;/li&gt;&lt;li&gt;At 500µs, M1 is turned on. Note that this simulation doesn&#39;t model the deadtime, but since we&#39;re primarily interested in the boostrap cap&#39;s dynamics, that is fine.&lt;/li&gt;&lt;li&gt;The sharp vertical drop right after 500µs is the charge transfer to M1&#39;s gate.&lt;/li&gt;&lt;li&gt;The continued droop afterwards, to 540µs, is due to Ibs and the gate-source-resistance.&lt;/li&gt;&lt;li&gt;The voltage drops from 11.403V to 10.921V.&lt;/li&gt;&lt;li&gt;VGS for M1 tracks this voltage from 500µs to 540µs.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Below is a simple script to estimate the total droop with Python:&lt;/div&gt;&lt;div&gt;Github link:&amp;nbsp;&lt;a href=&quot;https://github.com/SyedTahmidMahbub/boostrapcap_ir2110/blob/main/delV_bs.py&quot;&gt;https://github.com/SyedTahmidMahbub/boostrapcap_ir2110/blob/main/delV_bs.py&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;numpy&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;np&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4fc1ff;&quot;&gt;D&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0.4&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Tperiod&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;100e-6&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Ton&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;D&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Tperiod&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4fc1ff;&quot;&gt;V0&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;11.403&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Cboostrap&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1e-6&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Qg_FET&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;45e-9&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Rg_on&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1031&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Ibs&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;280e-6&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dV_Qg&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Qg_FET&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Cboostrap&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dV_Rg&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #4fc1ff;&quot;&gt;V0&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt; (&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;np&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;exp&lt;/span&gt;(&lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Ton&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Rg_on&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Cboostrap&lt;/span&gt;))&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dV_Ibs&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Ibs&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Cboostrap&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Ton&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;V_final&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;V0&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;dV_Qg&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;dV_Rg&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;dV_Ibs&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Droop sources:&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;  Gate charge: &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dV_Qg&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;:.3f}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt; V&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;  Gate resistor: &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dV_Rg&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;:.3f}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt; V&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;  Ibs: &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dV_Ibs&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;:.3f}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt; V&quot;&lt;/span&gt;)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Droops from &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #4fc1ff;&quot;&gt;V0&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;:.3f}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt; V to &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;V_final&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;:.3f}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt; V&quot;&lt;/span&gt;)&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The output of the script is:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Droop sources:&lt;/div&gt;&lt;div&gt;&amp;nbsp; Gate charge: -0.045 V&lt;/div&gt;&lt;div&gt;&amp;nbsp; Gate resistor: -0.434 V&lt;/div&gt;&lt;div&gt;&amp;nbsp; Ibs: -0.011 V&lt;/div&gt;&lt;div&gt;Droops from 11.403 V to 10.913 V&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The computed droop matches very well with the simulation!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Key observations:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;The droop will get worse with reduced gate-source resistance. Using a larger resistance than 1k will reduce the droop.&lt;/li&gt;&lt;li&gt;The droop will get worse with a longer on-time. This is why a larger capacitance is needed when operating at lower frequencies such as 50Hz or 60Hz.&lt;/li&gt;&lt;li&gt;Using a super large cap will increase how long the cap will require being charged at startup. This may be dealt with by precharging the cap (by turning on M2) before M1 has to be turned on.&lt;/li&gt;&lt;li&gt;A 100% duty cycle can&#39;t be used since the bootstrap cap can&#39;t be recharged. How high the max possible duty cycle is depends on how long it takes to recharge the cap through the bootstrap diode.&lt;/li&gt;&lt;li&gt;Gate charge for the MOSFET is a weak function of applied voltage and a very strong function of gate voltage. A larger gate drive voltage will result in a greater droop. Note though that this may not matter if the gate-source resistor dominates the droop.&lt;/li&gt;&lt;li&gt;A good max allowable droop is given by the 9.7V figure for the IR2110&#39;s max VBS undervoltage threshold. Given that there are always additional leakage components, and the cap has an associated tolerance (in many cases &amp;gt;20%), you will want to build in lots of margin.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Hopefully, this was a useful introduction to sizing the bootstrap capacitance for the IR2110 (or other gate driver). Here is also a good reference to look at: &lt;a href=&quot;https://www.infineon.com/dgdl/Infineon-HV_Floating_MOS_Gate_Drivers-ApplicationNotes-v01_00-EN.pdf?fileId=5546d4626c1f3dc3016c47de609d140a&amp;amp;redirId=117674&quot; target=&quot;_blank&quot;&gt;AN-978&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you want further clarification on any aspect of this, do let me know in the comments!&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/4774257802758782063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2023/12/sizing-ir2110-high-side-bootstrap.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/4774257802758782063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/4774257802758782063'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2023/12/sizing-ir2110-high-side-bootstrap.html' title='Sizing IR2110 high-side bootstrap capacitor'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTZ-tfTVwGidrjLdTcnCCKnM38BTxy88Fquqqylknbycy1zikFO9BjfM9d-JhohBzMKKcTnleZyi6dq__gOrfnIXyecF4arfYJF0B049DnPx1O6SJyCE47K_bzA9rP-d-9PuERkfdnIamzcPkENTdoin00QUd4DdsR1s1RiCFIn3JPLRr_soRdTigNkFKi/s72-w640-h618-c/sch.png" height="72" width="72"/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-5867555236025792610</id><published>2023-11-10T11:53:00.011-08:00</published><updated>2024-01-02T09:42:34.979-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="pure sine"/><category scheme="http://www.blogger.com/atom/ns#" term="sine wave"/><category scheme="http://www.blogger.com/atom/ns#" term="SPWM"/><title type='text'>SmartSinePy, and an example of GUI development with PySide6</title><content type='html'>&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgJo30XcbxxEcQm1m4SiJn44QNNORWu6NqwvfOiyeEXVeQFWaJxI8TAVnuGa3vb8j7WPhS0cYm3bA1JOFzq-0VBfP1M5lhujLNLc8Cr9bGMUCEJrVVGy4dGS7MeM9Xct0YHgjzzrIuRI8YUPTQ0PjCLEdlUePzjJda7qEPPFVFvxs-Z7muXevpzEIWrE4FP&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1240&quot; data-original-width=&quot;1704&quot; height=&quot;466&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgJo30XcbxxEcQm1m4SiJn44QNNORWu6NqwvfOiyeEXVeQFWaJxI8TAVnuGa3vb8j7WPhS0cYm3bA1JOFzq-0VBfP1M5lhujLNLc8Cr9bGMUCEJrVVGy4dGS7MeM9Xct0YHgjzzrIuRI8YUPTQ0PjCLEdlUePzjJda7qEPPFVFvxs-Z7muXevpzEIWrE4FP=w640-h466&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-size: large; text-align: left;&quot;&gt;&lt;b&gt;Source code at:&amp;nbsp;&lt;/b&gt;&lt;a href=&quot;https://github.com/SyedTahmidMahbub/SmartSinePy&quot;&gt;https://github.com/SyedTahmidMahbub/SmartSinePy&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Quite a very long time ago, I had posted a Windows tool called Smart Sine to generate a sine table. See:&amp;nbsp;&lt;a href=&quot;https://tahmidmc.blogspot.com/2012/10/smart-sine-software-to-generate-sine.html&quot;&gt;https://tahmidmc.blogspot.com/2012/10/smart-sine-software-to-generate-sine.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;This was very useful for pre-generating the sine-table instead of in the main program itself, often useful to save space (and not have to perform trig operations) especially on 8-bit microcontrollers.&lt;/p&gt;&lt;p&gt;I was recently looking into developing quick GUIs for some test bench automation and was primarily looking for something where I could position and size GUI elements visually (a WYSIWYG editor, basically) and decided to dig into QT Designer and PySide6. I don&#39;t mind defining properties and event handlers programmatically (in fact I do prefer it) but what I really don&#39;t want to do is have to add every GUI element in code and define its location and size - this is where the QT Designer&#39;s visual editing really comes in helpful! Reminds me a lot of the Visual Studio GUI editor back in Visual Basic development days.&lt;/p&gt;&lt;p&gt;This provided a good opportunity to redo Smart Sine and have an example project for developing the GUI application. A few aspects explored on the GUI side of things:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Creating the layout in QT Designer&lt;/li&gt;&lt;li&gt;Getting inputs from a table&lt;/li&gt;&lt;li&gt;Working with GUI widget signals (events such as button pressed or slider value changed)&lt;/li&gt;&lt;li&gt;Updating text in labels and a text browser (textbox)&lt;/li&gt;&lt;li&gt;Generating a plot with matplotlib and embedded it on the GUI&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;This is a great reference for embedding matplotlib:&amp;nbsp;&lt;a href=&quot;https://david.roesel.cz/notes/posts/matplotlib-figure-embedded-in-qt/&quot;&gt;https://david.roesel.cz/notes/posts/matplotlib-figure-embedded-in-qt/&lt;/a&gt;&lt;/div&gt;&lt;div&gt;Particularly about temporarily adding a text box within the widget to specify the layout.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For this particular project, I read in the .ui file (that QT Designer generates) straight in the main code without an intermediate conversion.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is a snapshot from QT Designer:&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiARUwf1PQy6_88_KqMiInvjYI0asRxUWIAZCiYLxMl-rsI-XDFxKwweErqDJvejFbYaLK7SJYdDFpvLI81HMlAVtrs808A5aMHdayAwAm7zVnn4QKTghodSKmgeEvfrtU2fgYvxhB-UDavuWkt4EQhkoqUnifHzGJVCR5t7LL9gxrUxaYTHqrgxqo5TrKQ&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1702&quot; data-original-width=&quot;2940&quot; height=&quot;370&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiARUwf1PQy6_88_KqMiInvjYI0asRxUWIAZCiYLxMl-rsI-XDFxKwweErqDJvejFbYaLK7SJYdDFpvLI81HMlAVtrs808A5aMHdayAwAm7zVnn4QKTghodSKmgeEvfrtU2fgYvxhB-UDavuWkt4EQhkoqUnifHzGJVCR5t7LL9gxrUxaYTHqrgxqo5TrKQ=w640-h370&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Here are a couple snapshots of the application running:&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiA7Da_HEfRa808-g5e83Y1kGC-cNnkBBL8vzEF5X4XiSpMCZSO9Hz428RqSuJCVUJMUrXQ2wXrPyXeZ_Y3Pj-IZ50kyn7HP31_ZJfnCa_0k21ZwGY4cZbTNU421IUrcFB036IkXPQywvQ7KwFHT-Ue549X7H0ibnh2AwjDMeQdvPsYf1Fuq0NJh5ioG1UT&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1240&quot; data-original-width=&quot;1704&quot; height=&quot;466&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiA7Da_HEfRa808-g5e83Y1kGC-cNnkBBL8vzEF5X4XiSpMCZSO9Hz428RqSuJCVUJMUrXQ2wXrPyXeZ_Y3Pj-IZ50kyn7HP31_ZJfnCa_0k21ZwGY4cZbTNU421IUrcFB036IkXPQywvQ7KwFHT-Ue549X7H0ibnh2AwjDMeQdvPsYf1Fuq0NJh5ioG1UT=w640-h466&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiX6Jzo1yL-QzNR6eo9xmHICTwyCbbt3scVc-kz6e0qW--cD70KRXmjx9GsJe2Gd4i30HVjEfyuoDgXMT39eMJBWOtlQSY5h_YYlFplGjofgw8jL0imn4kQHknM0gf0-aPaZiGVm7qfgHyW-ZaSENZ3W23YR74Y1jzcDO8F9V4SnUswdyEiHxg6d96Uz1uC&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1240&quot; data-original-width=&quot;1704&quot; height=&quot;466&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiX6Jzo1yL-QzNR6eo9xmHICTwyCbbt3scVc-kz6e0qW--cD70KRXmjx9GsJe2Gd4i30HVjEfyuoDgXMT39eMJBWOtlQSY5h_YYlFplGjofgw8jL0imn4kQHknM0gf0-aPaZiGVm7qfgHyW-ZaSENZ3W23YR74Y1jzcDO8F9V4SnUswdyEiHxg6d96Uz1uC=w640-h466&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;There are a fair few Python dependencies that you will have to install. A one-line command for installing them is:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;python3 -m pip install pyside6 numpy pyperclip matplotlib&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;If there&#39;s interest in packaging this up into an executable, let me know!&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Source code at:&amp;nbsp;&lt;a href=&quot;https://github.com/SyedTahmidMahbub/SmartSinePy&quot;&gt;https://github.com/SyedTahmidMahbub/SmartSinePy&lt;/a&gt;&lt;/div&gt;&lt;div&gt;The code is commented and should be self-explanatory. But if there are specific questions or anything that is unclear, let me know and I can clear it up!&lt;/div&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/5867555236025792610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2023/11/smartsinepy-and-example-of-gui.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/5867555236025792610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/5867555236025792610'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2023/11/smartsinepy-and-example-of-gui.html' title='SmartSinePy, and an example of GUI development with PySide6'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEgJo30XcbxxEcQm1m4SiJn44QNNORWu6NqwvfOiyeEXVeQFWaJxI8TAVnuGa3vb8j7WPhS0cYm3bA1JOFzq-0VBfP1M5lhujLNLc8Cr9bGMUCEJrVVGy4dGS7MeM9Xct0YHgjzzrIuRI8YUPTQ0PjCLEdlUePzjJda7qEPPFVFvxs-Z7muXevpzEIWrE4FP=s72-w640-h466-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-2429801446288236411</id><published>2023-11-03T02:18:00.005-07:00</published><updated>2023-11-10T12:35:03.885-08:00</updated><title type='text'>Modified Sine Wave Inverter: Harmonic Elimination</title><content type='html'>&lt;p&gt;In inverter designs, we see the concept of a modified (or quasi) sine wave inverter - &quot;better&quot; than a square wave but still very easy to implement by adding a deadtime. By adjusting the duty cycle of the square wave, the output RMS value can be adjusted - and this is often used in inverters for feedback regulation.&lt;/p&gt;&lt;p&gt;One concept that is tied to how a modified sine wave output is better than a square wave has to do with &lt;b&gt;harmonic elimination&lt;/b&gt;.&lt;/p&gt;&lt;p&gt;To start off with, let&#39;s remind ourselves that a square wave is composed of an infinite number of sine waves at odd multiples of the wave&#39;s frequency. Here is a great reference for this:&amp;nbsp;&lt;a href=&quot;https://mathworld.wolfram.com/FourierSeriesSquareWave.html&quot;&gt;Fourier Series--Square Wave -- from Wolfram MathWorld&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Now, if we consider the modified sine wave, what happens to the harmonic contents?&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc_rOmE5VYWb80rktwPW2Pq79KWMJUqgb_DLQlOeBaYG1vCh-a68odsNyzX_r3iLwPMk7pqHF2MEGk610JybKRoD85-jGmJgqYc9cAoNFxhbYZ1LLMr5ymkgmjvEwNhldVtvmFtPQp2ewgByjSPXAUp_Fzjznl29U-ZARUw3yZs4G5vIrFGSbQ-_ISpgV_/s640/quasinsine.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;480&quot; data-original-width=&quot;640&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc_rOmE5VYWb80rktwPW2Pq79KWMJUqgb_DLQlOeBaYG1vCh-a68odsNyzX_r3iLwPMk7pqHF2MEGk610JybKRoD85-jGmJgqYc9cAoNFxhbYZ1LLMr5ymkgmjvEwNhldVtvmFtPQp2ewgByjSPXAUp_Fzjznl29U-ZARUw3yZs4G5vIrFGSbQ-_ISpgV_/w640-h480/quasinsine.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;We can solve for the nth harmonic (where n=1, 3, 5, 7, ...) which gives a Fourier coefficient of:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgZBXZNvIpZIF_c_jxOZdU4IbgFhL3H8f2CDoNvpCYsyzBeDdR_75_vBAmUQOCOhBcAiNtg5MpNCjytFJ2QNOa0PzOlywMYLuYEHhUt6KURHxHnfrwnudumhCv6O2yuXN2fh9WXEtJ4TEXNe-rVXnSEJ1svXJJ48G8pYEpOLbBXC0gfh-9kb7CRL2fe-LOq&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;107&quot; data-original-width=&quot;205&quot; height=&quot;103&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgZBXZNvIpZIF_c_jxOZdU4IbgFhL3H8f2CDoNvpCYsyzBeDdR_75_vBAmUQOCOhBcAiNtg5MpNCjytFJ2QNOa0PzOlywMYLuYEHhUt6KURHxHnfrwnudumhCv6O2yuXN2fh9WXEtJ4TEXNe-rVXnSEJ1svXJJ48G8pYEpOLbBXC0gfh-9kb7CRL2fe-LOq=w200-h103&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Why is this interesting? Can we fix the duty cycle so that we eliminate certain harmonics? Yes! We can make the cos term go to zero by picking nδ =&amp;nbsp;π/2 = 90°. We could then pick &lt;b&gt;δ = 30° and eliminate the 3rd harmonic&lt;/b&gt;! Or &lt;b&gt;we could pick δ = 18° and eliminate the 5th harmonic.&lt;/b&gt; If we had to pick just one, it would then make sense to eliminate the 3rd harmonic which has a higher Fourier coefficient than the 5th! &lt;b&gt;This will contribute to a better THD (total harmonic distortion).&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;We can of course time shift this waveform and retain the same benefits - this would then correspond to a standard (edge-aligned) PWM. If we are using a full-bridge to generate this waveform, this would correspond to a duty cycle (for each pair of diagonal switches) of (180°-30°-30°)/360° = 33.33%. The off time would, of course, reduce the output RMS voltage compared to a square wave, so you would have to keep that in mind!&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;What about multiple harmonic eliminations? We can come up with a scheme where we add multiple notches and eliminate multiple harmonics. And, in fact, this is what SPWM achieves by forming these notches in a &quot;sinusoidally optimal&quot; fashion and eliminating several lower order harmonics. I have several articles where I have discussed SPWM (such as&amp;nbsp;&lt;a href=&quot;https://tahmidmc.blogspot.com/2011/01/generation-and-implementation-of-sine.html&quot;&gt;Generation and Implementation of Sine Wave Table&lt;/a&gt;) albeit not in the context of harmonic elimination.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;Can we do this in one-stage inverters like with an iron core? No.&lt;/b&gt; Unfortunately, in these one-stage inverters, the output voltage regulation is obtained by altering the duty cycle and so you can&#39;t have a fixed&amp;nbsp;δ and optimize for a particular harmonic elimination.&lt;/p&gt;&lt;div&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgghnUXWwzqfhyzwN3-9hPwtVfL-KxzyF7GYPf-wK7aBjYD7pBIs9297g3L22UKH_JYWl0q7cixIUHMZmssZeCcACKgRSpLlfQEdQQWZPY2WzbJlbgr420aJg3LV2_AR0olBh4rp4HcewJ9FhuF__pTDoE5tHZLoXfF725TrTK3iob4DS0OBxeEZ7gSNmAX&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;632&quot; data-original-width=&quot;1352&quot; height=&quot;188&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgghnUXWwzqfhyzwN3-9hPwtVfL-KxzyF7GYPf-wK7aBjYD7pBIs9297g3L22UKH_JYWl0q7cixIUHMZmssZeCcACKgRSpLlfQEdQQWZPY2WzbJlbgr420aJg3LV2_AR0olBh4rp4HcewJ9FhuF__pTDoE5tHZLoXfF725TrTK3iob4DS0OBxeEZ7gSNmAX=w400-h188&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Can we do this with two-stage inverters such as ones where the input voltage is first stepped up with a ferrite transformer at high frequencies followed by an H-bridge to generate the output? Yes - if we use feedback to control the output of the first stage, we can use this constant δ on the output of the second stage.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/2429801446288236411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2023/11/modified-sine-wave-inverter-harmonic.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/2429801446288236411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/2429801446288236411'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2023/11/modified-sine-wave-inverter-harmonic.html' title='Modified Sine Wave Inverter: Harmonic Elimination'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc_rOmE5VYWb80rktwPW2Pq79KWMJUqgb_DLQlOeBaYG1vCh-a68odsNyzX_r3iLwPMk7pqHF2MEGk610JybKRoD85-jGmJgqYc9cAoNFxhbYZ1LLMr5ymkgmjvEwNhldVtvmFtPQp2ewgByjSPXAUp_Fzjznl29U-ZARUw3yZs4G5vIrFGSbQ-_ISpgV_/s72-w640-h480-c/quasinsine.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-6691071380608233457</id><published>2023-08-13T23:04:00.003-07:00</published><updated>2023-08-13T23:14:17.197-07:00</updated><title type='text'>2023 Updates: PhD; Pi Pico</title><content type='html'>&lt;p&gt;It&#39;s 2023 and I&#39;m back to keep the blog going! Lots have changed in my life in the past 6 years since I last posted on the blog.&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;PhD&lt;/h2&gt;&lt;p&gt;After a six-year stint working as a hardware engineer at Apple, I am excited to now be pursuing my PhD in Electrical Engineering, focused on Power Electronics, at UC Berkeley. I start working with Professor &lt;a href=&quot;https://www2.eecs.berkeley.edu/Faculty/Homepages/pilawa.html&quot; target=&quot;_blank&quot;&gt;Robert Pilawa-Podgurski&lt;/a&gt;&amp;nbsp;this week! I anticipate more posts centered around power electronics in the future.&lt;/p&gt;&lt;p&gt;Why did I want to go back to school in a PhD program? There are 3 key aspects to this:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Technical depth. With the recent rapid advances enabled by wide bandgap semiconductors, the recent explosion in adoption of EVs and an expansion in the number of research labs in academia, now is an exciting time for power electronics.&lt;/li&gt;&lt;li&gt;Positive contributions to climate crisis solutions. Growing up in Bangladesh, I witnessed firsthand the devastating impact of natural disasters that continue to be exacerbated by the climate crisis. Direct impacts of this are witnessed every year half-way across the world in California where I now live. I envision pursuing research opportunities to significantly reduce emissions in the transportation and energy sectors: the largest contributors to the climate crisis and fields that can be directly improved through power electronics.&lt;/li&gt;&lt;li&gt;Education. This blog has been an early testament to my interest in sharing engineering information and knowledge. I would like to continue to do so, but also engage in a more formal manner through educational institutions, particularly with typically underserved institutions.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Pi Pico&lt;/h2&gt;&lt;p&gt;In the short term, I am exploring the Raspberry Pi Pico (based on the RP2040 MCU) using MicroPython. Having the resources to support running MicroPython, in a super-cheap part, is an exciting opportunity for me to explore. The idea here is to use Python (very simple software bringup time) to do the software heavy lifting and leveraging on-board hardware for timing-sensitive/hardware applications.&lt;/p&gt;&lt;p&gt;Here is a great relevant podcast episode: &lt;a href=&quot;https://theamphour.com/529-embedded-hardware-with-the-raspberry-pi-team/&quot; target=&quot;_blank&quot;&gt;The Amp Hour&amp;nbsp;#529 – Embedded Hardware with the Raspberry Pi Team&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;&lt;p&gt;Why Micropython? Listen to 11:30-12:30 in the linked podcast episode where the below qutoes are taken from.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;Computing is just so cheap compared to what it has been historically. That then enables things that are maybe not super efficient, not super tight timing like Micropython but who cares at that point? A lot of people will come in and say things like &#39;in this benchmark, I found that MicroPython is 100x slower than C&#39; but if your C code is 100x faster than you need, then it doesn&#39;t matter. You just write the code you need and you focus on the parts that add value to your project and then you move on to your next project.&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/6691071380608233457/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2023/08/2023-updates-phd-pi-pico.html#comment-form' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/6691071380608233457'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/6691071380608233457'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2023/08/2023-updates-phd-pi-pico.html' title='2023 Updates: PhD; Pi Pico'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><thr:total>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-8121644748708943110</id><published>2017-06-15T23:45:00.001-07:00</published><updated>2017-06-15T23:45:34.129-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="32-qam"/><category scheme="http://www.blogger.com/atom/ns#" term="4670"/><category scheme="http://www.blogger.com/atom/ns#" term="amplitude"/><category scheme="http://www.blogger.com/atom/ns#" term="Cornell"/><category scheme="http://www.blogger.com/atom/ns#" term="digital communication"/><category scheme="http://www.blogger.com/atom/ns#" term="division"/><category scheme="http://www.blogger.com/atom/ns#" term="ECE"/><category scheme="http://www.blogger.com/atom/ns#" term="frequency"/><category scheme="http://www.blogger.com/atom/ns#" term="matlab"/><category scheme="http://www.blogger.com/atom/ns#" term="modulation"/><category scheme="http://www.blogger.com/atom/ns#" term="multiplexing"/><category scheme="http://www.blogger.com/atom/ns#" term="ofdm"/><category scheme="http://www.blogger.com/atom/ns#" term="orthogonal"/><category scheme="http://www.blogger.com/atom/ns#" term="qam"/><category scheme="http://www.blogger.com/atom/ns#" term="qam-32"/><category scheme="http://www.blogger.com/atom/ns#" term="qam-5"/><category scheme="http://www.blogger.com/atom/ns#" term="qamdemod"/><category scheme="http://www.blogger.com/atom/ns#" term="qammod"/><category scheme="http://www.blogger.com/atom/ns#" term="quadrature"/><title type='text'>A digital communication project using OFDM and 32-QAM</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;This past semester (my last one during my undergrad years!), I was enrolled in ECE4670 -- Intro to Digital Communication with Professor Aaron Wagner. The final project required constructing the encoder and decoder (in Matlab) to send data over an existing channel (Cornell’s commcloud server). The project was done in groups of 2 and I had worked with my friend Balazs Szegletes. It was a fun learning experience, and I wanted to share the details of the project here!&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;The communication channel is effectively a DAC that outputs the results of the encoder, X, a low-pass filter, and then an ADC that samples this and sends data, Y, to the decoder. The means for sending data to the channel involves writing the data to a wav file, which is then passed as an input parameter to a program called ccplay that is provided for the class. The program handles the DAC and ADC and saves the sampled output as another wav file. The goal is to be able to push data through the channel as quick as possible with few number of bit errors. The figure of merit is computed as:&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;FOM = (min(R, 300000)*(1-N/50000)10)/max(1,400*Po)&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;Where R is the data rate defined as (100,000/(L/44100)) where L is the length of the output of the encoder&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;N is the number of bit errors&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;Po is the average transmitted power&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;The channel properties can be modeled by the Toeplitz matrix H, such that:&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;Y = HX + Z, where Z is iid (independent, identically distributed) Gaussian noise. The commcloud server has two such channels, audio0 and audio1.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;This builds on a previous lab, where orthogonal frequency division multiplexing (OFDM) is used with on/off keying to send data over the channel. This scheme achieved a data rate of about 14,000 bits per second with zero errors, resulting in a figure of merit of about 14,000. The high performance design utilizes orthogonal frequency division multiplexing (OFDM) and quadrature amplitude modulation (QAM) to achieve a figure of merit much higher than the previous lab.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;The overall OFDM system block diagram is shown below (taken from Professor Wagner’s course’s &lt;u&gt;&lt;a href=&quot;http://people.ece.cornell.edu/wagner/ece467-s16/scribe/gbk42.pdf&quot;&gt;Scribe notes&lt;/a&gt;&lt;/u&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: center;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-style: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;img src=&quot;https://lh3.googleusercontent.com/v-5VPt6DZe0ikzG9mAINAQXvBRt8l1_T-dCs1-6IveqBOW1FJc9m5pMQsLZm5ig19uLkTNj92Cbj56RiS1a-XPNiBv_QMqDAh4pnRcNKbI0s7G58Y6Fq2XE4xrubVjYURMSPILj1&quot; style=&quot;border: none; transform: rotate(0rad);&quot; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;The big gain in performance stems from the use of QAM, which allows encoding multiple bits per sample, in the complex plane. A modulation order (M) of 5 was selected for the design, ie 32-QAM. This was experimentally determined to be the optimal modulation order, which gives the highest data rate (R) before bit errors (N) start outweighing the benefits from a higher data rate.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;The encoder encodes the incoming bit-stream into frequency components and then processes it as described below before sending out its time-domain signal over the channel.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;The encoder accepts the input vector (of length 100,000) and encodes the vector using 32-QAM into 100,000/5 complex samples in a vector x. The encoder then separates x into 8 equal sized data blocks D1...D8 of length L1. The size of L1 is determined by modulation order M: L1=(100,000/(8*5)). Two training blocks, T1 and T2, each a vector consisting all 1’s and of length L1, &amp;nbsp;are inserted to create the following vector, x, of length 10L1.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr2bpsK-vCtXSugkjthg1e86jrGIPFitttw4KiWcnxI5hzj2RdY8PO6ail872OLJL2VgON_wGVopkijD_9hcdffv9rB8qjXmqk-usWyuLerM8spDiQnkXmr9R2Wszy4Z7YOH8dcaKpl_0e/s1600/data+blocks.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;30&quot; data-original-width=&quot;626&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr2bpsK-vCtXSugkjthg1e86jrGIPFitttw4KiWcnxI5hzj2RdY8PO6ail872OLJL2VgON_wGVopkijD_9hcdffv9rB8qjXmqk-usWyuLerM8spDiQnkXmr9R2Wszy4Z7YOH8dcaKpl_0e/s1600/data+blocks.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;Using a seed of 1, and Matlab’s rand function, a vector, p1, of pseudorandom phase angles (between 0 and 2 pi) is generated. These are used to create a vector p2 of phasors, where:&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;p2(i) = gamma*exp(1jp1(i)) for all i = indices of elements of p1,p2. The constant gamma sets the average power level.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;The elements of this vector are then multiplied element-wise with the elements in vector x. This is to prevent the constructive addition of several frequency components in the time domain which would cause the time-domain signal to clip or saturate.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;Each block is then prepended by NZpre zero’s. NZpost zero’s are appended to each block. Let this vector be called X. X is then padded with 0 for DC and concatenated with X*. This ensures that the time domain signal is real-valued. The inverse DFT of this is taken to get the real-valued time domain signal. Each block is prepended with a cyclic prefix (length Kc) to make the (Toeplitz) channel transformation effectively look circulant. The encoder then outputs this vector.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;The training blocks are inserted into the data vector so that it may be used at the decoder end for training of channel properties. Each element of a training block (in the frequency domain) has magnitude 1 and a phase theta_t. When this element goes through the channel, it is attenuated and incurs a phase shift and is presented to the decoder with magnitude gamma_c(attenuation of the channel) and phase (theat_t+theta_c) where theta_c is the phase added by the channel. Each frequency component has an associated attenuation and phase addition. Since the training block is the same length as any individual data block, there exists known training information about attenuation and phase for each frequency of interest in the system/encoding at the decoder end. The decoder is then able to use this block’s received data to cancel channel effects for the other blocks. However, it must be noted that the the attenuation and phase addition of the channel are not static and vary with time. Thus it is important not to let the training data be stale. This is the reason two training blocks are used, and also why they are inserted in the order they are, with respect to the data blocks.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;It was observed that placing only one training block at the beginning of the data vector allows determining channel phase reasonably well for only a couple data blocks adjacent to it. Additionally, it was noted that decreasing the number of blocks also made the prediction worse. By placing the two training blocks as they are in the vector allows using a block to cancel channel effects for two adjacent data blocks. The phase variation from the training data to the two data blocks is small enough to allow sufficiently high figure of merit. The phase variation from D1 to D4 is illustrated below:&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: center;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-style: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;img src=&quot;https://lh6.googleusercontent.com/ZSXf2jRddC_hsWmh0KM_CX_hkpmzMPvSf5QXGg725oNxVE2htHtZMSHOwWJfrauvQRcozZ2NgLcimmAXRFX7gXvu3rJSgJKtffN8LZ5EMKk1QsJKB5N6vd0ASxV63COuIn2tSg09&quot; style=&quot;border: none; transform: rotate(0rad);&quot; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;While the shift is somewhat significant, it is still possible to correctly decode the information. As can be imagined, too far from this and the bit error rate gets terrible.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;At the decoder end, synchronization is performed to determine the start of the signal. This is done by thresholding the average power level over five samples. To recover the samples encoded in the frequency domain, the decoder reverses what the encoder did, firstly ignoring the cyclic prefix, performing a DFT, dropping the flipped conjugate second half of the vector and then dropping the zero-padding. Since gamma_c*exp(1j*theta_c) is known from the training block for each of the frequency levels, the samples in D1 to D4 are divided by gamma_c*exp(1j*theta_c) from T1 to cancel the channel effects. Similarly, D5 to D8 use the channel information from T2. Finally, the pseudo-random phases added at the encoder side are removed by dividing by each of the known phases element-wise. These phases are known since the random number generator had a fixed seed of 1. The individual data blocks are then demodulated (QAM) and concatenated to each other to form the 100,000 long bit vector. For modulating and demodulating using QAM, Matlab’s inbuilt functions qammod and qamdemod are used.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;The following constants were determined to give the highest figure of merit:&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;NZpre = 110&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;NZpost = 1050&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;gamma =7.8 (chosen to meet the power constraint of 1/400)&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;Kc = 170&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;Experimentally, the figure of merit scores are about 44,000, and 56,000 for channels audio0 and audio1 respectively. The constants NZpre, NZpost, gamma, modulation order M, number of data blocks, number of training blocks, and placement of training block were all experimented with and the results presented here represent the best combination for the highest figure of merit. With only one training block, the phase drift was high enough to negate the benefits of higher data rate obtained from 32-QAM. However, adding a third training block was seen as a waste since it would minimally reduce the number of bit errors but would hurt the data rate appreciably. Using convolutional coding was considered but it was determined as not worth the effort given the performance obtained and the added complexity.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;I expect to write another post soon to discuss some technical background behind OFDM, training and synchronization. Let me know what you think and if there&#39;s something else from the project you&#39;d like me to cover in more detail!&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/8121644748708943110/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2017/06/a-digital-communication-project-using.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/8121644748708943110'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/8121644748708943110'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2017/06/a-digital-communication-project-using.html' title='A digital communication project using OFDM and 32-QAM'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh3.googleusercontent.com/v-5VPt6DZe0ikzG9mAINAQXvBRt8l1_T-dCs1-6IveqBOW1FJc9m5pMQsLZm5ig19uLkTNj92Cbj56RiS1a-XPNiBv_QMqDAh4pnRcNKbI0s7G58Y6Fq2XE4xrubVjYURMSPILj1=s72-c" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-8756460238973315289</id><published>2016-12-16T09:24:00.002-08:00</published><updated>2016-12-16T09:50:45.089-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="4999"/><category scheme="http://www.blogger.com/atom/ns#" term="Cornell"/><category scheme="http://www.blogger.com/atom/ns#" term="ECE"/><category scheme="http://www.blogger.com/atom/ns#" term="ICSP"/><category scheme="http://www.blogger.com/atom/ns#" term="JTAG"/><category scheme="http://www.blogger.com/atom/ns#" term="loader"/><category scheme="http://www.blogger.com/atom/ns#" term="Microchip"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32"/><category scheme="http://www.blogger.com/atom/ns#" term="programmer"/><title type='text'>PIC32 JTAG Loader / ICSP programmer</title><content type='html'>This past semester, I worked on an independent study/project where I explored the programming of the PIC32. I&#39;ve provided the details in the following PDF document. The key takeaway I believe is:&lt;br /&gt;
&lt;br /&gt;
&quot;This document presents sufficient
background information on the project, and implementation specific details. The
most important contribution this makes is adding the experiences and a full implementation
of the project. For even more detail and a thorough understanding, it is
recommended that this report be read along with the reference documents
mentioned in Section 4.1.&quot;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: justify;&quot;&gt;
I plan on improving this, as well as exploring the option of programming other PICs this summer. A cursory look made me think that the PIC32 programming standard was more complicated than the PIC16&#39;s. I&#39;ll find out!&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: justify;&quot;&gt;
All the project code and settings can be found &lt;a href=&quot;https://drive.google.com/open?id=0B4SoPFPRNziHeUhXQlZSRWxyeW8&quot;&gt;&lt;u&gt;here&lt;/u&gt;&lt;/a&gt;. This includes the PIC32 project, as well as the MATLAB code for the programmer software &lt;br /&gt;
&lt;a href=&quot;https://drive.google.com/open?id=0B4SoPFPRNziHeUhXQlZSRWxyeW8&quot;&gt;&lt;u&gt;https://drive.google.com/open?id=0B4SoPFPRNziHeUhXQlZSRWxyeW8&lt;/u&gt;&lt;/a&gt; &lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: justify;&quot;&gt;
Please let me know if you have any comments or feedback!&lt;/div&gt;
&lt;br /&gt;
&lt;iframe height=&quot;480&quot; src=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHR0dpc0Z4SkZINnM/preview&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/8756460238973315289/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2016/12/pic32-jtag-loader-icsp-programmer.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/8756460238973315289'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/8756460238973315289'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2016/12/pic32-jtag-loader-icsp-programmer.html' title='PIC32 JTAG Loader / ICSP programmer'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-3709014679171617573</id><published>2016-02-06T15:49:00.002-08:00</published><updated>2016-02-06T15:50:38.483-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IR"/><category scheme="http://www.blogger.com/atom/ns#" term="Keypad"/><category scheme="http://www.blogger.com/atom/ns#" term="NEC"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC16F684"/><category scheme="http://www.blogger.com/atom/ns#" term="RC5"/><category scheme="http://www.blogger.com/atom/ns#" term="RC6"/><category scheme="http://www.blogger.com/atom/ns#" term="SIRC"/><title type='text'>Creating my own TV Tuner IR remote with a PIC16F684</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNnxhaKiVq4hJU0qwiJp3VJJJSM4DYUfcnDlDgSASgK6N2nvCDxLf5I065bTpl0M6O7pcK5ukoNmCwuY_djXIs2m3kmUDqjahsm_0IYhYIGchWwTVpXK7fG8ayRujeiSdP9NaYL3fgMLjO/s1600/DSC_0425.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNnxhaKiVq4hJU0qwiJp3VJJJSM4DYUfcnDlDgSASgK6N2nvCDxLf5I065bTpl0M6O7pcK5ukoNmCwuY_djXIs2m3kmUDqjahsm_0IYhYIGchWwTVpXK7fG8ayRujeiSdP9NaYL3fgMLjO/s640/DSC_0425.jpg&quot; width=&quot;243&quot; /&gt;&lt;/a&gt; &lt;/div&gt;
&lt;br /&gt;
While I was home this winter, I saw that the remote for our TV tuner was damaged physically, causing the buttons to not function responsively. Some of them just didn&#39;t work. I saw this as an opportunity for a fun couple days&#39; project to build a new remote controller for the tuner.&lt;br /&gt;
&lt;br /&gt;
The TV tuner was manufactured by a brand name RealView and, as expected, I couldn&#39;t find much detail about it. Thus, I had to reverse engineer the remote. From my previous experience in working with IR remotes, I had a hunch that the IR was most likely modulated at ~38kHz or ~56kHz. For those of you who don&#39;t know how this works, I highly recommend going through this website: &lt;a href=&quot;http://www.sbprojects.com/knowledge/ir/&quot;&gt;&lt;u&gt;http://www.sbprojects.com/knowledge/ir/&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Thus, I connected a 38kHz IR receiver I had at home (TSOP1738) to an oscilloscope in order to figure out what IR protocol is used by the remote. Upon pressing the 4 key on the remote, I saw the following waveform:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9jOl8eKPCS_HO-bGdWNz9NNeTI5TrMDhPdRaNhzgl1YWD7Y8wXFV0yYNCB7NrBz574z7uBt0k4cQ3bB9xBE1r5a_CslaexGmNrpyeIsUOQ9xvj7g77KRXrVvvguu5QNybRVmlPC9Bgzcc/s1600/20141221_601403.bmp&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9jOl8eKPCS_HO-bGdWNz9NNeTI5TrMDhPdRaNhzgl1YWD7Y8wXFV0yYNCB7NrBz574z7uBt0k4cQ3bB9xBE1r5a_CslaexGmNrpyeIsUOQ9xvj7g77KRXrVvvguu5QNybRVmlPC9Bgzcc/s640/20141221_601403.bmp&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;b&gt;Fig. 1: &lt;/b&gt;Oscilloscope waveform capture of the received IR signal &lt;/div&gt;
&lt;br /&gt;
Note that I inverted the signal on the oscilloscope since the IR receiver output is active-low.&lt;br /&gt;
&lt;br /&gt;
I then compared the waveform to some of the common IR protocols, paying particular attention to the initial first high and low states. After going through SIRC, RC5, RC6 among others, I noticed that this matched the NEC protocol: &lt;a href=&quot;http://www.sbprojects.com/knowledge/ir/nec.php&quot;&gt;&lt;u&gt;http://www.sbprojects.com/knowledge/ir/nec.php&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_qq2odtsDG3p0b6K2gLfwLUGso-Cjq9uYUAtT6X_n1sTNQU_9kPektHSyTdVPWksGjhCzd879UP2X7ZRwQqULKd27Elm95tzBiIaGiRqh9DniD1MrjgAhjXEldYuBUFllnESu34zghJAG/s1600/nectrain.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_qq2odtsDG3p0b6K2gLfwLUGso-Cjq9uYUAtT6X_n1sTNQU_9kPektHSyTdVPWksGjhCzd879UP2X7ZRwQqULKd27Elm95tzBiIaGiRqh9DniD1MrjgAhjXEldYuBUFllnESu34zghJAG/s1600/nectrain.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;b&gt;Fig. 2: &lt;/b&gt;Standard NEC IR protocol pulse train&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTrB-e3qXLJm66unVcdO7846AWQRhVfBHRkQlhaGcXRaHYH4_UEcYPPZMAiHLd_3CuebobiNoJcBeIm7ct_vcGY-iIkuxgzywo7WSw4FzTYTbvGhRVunqsA4TWT1FltfIfMhHLZYA4-N7S/s1600/necmodulation.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTrB-e3qXLJm66unVcdO7846AWQRhVfBHRkQlhaGcXRaHYH4_UEcYPPZMAiHLd_3CuebobiNoJcBeIm7ct_vcGY-iIkuxgzywo7WSw4FzTYTbvGhRVunqsA4TWT1FltfIfMhHLZYA4-N7S/s1600/necmodulation.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;b&gt;Fig. 3: &lt;/b&gt;NEC IR protocol logic high and logic low signals&lt;/div&gt;
&lt;br /&gt;
Using the waveform shown above, I found that ~address was not being sent, meaning that the extended NEC protocol was being used:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil_U4Tu3Hh3KFDLo3wz0VBjG5bEWuqciC1ALbjC1oIibbWQvqPdE1wRwWyAW8IthmH-5uPfNFNalVg09r91WKtH0-RFpLb0shcDGxUzsJoSyXWrWG0FoB1I7jMnPr6hidUc8Qym-gO4Eoq/s1600/necexttrain.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil_U4Tu3Hh3KFDLo3wz0VBjG5bEWuqciC1ALbjC1oIibbWQvqPdE1wRwWyAW8IthmH-5uPfNFNalVg09r91WKtH0-RFpLb0shcDGxUzsJoSyXWrWG0FoB1I7jMnPr6hidUc8Qym-gO4Eoq/s1600/necexttrain.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;b&gt;Fig. 4: &lt;/b&gt;Extended NEC IR protocol pulse train&lt;/div&gt;
&lt;br /&gt;
From the waveform, I found that the address was 0xBD02. I then proceeded to make a simple decoder with a PIC16F877A since I had a development board with an IR sensor mounted on it. Using this, I found all the required commands for the different keys of the remote. I decided to exclude some of the keys that were never used (eg play, pause, stop, fast forward, rewind).&lt;br /&gt;
You can find this part of the project here:&lt;br /&gt;
&lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHZjk2N3pNLVE5V1E/view?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHZjk2N3pNLVE5V1E/view?usp=sharing&lt;/u&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
This left me with the following keys and commands:&lt;br /&gt;
&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;&lt;!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--&gt;&lt;/style&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; dir=&quot;ltr&quot; style=&quot;border-collapse: collapse; border: 1px solid #ccc; font-family: arial,sans,sans-serif; font-size: 13px; table-layout: fixed;&quot;&gt;&lt;colgroup&gt;&lt;col width=&quot;138&quot;&gt;&lt;/col&gt;&lt;col width=&quot;100&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody align=&quot;center&quot;&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,2,&amp;quot;Key&amp;quot;]&quot; style=&quot;font-weight: bold; padding: 2px 3px; vertical-align: bottom;&quot;&gt;Key&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,2,&amp;quot;Command&amp;quot;]&quot; style=&quot;font-weight: bold; padding: 2px 3px; vertical-align: bottom;&quot;&gt;Command&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,3,null,0]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;0&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,9]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;9&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,3,null,1]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;1&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,0]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;0&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,3,null,2]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;2&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,1]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;1&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,3,null,3]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;3&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,2]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;2&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,3,null,4]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;4&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,3]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;3&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,3,null,5]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;5&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,4]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;4&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,3,null,6]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;6&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,5]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;5&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,3,null,7]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;7&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,6]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;6&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,3,null,8]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;8&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,7]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;7&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,3,null,9]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;9&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,8]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;8&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,2,&amp;quot;UP&amp;quot;]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;UP&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,18]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;18&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,2,&amp;quot;DOWN&amp;quot;]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;DOWN&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,19]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;19&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,2,&amp;quot;RIGHT&amp;quot;]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;RIGHT&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,16]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;16&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,2,&amp;quot;LEFT&amp;quot;]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;LEFT&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,17]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;17&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,2,&amp;quot;PREVIOUS CHANNEL&amp;quot;]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;PREVIOUS CHANNEL&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,13]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;13&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,2,&amp;quot;-/--&amp;quot;]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;-/--&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,10]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;10&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,2,&amp;quot;POWER&amp;quot;]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;POWER&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,20]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;20&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,2,&amp;quot;MENU&amp;quot;]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;MENU&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,21]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;21&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 21px;&quot;&gt;&lt;td data-sheets-value=&quot;[null,2,&amp;quot;MUTE&amp;quot;]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;MUTE&lt;/td&gt;&lt;td data-sheets-value=&quot;[null,3,null,12]&quot; style=&quot;padding: 2px 3px; vertical-align: bottom;&quot;&gt;12&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
I then proceeded to write an IR transmitter using the PIC16F684 (using the MPLAB X IDE and XC8 compiler), following the timing information from the extended NEC protocol. In order to connect all the keys, I connected them in matrix keypad form.&lt;br /&gt;
&lt;br /&gt;
In order to power the remote off 2xAA batteries, it is necessary to use sleep mode - otherwise the battery will be drained extremely quickly. So, in order to detect when a button is pressed, an interrupt is used. After the IR command is sent, the microcontroller goes to sleep. The interrupt wakes up the microcontroller when a button is pressed. Debouncing is achieved using simple software delays. When a button is held down, the NEC command repeat sequence is not sent. Instead, the remote relies on releasing the button and pressing it again.&lt;br /&gt;
&lt;br /&gt;
To minimize leakage current through the input capacitor, I decided not to use an electrolytic capacitor. A red LED illuminates to confirm that a button has been pressed.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdHcZRQWOf6SnxvIvd7zMohX-5y1eS6y6Y9ml11Ea-7Zpv3BmfA0s0wqDxStT6PUQt9rE5CCkOCeKFL8m25x9ZxD-eicxsY_tKFWKLMc6fZuLDo6l3OJb0d1EFG1Zz_zIrfY_8TENUjpZb/s1600/sch684.BMP&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;356&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdHcZRQWOf6SnxvIvd7zMohX-5y1eS6y6Y9ml11Ea-7Zpv3BmfA0s0wqDxStT6PUQt9rE5CCkOCeKFL8m25x9ZxD-eicxsY_tKFWKLMc6fZuLDo6l3OJb0d1EFG1Zz_zIrfY_8TENUjpZb/s640/sch684.BMP&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&amp;nbsp;&lt;b&gt;Fig. 5: &lt;/b&gt;Schematic of IR remote design&lt;/div&gt;
&lt;br /&gt;
Everything was put together, a PCB was designed and when tested with the TV tuner, everything worked as expected! I measured the sleep current with a portable DMM and it was read as 1.6μA! I&#39;m not sure how accurate the DMM is at such low currents, so I wouldn&#39;t entirely trust this number - however, it does seem to be within spec for the PIC16F684.&lt;br /&gt;
&lt;br /&gt;
Due to a lack of time, I had to put the remote together with electric tape! Here you can see pictures of the final design:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTlZgNRHBcXcZFdCeES9q_kQSj8orj4OIEM9gwxsXurqXsK73C4F822G4sY4IkRDq6Bf4xd6LD4OIdQyD-cXXZI5_12a0oSWSqumiFLpQ41oHMF83jZnZxs3I5S3KwEXm4RB9ckHv3ALbh/s1600/DSC_0427.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTlZgNRHBcXcZFdCeES9q_kQSj8orj4OIEM9gwxsXurqXsK73C4F822G4sY4IkRDq6Bf4xd6LD4OIdQyD-cXXZI5_12a0oSWSqumiFLpQ41oHMF83jZnZxs3I5S3KwEXm4RB9ckHv3ALbh/s400/DSC_0427.jpg&quot; width=&quot;171&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;b&gt;Fig. 6: &lt;/b&gt;Final IR remote, top&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtr1LaETlkgQs2XkJwYei6oJvedVrGdKs0Hd4hqdZlvS5kOEEZWNIK6AVRxIQrT_my6ZADRi2my7FibLVMWsmZRP7apX0afllL7EPzACBqLcy1VViIBwTBWlqIyqfK86HS-E8VrxrPcbqg/s1600/DSC_0428.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtr1LaETlkgQs2XkJwYei6oJvedVrGdKs0Hd4hqdZlvS5kOEEZWNIK6AVRxIQrT_my6ZADRi2my7FibLVMWsmZRP7apX0afllL7EPzACBqLcy1VViIBwTBWlqIyqfK86HS-E8VrxrPcbqg/s400/DSC_0428.jpg&quot; width=&quot;195&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&amp;nbsp;&lt;b&gt;Fig. 7: &lt;/b&gt;Final IR remote, bottom&lt;/div&gt;
&lt;br /&gt;
I am back at college now, but I have been told that the same set of batteries are still working on the remote, and it is working perfectly fine!&lt;br /&gt;
&lt;br /&gt;
You can find the MPLABX project, source code, schematic and pcb files all here:&lt;br /&gt;
&lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHV2I1U1Bldm1OYUE/view?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHV2I1U1Bldm1OYUE/view?usp=sharing&lt;/u&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
Let me know what you think! If you have any questions, let me know in the comments section!</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/3709014679171617573/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2016/02/creating-my-own-tv-tuner-ir-remote-with.html#comment-form' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/3709014679171617573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/3709014679171617573'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2016/02/creating-my-own-tv-tuner-ir-remote-with.html' title='Creating my own TV Tuner IR remote with a PIC16F684'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNnxhaKiVq4hJU0qwiJp3VJJJSM4DYUfcnDlDgSASgK6N2nvCDxLf5I065bTpl0M6O7pcK5ukoNmCwuY_djXIs2m3kmUDqjahsm_0IYhYIGchWwTVpXK7fG8ayRujeiSdP9NaYL3fgMLjO/s72-c/DSC_0425.jpg" height="72" width="72"/><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-8322202345544493114</id><published>2015-12-28T04:41:00.001-08:00</published><updated>2015-12-28T05:30:12.606-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Device"/><category scheme="http://www.blogger.com/atom/ns#" term="Edison"/><category scheme="http://www.blogger.com/atom/ns#" term="embedded"/><category scheme="http://www.blogger.com/atom/ns#" term="event2"/><category scheme="http://www.blogger.com/atom/ns#" term="Intel"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Mouse"/><category scheme="http://www.blogger.com/atom/ns#" term="USB"/><category scheme="http://www.blogger.com/atom/ns#" term="Yocto"/><title type='text'>Using an input device on Embedded Linux: An example with a USB mouse on the Intel Edison</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3o5hB8d8dg1pCQIgP62lDTMnnZ8v0b_1f0MiC068l7SeW3q54hLeCmVXRhGjziSGP3BDLk7OruUpDjNKiDvsavFHDwhme0HSSBrSTzNHntgP0I8lpZpPVJ2-0y4Bhm3ydssA6EIiPHFh_/s1600/edison.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3o5hB8d8dg1pCQIgP62lDTMnnZ8v0b_1f0MiC068l7SeW3q54hLeCmVXRhGjziSGP3BDLk7OruUpDjNKiDvsavFHDwhme0HSSBrSTzNHntgP0I8lpZpPVJ2-0y4Bhm3ydssA6EIiPHFh_/s640/edison.jpg&quot; width=&quot;638&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
The Intel Edison test board, along with the USB mouse&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
I have recently been using the Intel Edison for the Cornell robotics project team (which co-hosts the Intel-Cornell Cup USA competition). Building on my previous knowledge of embedded systems, I started learning to use and program on Linux. The distro used is Yocto (all information is available on the Intel Edison website).&lt;br /&gt;
&lt;br /&gt;
One of the prototypes we worked on relied on using a wireless Playstation 4 controller for locomotion user interface. The concept of using an input device on Linux is not complicated, but can be a daunting task for someone new to Linux programming. Hence, I have decided to write this article giving an example of using an input device on an Embedded Linux platform. This demo application I am showing uses a USB mouse as the input device connected to the Intel Edison.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Prerequisite:&lt;/b&gt;&lt;/u&gt; I have assumed that you have a flashed Intel Edison board, know how to access the terminal (through the USB COM port, or through SSH) and have the Eclipse IDE installed and can program with it. Of course, if you don&#39;t have the IDE, you can compile the code through the terminal and I&#39;ll tell you how to do it at the end. If you are using a platform other than the Edison, details may change but the general idea is similar. Additionally, it is assumed that you have a basic understanding of C programming.&lt;br /&gt;
&lt;br /&gt;
First thing to note when you connect the USB mouse is that the switch on
 the board (labelled SW1) must be switched towards the USB-A connector 
from the default position facing the microUSB port.&lt;br /&gt;
&lt;br /&gt;
The device drivers in Linux abstract away the low-level nitty gritty details of the interface with the input device, presenting an input through file descriptors that can be interfaced with as files. The input devices can be viewed and read from in the Linux environment just like files, as mentioned before. The input device appears in the &lt;b&gt;/dev/input&lt;/b&gt; directory. Initially, before the mouse is plugged in, you can see that there is an event0 and an event1 file. Upon connecting the mouse, you can see an event2 file.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwpmhsMRU7aR8geCu8KzemUO3ct3X3T-NgP_3T2HxM20GQNm1550FeOtd5XRzdjXWXx3HRSN6NBculz9VQzt1tFJZAPuWioeqTPHmGGQ3mazPQsOTKgxVK8KAIan7u_nWK1We5EjqPGjbD/s1600/input+without+mouse.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwpmhsMRU7aR8geCu8KzemUO3ct3X3T-NgP_3T2HxM20GQNm1550FeOtd5XRzdjXWXx3HRSN6NBculz9VQzt1tFJZAPuWioeqTPHmGGQ3mazPQsOTKgxVK8KAIan7u_nWK1We5EjqPGjbD/s1600/input+without+mouse.png&quot; /&gt;&lt;/a&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;b&gt;Fig. 1:&lt;/b&gt; Input device files without mouse connected&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAqae-p0Hggmga0-Bq8EH2ARJKgICExPw2gk-4x4srGGn2wJ81LBOAR2vl-KGbxDM23yP48Nm63WSi9CMYcOxAXuK-cNfU_6SCvVpi19M83s4WJHd4rOzBFAqpAor1IcddTXnm1JsPT9mM/s1600/input+with+mouse.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;92&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAqae-p0Hggmga0-Bq8EH2ARJKgICExPw2gk-4x4srGGn2wJ81LBOAR2vl-KGbxDM23yP48Nm63WSi9CMYcOxAXuK-cNfU_6SCvVpi19M83s4WJHd4rOzBFAqpAor1IcddTXnm1JsPT9mM/s320/input+with+mouse.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;b&gt;Fig. 2:&lt;/b&gt; Input device files with mouse connected&lt;/div&gt;
&lt;br /&gt;
By reading the event2 file, you can read the mouse data. To dump data from the file, you can use the &lt;b&gt;od&lt;/b&gt; command (man page: &lt;a href=&quot;http://man7.org/linux/man-pages/man1/od.1.html&quot;&gt;&lt;u&gt;http://man7.org/linux/man-pages/man1/od.1.html&lt;/u&gt;&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
For example, to view the output dump in hex format:&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;od -x event2&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Move the mouse around, press the buttons, scroll the wheel and you&#39;ll see data appear on the console:&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJKs4KV9jDkmh5T7DY_BFsXFlApNsGg_M_5hYoNI5lXv6Z_MIkjvACC7n4gNZn8FHiHh6CxeOrL0Se59iRgQYsu1wDbyPwSwIPAE3lKffsqU7El1m_8AuHBBnAJz7x66sPL3U5fi3IvSBn/s1600/file+data+dump.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJKs4KV9jDkmh5T7DY_BFsXFlApNsGg_M_5hYoNI5lXv6Z_MIkjvACC7n4gNZn8FHiHh6CxeOrL0Se59iRgQYsu1wDbyPwSwIPAE3lKffsqU7El1m_8AuHBBnAJz7x66sPL3U5fi3IvSBn/s1600/file+data+dump.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;b&gt;Fig. 3:&lt;/b&gt; File event2 data dump using od command&lt;/div&gt;
&lt;br /&gt;
Hit Ctrl+C when you&#39;re satisfied you&#39;ve seen enough of the dump.&lt;br /&gt;
&lt;br /&gt;
Now to make sense of this input, decipher it and meaningfully use it, I have written a simple C application. I&#39;ll walk you through the process of developing it before I provide the code.&lt;br /&gt;
&lt;br /&gt;
First thing to do is to go through these references as part of the kernel documentation:&lt;br /&gt;
&lt;a href=&quot;https://www.kernel.org/doc/Documentation/input/event-codes.txt&quot;&gt;&lt;u&gt;https://www.kernel.org/doc/Documentation/input/event-codes.txt&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.kernel.org/doc/Documentation/input/input.txt&quot;&gt;&lt;u&gt;https://www.kernel.org/doc/Documentation/input/input.txt&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Additionally, you should go through the linux/input.h header file. You can find a copy here:&lt;br /&gt;
&lt;a href=&quot;http://lxr.free-electrons.com/source/include/linux/input.h?v=2.6.38&quot;&gt;&lt;u&gt;http://lxr.free-electrons.com/source/include/linux/input.h?v=2.6.38&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
You can also type it into Eclipse, hit Ctrl on your keypad and left mouse click on the header file name to view the file itself.&lt;br /&gt;
&lt;br /&gt;
From the kernel documentation and the input.h file, you should find that the data output happens such that every time an event occurs, it can be &quot;fit&quot; into the following structure (defined in linux/input.h):&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;struct input_event {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; struct timeval time;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __u16 type;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __u16 code;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __s32 value;&lt;br /&gt;};&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
You can find that this has a total length of 16 bytes. You can look through the different data types and add, and confirm using the sizeof function in Eclipse:&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;fprintf(stdout, &quot;Size of event is: %d\n&quot;, sizeof(event));&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Each event has a timestamp, type, code and value as you can guess from the input structure. Additionally events are separated by EV_SYN type events which are just markers. EV_SYN is defined as 0.&lt;br /&gt;
&lt;br /&gt;
You can read the file in a C program and then just print out the values separated as fields in the input event structure to confirm that and observe the different types of data as you interact with the mouse. You can limit the type of event as you interact with your mouse. To understand the meaning of the numbers you receive, peruse the linux/input.h file and the kernel documentation linked above. You will see a section describing the events:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;/*&lt;br /&gt;&amp;nbsp;* Event types&lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define EV_SYN&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00&lt;br /&gt;#define EV_KEY&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x01&lt;br /&gt;#define EV_REL&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x02&lt;br /&gt;#define EV_ABS&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x03&lt;br /&gt;#define EV_MSC&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x04&lt;br /&gt;#define EV_SW&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x05&lt;br /&gt;#define EV_LED&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x11&lt;br /&gt;#define EV_SND&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x12&lt;br /&gt;#define EV_REP&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x14&lt;br /&gt;#define EV_FF&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x15&lt;br /&gt;#define EV_PWR&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x16&lt;br /&gt;#define EV_FF_STATUS&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 0x17&lt;br /&gt;#define EV_MAX&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x1f&lt;br /&gt;#define EV_CNT&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (EV_MAX+1)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
You can also find a section describing the different keys/buttons for a keyboard, gamepad, mouse, etc. The section describing the mouse is:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define BTN_MOUSE&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 0x110&lt;br /&gt;#define BTN_LEFT&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x110&lt;br /&gt;#define BTN_RIGHT&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 0x111&lt;br /&gt;#define BTN_MIDDLE&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 0x112&lt;br /&gt;#define BTN_SIDE&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x113&lt;br /&gt;#define BTN_EXTRA&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 0x114&lt;br /&gt;#define BTN_FORWARD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x115&lt;br /&gt;#define BTN_BACK&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x116&lt;br /&gt;#define BTN_TASK&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x117&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;/*&lt;br /&gt;&amp;nbsp;* Relative axes&lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;&lt;br /&gt;#define REL_X&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00&lt;br /&gt;#define REL_Y&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x01&lt;br /&gt;#define REL_Z&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x02&lt;br /&gt;#define REL_RX&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 0x03&lt;br /&gt;#define REL_RY&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 0x04&lt;br /&gt;#define REL_RZ&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 0x05&lt;br /&gt;#define REL_HWHEEL&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 0x06&lt;br /&gt;#define REL_DIAL&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x07&lt;br /&gt;#define REL_WHEEL&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0x08&lt;br /&gt;#define REL_MISC&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x09&lt;br /&gt;#define REL_MAX&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 0x0f&lt;br /&gt;#define REL_CNT&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; (REL_MAX+1) &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
You can compare these against the values you see to see if they make sense (they should!). Then, you can proceed to mold this to read the different codes, types and values based on these. This is what I have done in my demo application, which should be commented enough for you to understand. (Obviously, if you have questions, let me know in the comments section!)&lt;br /&gt;
&lt;br /&gt;
One last thing that I haven&#39;t covered yet (but you may already know) is how to do the file read. I have used the low-level file IO functions &lt;b&gt;open &lt;/b&gt;and &lt;b&gt;read&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Opening the file:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;// Use low-level Linux file IO operations&lt;br /&gt;// Device is presented as a file, event2 in /dev/input for the Edison&lt;br /&gt;int fid = open(&quot;/dev/input/event2&quot;, O_RDONLY);&lt;br /&gt;if (fid == 0){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(stderr, &quot;Could not open event2 device!\n&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return EXIT_FAILURE;&lt;br /&gt;}&lt;br /&gt;fprintf(stdout, &quot;Opened event2 device!\n&quot;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;u&gt;&lt;b&gt;Reading the file:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;int nbytes;&lt;br /&gt;struct input_event event; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;// Event type from &amp;lt;linux/input.h&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;nbytes = read(fid, &amp;amp;event, sizeof(event));&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The demo application prints out messages describing mouse motion, wheel motion and left, middle (wheel) and right button presses. See Fig. 4 below.&lt;br /&gt;
&lt;br /&gt;
You can find the full code for my demo project here: &lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHUUVCRHVPNjkwZ2s/view?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHUUVCRHVPNjkwZ2s/view?usp=sharing&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
A typical output is shown below:&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYUYvAFvY_ZhGNgHEbocSQB7pPKkxb16d6IXmg57ziMP66qtz69Zr0Ly1udwUwFSXYj71JH4_BMJtjWCKf9niTdGTFIToYCyoRz7k6YA0cF7lo3n_06_9405jkEJYPmOWomN1JJ4_CI5Pd/s1600/demo+project+output.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYUYvAFvY_ZhGNgHEbocSQB7pPKkxb16d6IXmg57ziMP66qtz69Zr0Ly1udwUwFSXYj71JH4_BMJtjWCKf9niTdGTFIToYCyoRz7k6YA0cF7lo3n_06_9405jkEJYPmOWomN1JJ4_CI5Pd/s1600/demo+project+output.png&quot; /&gt;&lt;/a&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;b&gt;Fig. 4:&lt;/b&gt; Output of the demo application&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Programming without the Eclipse IDE:&lt;/b&gt;&lt;/u&gt; As I have mentioned before, even if you don&#39;t have the Eclipse IDE (which you should get), you can still program the Edison. Here are a few ways you can do so. You can copy-paste the code from a text editor to the terminal (using PuTTY, mouse right-click is paste), or even write the code on the terminal. Additionally, you can use a program such as WinSCP to transfer a C file. Be careful with Windows files since lines end in a newline and a carriage return character, whereas on Linux, they end with only a newline character. The carriage return character will be displayed as ^M if you open the file with the text editor. Once the file is on the Edison file system somewhere, cd into that folder and compile it:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;gcc -o &amp;lt;output name&amp;gt; &amp;lt;source file name&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;eg: &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;gcc -o mouse mouse.c&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Then you can run it:&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;&quot;&gt;eg:&lt;/span&gt; &lt;span style=&quot;font-size: small;&quot;&gt;./mouse&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I have attempted to make the code self-explanatory and provide 
sufficient background detail here for you to understand what&#39;s going on.
 By changing the code and type checks, you can extend this to other devices. Hopefully you&#39;ll find this useful! Let me know what you think!</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/8322202345544493114/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2015/12/using-input-device-on-embedded-linux.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/8322202345544493114'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/8322202345544493114'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2015/12/using-input-device-on-embedded-linux.html' title='Using an input device on Embedded Linux: An example with a USB mouse on the Intel Edison'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3o5hB8d8dg1pCQIgP62lDTMnnZ8v0b_1f0MiC068l7SeW3q54hLeCmVXRhGjziSGP3BDLk7OruUpDjNKiDvsavFHDwhme0HSSBrSTzNHntgP0I8lpZpPVJ2-0y4Bhm3ydssA6EIiPHFh_/s72-c/edison.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-6137120464140801209</id><published>2015-08-02T13:04:00.000-07:00</published><updated>2015-08-02T19:31:50.215-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LCD"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32MX"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32MX250F128B"/><category scheme="http://www.blogger.com/atom/ns#" term="Protothreads"/><category scheme="http://www.blogger.com/atom/ns#" term="TFT"/><category scheme="http://www.blogger.com/atom/ns#" term="threading"/><category scheme="http://www.blogger.com/atom/ns#" term="touch screen"/><title type='text'>PIC32 Tic-Tac-Toe: Demonstration of using touch-screen, TFT and the Protothreads threading library</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbOBKyipPU7tPOwI4EImOgJm9IGSAXPLKmZuEpu4O9-SylMJI7wQI_xNyhFVkzNAuH5bPaTZAPsiSqQKyvZKd6S-OxFexiAvA1mg8DU738For8YoXewGpjRxNnN_sAv3kV942iokIns5y3/s1600/2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbOBKyipPU7tPOwI4EImOgJm9IGSAXPLKmZuEpu4O9-SylMJI7wQI_xNyhFVkzNAuH5bPaTZAPsiSqQKyvZKd6S-OxFexiAvA1mg8DU738For8YoXewGpjRxNnN_sAv3kV942iokIns5y3/s320/2.jpg&quot; width=&quot;228&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8H-AnStuy4LFV-Amcq5c2gNHU06VA3sgT4VrsQcFIGtGMYFPbKohIHQkMQhpXxNeBCABJl_VCCXpv_Cg6dBCi2NxBYtjBQn8ybTw4sduflPDPXmjOg9E2b2lp4LCEWlYUvaLnTlZZ9uQq/s1600/4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8H-AnStuy4LFV-Amcq5c2gNHU06VA3sgT4VrsQcFIGtGMYFPbKohIHQkMQhpXxNeBCABJl_VCCXpv_Cg6dBCi2NxBYtjBQn8ybTw4sduflPDPXmjOg9E2b2lp4LCEWlYUvaLnTlZZ9uQq/s320/4.jpg&quot; width=&quot;247&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
I had previously used the Adafruit TFT display using my 
library (ported from the Adafruit Arduino library). I decided to 
optimize the library to improve drawing speed. The same
 display I use comes with a 4-wire resistive touch-screen as well. I 
decided to write a simple library for the touch-screen and give
&lt;a href=&quot;http://dunkels.com/adam/pt/&quot;&gt;&lt;u&gt;Protothreads &lt;/u&gt;&lt;/a&gt;a try. To incorporate all this, I thought it would be cool 
if I used these to make a simple game. Tic-tac-toe came to mind as a fun 
little demo.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&#39;m sure everyone&#39;s familiar with the game
 so I won&#39;t explain the rules there. The touch-screen is simply two 
resistive sheets placed on top of each other on top of the TFT screen. 
When it is pressed down at a given place, the two sheets make contact 
and a voltage divider is formed. Using the IO&#39;s and the ADC, this 
voltage is read in the X and Y directions to register a touch.&lt;br /&gt;
&lt;br /&gt;
Here is a very good pictorial depiction of the resistive touch screen (taken from the &lt;a href=&quot;http://www.atmel.com/Images/doc8091.pdf&quot;&gt;&lt;u&gt;Atmel AVR341 document&lt;/u&gt;&lt;/a&gt;):&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxFki1vOJPN9kWR1z373NX5DurXpB6goS082o24cmnDEw8itmb3HYHwEnnXPI4ysyg89vxAtyiqF0mqy1AKb6g8A1ecEtkgdo-h_WOD1wiUzHTnoCaRLk4JpWb8CxcMcbMgU8_7MbMN9BQ/s1600/atmel+touch+screen.PNG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;269&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxFki1vOJPN9kWR1z373NX5DurXpB6goS082o24cmnDEw8itmb3HYHwEnnXPI4ysyg89vxAtyiqF0mqy1AKb6g8A1ecEtkgdo-h_WOD1wiUzHTnoCaRLk4JpWb8CxcMcbMgU8_7MbMN9BQ/s320/atmel+touch+screen.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So
 in order to read the touch, the X+ and X- points are applied power, and
 one of Y+ or Y- is read to read the x-coordinate. Then Y+ and Y- are 
applied power and one of X+ or X- is read to read the y-coordinate. X+, 
X-, Y+ and Y- are connected to four GPIO pins on the PIC32 that are 
configured to outputs when driving the touch-screen and analog inputs 
when reading. Every time the IO pin switches state, a long delay is 
provided to allow the outputs to stabilize. Alternately, the ADC is 
significantly slowed down to negate effects of capacitive charging by 
high source impedance. The library is written in the form of a simple 
state machine cycling through its states every few milliseconds, decided
 by the application calling the library functions. In my application, I 
use 5 milliseconds.&lt;br /&gt;
&lt;br /&gt;
To organize the game, I&#39;ve made use of the Protothreads threading library. &lt;a href=&quot;http://dunkels.com/adam/pt/&quot;&gt;Protothreads&lt;/a&gt;
 is a very light-weight, stackless, threading library written entirely 
as C macros by Adam Dunkels. Bruce Land has ported Protothreads over for
 the PIC32. You can find more details on his excellent site: &lt;a href=&quot;http://people.ece.cornell.edu/land/courses/ece4760//PIC32/index_Protothreads.html&quot;&gt;&lt;u&gt;http://people.ece.cornell.edu/land/courses/ece4760//PIC32/index_Protothreads.html&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
There
 are two main executing threads, one is the main game thread and the 
other is a clock thread that keeps track of, and displays, time since 
the program was started. There is a third thread used to retrieve touch 
information. It is spawned by the main game thread when touch input is 
required. The main Protothreads functions (macros) I&#39;ve 
made use of are:&lt;br /&gt;
&lt;br /&gt;
PT_setup()&lt;br /&gt;
PT_INIT()&lt;br /&gt;
PT_SCHEDULE()&lt;br /&gt;
PT_SPAWN()&lt;br /&gt;
PT_WAIT_UNTIL()&lt;br /&gt;
PT_YIELD_TIME_msec()&lt;br /&gt;
PT_GET_TIME()&lt;br /&gt;
&lt;br /&gt;
Pin connections:&lt;br /&gt;
&lt;br /&gt;
BL (backlight): I left it unconnected, but you can connect it to 3.3V for backlight.&lt;br /&gt;
SCK: connected to RB14 on the PIC&lt;br /&gt;
MISO: left unconnected, since I&#39;m not reading anything from the screen&lt;br /&gt;
MOSI: connected to RB11 on the PIC&lt;br /&gt;
CS: connected to RB1 on the PIC&lt;br /&gt;
SDCS: left unconnected as I&#39;m not using the microSD card for this&lt;br /&gt;
RST: connected to RB2 on the PIC&lt;br /&gt;
D/C: connected to RB0 on the PIC&lt;br /&gt;
X+: connected to RA4 on the PIC&lt;br /&gt;
X-: connected to RB13 on the PIC&lt;br /&gt;
Y+: connected to RB5 on the PIC&lt;br /&gt;
Y-: connected to RB15 on the PIC&lt;br /&gt;
VIN: connected to 3.3V supply&lt;br /&gt;
GND: connected to gnd &lt;br /&gt;
&lt;br /&gt;
Here is a demo of the game:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/77wlPeXzSJM/0.jpg&quot; frameborder=&quot;0&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/77wlPeXzSJM?feature=player_embedded&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Besides the game itself, you can see the running clock on the bottom left right above the players&#39; scores. To the bottom right you can see a flickering circle that is either green or red, depending on if it&#39;s player 1 or 2&#39;s turn, respectively. Once the game is over, you have the option of playing another game while score is being tracked.&lt;br /&gt;
&lt;br /&gt;
Here is a link to the MPLABX project with all required header and source files:&lt;br /&gt;
&lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHbURwVWVSN1c3VVE/view?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHbURwVWVSN1c3VVE/view?usp=sharing&lt;/u&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
I
 have commented the code to make it fairly self-explanatory. If you have
 doubts or questions about anything, let me know and I&#39;ll add more 
detail. Let me know what you think!</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/6137120464140801209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2015/08/pic32-tic-tac-toe-demonstration-of.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/6137120464140801209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/6137120464140801209'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2015/08/pic32-tic-tac-toe-demonstration-of.html' title='PIC32 Tic-Tac-Toe: Demonstration of using touch-screen, TFT and the Protothreads threading library'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbOBKyipPU7tPOwI4EImOgJm9IGSAXPLKmZuEpu4O9-SylMJI7wQI_xNyhFVkzNAuH5bPaTZAPsiSqQKyvZKd6S-OxFexiAvA1mg8DU738For8YoXewGpjRxNnN_sAv3kV942iokIns5y3/s72-c/2.jpg" height="72" width="72"/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-4276924228151528058</id><published>2015-01-07T14:35:00.003-08:00</published><updated>2015-01-10T13:22:49.967-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MDDFS"/><category scheme="http://www.blogger.com/atom/ns#" term="microSD"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32MX250F128B"/><category scheme="http://www.blogger.com/atom/ns#" term="SD"/><title type='text'>Stereo audio player using the PIC32, MCP4822, microSD card and the MDDFS library</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjooA7JfRE2cVyHz5GzvpRU4Lv8L8apzWdT3Ej94sFoHKqEo6h9hUcycUgEz4pBWu9cM07B7nFZK7laW5fhoW99UyZJfSeCwaBhWM6VDrSL_xYSKSUxGtc7bV9tUjvY3n5qUpdErIruqKsz/s1600/20141016_213036.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjooA7JfRE2cVyHz5GzvpRU4Lv8L8apzWdT3Ej94sFoHKqEo6h9hUcycUgEz4pBWu9cM07B7nFZK7laW5fhoW99UyZJfSeCwaBhWM6VDrSL_xYSKSUxGtc7bV9tUjvY3n5qUpdErIruqKsz/s1600/20141016_213036.png&quot; height=&quot;480&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;b&gt;Oscilloscope screen capture of output from the audio player&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
Top - left channel&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
Bottom - right channel&lt;/div&gt;
&lt;br /&gt;
Using the PIC32MX250F128B, I decided to make a simple audio player. I
 wanted to play back good quality audio from a large memory space - a 
microSD card. So, I made this WAV player that can play back 16-bit 
44.1kHz WAV files with 12-bit stereo audio output. Of course that&#39;s not all it can play back. It is programmed for automatic period configuration so that the period is set on the fly based on the song sample rate. It can play back both 8-bit and 16-bit mono and stereo audio files and I have tested from 8kHz 8-bit mono to 44.1kHz 16-bit stereo. The player itself does not include an audio amplifier to drive speakers but can drive earphones. I&#39;ve used an external stereo speaker for testing.&lt;br /&gt;
&lt;br /&gt;
The hardware is 
fairly simple! Using the Microchip Memory Disk Drive File System (MDDFS)
 library, and my previous work using the MCP4822 dual 12-bit DAC, 
integrating these components to make a working audio player was quite 
fun and a good learning experience.&lt;br /&gt;
&lt;br /&gt;
Here I share all my project files and source code, along with documentation regarding this project. Let me know what you think!&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK0x1hdQ3SobgZmiVSmH8_E04lEkyu6SmVnd2Ip5bNHF-G-Y4nk1tAtGX67A0l6VoFet-fP71Ad2bk3gV3VvItlO5ZX6dwnf7Gcmt37Tl8MEjoO8zU1LBQn8ru_Hu1ehsI9aFMFUC5W7f1/s1600/schema_i2_wav_player.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK0x1hdQ3SobgZmiVSmH8_E04lEkyu6SmVnd2Ip5bNHF-G-Y4nk1tAtGX67A0l6VoFet-fP71Ad2bk3gV3VvItlO5ZX6dwnf7Gcmt37Tl8MEjoO8zU1LBQn8ru_Hu1ehsI9aFMFUC5W7f1/s1600/schema_i2_wav_player.png&quot; height=&quot;554&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
Schematic of PIC32-based audio player&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;-x-system-font: none; display: block; font-family: Helvetica,Arial,Sans-serif; font-size-adjust: none; font-size: 14px; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; margin: 12px auto 6px auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;iframe class=&quot;scribd_iframe_embed&quot; data-aspect-ratio=&quot;undefined&quot; data-auto-height=&quot;false&quot; frameborder=&quot;0&quot; height=&quot;600&quot; id=&quot;doc_62344&quot; scrolling=&quot;no&quot; src=&quot;https://www.scribd.com/embeds/252053802/content?start_page=1&amp;amp;view_mode=scroll&amp;amp;show_recommendations=true&quot; width=&quot;100%&quot;&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Running demo of the audio player:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/PLoyxrjAPZo?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
All project files and schematic can be downloaded from:&lt;br /&gt;
&lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHRGE0bVNZYV9uVjQ/view?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHRGE0bVNZYV9uVjQ/view?usp=sharing&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Documentation can be downloaded from:&lt;br /&gt;
&lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHaWpIWFQ3RkJFVzQ/view?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHaWpIWFQ3RkJFVzQ/view?usp=sharing&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/4276924228151528058/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2015/01/audio-player-using-pic32-microsd-card.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/4276924228151528058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/4276924228151528058'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2015/01/audio-player-using-pic32-microsd-card.html' title='Stereo audio player using the PIC32, MCP4822, microSD card and the MDDFS library'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjooA7JfRE2cVyHz5GzvpRU4Lv8L8apzWdT3Ej94sFoHKqEo6h9hUcycUgEz4pBWu9cM07B7nFZK7laW5fhoW99UyZJfSeCwaBhWM6VDrSL_xYSKSUxGtc7bV9tUjvY3n5qUpdErIruqKsz/s72-c/20141016_213036.png" height="72" width="72"/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-3361416705203669681</id><published>2014-10-30T12:06:00.002-07:00</published><updated>2015-04-08T10:21:49.794-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Adafruit"/><category scheme="http://www.blogger.com/atom/ns#" term="C32"/><category scheme="http://www.blogger.com/atom/ns#" term="graphics"/><category scheme="http://www.blogger.com/atom/ns#" term="ILI9340"/><category scheme="http://www.blogger.com/atom/ns#" term="LCD"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32MX"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32MX250F128B"/><category scheme="http://www.blogger.com/atom/ns#" term="TFT"/><category scheme="http://www.blogger.com/atom/ns#" term="XC32"/><title type='text'>Interfacing a color TFT display with the PIC32MX250F128B</title><content type='html'>I have been working on interfacing the PIC32MX250F128B with a small 2.2&quot; TFT display from Adafruit. It&#39;s a nice little display that is fairly easy to communicate with, using SPI communication. The display I&#39;m using is: &lt;a href=&quot;http://www.adafruit.com/product/1480&quot;&gt;&lt;u&gt;http://www.adafruit.com/product/1480&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Adafruit provides nice open-source libraries for their products. However, they are for Arduino and thus cannot be directly reused for the PIC32. I went through the library and ported it over for the PIC32, in C. I have attached my project file as a .zip file and you can download it to go through the library header and source files, as well as the demo code. I&#39;ve tried heavily commenting the code so that it is self-explanatory.&lt;br /&gt;
&lt;br /&gt;
As far as hardware goes, with the demo code, the pin connections for the display are:&lt;br /&gt;
&lt;br /&gt;
BL (backlight): I left it unconnected, but you can connect it to 3.3V for backlight.&lt;br /&gt;
SCK: connected to RB14 on the PIC&lt;br /&gt;
MISO: left unconnected, since I&#39;m not reading anything from the screen&lt;br /&gt;
MOSI: connected to RB11 on the PIC&lt;br /&gt;
CS: connected to RB1 on the PIC&lt;br /&gt;
SDCS: left unconnected as I&#39;m not using the microSD card for this&lt;br /&gt;
RST: connected to RB2 on the PIC&lt;br /&gt;
D/C: connected to RB0 on the PIC&lt;br /&gt;
VIN: connected to 3.3V supply&lt;br /&gt;
GND: connected to gnd&lt;br /&gt;
&lt;br /&gt;
The pins I used are defined in the code and you can easily change them as required.&lt;br /&gt;
&lt;br /&gt;
I used my custom proto-board for testing on a breadboard. You can find details here: &lt;a href=&quot;http://tahmidmc.blogspot.com/2014/02/pic32-proto-board-details-schematic-pcb.html&quot;&gt;&lt;u&gt;http://tahmidmc.blogspot.com/2014/02/pic32-proto-board-details-schematic-pcb.html&lt;/u&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here&#39;s a video showing the PIC32 running the demo code and doing some simple graphics on the screen. You can see that it runs fairly quickly and quite smoothly.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/JUHIxQL1xyQ?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;br /&gt;
Project files with all source and header files:&lt;br /&gt;
&lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHdksweU1vUkZ4SHM/view?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHdksweU1vUkZ4SHM/view?usp=sharing&lt;/u&gt;&lt;/a&gt; &lt;br /&gt;
&lt;a href=&quot;http://www.4shared.com/zip/O-LcEU0Ace/Adafruit_TFTX.html&quot;&gt;&lt;u&gt;http://www.4shared.com/zip/O-LcEU0Ace/Adafruit_TFTX.html&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
If you have any comments, questions or suggestions, do let me know!</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/3361416705203669681/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2014/10/interfacing-color-tft-display-with.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/3361416705203669681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/3361416705203669681'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2014/10/interfacing-color-tft-display-with.html' title='Interfacing a color TFT display with the PIC32MX250F128B'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-5669204606695779492</id><published>2014-10-16T22:14:00.002-07:00</published><updated>2015-07-09T18:18:34.580-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CPU overhead"/><category scheme="http://www.blogger.com/atom/ns#" term="DDS"/><category scheme="http://www.blogger.com/atom/ns#" term="DMA"/><category scheme="http://www.blogger.com/atom/ns#" term="offload"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32MX"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32MX250F128B"/><category scheme="http://www.blogger.com/atom/ns#" term="sine wave"/><category scheme="http://www.blogger.com/atom/ns#" term="SPI"/><title type='text'>PIC32 DMA+SPI+DAC : Analog output synthesis with zero CPU overhead</title><content type='html'>I have previously shown how to use the PIC32 SPI module to use the 12-bit DAC MCP4822: &lt;a href=&quot;http://tahmidmc.blogspot.com/2014/10/pic32-spi-using-mcp4822-12-bit-serial.html&quot;&gt;&lt;u&gt;http://tahmidmc.blogspot.com/2014/10/pic32-spi-using-mcp4822-12-bit-serial.html&lt;/u&gt;&lt;/a&gt;. While that does allow you to generate analog outputs as desired, it requires you to use CPU cycles to process the timer interrupt and accordingly drive the SPI module.&lt;br /&gt;
&lt;br /&gt;
Since the PIC32 contains DMA channels, the process can be completely offloaded from the CPU. For an idea of the PIC32 DMA module, refer to my previously written article: &lt;a href=&quot;http://tahmidmc.blogspot.com/2014/05/simple-pic32-dma-example.html&quot;&gt;&lt;u&gt;http://tahmidmc.blogspot.com/2014/05/simple-pic32-dma-example.html&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8M5jwy15WZ7RdhI59s5zdaftcb91aIE3LdIz__zVM4CHmnkLxqKCUBAqo0ExWYeW0M8RYAuc00suY9o6DlMZnZNOGj-PxuR53LbUIYJ7ZTwkqdngfxEWat11mSlW2xrMDAjQzTurBvGWn/s1600/dac_dma_400_32.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8M5jwy15WZ7RdhI59s5zdaftcb91aIE3LdIz__zVM4CHmnkLxqKCUBAqo0ExWYeW0M8RYAuc00suY9o6DlMZnZNOGj-PxuR53LbUIYJ7ZTwkqdngfxEWat11mSlW2xrMDAjQzTurBvGWn/s1600/dac_dma_400_32.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
Fig. 1 - The generated sine wave at fpwm = 400kHz and 32 elements in the sine table&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
So, the simple way of offloading the SPI update to the DMA module would be to let the DMA channel transfer data to the SPI buffer. The SPI module is configured for 16-bit data transfer (since the MCP4822 write command requires 2 bytes). This means that the cell size for the DMA channel has been set to 2 (2 bytes to transfer once triggered). The DMA transfer is triggered by a timer interrupt. Unlike the previous example where I used Timer 1 and its interrupt for the SPI transfer, here I use Timer 2. The reason for this is that, if I want the entire process to be offloaded from the CPU, the SS (Slave Select) or CS (Chip Select) also has to be done entirely in hardware. For that I used the Output Compare 1 module. To use the OC1 module, either Timer 2 or Timer 3 (or the combined 32-bit timer) has to be used. So, I just went with Timer 2.&lt;br /&gt;
&lt;br /&gt;
Configuring the DMA module for transferring data to the SPI buffer was the simple part. I found the configuration of the SS/CS pin the more challenging part. The idea here was to use the OC module in &quot;dual compare mode continuous output pulses&quot; mode. The OC module in this mode generates continuous pulses - the output pin OC1 - which I used as CS/SS - is set high one PBCLK (peripheral bus clock) after the Timer value reaches OC1R; the OC1 pin is cleared one PBCLK after the Timer value reaches OC1RS. Since SS/CS is active low, I set ( (period register) - 4) to be OC1RS and a variable CSlength to be OC1R. CSlength was chosen to be 80% of the period register. What this meant was that. One PBCLK after the Timer reached the (period register - 4), the OC1 pin went low (CS/SS went low) &quot;selecting&quot; the DAC. After about 0.80*(period register) from there, the OC1 pin went high. This means that the CS pin is low for 80% of the period - it goes low a small time right before the DMA transfer happens and is raised high late enough, after the DMA transfer occurs. I determined that 80% the period was enough time since that is higher than the time required to shift out 16 bits of data at 20MHz SPI clock. See Fig. 2 below for an illustration of the operation of the output compare module in the &quot;dual compare mode continuous output pulses&quot; mode:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIvrFeMC3RPaoNeQgIVlsArUZ6D_NWIloDFSqNcRlaDdNrCgDSF3NX6vFfUAkmNLI5fm3isiZiG1IvahhR1qQbquDy2azFWWmZQd2sRCFLjUJUTX0yolfQZnYSDWQDqndLNhfEKJybJkfq/s1600/oc1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIvrFeMC3RPaoNeQgIVlsArUZ6D_NWIloDFSqNcRlaDdNrCgDSF3NX6vFfUAkmNLI5fm3isiZiG1IvahhR1qQbquDy2azFWWmZQd2sRCFLjUJUTX0yolfQZnYSDWQDqndLNhfEKJybJkfq/s1600/oc1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&amp;nbsp;Fig. 2 - Output Compare module in Dual Compare Mode: Continuous Output Pulse mode (taken from PIC32 reference manual, figure 16-16)&lt;/div&gt;
&lt;br /&gt;
Beyond that, the idea is simple. There is a sine table that is the DMA source. The key thing to remember here is that the 12-bit data must be OR-ed with 0x3000 since that is required for the DAC (to set gain=1, shutdown = 0 and channel = A):&lt;br /&gt;
&lt;br /&gt;
void generateTables(void){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t i;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i = 0; i&amp;lt;TABLE_SIZE; i++){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sineTable[i] = (short) (2047.0 * sin(6.2832*((float)i)/(float)TABLE_SIZE));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sineTable[i] = sineTable[i] + 2047;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sineTable[i] = &lt;u&gt;&lt;b&gt;0x3000&lt;/b&gt;&lt;/u&gt;&lt;b&gt; &lt;/b&gt;&lt;b&gt;|&lt;/b&gt; sineTable[i];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
Since the entries in the sine table are of &quot;short&quot; data type (each element occupies two bytes), the source size (in bytes) is twice the number of elements. The destination source size is two bytes since I&#39;m transferring two bytes to the SPI buffer register. The cell size is two bytes since the DMA channel has to transfer two bytes (16 bits) at a time to the SPI buffer register. The DMA configuration is:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; DmaChnOpen(0, 3, DMA_OPEN_AUTO);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // (ch, ch priority, mode)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; DmaChnSetTxfer(0, sineTable, &amp;amp;SPI1BUF, TABLE_SIZE*2, 2, 2);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // (ch, start virtual addr, dest virtual addr, source size, dest size, cell size)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; DmaChnSetEventControl(0, DMA_EV_START_IRQ(_TIMER_2_IRQ));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // (ch, trigger irq)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; DmaChnEnable(0);&lt;br /&gt;
&lt;br /&gt;
A point of note is that, the DmaChnSetTxfer( ) takes in the virtual addresses of the source and destination, not the physical addresses. The virtual-to-physical address conversion is done by the function itself as opposed to it being required manually when doing register level operations (as done in my previous DMA example article).&lt;br /&gt;
&lt;br /&gt;
To demonstrate that the DAC control is done with no CPU overhead, in the main( ) function, I have an infinite loop that is just toggling RA0. The output is checked on an oscilloscope:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQk2gd6paaCX1yClgld32HBUbCWTMGDco0RFJouugm8vQQz0VywnblHJ7zta4KXadV2WO6fGruHHbo0KFrtVdcGilhd8Y-PmXlmFHlxwFgHgPQ9s3rBp21-J4HCGEzaH849wMluWC-Eb6u/s1600/dac_dma_ra0+toggle.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQk2gd6paaCX1yClgld32HBUbCWTMGDco0RFJouugm8vQQz0VywnblHJ7zta4KXadV2WO6fGruHHbo0KFrtVdcGilhd8Y-PmXlmFHlxwFgHgPQ9s3rBp21-J4HCGEzaH849wMluWC-Eb6u/s1600/dac_dma_ra0+toggle.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
Fig. 3 - RA0 toggle being demonstrated&lt;/div&gt;
&lt;br /&gt;
Observe that the frequency of the square wave is 4.0MHz - the same that would be observed if all the PIC was doing was the pin toggling.&lt;br /&gt;
&lt;br /&gt;
This also gave better performance than my previous experiment where I did not use DMA. The output sine wave has a higher frequency than observed before and this matches exactly as expected: 400kHz/32 = 12.5kHz as seen (see Fig. 1).&lt;br /&gt;
&lt;br /&gt;
The rest should be very easy to understand and self-explanatory. If you have any questions or suggestions, feel free to comment!&lt;br /&gt;
&lt;br /&gt;
Here are the source and header files:&lt;br /&gt;
&lt;i&gt;config.h&lt;/i&gt;: &lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHcmlxMmg2Si0zWjQ/view?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHcmlxMmg2Si0zWjQ/view?usp=sharing&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;i&gt;main.c&lt;/i&gt;: &lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHcmlxMmg2Si0zWjQ/view?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHcmlxMmg2Si0zWjQ/view?usp=sharing&lt;/u&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/5669204606695779492/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2014/10/pic32-dmaspidac-analog-output-synthesis.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/5669204606695779492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/5669204606695779492'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2014/10/pic32-dmaspidac-analog-output-synthesis.html' title='PIC32 DMA+SPI+DAC : Analog output synthesis with zero CPU overhead'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8M5jwy15WZ7RdhI59s5zdaftcb91aIE3LdIz__zVM4CHmnkLxqKCUBAqo0ExWYeW0M8RYAuc00suY9o6DlMZnZNOGj-PxuR53LbUIYJ7ZTwkqdngfxEWat11mSlW2xrMDAjQzTurBvGWn/s72-c/dac_dma_400_32.png" height="72" width="72"/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-181353019630136952</id><published>2014-10-11T20:57:00.001-07:00</published><updated>2015-09-11T07:34:17.697-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="12-bit"/><category scheme="http://www.blogger.com/atom/ns#" term="32-bit"/><category scheme="http://www.blogger.com/atom/ns#" term="DAC"/><category scheme="http://www.blogger.com/atom/ns#" term="MCP4822"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32MX250F128B"/><category scheme="http://www.blogger.com/atom/ns#" term="SPI"/><category scheme="http://www.blogger.com/atom/ns#" term="XC32"/><title type='text'>PIC32 SPI: Using the MCP4822 12-bit serial dual DAC</title><content type='html'>I recently got a few pieces of the MCP4822 DAC. You can check out the datasheet here: &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/22249A.pdf&quot;&gt;&lt;u&gt;http://ww1.microchip.com/downloads/en/DeviceDoc/22249A.pdf&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I found them to be neat little devices. In a small 8-pin PDIP package, the MCP4822 comes with 2 12-bit DACs, which you can easily configure over SPI. This was a great opportunity to get a simple PIC32 SPI application going. I worked on this today to see how fast I can get the DAC output going. &lt;br /&gt;
&lt;br /&gt;
Here&#39;s the pinout of the MCP4822:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvquGnssS1PhSP2an_QGX5Ib5uUr70co0VERHaJbJHEP1QgYOTTdWfOBhSZUnfaB9N-xhHIfOmwXiDdPYOKJYfnDfJms0biVlwT-VndbxJwQnDJwl7JAoADP9avEjZ7gKQeHPkX40TnE5K/s1600/pinout.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvquGnssS1PhSP2an_QGX5Ib5uUr70co0VERHaJbJHEP1QgYOTTdWfOBhSZUnfaB9N-xhHIfOmwXiDdPYOKJYfnDfJms0biVlwT-VndbxJwQnDJwl7JAoADP9avEjZ7gKQeHPkX40TnE5K/s1600/pinout.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
Fig. 1 - MCP4822 pinout (taken from datasheet)&lt;/div&gt;
&lt;br /&gt;
The MCP4822 can be supplied a voltage in the range of 2.7V to 5.5V. Since I use 3.3V for my PIC32, I used the same 3.3V supply for the VDD for the MCP4822. Pin 5 is the active low signal LDAC that is used to synchronize the two DAC channels. When this pin is brought low, the data in the DAC&#39;s input register is copied to the output and both outputs are updated at the same time. I just had this tied to ground. VoutA and VoutB are the two output pins. The other pins are the regular pins for SPI communication - CS (active low) chip select, SCK serial clk, SDI serial data in.&lt;br /&gt;
&lt;br /&gt;
The datasheet provides a nice diagram explaining the timing and pin functions very nicely:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg65QTkULCLyigtXktJBdT2NLOTYahlmkKztm5LVr2Mf4oAKP-cDRIgFS66tW4cJYykQ0pUbyl3fNCCIU3jkhz91HXEQ94GytVmKjvUH4lQNNU3mpfSEGxQg7C08VczbSgOQswcyW5LcmCf/s1600/timing+diagram.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;270&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg65QTkULCLyigtXktJBdT2NLOTYahlmkKztm5LVr2Mf4oAKP-cDRIgFS66tW4cJYykQ0pUbyl3fNCCIU3jkhz91HXEQ94GytVmKjvUH4lQNNU3mpfSEGxQg7C08VczbSgOQswcyW5LcmCf/s1600/timing+diagram.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
Fig. 2 - Write command for MCP4822 (taken from datasheet)&lt;/div&gt;
&lt;br /&gt;
The write command to the MCP4822 is a 16-bit wide command sent over SPI. Bit 15 (A/B) selects which channel you&#39;re sending data to: 1 signifies channel B, 0 signifies channel A. Bit 13 (GA) selects the gain. The MCP4822 has an internal 2.048V reference it uses for the DAC. So, that means that with a gain of 1, the maximum possible output voltage is 2.04975V (4095/4096 * Vref). If a higher output is required, the gain can be increased. The MCP4822 has a configurable gain of 1 or 2. When GA = 1, gain = 1; when GA = 0, gain = 2. Bit 12 SHDN is the shutdown signal. When SHDN is low, the output of the DAC is shut down. The 12 data bits from there on: D11 to D0 ([D11:D0], [bit11:bit0]) are the 12 data bits for the digital to analog conversion.&lt;br /&gt;
&lt;br /&gt;
The transfer function is the very-simple, (almost) typical-for-DACs:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Vout = (D_12 / 4096) * 2.048V * Gain&lt;/blockquote&gt;
D_12 is the digital value given by D11 to D0 in the write command, 4096 = 2^12 (12-bit resolution), 2.048V = internal voltage reference, gain = 1 or 2 depending on bit GA in write command.&lt;br /&gt;
&lt;br /&gt;
While I typically use the registers and configure them manually, I decided to use the Microchip plib (peripheral library) here for the SPI module. The peripheral library consists of a lot of low-level functions and macros that essentially require understanding the peripheral but just make the code nicer and easier to read.&lt;br /&gt;
&lt;br /&gt;
I decided to clock the MCP4822 at 20MHz (max for MCP4822) to get quick data transfers.&lt;br /&gt;
&lt;br /&gt;
The SPI module can be initialized using one of 2 options:&lt;br /&gt;
1) Using the OpenSPIx(config1, config2) and SpiChnSetBrg(spi_channel, spi_brg) functions&lt;br /&gt;
2) Using the SpiChnOpen(spi_channel, config, spi_divider) function&lt;br /&gt;
&lt;br /&gt;
These are both described in the plib documentation.&lt;br /&gt;
&lt;br /&gt;
The DAC initialization routine I wrote is shown below:&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;//================================================================&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;// SS = PORTA4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define SS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LATAbits.LATA4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define dirSS&amp;nbsp;&amp;nbsp; TRISAbits.TRISA4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void initDAC(void){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;/* Steps:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; 1. Setup SS as digital output.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; 2. Map SDO to physical pin.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; 3. Configure SPI control and clock with either of a or b:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; a. OpenSPIx(config1, config2) and SpiChnSetBrg(spi_channel, spi_brg)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; b. SpiChnOpen(spi_channel, config, spi_divider)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dirSS = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // make SS an output&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SS = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // set SS = 1 to deselect slave&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PPSOutput(2, RPB5, SDO2);&amp;nbsp;&amp;nbsp;&amp;nbsp; // map SDO2 to RB5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;///////&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define config1 SPI_MODE16_ON | SPI_CKE_ON | MASTER_ENABLE_ON&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*&amp;nbsp;&amp;nbsp;&amp;nbsp; FRAME_ENABLE_OFF&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; ENABLE_SDO_PIN&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; SPI Output pin enabled&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_MODE16_ON&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; 16-bit SPI mode&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_SMP_OFF&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; Sample at middle of data output time&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_CKE_ON&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; Output data changes on transition from active clock&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; to idle clock state&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; SLAVE_ENABLE_OFF&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; Manual SW control of SS&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; MASTER_ENABLE_ON&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; Master mode enable&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define config2 SPI_ENABLE&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_ENABLE&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; Enable SPI module&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; OpenSPI2(config1, config2);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // see pg 193 in plib reference&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define spi_channel&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Use channel 2 since channel 1 is used by TFT display&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define spi_brg&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Divider = 2 * (spi_brg + 1)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Divide by 2 to get SPI clock of FPBDIV/2 -&amp;gt; max SPI clock&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; SpiChnSetBrg(spi_channel, spi_brg);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // see pg 203 in plib reference&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;//////&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;//////&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define spi_divider 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;/* Unlike OpenSPIx(), config for SpiChnOpen describes the non-default&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;* settings. eg for OpenSPI2(), use SPI_SMP_OFF (default) to sample&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;* at the middle of the data output, use SPI_SMP_ON to sample at end. For&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;* SpiChnOpen, using SPICON_SMP as a parameter will use the non-default&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;* SPI_SMP_ON setting.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define config SPI_OPEN_MSTEN | SPI_OPEN_MODE16 | SPI_OPEN_DISSDI | SPI_OPEN_CKE_REV&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_OPEN_MSTEN&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; Master mode enable&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_OPEN_MODE16&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; 16-bit SPI mode&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_OPEN_DISSDI&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; Disable SDI pin since PIC32 to DAC is a&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; master-to-slave&amp;nbsp;&amp;nbsp;&amp;nbsp; only communication&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_OPEN_CKE_REV&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; Output data changes on transition from active&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; clock to idle clock state&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; SpiChnOpen(spi_channel, config, spi_divider);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;//////&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;//================================================================&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The code block above has code written using both the initialization functions (one is commented out). Essentially, the configuration is that SPI channel 2 is enabled as a master, it is configured for 16-bit data transmission, the SDI pin is disabled, it is configured for serial output change from active high (1) to active low (0) as required by the MCP4822 (see Fig. 2) and the clock divisor is set to 2 so that SPI clock = 20MHz.&lt;br /&gt;
&lt;br /&gt;
The SCK pins for the PIC32 are mapped physically to the RB15 (SCK2) and RB14 (SCK1) pins (check pinout on page 4 in datasheet). The SDO and SDI pins are remappable pins and thus require you to map them to physical pins. The SDI pin here is unused since the PIC32-to-MCP4822 is a one way communication with the PIC32 as the master and the MCP4822 as the slave.&lt;br /&gt;
&lt;br /&gt;
The datasheet provides the table for all the PPS (peripheral pin select) mappings. The relevant section for the SDO is:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfPuOfMvKyiTuwV6v6Y6zamVfV4fnUMDImomY6w9mb-ZFkDZWQIfF3c2vZSp35y98nQTkHltPhZH_MKD_J1ifKfzgAi6m_5x0W8B-OBAR7fLhpzhjbrWqEiZEvSpH5UCWbkHFB1iC_GEPw/s1600/mapping.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;182&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfPuOfMvKyiTuwV6v6Y6zamVfV4fnUMDImomY6w9mb-ZFkDZWQIfF3c2vZSp35y98nQTkHltPhZH_MKD_J1ifKfzgAi6m_5x0W8B-OBAR7fLhpzhjbrWqEiZEvSpH5UCWbkHFB1iC_GEPw/s1600/mapping.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
Table 1 - PPS configuration for SDO&lt;/div&gt;
&lt;br /&gt;
I decided to use RPB5:&lt;br /&gt;
&lt;br /&gt;
PPSOutput(2, RPB5, SDO2);&amp;nbsp;&amp;nbsp;&amp;nbsp; // map SDO2 to RB5&lt;br /&gt;
&lt;br /&gt;
The connections I used for the MCP4822 are:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-uuHGkx-wmRUgN78esKU1oei4so0GXnSb8NnfT73kDuBkCygJD1EbS5VkLMXPJPCGRJPRhLnn7CnRw9QxFOep0SAoJgKtJYU7leaprX77SIzAK0kskGo6oqM6Seg4XHAwmY_ieQL2GgBG/s1600/mcp4822+pins.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-uuHGkx-wmRUgN78esKU1oei4so0GXnSb8NnfT73kDuBkCygJD1EbS5VkLMXPJPCGRJPRhLnn7CnRw9QxFOep0SAoJgKtJYU7leaprX77SIzAK0kskGo6oqM6Seg4XHAwmY_ieQL2GgBG/s1600/mcp4822+pins.png&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
Fig. 3 - MCP4822 connections &lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The chip select / slave select line (CS as shown on the MCP4822 pinout, see Fig. 1) has to be controlled manually. (For a hardware-based processor-free control scheme, see &lt;a href=&quot;http://tahmidmc.blogspot.com/2014/10/pic32-dmaspidac-analog-output-synthesis.html&quot;&gt;PIC32 DMA+SPI+DAC : Analog output synthesis with zero CPU overhead&lt;/a&gt;.) This is an active low chip select signal. When data is being sent to the MCP4822, while the SPI transaction is occurring, the CS pin must be kept low. Initially I checked to see if there was a way the hardware would take care of that. I looked into the framed SPI mode. However, this did not serve my purpose. From what I&#39;ve read, the framed SPI mode is an SPI mode where the clock is always output (instead of only during transactions as traditionally done). However, the hardware generates a low sync signal (by pulling CS low) before the data is transmitted from the PIC32. The problem here was that the CS pin was pulled low and kept low for one SPI clock period before raising CS high as data is transmitted out from SDO. This isn&#39;t going to work for the MCP4822 since the chip requires that CS be held low during the entirety of data transmission (see Fig. 2). So I just decided to use RA4 as the pin for CS. Before starting any transmission, I pull CS low in software and raise it high at the end.&lt;br /&gt;
&lt;br /&gt;
Here&#39;s the code for writing to the DAC:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;drive-viewer-text-page drive-viewer-focus-to-default&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;inline void writeDAC(uint16_t data){
    SS = 0; // select slave device: MCP4822 DAC
    while (TxBufFullSPI2()); // ensure buffer is free before writing
    WriteSPI2(data);   // send the data through SPI
    while (SPI2STATbits.SPIBUSY); // blocking wait for end of transaction
    SS = 1; // deselect slave device, transmission complete
}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Since I called this function from the ISR in my code, I decided to make it an inline function to eliminate function call overhead.&lt;br /&gt;
&lt;br /&gt;
In my test code, I just wanted to see how fast an output I can get. So I clocked the MCP4822 at 20MHz and tried to maximize the frequency of the output signal I generate: I used channel A to generate a sine wave output and channel B to generate a triangle wave output. I used a timer (Timer 1) to control the timing and in the ISR, I just called the writeDAC inline function to generate outputs as required from two pre-generated tables.&lt;br /&gt;
&lt;br /&gt;
Here are the different waveforms and outputs I generated:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjobd5L1_LZtE26JR6PdtxuRz5Wyow4ZaNCrjqYDZncM3VLrpzjzCsV7f9jkw_S1JkbPDZuDYfX20MxwrsRHhwgMabeEFwP0SOxi0-0UjGi5HOBA9LmYxxbFu1nfhqyyhoggPdPfdBzSJ9S/s1600/2+channel+dac+400khz+64.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjobd5L1_LZtE26JR6PdtxuRz5Wyow4ZaNCrjqYDZncM3VLrpzjzCsV7f9jkw_S1JkbPDZuDYfX20MxwrsRHhwgMabeEFwP0SOxi0-0UjGi5HOBA9LmYxxbFu1nfhqyyhoggPdPfdBzSJ9S/s1600/2+channel+dac+400khz+64.png&quot; width=&quot;320&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
Fig. 4 - Generating the outputs with timer period = 400kHz, sine table entries = 64&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFApEG450exXIHaUGWEPjzeHHjX5-IX0llPiv5Icr_jdpOyVx6tNn-lEmoDE6kMOU9HH56u9zfXLGZTX2NcqQzy-CkTx1kydXy5hNuc8w2E87Sz53OBTC6doeGN6rhhigStdKkiIrnzb0t/s1600/2+channel+dac+550khz+32.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFApEG450exXIHaUGWEPjzeHHjX5-IX0llPiv5Icr_jdpOyVx6tNn-lEmoDE6kMOU9HH56u9zfXLGZTX2NcqQzy-CkTx1kydXy5hNuc8w2E87Sz53OBTC6doeGN6rhhigStdKkiIrnzb0t/s1600/2+channel+dac+550khz+32.png&quot; width=&quot;320&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
Fig. 5 - Generating the outputs with timer period = 550kHz, sine table entries = 32&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaU_GeHGVIhuAqBdhAIgmMeh_9eUuBM_Cla1IcJ9FsHYiO_dnjIZs4B4SuqKRlorLYuDDzqi_eGVTjmYMMMhfyIpewFGPusgpuxwdJ1lGfMKLB3Y4XtTzUwm_lPVGgO8d6T_APQmnglU_l/s1600/2+channel+dac+550khz+64.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaU_GeHGVIhuAqBdhAIgmMeh_9eUuBM_Cla1IcJ9FsHYiO_dnjIZs4B4SuqKRlorLYuDDzqi_eGVTjmYMMMhfyIpewFGPusgpuxwdJ1lGfMKLB3Y4XtTzUwm_lPVGgO8d6T_APQmnglU_l/s1600/2+channel+dac+550khz+64.png&quot; width=&quot;320&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
Fig. 6 - Generating the outputs with timer period = 550kHz, sine table entries = 64&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlbwSRXYqLBqxC45XC19-Nz1wR9Z8EeTkkH_H9gdtyt4whSVaAueBU4sLKQPAt4fmKdgo2t64h9ybOjIbJXi2_FooBUL3Q6oTTaUtDSyQFZXK5aUz3cIVrK9LOcS566guTWzW-NVSQwuYU/s1600/spi+clk+20mhz+and+data.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlbwSRXYqLBqxC45XC19-Nz1wR9Z8EeTkkH_H9gdtyt4whSVaAueBU4sLKQPAt4fmKdgo2t64h9ybOjIbJXi2_FooBUL3Q6oTTaUtDSyQFZXK5aUz3cIVrK9LOcS566guTWzW-NVSQwuYU/s1600/spi+clk+20mhz+and+data.png&quot; width=&quot;320&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
Fig. 7 - SPI clock and data transmission&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
You can clearly see the SPI clock during transmission here. From the measurement panel on the right you can see that the SPI clock is 20MHz. There are also 16 pulses you can count - since a write command to the DAC consists of 16 bit transfers. CH2, on the bottom, shows the data being transmitted. Since the first signal (leftmost) is a 1, and since this corresponds to bit 15, this is a snapshot of data being transmitted to DAC channel B.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiO9XWKdD0g3skifS56FZk1Y7L-vW2UBmPO26fw5vQqc1QGnoyq3WZEw9V57XCBe8dCf9Exgfccby0frxck9t7p5ucO_8xEXhhk5LZIw08qixSQLypFvkFMdCOm5VtpX0jwBUynhjB21kkf/s1600/zoomed+in+quantization+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiO9XWKdD0g3skifS56FZk1Y7L-vW2UBmPO26fw5vQqc1QGnoyq3WZEw9V57XCBe8dCf9Exgfccby0frxck9t7p5ucO_8xEXhhk5LZIw08qixSQLypFvkFMdCOm5VtpX0jwBUynhjB21kkf/s1600/zoomed+in+quantization+2.png&quot; width=&quot;320&quot; /&gt; &lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
Fig. 8 - DAC steps - zoomed in&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh5dw16h1HNJqNVRCmtdCpJ4oN_I-dsdXbZtoOre2jTEW8QzlN4EA4AxuiriqxuX0ciF60IAH9FmVdT5KJdH-fSi0uD4U2MFfPBWGIt64QmuhmC4VmBrKZDr6KjLn4MAdvark6Nl1mVykb/s1600/zoomed+in+quantization.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh5dw16h1HNJqNVRCmtdCpJ4oN_I-dsdXbZtoOre2jTEW8QzlN4EA4AxuiriqxuX0ciF60IAH9FmVdT5KJdH-fSi0uD4U2MFfPBWGIt64QmuhmC4VmBrKZDr6KjLn4MAdvark6Nl1mVykb/s1600/zoomed+in+quantization.png&quot; width=&quot;320&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
Fig. 9 - DAC steps - zoomed out&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimXtTAVRIXdrienxHo2nPxBlal3vMFijoV4wDrW0KrHrw2KlcXktWByCarryUZo1X28LDiRjDR-5feEFPyUl0tDhgLqOXKJjcKyRWsHHNdfk_pFhulhMQMxB-rhjqEYb-O0YGuIv-y4WV-/s1600/DSC_0291.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimXtTAVRIXdrienxHo2nPxBlal3vMFijoV4wDrW0KrHrw2KlcXktWByCarryUZo1X28LDiRjDR-5feEFPyUl0tDhgLqOXKJjcKyRWsHHNdfk_pFhulhMQMxB-rhjqEYb-O0YGuIv-y4WV-/s1600/DSC_0291.jpg&quot; width=&quot;276&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
Fig. 10 - Hardware test setup&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
For the PIC32 proto board, I used my own custom proto board: &lt;a href=&quot;http://tahmidmc.blogspot.com/2014/02/pic32-proto-board-details-schematic-pcb.html&quot;&gt;&lt;u&gt;http://tahmidmc.blogspot.com/2014/02/pic32-proto-board-details-schematic-pcb.html&lt;/u&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Here are the header and source files for my test program:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;config.h:&lt;/i&gt; &lt;a href=&quot;https://drive.google.com/open?id=0B4SoPFPRNziHdk5KT2hWNUNCckE&quot;&gt;&lt;u&gt;https://drive.google.com/open?id=0B4SoPFPRNziHdk5KT2hWNUNCckE&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;i&gt;main.c: &lt;/i&gt;&lt;a href=&quot;https://drive.google.com/open?id=0B4SoPFPRNziHWFc0Y01qSW5XUkE&quot;&gt;&lt;u&gt;https://drive.google.com/open?id=0B4SoPFPRNziHWFc0Y01qSW5XUkE&lt;/u&gt;&lt;/a&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
While this was a quick test I did to test the PIC32 SPI and the MCP4822, this is in no means a complete evaluation of the MCP4822. For example, I updated the DAC more quickly than I should have, to push for speed, as this didn&#39;t give enough of a settling time. However, I was satisfied with the results and so, stuck with that. I will do some further testing on this later.&lt;br /&gt;
&lt;br /&gt;
For more details of the PIC32MX250F128B SPI module, refer to the datasheet and reference manual. For more details on the MCP4822, refer to its datasheet.&lt;br /&gt;
&lt;br /&gt;
If you have any questions, feel free to ask. Let me know what you think, in the comments section below!&lt;br /&gt;
&lt;br /&gt;
Note: Updated September 10, 2015 </content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/181353019630136952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2014/10/pic32-spi-using-mcp4822-12-bit-serial.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/181353019630136952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/181353019630136952'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2014/10/pic32-spi-using-mcp4822-12-bit-serial.html' title='PIC32 SPI: Using the MCP4822 12-bit serial dual DAC'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvquGnssS1PhSP2an_QGX5Ib5uUr70co0VERHaJbJHEP1QgYOTTdWfOBhSZUnfaB9N-xhHIfOmwXiDdPYOKJYfnDfJms0biVlwT-VndbxJwQnDJwl7JAoADP9avEjZ7gKQeHPkX40TnE5K/s72-c/pinout.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-7285323631101999947</id><published>2014-06-23T08:48:00.000-07:00</published><updated>2014-07-02T12:29:33.026-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="32-bit"/><category scheme="http://www.blogger.com/atom/ns#" term="C32"/><category scheme="http://www.blogger.com/atom/ns#" term="DC-AC"/><category scheme="http://www.blogger.com/atom/ns#" term="interrupt"/><category scheme="http://www.blogger.com/atom/ns#" term="ISR"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32MX250F128B"/><category scheme="http://www.blogger.com/atom/ns#" term="register"/><category scheme="http://www.blogger.com/atom/ns#" term="shadow"/><category scheme="http://www.blogger.com/atom/ns#" term="SRS"/><category scheme="http://www.blogger.com/atom/ns#" term="XC32"/><title type='text'>PIC32MX250F128B ipl7: odd shadow register set behavior and observations</title><content type='html'>&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;u&gt;This issue has now been solved. Scroll to the bottom for the update.&lt;/u&gt;&lt;/b&gt;&lt;/span&gt; &lt;br /&gt;
&lt;br /&gt;
I started working on a pure sine wave inverter based on the PIC32MX250F128B. The first stage was to just get the SPWM working and test that before proceeding to add the power stage, feedback and other control, etc.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This led me to some interesting observations regarding the PIC32MX250F128B interrupts, especially the use of the shadow register set and a related problem.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I set up Timer 2 to be the time base for sine wave generation 
(DDS/SPWM) using OC1. In the Timer 2 interrupt, the duty cycle update request
 is performed (OC1RS is updated). Timer 2 interrupt priority was set to 
7.&lt;/div&gt;
This all worked fine. The initial ISR definition was:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;void __ISR(_TIMER_2_VECTOR, ipl7) T2int(void) {&lt;br /&gt;.....&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
However, when I used the ADC 
(input from potentiometer for amplitude control - a start at implementing feedback), accessing any of the 
ADC registers in the while (1) loop in main stopped the PIC32 from 
working.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I then added a line of code in main to continuously toggle RA0 (PORTA bit 0). This would stop when trying to access the ADC registers as well. (It worked fine if I removed the code that accessed the ADC.) This meant that the core was being stopped. So, I thought that it might be some kind 
of exception being thrown (?).&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
However, changing the timer 2 interrupt priority from 7 (which
 I had initially) to anything else fixes the problem. My guess was that 
something went wrong when the shadow register set was being used for 
interrupt priority level 7 (?).&lt;br /&gt;
&lt;br /&gt;
So I did some more tests and came up with this:&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;div&gt;
The
 way I have the ISR defined initially selects the &quot;AUTO&quot; mode of selection where, I
 believe, the compiler decides whether to use the shadow register set or
 software for context save/restore.&lt;/div&gt;
Forcing the compiler to use the software context save/restore instead of the shadow register set seems to fix it:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;void __ISR(_TIMER_2_VECTOR, ipl7SOFT) T2int(void) {&lt;br /&gt;.....&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I forced the shadow register set just to confirm:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;void __ISR(_TIMER_2_VECTOR, ipl7SRS) T2int(void) {&lt;br /&gt;.....&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
and sure enough it didn&#39;t work.&lt;br /&gt;
&lt;br /&gt;
So,
 since it worked with ipl6, my guess was that for ipl6 (and for any ipl 
except 7), the compiler chooses software for AUTO, whereas for ipl7, the
 compiler chooses SRS.&lt;br /&gt;
&lt;br /&gt;
So, I forced the shadow register set on ipl6:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;void __ISR(_TIMER_2_VECTOR, ipl6SRS) T2int(void) {&lt;br /&gt;.....&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
and sure enough, it didn&#39;t work.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
Forcing software for ipl6 fixes it (as does AUTO).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;strike&gt;I looked through the errata of the chip and couldn&#39;t find
 anything. (The errata is an interesting read.)&amp;nbsp; I am also a little 
surprised since I did have ipl7 running fine previously. Maybe something weird happens with a certain combination of peripherals
 (?) that I unfortunately happened to use. I&#39;ll still see if I can find 
this documented, and I&#39;ll have to check whether an exception is thrown and if so, what type. If nothing else, at least it was a nice, albeit frustrating, 
lesson. Hopefully, it&#39;ll help someone else who might run into a similar problem.&lt;/strike&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;UPDATE/SOLUTION:&lt;/b&gt;&lt;/u&gt; It turns out that the PIC32MX250F128B does not have a shadow register set, as mentioned in the datasheet. I seemed to have missed that while concentrating on the reference manual which talks about the shadow register set for the PIC32 series. Thus, from the point of view of my &#39;experiments&#39;, the lesson learnt could very well just be that when using ipl7, force the compiler to use software instead of the default AUTO mode (which may make the compiler try to use the shadow register set, which doesn&#39;t exist - explaining the problem I faced earlier).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
---------------------------------------------------&lt;/div&gt;
&lt;div&gt;
DDS = direct digital synthesis&lt;/div&gt;
&lt;div&gt;
ipl = interrupt priority level&lt;/div&gt;
&lt;div&gt;
ISR = interrupt service routine&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
SPWM = sinusoidal pulse width modulation&lt;/div&gt;
&lt;div&gt;
SRS = shadow register set&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/7285323631101999947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2014/06/pic32mx250f128b-ipl7-odd-shadow.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/7285323631101999947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/7285323631101999947'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2014/06/pic32mx250f128b-ipl7-odd-shadow.html' title='PIC32MX250F128B ipl7: odd shadow register set behavior and observations'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-742864977902725758</id><published>2014-06-17T11:27:00.001-07:00</published><updated>2014-06-23T09:29:26.147-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="16F676"/><category scheme="http://www.blogger.com/atom/ns#" term="16F684"/><category scheme="http://www.blogger.com/atom/ns#" term="AC"/><category scheme="http://www.blogger.com/atom/ns#" term="DMM"/><category scheme="http://www.blogger.com/atom/ns#" term="Voltmeter"/><title type='text'>Simple AC voltmeter</title><content type='html'>I had long been thinking of designing a simple AC voltmeter but had 
somehow never gotten to it. However, with school just ending, and me 
going back to electronics, this was a neat simple yet useful circuit 
that I felt I could just get done with in a day or two.&lt;br /&gt;
&lt;br /&gt;
The
 concept is fairly straight forward. Since I needed this only to measure
 the mains AC voltage and the output voltage of the sine wave inverter I
 was working on (based on the PIC32MX250F128B - more on this later), I 
didn&#39;t need to do any &quot;true RMS&quot; measurement. All I had to do was to 
convert the mains AC to DC, filter it and measure the peak voltage. Of 
course this had to be scaled down to a safe range for the 
microcontroller. The RMS voltage for a sine wave is equal to 0.707 (to 3
 decimal places) the peak voltage.&lt;br /&gt;
&lt;br /&gt;
The design was based
 on the Microchip PIC16F676. However I realized that I didn&#39;t have any 
in stock with me. So, I just used the pin-compatible PIC16F684. On the 
software side of things, the difference between the code for PIC16F676 
and PIC16F684 is just one line. (See source file attached below.)&lt;br /&gt;
&lt;br /&gt;
The
 variable resistor is adjusted so that the reading of my AC voltmeter 
matches that of a commercial voltmeter (Extech MA640 DMM). This is a sort of calibration.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;CAUTION: THIS CIRCUIT IS NOT ISOLATED FROM THE MAINS AC AND HAS THE POTENTIAL TO BE LETHAL. YOU MUST BE VERY CAREFUL IF YOU ARE GOING TO USE THIS DESIGN. DO NOT ATTEMPT IF INEXPERIENCED. I CANNOT AND WILL NOT BE HELD RESPONSIBLE FOR ANY DAMAGE DONE WHILE USING THIS CIRCUIT.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Here&#39;s the schematic:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYjLHA8MdJ2CaZFlmuZPpAb88ci7IW9mE-p2cvPb7U5-6M0MOGScTMBYFByLBRVLXGiLl104TueQtd65CsDEJD-Ub7KkhljxhRVZYDS2d6hBAVqM4I7WLGKsXoAVAniodLd9POGs4jKpIj/s1600/schematic.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYjLHA8MdJ2CaZFlmuZPpAb88ci7IW9mE-p2cvPb7U5-6M0MOGScTMBYFByLBRVLXGiLl104TueQtd65CsDEJD-Ub7KkhljxhRVZYDS2d6hBAVqM4I7WLGKsXoAVAniodLd9POGs4jKpIj/s1600/schematic.png&quot; height=&quot;450&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&amp;nbsp;Fig. 1 - Voltmeter&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
Here are some pictures:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6kmUVyFJqp9fNEwLwFwm-X5PaQ0hdZXz1kf6NojexsEeAZyrR54uluurGWXGYd0tzhqsdINtCSSgM2lWQqTxrl2F2ReB_QKx3GBrQ8Hl2Zq_VmlEsTg68AyMRALNpQPEDjPVW8Ip-y10e/s1600/DSC_0024.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6kmUVyFJqp9fNEwLwFwm-X5PaQ0hdZXz1kf6NojexsEeAZyrR54uluurGWXGYd0tzhqsdINtCSSgM2lWQqTxrl2F2ReB_QKx3GBrQ8Hl2Zq_VmlEsTg68AyMRALNpQPEDjPVW8Ip-y10e/s1600/DSC_0024.jpg&quot; height=&quot;478&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe0yVd80FFAxBnReZhNCqDSTTqc8gO552k_fmnxiv0l6PKdUVgNgxCzYh2jA1Nq4FCXpxW8aRST3IN1BIaA4heBMCTbNWkEqVGyYDUIF_5zkE98taInahqW9t6Wken_jqp2XrhwDcQxb1U/s1600/DSC_0025.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe0yVd80FFAxBnReZhNCqDSTTqc8gO552k_fmnxiv0l6PKdUVgNgxCzYh2jA1Nq4FCXpxW8aRST3IN1BIaA4heBMCTbNWkEqVGyYDUIF_5zkE98taInahqW9t6Wken_jqp2XrhwDcQxb1U/s1600/DSC_0025.jpg&quot; height=&quot;478&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&amp;nbsp;Fig. 2 - The PCB without (above) and with (below) the transformer&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0Uoy0ewihTr7Djxhiplaps0qkEWg3gvshqs7ZLNZmN_4LoMEhqqdn8eOKOXlFisAC2Ma5T5aulXShU1RL2lcfr6yDlf7iAa0H8Hg2Eyk2Y6o1Tr8IJM-uRfc2AnRgF7X_Eiarh0HI_xk6/s1600/DSC_0027.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0Uoy0ewihTr7Djxhiplaps0qkEWg3gvshqs7ZLNZmN_4LoMEhqqdn8eOKOXlFisAC2Ma5T5aulXShU1RL2lcfr6yDlf7iAa0H8Hg2Eyk2Y6o1Tr8IJM-uRfc2AnRgF7X_Eiarh0HI_xk6/s1600/DSC_0027.jpg&quot; height=&quot;640&quot; width=&quot;478&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
Fig. 3 - The test setup&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGjHBjUbT_Zx8LkR2JP-okspI5HHYQKddh44UR_Jjg_fxfb1r7wbLTrQD8HQQtAxgJo2ov-Vi-0v-aXIGsSoZLRonYcDYnyic0lOPLSvihTvyvbXvBZigmg3SnL4c8Go0OmCLhKqL2ZXMT/s1600/DSC_0028.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGjHBjUbT_Zx8LkR2JP-okspI5HHYQKddh44UR_Jjg_fxfb1r7wbLTrQD8HQQtAxgJo2ov-Vi-0v-aXIGsSoZLRonYcDYnyic0lOPLSvihTvyvbXvBZigmg3SnL4c8Go0OmCLhKqL2ZXMT/s1600/DSC_0028.jpg&quot; height=&quot;478&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
Fig. 4 - Measuring voltage set with the variac&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh2igyEuK__dMubUEjDAtve9YY3P4kFIZ4OC5ho2_klw1FPiPYkV7OEwV9raROAlubjiEDigd7pTjUk58JhoYaOjatAc64XEK9zE7oDxGz7GrukLaxCHSFkGyQuaqlZ9GhH0Nvq77KjFPD/s1600/DSC_0031.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh2igyEuK__dMubUEjDAtve9YY3P4kFIZ4OC5ho2_klw1FPiPYkV7OEwV9raROAlubjiEDigd7pTjUk58JhoYaOjatAc64XEK9zE7oDxGz7GrukLaxCHSFkGyQuaqlZ9GhH0Nvq77KjFPD/s1600/DSC_0031.jpg&quot; height=&quot;478&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&amp;nbsp;Fig. 5 - Measuring voltage set with the variac&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-pH2m8zwJNKQXRNVoE-F8dY1DQS-INktX3MoMRAgg2QhXEKmw45SG2D1ex_paqEaSyyBFkf51ARmBSYdTz77CWSrif9wSChiCsVotnmIS9CeJo8avw3Nwr776S0YqLUmmQE8tZEz4bPh0/s1600/DSC_0033.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-pH2m8zwJNKQXRNVoE-F8dY1DQS-INktX3MoMRAgg2QhXEKmw45SG2D1ex_paqEaSyyBFkf51ARmBSYdTz77CWSrif9wSChiCsVotnmIS9CeJo8avw3Nwr776S0YqLUmmQE8tZEz4bPh0/s1600/DSC_0033.jpg&quot; height=&quot;478&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&amp;nbsp;Fig. 6 - Measuring voltage set with the variac&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIP40ibClNJ8XhH99Bh8CAUn9wkEFEMlSGtg19RCGivgvNqoUlHwN2HlZqwcqoA6Im7R050ST6BryObprOOxO-7BMqnTFvTuyAIY8iTlSVt4sR3LdKERt0NDFLBnBfcpAbcJY7hOf2clwL/s1600/DSC_0038.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIP40ibClNJ8XhH99Bh8CAUn9wkEFEMlSGtg19RCGivgvNqoUlHwN2HlZqwcqoA6Im7R050ST6BryObprOOxO-7BMqnTFvTuyAIY8iTlSVt4sR3LdKERt0NDFLBnBfcpAbcJY7hOf2clwL/s1600/DSC_0038.jpg&quot; height=&quot;640&quot; width=&quot;478&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
Fig. 7 - Measuring voltage set with the variac&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
C source file:&lt;br /&gt;
&lt;u&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHdDB6cDdzNGZPdXc/edit?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHdDB6cDdzNGZPdXc/edit?usp=sharing&lt;/u&gt;&lt;/a&gt; &lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.4shared.com/file/Cz56s9Zlba/ACvoltmeter.html&quot;&gt;&lt;u&gt;http://www.4shared.com/file/Cz56s9Zlba/ACvoltmeter.html&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
mikroC project file: &lt;br /&gt;
&lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHN2MydDRDalRWS1k/edit?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHN2MydDRDalRWS1k/edit?usp=sharing&lt;/u&gt;&lt;/a&gt; &lt;br /&gt;
&lt;a href=&quot;http://www.4shared.com/file/JwW3bpJNce/ACvoltmeter.html&quot;&gt;&lt;u&gt;http://www.4shared.com/file/JwW3bpJNce/ACvoltmeter.html&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Parts list (Excel XLSX file): &lt;br /&gt;
&lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHb2ZCcnFNVnNpc2s/edit?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHb2ZCcnFNVnNpc2s/edit?usp=sharing&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.4shared.com/file/b_NcW4vdce/parts_list.html&quot;&gt;&lt;u&gt;http://www.4shared.com/file/b_NcW4vdce/parts_list.html&lt;/u&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
Schematic (ARES DSN file): &lt;br /&gt;
&lt;u&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHb1NFWDdwcWpJV2M/edit?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHb1NFWDdwcWpJV2M/edit?usp=sharing&lt;/u&gt;&lt;/a&gt; &lt;/u&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.4shared.com/file/U6kPQH_rce/schematic.html&quot;&gt;&lt;u&gt;http://www.4shared.com/file/U6kPQH_rce/schematic.html&lt;/u&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
PCB (ARES LYT file): &lt;br /&gt;
&lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHNDhhMDBkNFlnWW8/edit?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHNDhhMDBkNFlnWW8/edit?usp=sharing&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.4shared.com/file/ZVczMJ7Wba/schematic.html&quot;&gt;&lt;u&gt;http://www.4shared.com/file/ZVczMJ7Wba/schematic.html&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
PCB (PDF files):&lt;br /&gt;
&lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHMV9LdTBab1BXeDg/edit?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHMV9LdTBab1BXeDg/edit?usp=sharing&lt;/u&gt;&lt;/a&gt; &lt;br /&gt;
Mirrored: &amp;nbsp;&lt;u&gt;&lt;/u&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B4SoPFPRNziHSmxvT1pSbXBWOTA/edit?usp=sharing&quot;&gt;&lt;u&gt;https://drive.google.com/file/d/0B4SoPFPRNziHSmxvT1pSbXBWOTA/edit?usp=sharing&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
It&#39;s
 a fun simple yet useful project that you can build pretty easily if you
 want. Let me know what you think in the comments section below!</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/742864977902725758/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2014/06/simple-ac-voltmeter.html#comment-form' title='35 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/742864977902725758'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/742864977902725758'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2014/06/simple-ac-voltmeter.html' title='Simple AC voltmeter'/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYjLHA8MdJ2CaZFlmuZPpAb88ci7IW9mE-p2cvPb7U5-6M0MOGScTMBYFByLBRVLXGiLl104TueQtd65CsDEJD-Ub7KkhljxhRVZYDS2d6hBAVqM4I7WLGKsXoAVAniodLd9POGs4jKpIj/s72-c/schematic.png" height="72" width="72"/><thr:total>35</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6338993703407602171.post-3569456305739202174</id><published>2014-05-22T23:15:00.005-07:00</published><updated>2014-05-22T23:45:39.196-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AT91"/><category scheme="http://www.blogger.com/atom/ns#" term="AT91SAM3X8E"/><category scheme="http://www.blogger.com/atom/ns#" term="Cornell"/><category scheme="http://www.blogger.com/atom/ns#" term="Galileo"/><category scheme="http://www.blogger.com/atom/ns#" term="Intel"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32"/><category scheme="http://www.blogger.com/atom/ns#" term="PIC32MX250F128B"/><title type='text'> A further study into the use of the PIC32MX250F128B, with side projects using the AT91SAM3X8E (Arduino Due) and the Intel Galileo  </title><content type='html'>&lt;iframe class=&quot;scribd_iframe_embed&quot; data-aspect-ratio=&quot;undefined&quot; data-auto-height=&quot;false&quot; frameborder=&quot;0&quot; height=&quot;600&quot; id=&quot;doc_87642&quot; scrolling=&quot;no&quot; src=&quot;//www.scribd.com/embeds/225743783/content?start_page=1&amp;amp;view_mode=scroll&amp;amp;show_recommendations=true&quot; width=&quot;100%&quot;&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;br /&gt;
Download PDF from:&lt;br /&gt;
&lt;a href=&quot;http://www.4shared.com/office/kRJ8hVWPce/A_further_study_into_the_use_o.html&quot;&gt;http://www.4shared.com/office/kRJ8hVWPce/A_further_study_into_the_use_o.html&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tahmidmc.blogspot.com/feeds/3569456305739202174/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tahmidmc.blogspot.com/2014/05/a-further-study-into-use-of.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/3569456305739202174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6338993703407602171/posts/default/3569456305739202174'/><link rel='alternate' type='text/html' href='http://tahmidmc.blogspot.com/2014/05/a-further-study-into-use-of.html' title=' A further study into the use of the PIC32MX250F128B, with side projects using the AT91SAM3X8E (Arduino Due) and the Intel Galileo  '/><author><name>Tahmid</name><uri>http://www.blogger.com/profile/09117804893438710050</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5kAefUsusBSgz-IxGKaBDKSZVnMif7nm3crwqO30C3MEHCLREg86_m4xST7uB4VRj24Xg1fsJAx3r4Mi6LGKf2De5AA6AIzMPUB3GmApll07mhUnpLfgaQYuCFSZhp4CuqGSUqU41K4oquURx2uuMz93yEaSh5XIILhTLyQE0PvWNYQ/s220/headshot%20reduced.jpg'/></author><thr:total>4</thr:total></entry></feed>