tag:blogger.com,1999:blog-32180087720583472462024-03-28T01:52:37.274+02:00Robert Gawronexperiments.Unknownnoreply@blogger.comBlogger96125tag:blogger.com,1999:blog-3218008772058347246.post-2258517192942878712020-01-18T21:28:00.000+02:002020-01-23T21:30:46.867+02:00Ionization Chamber<p>Ionization chamber is a device to measure radioactivity level. When air's atoms are hit by radioactive particles, an ion-pair is produced. Ions has electric charge, if they are in electric field create by positive and negative electrodes, negative ions will move to positive electrode and positive will move to negative electrode. They will try to "meet each other" thus creating a current. This current can be measured. The current is proportional to amount of ion-pairs. Amount of ion-pairs is proportional to radioactivity level.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhut6BsUZ7vh-MQCgDscRXVbTh8hVElhsnE5v8bu1ulGk4govUDgKK8yRv5lKfJy8AWJwIEYLBiotcGRYWeOtwHVuW3lg6vQeYkdgeaSc7CrsL1rKzEzKTWGP-IOwaULULCVcIc6SGO2F0I/s1600/IMG_20190804_123441.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhut6BsUZ7vh-MQCgDscRXVbTh8hVElhsnE5v8bu1ulGk4govUDgKK8yRv5lKfJy8AWJwIEYLBiotcGRYWeOtwHVuW3lg6vQeYkdgeaSc7CrsL1rKzEzKTWGP-IOwaULULCVcIc6SGO2F0I/s1600/IMG_20190804_123441.jpg" data-original-width="1292" data-original-height="969" /></a>
<p></p>
<p>Architecture of the device is presented below. It's made of analog part + STM8 microcontroller that collects and sends measurements via UART. Those measurements are collected on Raspberry side and processed using Python and R scripts. results are stored in .cvs (raw data) or .png (diagrams). It would be possible to simplify this setup and avoid Raspberry, but I wanted to made it possible to gather data and flash the chip without being physically around the device.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPm2KOPgxHQeFvva60QR_gNjo-7CYmJOPuH8zWpvYVr4EcFnGB6ktUata1eTUdUUZGMp_T5G7WGT2H7H0Nr92XLg2zenR6Ey4a6hGl7NzAjeXTIamdCfOBruTz1v6CYddG1AULWfIc7Iee/s1600/ArchitectureOverview-1.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPm2KOPgxHQeFvva60QR_gNjo-7CYmJOPuH8zWpvYVr4EcFnGB6ktUata1eTUdUUZGMp_T5G7WGT2H7H0Nr92XLg2zenR6Ey4a6hGl7NzAjeXTIamdCfOBruTz1v6CYddG1AULWfIc7Iee/s1600/ArchitectureOverview-1.png" data-original-width="1600" data-original-height="1393" /></a>
<p>Outside electrode of ionization chamber was made from PCB scraps and copper plate, inside electrode was made using a couple of centimeters of non-emaled wire. To avoid electromagnetic interference, amplifier was placed in metal chassis.</p>
<p><strong>PCB for analog ans data acquisition part was designed in KiCAD, all files are <a href="https://github.com/RobertGawron/IonizationChamber">available on project's GitHub.</a></strong></p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN6V7kpQL6uX8gVh47nhNL8K2FFiiriKMlpdtxkdLjWkzDcDRh6eiQuWq4w0fpRNxSwFonvm_5q6c92oibSN-bPgLm1LTEB9wzw7fzpPZ49DZFw2m4jn3UqbRzwN1wnbO8i9O5lxOY5QLM/s1600/IonChamberAnalogSide.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN6V7kpQL6uX8gVh47nhNL8K2FFiiriKMlpdtxkdLjWkzDcDRh6eiQuWq4w0fpRNxSwFonvm_5q6c92oibSN-bPgLm1LTEB9wzw7fzpPZ49DZFw2m4jn3UqbRzwN1wnbO8i9O5lxOY5QLM/s1600/IonChamberAnalogSide.png" data-original-width="1600" data-original-height="1132" /></a>
<p>High voltage is needed to create sufficient voltage field in the chamber. Originally I didn't know how big it needs to be, so I added on the PCB a simple DC/DC converter to generate 400V DC. Tests show that 4x12V from batteries is sufficient, so while the DC/Dc converter is soldered (visible on the bottom left side of the picture), it's not used.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQuTERhwJQLy8hiKyO7Oc8gW6wHUUHSBgUWFaCyennZgW0hjow07elmbs-G7U5AQYcM4e8opTVflGGcBhyNR1yKUilYkyOPBZOH9cxwEfaUcejcuqOBLk6QDa888fMX9Iz4qMIs6-4ql-e/s1600/IonChamberDigitalSide.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQuTERhwJQLy8hiKyO7Oc8gW6wHUUHSBgUWFaCyennZgW0hjow07elmbs-G7U5AQYcM4e8opTVflGGcBhyNR1yKUilYkyOPBZOH9cxwEfaUcejcuqOBLk6QDa888fMX9Iz4qMIs6-4ql-e/s1600/IonChamberDigitalSide.png" data-original-width="1600" data-original-height="1132" /></a>
<p>Software was written in C, compiled by SDCC. A weird limitation of SDCC is that even if functions are unused, they are still compiled and added to final binary. I'm using StdPeriph as a HAL, so there is a lot of unused functions, that took space, so I ended up with adding #ifdef 0 ... #endif around each of them and then trying to compile and uncommenting those that are needed.</p>
<p>Below diagram shows results obtained from the device. As visible, it's quite sensitive.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFiNMWVXN01z_Vt76PitPw97xaRShEoqS4racBnBh-GZXFHM4zKFqRk6Dv9mA5H6sK4VlwRgQEVetYwrqR4TLdiyym6ftqhU0-ZPGxqa-Dn0gHwFW-q2n7RY69UoyZYYMRjbaxIbXJtc1M/s1600/results.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFiNMWVXN01z_Vt76PitPw97xaRShEoqS4racBnBh-GZXFHM4zKFqRk6Dv9mA5H6sK4VlwRgQEVetYwrqR4TLdiyym6ftqhU0-ZPGxqa-Dn0gHwFW-q2n7RY69UoyZYYMRjbaxIbXJtc1M/s1600/results.png" data-original-width="800" data-original-height="900" /></a>
<p>More detailed documentation, source code and PCB design are <a href="https://github.com/RobertGawron/IonizationChamber">available on project's GitHub</a></p>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3218008772058347246.post-36507829328543708492019-05-03T16:48:00.001+03:002019-05-31T18:54:42.767+03:00Camera nuclear-radiation sensor: part I<p>In previous posts I've described a radioactivity detector based on a photodiodes. Image sensors in cameras use photoelements too, so I think that they could be also used to detect radioactivity. At this moment i didn't success in this , nevertheless I will describe here my attempts.</p>
<p>I'm using RaspbberyPI, to get data from the sensor, camera is some low-budget/quality clone designed for RaspberryPI. I have removed optics, and covered whole camera in black tape to block any light coming to the sensor. It's visible on the picture below.</p>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuzBuqr9-k73y6nDwVzCBbiUy0grxWpjsvy-haPHhh9mg-S08AsK0QCaKkqUWJqO2vHc6IoEJn19EVmTPMjdT7Y2Sfx999jkiLgZDezXPOJuyrTr6seTL5YZ3r1w9lI-H6nAfway7M9pRZ/s1600/IMG_3276.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuzBuqr9-k73y6nDwVzCBbiUy0grxWpjsvy-haPHhh9mg-S08AsK0QCaKkqUWJqO2vHc6IoEJn19EVmTPMjdT7Y2Sfx999jkiLgZDezXPOJuyrTr6seTL5YZ3r1w9lI-H6nAfway7M9pRZ/s1600/IMG_3276.JPG" data-original-width="1600" data-original-height="1200" /></a></div>
<p>To handle the camera on the software side, I'm using Python script (with PiCamera library). In infinitive loop it takes a photo and calculate sum of pixels value and then sums values of each RGB channel. This value with timestamp is put to CSV file that is later parsed to diagrams using R script.</p>
<p>Without any sample, internal noise of the sensor (and maybe background radiation) should give after some time (e.g. after a couple of hours) a Gaussian curve on the histogram. After putting measured sample to the sensor and waiting similar period, a new Gaussian curve would appear, so that the histogram would have to visible peaks. That was my assumption, hit would prove that the sensor works, however as visible below it doesn't - there is only one peek.</p>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwbTMjubxXpQhUeJrqXzKqAMDxBwTgvJ4iDxZNelx8orhfsORxw2uV-xTnEYdvfl-KrXtGRKAkcL16z1A9W88a7pFyPK9HFZixP3JIBX2NMI9hbfe3yHOsAPyUeZSzL8pFAAkTVpxE0MYh/s1600/results-05_Apr_2019_16_54.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwbTMjubxXpQhUeJrqXzKqAMDxBwTgvJ4iDxZNelx8orhfsORxw2uV-xTnEYdvfl-KrXtGRKAkcL16z1A9W88a7pFyPK9HFZixP3JIBX2NMI9hbfe3yHOsAPyUeZSzL8pFAAkTVpxE0MYh/s1600/results-05_Apr_2019_16_54.png" data-original-width="800" data-original-height="900" /></a></div>
<p>I will try to better isolate the sensor also from electromagnetic noise or maybe buy a new camera (less noisy). Other than that I don't have ideas to make it works.</p>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-3218008772058347246.post-8165069973753621582019-05-03T16:12:00.000+03:002019-05-03T16:12:16.504+03:00Weird arrays in C<p>Recently I've saw quite strange way to create an array in C. I will describe it bellow - looks quite interesting!</p>
<p>Let's assume we have an array given bellow:</p>
<pre>int myArray[4];</pre>
We could rework it, so that each element is declared separately:
<pre>
int myArray0;
int myArray1;
int myArray2;
int myArray3;</pre>
<p>Now we can obtain pointer to first element and last element, and iterate through elements in between it as with regular array. We exploit that compiler will probably put those variables in the same order in the same place in memory.</p>
<p>A full example is given below:</p>
<pre>#include <stdio.h>
void processElement(int e)
{
printf("processing element in array, it has value %d\n", e);
}
int main()
{
int myArray0 = 0;
int myArray1 = 1;
int myArray2 = 2;
int myArray3 = 3;
// dummy way to force compiler not to optimalize-out our array members
printf("%d\n%d\n%d\n%d\n", &myArray0, &myArray1, &myArray2, &myArray3);
int *start = &myArray0;
int *stop = &myArray3;
if(start > stop)
{
start = &myArray3;
stop = &myArray0;
}
for(int* it= start; it <= stop; *it++)
{
processElement(*it);
}
}
</pre>
<p>:)</p>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3218008772058347246.post-35825961246426554012019-05-03T14:45:00.001+03:002019-05-26T22:53:21.152+03:00Semiconductor nuclear-radiation sensor: part III<p>In this post I will present a new hardware version of my sensor, older versions are described in <a href="https://robertgawron.blogspot.com/2016/12/semiconductor-radioactivity-detector.html">part I</a> and <a href="https://robertgawron.blogspot.com/2019/02/semiconductor-radioactivity-detector.html">part II</a>. In comparison to the previous one, sensitivity is roughly x10 more sensitive.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggl394tNDeOcHw0Ik7AIUGOG1BUqb3Nxcg5xVN6mXcidKvRJofBdfg737Qbs8BPHW1kDw7VqW0jtp0pyWM0kBYDCsWnVvqryu9UmhRdjjsxeQ2AcvVKFrr9XPzT4mnz8m4LQO8Ki6QSjOb/s1600/IMG_3274.JPG" imageanchor="1"><img border="0" data-original-height="1200" data-original-width="1600" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggl394tNDeOcHw0Ik7AIUGOG1BUqb3Nxcg5xVN6mXcidKvRJofBdfg737Qbs8BPHW1kDw7VqW0jtp0pyWM0kBYDCsWnVvqryu9UmhRdjjsxeQ2AcvVKFrr9XPzT4mnz8m4LQO8Ki6QSjOb/s640/IMG_3274.JPG" width="640" /></a>
<p>In previous version, tin foil window for photodiodes was very close to the BNC sockets and because enclosure was small, it was hard to place a sample close enough. Not it's better, however, if I would choosing again, I would use metal enclosure similar to those used in PC oscilloscopes and put BNCs on front panel, power socket on rear panel and tin foil window on top. This would allow me to easier access for debugging- now I have to desolder sockets to get to photodiodes or to bottom side of PCB (fortunately this side is empty).</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2wjxaoImULKJZVlT5aMuyDOEXK4AvvlgyvsLjpW9BMCMRGhJ9OrUkfGczmkJ25VsWkhAdhdj0y2DJzc89sEJecvuvMa2wROzVKnsuTwIPa9wWHNzYYhTNEgVw8pouCtw3DOjS5dfvHnQI/s1600/IMG_3261.JPG" imageanchor="1"><img border="0" data-original-height="1200" data-original-width="1600" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2wjxaoImULKJZVlT5aMuyDOEXK4AvvlgyvsLjpW9BMCMRGhJ9OrUkfGczmkJ25VsWkhAdhdj0y2DJzc89sEJecvuvMa2wROzVKnsuTwIPa9wWHNzYYhTNEgVw8pouCtw3DOjS5dfvHnQI/s640/IMG_3261.JPG" width="640" /></a>
<p>Bellow you can see the diagram (click on it to enlarge), what has changed in comparison to previous version:</p>
<ul>
<li>One additional photodiode (previous version has only two of them) to increase sensitivity, also the window in enclosure is much bigger</li>
<li>x10 bigger resistance of the feedback loop resistor in first stage amplifier, I tried bigger, but then osculations started</li>
<li>Bias for photodiodes using 12V batteries, I could increase it, but didn't have enough space in this enclosure</li>
<li>Buffer op-amp at the analog output</li>
<li>Digital output.</li>
</ul>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9YAfsLWzFLSc4KQNC29KQYYfV1h6NiwVt34EzL5OCEQ5cHoZQkX3AfmjUxXC4gVofCwT34jPrNv65woQbFodDTKm3d-rPDVrQw0UsXpRRZpA5yci0QANIiLYf9-nheRVf58O3yJPzxhlT/s1600/p1d9ujoipb1vdl1p3ccgff3015er4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9YAfsLWzFLSc4KQNC29KQYYfV1h6NiwVt34EzL5OCEQ5cHoZQkX3AfmjUxXC4gVofCwT34jPrNv65woQbFodDTKm3d-rPDVrQw0UsXpRRZpA5yci0QANIiLYf9-nheRVf58O3yJPzxhlT/s1600/p1d9ujoipb1vdl1p3ccgff3015er4.png" data-original-width="1600" data-original-height="761" /></a></div>
<p>Additional changes not shown on diagram:</p>
<ul>
<li>U1 is OPA657U</li>
<li>U2 is OPA656U</li>
<li>R4 is 1G</li>
<li>As close as possible to input power socket are placed in paraller 1n/16V and 100n/16V, without them the device started to oscillate randomly.</li>
<li>A Schottky diode is connected in series after mentioned above extra capacitors to reduce risk of damaging the device when power supply is connected incorrectly. I don't know if it will help enough but I have already broke one PCB of this device this way, so now it's there.</li>
</ul>
<p>Digital output is 12V in high state, 0V in low state, this is not very useful for 3V3 logic microcontroller that I'm using for data acquisition, so I made a simple converter using additional PCB.</p>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQSIwIEHwS5ZRHGHJ2ce0_DzLafW4NJmIv-uzldPkOWxvbwuI3NmigiIEJ7PLtY_CfHhu9wKNWwjYPdT3js_Faz_RRK3WP3XdXTVlD_Cw7h4S1F5URfYPyYkFTAFgp4zRXE7ql0ITQqhFZ/s1600/p1d9umb70ukl1plkhth1ine168v4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQSIwIEHwS5ZRHGHJ2ce0_DzLafW4NJmIv-uzldPkOWxvbwuI3NmigiIEJ7PLtY_CfHhu9wKNWwjYPdT3js_Faz_RRK3WP3XdXTVlD_Cw7h4S1F5URfYPyYkFTAFgp4zRXE7ql0ITQqhFZ/s1600/p1d9umb70ukl1plkhth1ine168v4.png" data-original-width="1600" data-original-height="704" /></a></div>
<p>Here it is visible soldered. I like in those SMA Female sockets that they can be soldered to the edge of the PCB (as visible below) and this is still quite mechanically stable, but doesn't require to drill holes as in regular mounting way.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUGmgX0Gi1IJl05vl2Fo-Ui3JsZBe9JqGMRkeLgd2oAJ4xM-EVEQXH0VRdG-mR5U3Pur0Vx6MkzB-BJqoocXJ0nP5GizO_kEYGkIaRSCrsWCg0B7UWMLO_10FWPxAxYLaopaGBqPFq3Hy2/s1600/IMG_3265.JPG" imageanchor="1"><img border="0" data-original-height="1200" data-original-width="1600" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUGmgX0Gi1IJl05vl2Fo-Ui3JsZBe9JqGMRkeLgd2oAJ4xM-EVEQXH0VRdG-mR5U3Pur0Vx6MkzB-BJqoocXJ0nP5GizO_kEYGkIaRSCrsWCg0B7UWMLO_10FWPxAxYLaopaGBqPFq3Hy2/s640/IMG_3265.JPG" width="640" /></a>
<p>All materials (including software part presented in previous post) for this hardware revision <a href="https://github.com/RobertGawron/SemiconductorRadioactivityDetector/releases/tag/4.0">can be downloaded from project's repository.</a></p>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3218008772058347246.post-91769442845917580132019-02-17T22:41:00.002+02:002019-05-31T17:37:45.521+03:00Semiconductor nuclear-radiation sensor: part II<p>There are many ways to measure radioactivity level, semiconductor detectors sense interactions between ionizing radiation and p-n junction. Because in hobbyist area most popular are <a href="https://robertgawron.blogspot.com/2015/02/homemade-geigermuller-counter-part-i.html">Geiger-Muller based detectors</a> (in short: not a semiconductor but lamp based devices), I think it's a cool idea to take a look at this approach.</p>
<p>In this post I will present such home-made sensor and a set of software to parse collected results.</p>
<p>Picture below presents circuit of the sensor that I made, it consist of a photodiode that acts as a sensor, transimpedance amplifier and "regular" amplifier. I've selected op-amps that has little input noise.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh076l0mrPhRZJ7UBdrbNFtQ2eGXgkhpnEQ132HcCrIIlEe7c7Rzrvx4hE7ZqRT7r2QOBDBlo14ENzRXwiNuEoDpFOryE642C1l4yukyN1SwSg57utqtwK6qpmA-MSfSl9oweWP7EG81S6/s1600/p1d3ubascj15i01u6thm1cqb11294.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh076l0mrPhRZJ7UBdrbNFtQ2eGXgkhpnEQ132HcCrIIlEe7c7Rzrvx4hE7ZqRT7r2QOBDBlo14ENzRXwiNuEoDpFOryE642C1l4yukyN1SwSg57utqtwK6qpmA-MSfSl9oweWP7EG81S6/s1600/p1d3ubascj15i01u6thm1cqb11294.png" data-original-width="1600" data-original-height="639" /></a>
<p>Changes that I made during testing the device, that are not presented on the diagram:</p>
<ul>
<li>D1 is BPW34</li>
<li>U1 is OPA657U</li>
<li>U2 is OPA656U</li>
<li>2p capacitor is connected in parallel with R6</li>
<li>820k resistor is connected between U2 out and BNC socket.</li>
</ul>
<p>Below is visible sensor in enclosure and without it. Because the device is sensitive for background EMI and light noise, a metal housing is needed. To increase exposure of the sensor to the radiation, where it is, in the housing, a hole is made and just a tiny adhesive metal tape is covering it.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfXY3NkkBxFwe_MzHgYqE_MFF2o8wPuYerKbICgHp6gN-4z0_7Am6m9OPmZPN_uqol-_5nt9W5lVl5PKci4PzNcehnI0fqdQPey8NWmK5k_-rtjif3v5w5JPm67LhsGHZkkZ22CImOeHQW/s1600/IMG_3252.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfXY3NkkBxFwe_MzHgYqE_MFF2o8wPuYerKbICgHp6gN-4z0_7Am6m9OPmZPN_uqol-_5nt9W5lVl5PKci4PzNcehnI0fqdQPey8NWmK5k_-rtjif3v5w5JPm67LhsGHZkkZ22CImOeHQW/s1600/IMG_3252.JPG" data-original-width="1600" data-original-height="1200" /></a>
<a name='more'></a>
<p>Because the housing was used in different projects, a lot of holes was made and a lot of additional tape was needed to cover them.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPyFvdftW6aju951sO2s0hSmPYDcY1n08lnTGJ4cTgY04St7Q3mLQ564xt6-F0cdHvYPrYBNyN1pJl9uUQInfQSXWxOV6B6Y2rbOuv-zs8q_A4DqECfhqUJsIv_H-BtbxdYw_nJoMyQvhyphenhyphen/s1600/IMG_3247.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPyFvdftW6aju951sO2s0hSmPYDcY1n08lnTGJ4cTgY04St7Q3mLQ564xt6-F0cdHvYPrYBNyN1pJl9uUQInfQSXWxOV6B6Y2rbOuv-zs8q_A4DqECfhqUJsIv_H-BtbxdYw_nJoMyQvhyphenhyphen/s1600/IMG_3247.JPG" data-original-width="1600" data-original-height="1200" /></a>
<p>PCB was cleaned using cheap ultrasonic washer and isopropyl alcohol to avoid flux residues.</p>
<p>Diagram below presents how the sensor is connected. All diagrams were created using LATEX, and can be automatically regenerated using documentation/creatediagrams.h script.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7-nVQS_D6hJx-RE3CU1atJqccIuN5U8ENPXelRUeZNO04bOo0TMim5Tt6FHdWKSpceg3kf-gO0TpkK0aKJW1aendnTCl-gtYRl6LSlGR6tj1ObU3I6XKSH1WXPxeuc6h5OZvDTKB5_k4Y/s1600/diagram-output-1.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7-nVQS_D6hJx-RE3CU1atJqccIuN5U8ENPXelRUeZNO04bOo0TMim5Tt6FHdWKSpceg3kf-gO0TpkK0aKJW1aendnTCl-gtYRl6LSlGR6tj1ObU3I6XKSH1WXPxeuc6h5OZvDTKB5_k4Y/s1600/diagram-output-1.png" data-original-width="1587" data-original-height="359" /></a>
<p>Sensor and oscilloscope are connected via BNC cable, not via a regular probe because. BNC-BNC connection is more mechanically stable and can be used here.</p>
<p>Oscilloscope is used as a dirty hack because I don't have yet a circuit to convert analog output of the sensor to digital form. It's connected with Nucleo board via it's trigger out, so when the trigger occurs, the state is high for some moment. Coupling is set to AC to skip DC bias. Level of the trigger is set in a way that pulses are visible when the sample (that is radioactive) are visible and aren't when no sample is present. It's not the best way, but it works.</p>
<p>Below is a sample "count" occurrence.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnL5b83C2p6RxSMNIOWGNR42Cf7rQV4Nv1djpcblO0pvyTxiryCL_UevIK0COPcit6gfzidGWVo2Rrh6yvZylVI8SzIfyV5uX0DT5MYSkbt17w7u95j2nqen9MAp5zpplKNqrK6uOASPgF/s1600/DS1Z_QuickPrint5.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnL5b83C2p6RxSMNIOWGNR42Cf7rQV4Nv1djpcblO0pvyTxiryCL_UevIK0COPcit6gfzidGWVo2Rrh6yvZylVI8SzIfyV5uX0DT5MYSkbt17w7u95j2nqen9MAp5zpplKNqrK6uOASPgF/s1600/DS1Z_QuickPrint5.png" data-original-width="800" data-original-height="480" /></a>
<p>To collect and easily display of the data, I used a STM32F103RBT6 board, output of the sensor is connected to a pin that raises external interrupt. On interrupt, counter is increased, each 60 seconds, counter value is presented on the display (making bar graph) and its value is send to the host CPU (Raspberry PI) for further processing. The board is powered via USB.</p>
<p>To analyze the data in detail, I made set of scripts on Raspberry, theirs connections are presented below. It all could all be just written in Python but I don't like visual appearance of its plotting libraries, therefore python part is storing data into .cvs, that is periodically transformed into a diagram by a R script. The R script is based heavily on the one that I used to <a href="https://robertgawron.blogspot.com/2018/09/collecting-and-processing-data-from.html">communicate with my bench multimeters (click to go to the article).</a></p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTC3EgQ3n9drxcFsgKaSHuONP6HCA7k4IWIrvh8BJT4eYQacyvljOF6Ldua0fEFQKBYwJfEmrjVcyF8-on2Pqsgg3IGk-r1Dpr-JTZkKDd8pXzeaEuUbsr1AYBJmMJ4xZYc4l3Dj_3_lOf/s1600/hostarchitecture-1.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTC3EgQ3n9drxcFsgKaSHuONP6HCA7k4IWIrvh8BJT4eYQacyvljOF6Ldua0fEFQKBYwJfEmrjVcyF8-on2Pqsgg3IGk-r1Dpr-JTZkKDd8pXzeaEuUbsr1AYBJmMJ4xZYc4l3Dj_3_lOf/s1600/hostarchitecture-1.png" data-original-width="1600" data-original-height="166" /></a>
<p>Regarding running the scripts, in one terminal (i'm using Linux <a href="https://linux.die.net/man/1/screen">screen</a> command-line tool), a python script is executed. In addition of creating output file, it will also print collected data to STDIO. Sample usage is below:</p>
<pre><b>root@raspberrypi:/home/pi/repositories/SemiconductorRadioactivityDetector/software/presentation# python3 ./datalogger.py</b>
2
3
2
1
</pre>
<p>In a second window, the R script is run to parse the data into a .png image. Output file has theirs creation timestamp as part of file name. Sample usage below:</p>
<pre><b>root@raspberrypi:/home/pi/repositories/SemiconductorRadioactivityDetector/software/presentation# Rscript script.R</b>
Loading required package: lattice
Loading required package: RColorBrewer
Loading required package: gridExtra
Loading required package: grid
</pre>
<p>Regarding results, here are some of meassurements.</p>
<p>Measuring an old military compass with radioactive tips:</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXmOQmwU1h6sMe7b01YQ68mxiUg70LkI2oVdCc1ldeqO0LDVaRGKb5zijisrHeDoRhA2NheKbVY0_qq95eVgp_YF0Iai5-XcfCbP6vBxPvmzetoWxfJpNMjKvD-tra18y0hbpz0ebUmFgS/s1600/results-17_Feb_2019_20_00.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXmOQmwU1h6sMe7b01YQ68mxiUg70LkI2oVdCc1ldeqO0LDVaRGKb5zijisrHeDoRhA2NheKbVY0_qq95eVgp_YF0Iai5-XcfCbP6vBxPvmzetoWxfJpNMjKvD-tra18y0hbpz0ebUmFgS/s1600/results-17_Feb_2019_20_00.png" data-original-width="800" data-original-height="900" /></a>
<p>Measuring thorium welding rods:</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjELuB_DNDBnmLk99inDmTHRWZTUBxf12tK7hx04l-1QQiB2ptaF34NUjQRQiJHJSV-eKAaUVt2CuAqF_IBaXrRnLS_rCj9AtzDmS8ogN48y2fX1un1L4r65BSwT7XW6ftyz0pp9ZQLRmP/s1600/results-17_Feb_2019_22_13.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjELuB_DNDBnmLk99inDmTHRWZTUBxf12tK7hx04l-1QQiB2ptaF34NUjQRQiJHJSV-eKAaUVt2CuAqF_IBaXrRnLS_rCj9AtzDmS8ogN48y2fX1un1L4r65BSwT7XW6ftyz0pp9ZQLRmP/s1600/results-17_Feb_2019_22_13.png" data-original-width="800" data-original-height="900" /></a>
<p>Measuring background radioactivity:</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDbW72efQGABR0eo2tsuWkWNDnaoU6_KzWaHdi0rdE8CxzNqoqjFH_EDKU0HAes2I3PtZZq7iJ837Jiyrzzajw3tyaJ7yTztKWhJv-vCanvN5K1hxWD_dygWqCPe1eMb1-EeH_jEOjR0PR/s1600/results-17_Feb_2019_22_36.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDbW72efQGABR0eo2tsuWkWNDnaoU6_KzWaHdi0rdE8CxzNqoqjFH_EDKU0HAes2I3PtZZq7iJ837Jiyrzzajw3tyaJ7yTztKWhJv-vCanvN5K1hxWD_dygWqCPe1eMb1-EeH_jEOjR0PR/s1600/results-17_Feb_2019_22_36.png" data-original-width="800" data-original-height="900" /></a>
<p>All <a href="https://github.com/RobertGawron/SemiconductorRadioactivityDetector">project files can be downloaded from my Github</a>, branch name is feature/hw_rev_3_0
.</p>
<p>That's all, thanks for reading :-)</p>Unknownnoreply@blogger.com11tag:blogger.com,1999:blog-3218008772058347246.post-74214473043546097252018-09-28T15:14:00.000+03:002019-05-26T22:37:47.169+03:00Collecting data from measurements devices using USBTMC, SCPI, Python and R <p>High end test gear allows two-way communication with PC to set measurement parameters and to send the measured data to PC for further analyze. On PC side there are applications for this (LabView, BenchVue), but they are expensive. One option is to make own program/script that will communicate with the device and parse/present measured data - this approach I will present it in this post. The tool I'm using it with is <a href="https://www.keysight.com/en/pdx-2835291-pn-34460A/digital-multimeter-6-digit-basic-truevolt?cc=US&lc=eng">34460A(digital multimeter)</a>.</p>
<p>Below is an example of the measurement graph made using this home-made software.</p>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpDUKRe4knzV6jElij6M3VrBIp7AnBoNPIOinBr8ACWwB-FHqgRbn4wYVhSgWnu1232h10K1rkt876UNy15T_TxYRG3BhfeeSd4m3sCKGgB8cXJOWazStHS5PYg2D23xA9rAP2FsVmgGzG/s1600/results.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpDUKRe4knzV6jElij6M3VrBIp7AnBoNPIOinBr8ACWwB-FHqgRbn4wYVhSgWnu1232h10K1rkt876UNy15T_TxYRG3BhfeeSd4m3sCKGgB8cXJOWazStHS5PYg2D23xA9rAP2FsVmgGzG/s1600/results.png" data-original-width="800" data-original-height="900" /></a></div>
<p>The module of communication with the device I made in Python, it stores data to .csv file, that is later parsed by a script in R and the output graph is stored as .png image. The R part could ass well do some numeric stuff and print it on STDOUT, but for me that was not the case.</p>
<p>Initially all was in Python, but I didn't like Python's graphs, they weren't visually nice.</p>
<p>Python part when started will save measurements to the .csv file constantly, at any time, user can run R script to create new graph.</p>
<h2>Installation steps</h2>
<p>Assuming device driver correctly enumerate in the <i>Device Manager</i> (if not one needs to install its drivers first).</p>
<ul>
<li>Install Python and R, add them to <i>Path</i> (environment variable).</li>
<li>In R, install following packages: latticeExtra, gridExtra, grid.</li>
<li>In Python install following packages: usbtmc, pyusb.</li>
<li>On Windows, download libusb-win32 and follow README steps to bind it to the device. In addition it didn't work for me if I didn't run the tool as an Administrator. If everything went ok, device will be visible in Device Manager in branch named <i>libusb-win32 devices</i>.</li>
<li>Download Python/R scripts, they are available via my <a href="https://github.com/RobertGawron/IonizationChamber/tree/master/software/DMMDataAcquisition">IonizationChamber repository.</a></li>
<li>In main.py, replace idDMM with id of the device.</li>
</ul>
<p><a href="https://github.com/python-ivi/python-usbtmc/issues/46">For usbtmc, I got the same problem as described here</a>, fortunately the fix presented in that thread fixed it, so please check it if you have some weird stacktrace errors in Python.</p>
<h2>Usage</h2>
<p>I made those scripts for my personal use, so they may be a bit awkward to work with, but once the setup is done, everything should work fine.</p>
<ul>
<li>Set meassurement type and range on your device (this could be also done via python script)</li>
<li>Start python script</li>
<li>Run R script, it will create results.png file with graphs.</li>
</ul>
<p>That's all.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3218008772058347246.post-53637699988954248962017-02-19T17:25:00.000+02:002019-05-26T22:38:06.270+03:00Negative resistance oscillators<p>Normally -according to the <a href="https://en.wikipedia.org/wiki/Ohm's_law">Ohm's law</a>- when the applied voltage is increasing, the current is increasing too, however some components can break this law. When the voltage increases, current decreases. This is called <a href="https://en.wikipedia.org/wiki/Negative_resistance">negative resistance</a>.</p>
<p>One of the most know element that exhibits this behavior is a <a href="https://en.wikipedia.org/wiki/Tunnel_diode">tunnel diode</a>. Once very promising, today it isn't widely used in popular designs and occupies a niche in microwave applications. It's a bit challenging to get one, fortunately simple circuits that have <a href="https://en.wikipedia.org/wiki/Negative_resistance">negative resistance feature</a> can be build from popular discrete elements. One of them I will present today.</p>
<center>
<iframe width="800" height="450" src="https://www.youtube.com/embed/iXfbbxoalns" frameborder="0" allowfullscreen></iframe>
</center>
<p>The circuit is so called <b>"negistor"</b> - a regular npn transistor connected in a way that the base is not connected at all, and collector-emiter junction is polarized in reverse direction. The generator that uses negative resistance is presented below, and consists of R1, C1 and T1, the voltage when it works is between 9-12V, R2, C2 are used to block DC voltage, D1 is used to indicate if the generator works. T1 works as the negistor.</p>
<p>It's worth noticing that the tunnel diode works due to a quantum effect called <a href="https://en.wikipedia.org/wiki/Quantum_tunnelling">quantum tunelling</a>, I'm not exactly sure if the negistor works also due to it.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglcaMrRB9-70h5Y7DrOzMzjjlNdGrbKh2Fu1NkOjJ5IBqhPUKDlZJMdkKi-HbfvFHIB28_ZPmJbmrEWwPbS0NDg8vyE0YA515FraUS4i2mzbIiuY2e_Rb5toTjVNmbt866v-1hV8CLTFkC/s1600/negistor.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglcaMrRB9-70h5Y7DrOzMzjjlNdGrbKh2Fu1NkOjJ5IBqhPUKDlZJMdkKi-HbfvFHIB28_ZPmJbmrEWwPbS0NDg8vyE0YA515FraUS4i2mzbIiuY2e_Rb5toTjVNmbt866v-1hV8CLTFkC/s320/negistor.png" width="299" height="320" /></a>
<p>Below you can see the voltage on the TP1 (test point), on the first image the scope was is in DC coupled mode, on the second in AC coupled mode.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQj7izydwL_po3oztx7tF5xSn1tuwqbUiidUZ0h-vS96xuSegNEn4sdqONtyrL3JSHzvz81HDwEHv-Mej9e_O_8Y7KyPnI4d8rmj2kvjy9PiJbsYYCqJmXZ9aumjhI8vi8nk1Za_uuz5D1/s1600/DS1Z_QuickPrint44.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQj7izydwL_po3oztx7tF5xSn1tuwqbUiidUZ0h-vS96xuSegNEn4sdqONtyrL3JSHzvz81HDwEHv-Mej9e_O_8Y7KyPnI4d8rmj2kvjy9PiJbsYYCqJmXZ9aumjhI8vi8nk1Za_uuz5D1/s1600/DS1Z_QuickPrint44.png" /></a>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiootyuOnKogosQnnmH-LLkJsCc3pS1Q8fokueM2cbYJz9Y4zFA5ClzjTJsvehH7PlXqqH41U2qkwmOz0QJA6hCHUkHqtnSLWlF5pyItCTFR1ML2rvFZ1_7sVYMryY03LX2ZwMHJpKB7xyM/s1600/DS1Z_QuickPrint45.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiootyuOnKogosQnnmH-LLkJsCc3pS1Q8fokueM2cbYJz9Y4zFA5ClzjTJsvehH7PlXqqH41U2qkwmOz0QJA6hCHUkHqtnSLWlF5pyItCTFR1ML2rvFZ1_7sVYMryY03LX2ZwMHJpKB7xyM/s1600/DS1Z_QuickPrint45.png" /></a>
<!--
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhphBsnlrqAO-KrDGgrDY3VDF4NV2ey8qRJR-3Q1T3gbHgBXleckix6zXT1tjAkPm8CPxds3Uo16IuQTX8nbg6AshSkUZAHx5lr2Id0wzTBo3dyPM3t4pXfdGKnBA0U01YLwzFTf8Zvf0Z/s1600/DS1Z_QuickPrint46.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhphBsnlrqAO-KrDGgrDY3VDF4NV2ey8qRJR-3Q1T3gbHgBXleckix6zXT1tjAkPm8CPxds3Uo16IuQTX8nbg6AshSkUZAHx5lr2Id0wzTBo3dyPM3t4pXfdGKnBA0U01YLwzFTf8Zvf0Z/s1600/DS1Z_QuickPrint46.png" /></a>
-->
<p>Other configurations od the oscillators based on the negistors can be found on <a href="http://www.vk2zay.net/article/157">Alan's blog</a>.</p>
<p>Another circuit that also exhibits negative resistance region is a <a href="https://en.wikipedia.org/wiki/Lambda_diode">lambda diode</a>. While P-JFETs aren't widely popular, it's <a href="http://www.zen22142.zen.co.uk/Theory/neg_resistance/negres.htm">possible to replace it by an npn transistor, as presented in this article</a>. An interesting <a href="http://users.tpg.com.au/users/ldbutler/NegResDipMeter.htm">oscillator based on the lambda diode is presented here</a>.</p>
<p>The idea of a negative resistance is something very interesting and it's worth to take a look on it. Another fascinating and simple generator is a <a href="https://en.wikipedia.org/wiki/Joule_thief">Joule thief</a> but this is a topic for another post.</p>Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-3218008772058347246.post-50239054795438878522017-01-08T20:26:00.003+02:002019-05-31T17:38:02.527+03:00Raspberry Pi 3 nuclear-radiation monitoring station<p>Recently I've found <a href="https://apollo.open-resource.org/lab:pigi">Pi-GI, it's an open source project of a radiation monitoring system</a> based on Raspberry Pi, and (open source hardware) Geiger-Muller detector. Statistics are available through a web page, so it's possible to use it conveniently on a PC, tablet or a phone. It's written in python.</p>
<p>Today I will present how I've glued together this software and <a href="https://robertgawron.blogspot.com/2015/02/homemade-geigermuller-counter-part-i.html">my Geiger-Muller counter described in my previous posts</a>.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2MPII1EPf5nnJE9am3DMc_HW_HqRiuiZFOJOSWAp1aaTolViNbo39lJWkh9llMV6XCVulJXSioWnOVF8tdPSPybRC7adG7sOKunSW7NGfom9v004iIZ_FCRGdKF7cr0XUiWbwzIqFgo_D/s1600/IMG_2737.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2MPII1EPf5nnJE9am3DMc_HW_HqRiuiZFOJOSWAp1aaTolViNbo39lJWkh9llMV6XCVulJXSioWnOVF8tdPSPybRC7adG7sOKunSW7NGfom9v004iIZ_FCRGdKF7cr0XUiWbwzIqFgo_D/s1600/IMG_2737.JPG" /></a>
<p>Below is a circuit of my counter, it uses 5V power supply and draws a couple of mA, so it's possible to power it directly from Raspberry. Since originally I've used three tubes in parallel, I had to remove two of them to not have values multiplied by three - most of the detectors and software for them uses only one tube.</p>
<p>Raspberry Pi requires 3V3 logic on GPIO ports, fortunately, that's not a problem here, pin 3 of SV3 socket just needs to be connected to 3V3 rail on the Raspberry Pi. The output (pin 2 of the same socket) needs to be connected to one of the GPIO pins. It's a bit confusing, because <a href="https://apollo.open-resource.org/lab:pigi:hardware">on the webpage the circuit states that GPIO0 is used</a>, but in the current version of the software GPIO4 is used instead. The pin can be configured in software by editing gpio_port variable in PiGI/software/conf/default.cfg</p>
<p>Software <a href="https://apollo.open-resource.org/lab:pigi#software">installation and configuration is presented in this article</a>, in addition, because I use STS-5 tubes, I had to change the tube type in PiGI/software/conf/default.cfg - SBM-20 has almost the same parameters as STS-5.</p>
<pre>
60 # See: https://apollo.open-resource.org/lab:pigi:common-geiger-tube-parameter
61 tube_id = <b>SBM-20</b>
62
63 # GM tube specific cpm to microsievert/h conversion factor
64 tube_rate_factor = <b>0.00277</b>
</pre>
<p>Application starts by default on 8080 port, so logs are available by the web on http:/[IP of the Raspberry Pi]:8080 address. By default it starts in simulation mode, to change it and get real values, it's needed to change in http://[IP of the Raspberry Pi]:8080/webGI/index.html#serverOptionsPanel source to "environment".</p>
<p>That was all, now I'm able to monitor radioactivity just from my browser!</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQtgZeYDLxb0A6KQdgMGX4t_0vvt3O2RAsi3xymSO3kX6b7LY_dyVJCyWxbGDAi5mXA33SzAVIrW_IwNtTyyamADwZ_0cHcZzMyxxQF3w1-qOTdi2DwgPUER2Zgsxci8qjDg15x6d3aqgu/s1600/raspberry_radioactivity_monitoring.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQtgZeYDLxb0A6KQdgMGX4t_0vvt3O2RAsi3xymSO3kX6b7LY_dyVJCyWxbGDAi5mXA33SzAVIrW_IwNtTyyamADwZ_0cHcZzMyxxQF3w1-qOTdi2DwgPUER2Zgsxci8qjDg15x6d3aqgu/s1600/raspberry_radioactivity_monitoring.png" /></a>
<p>On the picture above, you may see an increased radioactivity level, I've placed smoke detector containing a radioisotope of americium on the GM tube, at the end is visible big decrease, this is because I've taken the smoke detector out, so only environmental radiation was present.</p>
<p>The value drops to 20-25 pulses per minute, that's normal value for environmental radioactivity - it's mentioned in the tube datasheet.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3218008772058347246.post-18196806184362411302016-12-28T23:20:00.002+02:002019-05-31T17:38:12.038+03:00Nuclear-radiation detection using very simple ionization chamber and a single J-FET transistor<p>Today I will show a very simple ionization chamber that can detect radioactivity. I was able to detect with it <a href="https://robertgawron.blogspot.com/2016/12/nuclear-physic-applied-in-smoke.html">ionizing radiation from a smoke detector (Am<sup>241</sup> isotope)</a>. It's also immune to electromagnetic interference (EMI) due to a good shielding.</p>
<p>This device doesn't explicitly use any power supply. It's connected to a multimeter set to measure resistance, in this mode, the multimeter provides a small voltage to its probes (R=I/U, so to measure resistance, it has to put voltage across measured element). This is sufficient here, because basically we just need to polarise electrodes of the ionization chamber and nothing more. My multimeter provides 5.6V in this mode.</p>
<p>My setup is presented below, note that the sensor is this metal box, not the PCB visible on the image.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisNUXduI8YDn3DqcHV1gpRL_jy5HEHuLPQsz9y4JqcoHCi0bBGdzvWj_UwAIzIuAsDT2LVV-Z8CzmSuyAfdOTxHT1ykG_gQRdgBPEJBbykFLPnI0R57yhg1QK4Zt0Hi7DChvc2ZxDYDBxY/s1600/IMG_2724.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisNUXduI8YDn3DqcHV1gpRL_jy5HEHuLPQsz9y4JqcoHCi0bBGdzvWj_UwAIzIuAsDT2LVV-Z8CzmSuyAfdOTxHT1ykG_gQRdgBPEJBbykFLPnI0R57yhg1QK4Zt0Hi7DChvc2ZxDYDBxY/s1600/IMG_2724.JPG" /></a>
<p>The chamber is made from copper plate soldered carefully to prevent any holes where electromagnetic fields could flow and disturb readings. Inside is one <a href="http://akizukidenshi.com/download/ds/fairchild/BF256B.pdf">BF256B (n-channel J-FET) transistor</a>, its gate is connected to one of ionization chamber plate made from a leg of a THT resistor, source pin is available externally, this is where "plus" probe of the DMM is connected, drain is connected to the metal case (that is both and electrode and is shielded against EMI).</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr0hcdDpEjODlBbG31JmfLUdUMfcpAiW6YwDlddKT6eM_aqvFqasdOhyphenhypheneuWomQTP-FnEvNWzJS4OIiptOudVbol1fYvfsq2v2ns3gIrUHMAXvuY5BdXxE1Ct-py6sOUY8L0XzYdvjUCdPp/s1600/IMG_2726.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr0hcdDpEjODlBbG31JmfLUdUMfcpAiW6YwDlddKT6eM_aqvFqasdOhyphenhypheneuWomQTP-FnEvNWzJS4OIiptOudVbol1fYvfsq2v2ns3gIrUHMAXvuY5BdXxE1Ct-py6sOUY8L0XzYdvjUCdPp/s1600/IMG_2726.JPG" alt="ionization chamber circuit"/></a>
<p>I've used Keysight 34460A as a multimeter here, because it has histogram mode, that will be useful to look if the measured value is stable over time. PLC was set to 0.2, it will reduce accuracy, but will give much more samples.</p>
<p>Below two images present what is inside of the sensor (only JFET, as mentioned above) and the sensor mounted. The front was shielded using tin foil, that was secured tightly by insulation tape.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQamYg3YeGFfuIDBGAD_WeXG8x1lgCrekE2xuvP5u3W8i1n94XjyDaVeFvL8ABeLsBLMhTMLzVOxck4UDzym92klx8N7GvUDIpKSkS8F1_y4R2lDBzOE_EGl55NvBuSY2HH-6q9YvloLwQ/s1600/IMG_2716.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQamYg3YeGFfuIDBGAD_WeXG8x1lgCrekE2xuvP5u3W8i1n94XjyDaVeFvL8ABeLsBLMhTMLzVOxck4UDzym92klx8N7GvUDIpKSkS8F1_y4R2lDBzOE_EGl55NvBuSY2HH-6q9YvloLwQ/s1600/IMG_2716.JPG" /></a>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXwDJBDtMhVtt-TScAbLv8_OHQDy-n6jUmCx8Z9jMt_oMKrMRybyykmUI7e5CO0sjJmVk6b_F7qV0e8xpm43OIUDZUtXQUXuqWJLW6pwPxt2jGwE_PVoh5C5HZw9XRVcPgS6s0DoTThH24/s1600/IMG_2720.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXwDJBDtMhVtt-TScAbLv8_OHQDy-n6jUmCx8Z9jMt_oMKrMRybyykmUI7e5CO0sjJmVk6b_F7qV0e8xpm43OIUDZUtXQUXuqWJLW6pwPxt2jGwE_PVoh5C5HZw9XRVcPgS6s0DoTThH24/s1600/IMG_2720.JPG" /></a>
<p>There are many movies on YouTube with people constructing ionization chambers, however, those aren't shielded completely and due to high wideband gain in those circuits, they will pick-up any electromagnetic radiation, so the results aren't very useful.</p>
<p>Those designs measures not only ionizing radiation, but also whole electromagnetic spectrum. Here I tried as a dummy test to place the a metal object to check if the measured value won't change, without a shielding it would probably be a big peak.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUrh0OhM9gcLiyWjOX6s7Y0H1rhtZaxCJcjDhUTJRrv8v0oJ8liCIERMo6veAzwe_DgeMCqugKW7WphJMaM1bn2xDUn5rUWZa3YhH-hPDCiGt_L_1TfqKT8DsNhFrZ7Z47-Tb5UhJr3LFK/s1600/IMG_2723.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUrh0OhM9gcLiyWjOX6s7Y0H1rhtZaxCJcjDhUTJRrv8v0oJ8liCIERMo6veAzwe_DgeMCqugKW7WphJMaM1bn2xDUn5rUWZa3YhH-hPDCiGt_L_1TfqKT8DsNhFrZ7Z47-Tb5UhJr3LFK/s1600/IMG_2723.JPG" /></a>
<p>Time to show results. The resistance decreases when the amount of ionizing radiation increases, below you can see two peaks on the histogram, one on the left is when the sample (Am<sup>241</sup> isotope) is present next to the sensor, on the right, when there is no sample.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk6F1cebr6OZgGqd1nGCbJHi5sfcI9wZgCLkq1MFnCQ2WyGX__9-5rCmsm8EotNKC-YInoVxtPChz4PLuNPxGhZIqE3l3NWm6BS0CmRRuRq2tRx1oOayb0QVOlY_pzm1kiiZloPNIcaDF7/s1600/SCREEN_D.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk6F1cebr6OZgGqd1nGCbJHi5sfcI9wZgCLkq1MFnCQ2WyGX__9-5rCmsm8EotNKC-YInoVxtPChz4PLuNPxGhZIqE3l3NWm6BS0CmRRuRq2tRx1oOayb0QVOlY_pzm1kiiZloPNIcaDF7/s1600/SCREEN_D.png" alt="ionization chamber results"/></a>
<p>I think, that it's a very interesting circuit, and can be used for example to understand how different shielding prevents radioactive radiation, etc. It's limited, but a good start to making own ionizing chambers.</p>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3218008772058347246.post-52972537318795853692016-12-24T17:48:00.002+02:002019-05-31T17:38:16.355+03:00Nuclear physic applied in smoke detectors<p>Not many people know, but in some smoke detectors, radioactive materials play an essential role. Today I will present one of those devices, and my -successful- attempt to reverse engineer it and get the circuit diagram.</p>
<p>Those smoke detectors use a small amount of Americium-241 (chemical symbol: Am) obtained in nuclear reactors as a decay product of Plutonium-241. Am<sup>241</sup> emits mainly alpha particles, but also some gamma rays. In smoke detectors it is in a form of an oxide Am0<sub>2</sub>.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWUNNqNjm0rZ7Bc-o7ASVRDX-Dc5mtlQlsQ3vSSwTn-Whzi1Z8_f4wbio27jpvyqXkEm4S8vq6I1VF0RrauaDr8RzWjE6X_QWYzTL10GQrIhLCTXdGwyxvXlltLIjoNuTBWy4H_JmifDMw/s1600/IMG_2687.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWUNNqNjm0rZ7Bc-o7ASVRDX-Dc5mtlQlsQ3vSSwTn-Whzi1Z8_f4wbio27jpvyqXkEm4S8vq6I1VF0RrauaDr8RzWjE6X_QWYzTL10GQrIhLCTXdGwyxvXlltLIjoNuTBWy4H_JmifDMw/s1600/IMG_2687.JPG" /></a>
<p>When alpha particles collide with atoms in the air, as a result, ions are produced. The amount of those ions is measured by smoke detector and is quite stable over time (Am<sup>241</sup> has half-life of 432 years), however, when the smoke is present, smoke particles neutralise alpha particles, so the measured value drops. This drop is the signal of fire, so the smoke detectors start buzzer to alert people in the building.</p>
<p>To measure those ions (produced by <a href="https://robertgawron.blogspot.com/search/label/radioactivity">ionizing radiation</a>), ionization chamber is used. It has a form of two differently charged plates shaped and placed in such distance that the ionizing radiation can flow between them.</p>
<p>Those plates, when charged, create an electric field that attracts those ions. When they are collected by plates, and additional voltage is created between plates, this voltage can be measured. The bigger this additional voltage, the bigger is the ionizing radiation.</p>
<p><strong>When those smoke detectors are used as designed, they don't pose a radioactive hazard, however, if those devices are disassembled, it must be done with great care. Alpha particle sources (as used here) are very dangerous if they came into the lungs in a form of dust. They are also dangerous if digested.</strong></p>
<p>On below image, you can see the ionization chamber. It's connected in the air directly to the pin of the chip to avoid parasitic currents flowing on the PCB. This is because voltages created by ionization chambers are very low. Radioactive element is inside of the ring.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtJp9lq949-NJd2Y3cJYZFAuoxzAEw7VxqQ9U01VVshF77apB5FgoO9DrlRpRt1JvZ6RkRTim2PVeA5ktpatsSkL1eTC-RZ4YGxM4Hor0BlrcANOlRUjvgOwoQlbS5PBX-zVWDJRMy46Bd/s1600/IMG_2699.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtJp9lq949-NJd2Y3cJYZFAuoxzAEw7VxqQ9U01VVshF77apB5FgoO9DrlRpRt1JvZ6RkRTim2PVeA5ktpatsSkL1eTC-RZ4YGxM4Hor0BlrcANOlRUjvgOwoQlbS5PBX-zVWDJRMy46Bd/s1600/IMG_2699.JPG" /></a>
<p>To be honest, I think that the PCB could be routed much better - angles of traces should be 45° if possible.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0dnu8h1ePrJ_QmOB_-Aw_vGXFtZqrynWeCK21R2bIQtcNqCtyd8HzjeHFFsUxOqn-DDmRLfc-NYgCUaku0w4I5-2-DK2ugKebnPiWxT_KWetO3sgz5lWOZFoRgBaT6C0C55E2Zgm-d1fV/s1600/smoke_detector_pcb.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0dnu8h1ePrJ_QmOB_-Aw_vGXFtZqrynWeCK21R2bIQtcNqCtyd8HzjeHFFsUxOqn-DDmRLfc-NYgCUaku0w4I5-2-DK2ugKebnPiWxT_KWetO3sgz5lWOZFoRgBaT6C0C55E2Zgm-d1fV/s1600/smoke_detector_pcb.png" /></a>
<p>As was visible on previous pictures, ionization chamber is soldered directly above the chip that runs this device. I wanted to know what is this chip, but didn't want to solder off the ionization chamber, that's why I reverse engineered this PCB into electronic circuit and later found an online datasheet of the chip that fits here. My works are visible below.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_kemgFfFu8lnCb9BCCQUqtP64fOYYHb77YU05PPQkVFbcXpbyWUj3mc7KRPUdQWwjSaaw5Ygk20lYXZkX2priJDvVvmXD477V8KhIx2oT1EsmYucpQRpDu9U59B-S49KxQwC2HPh9sy1c/s1600/IMG_2707.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_kemgFfFu8lnCb9BCCQUqtP64fOYYHb77YU05PPQkVFbcXpbyWUj3mc7KRPUdQWwjSaaw5Ygk20lYXZkX2priJDvVvmXD477V8KhIx2oT1EsmYucpQRpDu9U59B-S49KxQwC2HPh9sy1c/s1600/IMG_2707.JPG" /></a>
<p>After searching, I have found <a href="http://ww1.microchip.com/downloads/en/DeviceDoc/22157B.pdf">RE46C120 datasheet</a>, so now I was pretty sure it's this chip. Just to be sure, I checked on the oscilloscope, what signal is on the TP3 and how it looks on the datasheet - it's the same. <p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqVaPe0b_BNbAW43y7-U6-Jk9OG8-95Sa6EEJgEWaw2X-Z8oHrxjBXu2bZgnMimayaY85QY_tp42FJnMezrs607G2HLJkjTc-xug2IVqf-xUYmLT7ZmanWzGEtLY3jd8ElRRjzuxQtozuc/s1600/smoke_detector_typical_aplication.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqVaPe0b_BNbAW43y7-U6-Jk9OG8-95Sa6EEJgEWaw2X-Z8oHrxjBXu2bZgnMimayaY85QY_tp42FJnMezrs607G2HLJkjTc-xug2IVqf-xUYmLT7ZmanWzGEtLY3jd8ElRRjzuxQtozuc/s1600/smoke_detector_typical_aplication.png" /></a>
<p>That's basically all for today, I wanted to share with you the idea of those pretty interesting devices.</p>
Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-3218008772058347246.post-34813431712139749602016-12-10T23:22:00.000+02:002019-05-31T17:38:19.930+03:00Semiconductor Nuclear-Radiation Sensor: Part I<p>Currently I'm trying to make a working version of a radioactivity detector that uses semiconductor as a sensor. It's a different approach than <a href="http://robertgawron.blogspot.com/2015/02/homemade-geigermuller-counter-part-i.html">Geiger-Muller detectors</a> or <a href="https://robertgawron.blogspot.com/2016/12/nuclear-physic-applied-in-smoke.html">ionization chambers</a>, more complicated, but also much more interesting.</p>
<p>While Geiger-Muller counters can only provide information about the amount of particles in a period of time, semiconductor detectors can also measure their energy, so it's possible to say much more about the nature of observed ionizing radiation. Some of the disadvantages of these detectors are that they are more expensive, complex and sensitivity may degrade over time.</p>
<p>The current version doesn't work, but I think it's so interesting concept that I've written this entry anyway.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjumSgWOkKcjM43P_htpb_W1UMaQtLJPHFjsHzUQUthzPx7WTLPuUrj9iXABre3mHFbI8005uwB1EGg_vupZNl8wMSp1ovwS1un7fV7p47JdZjBksQzmstuWMwxGVyZRh-TQF4A1wocMUnM/s1600/IMG_2665.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjumSgWOkKcjM43P_htpb_W1UMaQtLJPHFjsHzUQUthzPx7WTLPuUrj9iXABre3mHFbI8005uwB1EGg_vupZNl8wMSp1ovwS1un7fV7p47JdZjBksQzmstuWMwxGVyZRh-TQF4A1wocMUnM/s1600/IMG_2665.JPG" alt="semiconductor radioactivity detector" /></a>
<p>The idea is that when ionizing particle (alpha, beta or gamma) is blocked by the p-n junction, a small amount of the energy is released. It has a form of a current spike and can be observed by the next stages of the device. </p>
<p>The p-n junction is just a diode polarized reverse-biased. To make the working area of the p-n junction bigger, a photodiode is used. I know that there also exists specialized versions that are more sensitive, however, I couldn't find any in any online electronic shops.</p>
<p>In my design, the sensor is D1, it's polarized by R1, and C1, R2, L1 (those last three elements are making a low band filter to block noise from power supply, they should be as close to D1 as possible).</p>
<p>The first stage of an amplifier is based on a N-JFET to minimize current sink from the measured circuit, in addition, this type of transistors are extremely fast (that's why they are used widely in RF designs). To reduce parasitic currents between PCB traces, this part is mounted "in the air". EMI that could affect this stage are reduced by a small mass connected shield made from copper and aluminium tape.</p>
<p>Next two steps are high pass amplifiers. Since the signal is very small and those are not rail-to-rail opamps, a symmetrical power supply or virtual mass should be used. I've forgotten about that so lately I just used additional AA battery connected between negative power pin of the opamp and ground.</p>
<p>There are three outputs: raw, high/low (R10, R11, IC1C) and integrated over a period of time (IC1D, R12, R13, R14, C9, C10).</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_WUR7Ds-228KT2ovL6pSQXufTICwZSwFbZd97TWfAm19ysEij-ZKLE-6zpY1Rcw2mHI36X2iAsGR6sY41I934ZK4D-6iY-nYcuPH7Ib9XVLb4EJjwTtfjFciP6IdCdbAYz0Vv8ajFstTl/s1600/semiconductor_radioactivity_detector.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_WUR7Ds-228KT2ovL6pSQXufTICwZSwFbZd97TWfAm19ysEij-ZKLE-6zpY1Rcw2mHI36X2iAsGR6sY41I934ZK4D-6iY-nYcuPH7Ib9XVLb4EJjwTtfjFciP6IdCdbAYz0Vv8ajFstTl/s1600/semiconductor_radioactivity_detector.png" alt="semiconductor radioactivity detector circuit"/></a>
<p>Below image shows the sensor, I've removed the protective glass from the photodiode to expose it better on the ionizing radiation.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizh83Pqu4yzUpYl4_adhOhAnUr5zC2Ri6GQygp5itedr0tGzT9RH_N8w5cdBsXUWyBcInGfkxiFjuLsatT-uEnDrUZ0AsvlQjfscCMil3c0Pn2N6R5Sqjze1PeOGdoA8MDBe0mJDBAnnwd/s1600/IMG_2669.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizh83Pqu4yzUpYl4_adhOhAnUr5zC2Ri6GQygp5itedr0tGzT9RH_N8w5cdBsXUWyBcInGfkxiFjuLsatT-uEnDrUZ0AsvlQjfscCMil3c0Pn2N6R5Sqjze1PeOGdoA8MDBe0mJDBAnnwd/s1600/IMG_2669.JPG" /></a>
<p>The PCB looks like a nightmare because I've scratched some pads during multiple soldering and desoldering of elements, also some traces were cut and connected again, etc. It's a big blow of a mess now and I think that the story of this PCB is ended, soon I will design a new one based on the experience I've gained.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoF8u6saFMcZnjilu6TE5FNBBig7LYprA-8X_1wo6pdwM3QZYnbhlbnw_coM38VePRCiSbG6oymq2qNdjGMY7p9ehL8aGwF8dDJGaH7gXHTwv0sfuwDXYWJH-Ex5wxB4kV-RFN3w2_lb2b/s1600/IMG_2671.JPG" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoF8u6saFMcZnjilu6TE5FNBBig7LYprA-8X_1wo6pdwM3QZYnbhlbnw_coM38VePRCiSbG6oymq2qNdjGMY7p9ehL8aGwF8dDJGaH7gXHTwv0sfuwDXYWJH-Ex5wxB4kV-RFN3w2_lb2b/s1600/IMG_2671.JPG" /></a>
<p>As I've said in the beginning of the article, the current version doesn't work - I can't observe anything except noise. This may be due to multiple problems. One of them is a proper shielding, tracks length, etc. It's a challenge to shield the device from EMI, but still make it sensitive to ionizing radiation.</p>
<p>Another problem is that I can test it only with alpha or beta particles, but they have big problems penetrating objects (are easily blocked), so it may be that they aren't even going to the pn junction, but are blocked by the case. This is something that is unclear to me at this moment.</p>
<p>I will continue working on this project and write a new article when I will make some progress.</p>Unknownnoreply@blogger.com24tag:blogger.com,1999:blog-3218008772058347246.post-58555859899948249932016-07-24T21:51:00.001+03:002019-05-31T17:38:23.777+03:00Using Arduino to process data from Geiger–Müller counters<p>In the previous posts I've described a <a href="http://robertgawron.blogspot.com/2015/02/homemade-geigermuller-counter-part-i.html">simple Geiger–Müller counter</a> and <a href="http://robertgawron.blogspot.com/2015/07/measuring-radioactivity-of-potassium.html">various experiments with this device</a>. Today I would like to present Arduino project to communicate with a Geiger-Muller counter, gather data and present it to the user. The device is based on Arduino Uno, Nokia 5110 LCD and homemade shield.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1W-fKlWfLZMLkTgBCOPQn3JlPC0tM_Ji9699tmHlRDA_lui9sGVfAteGNFMMNr6hFwGjnJHh1aphdM7LfaKzIJ79TtDJMUGSVn0xVtXrK6xUC-4V06HHV-J6nLIeOhWHDFP2XG4q1ZgmC/s800/IMG_2572.JPG" />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpLBbWedmaTXnzRObr0eipXaJYGW1XvDYU5RH4EmYfXDhw4jw3lMXOUiVLin8zM21zhXquWJTtc22Uq3cb8-dPCzfmxb0UMYR0QDA2DkgTQInd3-ROwdZyV8PZkxq7oVwNN1Izc-c64lk7/s800/IMG_2568.JPG" />
<p>Currently it's possible to show two layouts: bar graph of the pulses in one minute interval and <a href="https://en.wikipedia.org/wiki/Histogram">histogram</a> of the gathered data. Both graphs are auto-ranging in Y axis. On the top of the pulse graph is visible also a numeric value of the last sample. The length of the histogram data is 4 minutes, the amount of bins is calculated automatically.</p>
<p>Below is visible layout with pulses per quant of time and histogram of them. You can clearly observe <a href="https://en.wikipedia.org/wiki/Normal_distribution">Gaussian distribution</a> on the second image.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjkwMs1wfWr3exIZBs8qpiiVHKtmDOKQxw-HU2lurQBdKzUdWVnS5Y9Xlv6sw7kuA8bFIviTkjbwocERIeZ35SbudHLAHoI-AjkVUGUCuu6X853laJKzuc5lVATrl0v6-01WRBN6mW7RbY/s800/IMG_2554.JPG" />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0Uhb2rXfLSZVqYWV_sqR57TbMqj73i7oqKdjHgegcbR7bj1Srp8kGycxEo0R3I7pG2AQSM48WU1doVNCB-yssqBskYoGgR4hbXoPNApR2aAqrrwbnsTFQsh3nO91sB51aykKGAGYdOadt/s800/IMG_2551.JPG" />
<h2>Hardware</h2>
<p>I didn't want to place all of the connections and input PCB dimensions of a shield, so I've used as a base one of freely available shields and modified it to my needs - I've left the licence disclaimer unmodified. Unfortunately, I wrongly connected LCD, that's why the LCD looks like rotated 180 degrees. Anyway, it still works and I don't plan to make a new PCB to fix it.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu74BLIWBRIChadUdlJRaRs2c1wGP5tWSdBF_DSwpjJfB4v_DkxORnjKMLzOUT223sJrhkkhIndv9GNo0cFJB_c4ChzQYYx2v3qW05DmC0-4bRsfN4NFyBQ0b4plcgpv5JKWt6xIlXa_DQ/s1600/geiger-muller-arduino-shield.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu74BLIWBRIChadUdlJRaRs2c1wGP5tWSdBF_DSwpjJfB4v_DkxORnjKMLzOUT223sJrhkkhIndv9GNo0cFJB_c4ChzQYYx2v3qW05DmC0-4bRsfN4NFyBQ0b4plcgpv5JKWt6xIlXa_DQ/s800/geiger-muller-arduino-shield.png" /></a>
<p>I tried to make the code reusable in my other projects so the structure may look overcomplicated, but I think it's as it should be.</p>
<h2>Software</h2>
<p>Followed 3rd party librairies needs to be installed, to install them in Arduino IDE go to sketch -> Include Library -> Manage Libraries then type library name and proceed with installation.</p>
<ul>
<li>Adafruit-GFX-Library</li>
<li>Adafruit-PCD8544-Nokia-5110-LCD-library</li>
</ul>
The main component is the GMCounter class that collects data in a circular buffer. I wanted to pass as an argument a size of the buffer, but also wanted to avoid using dynamic memory, finally I made this parameter an argument of template class, so now creating an object of this class looks like:
<pre>
static GMCounter<4 * 24> hourGMCounter;
</pre>
<p>This will create an object with this class with a buffer for 4*24 samples. I think, that it's quite cool.</p>
<p>There's a lot of commented out code in the main function, it was used to test parts of the program as it was developed. I didn't remove it because it still can be used if I will add new features.</p>
<h2>Download.</h2>
<p>The source code and Eagle files of the project is <a href="https://github.com/RobertGawron/GeigerMullerCounter/tree/master/software/Arduino">available on the GitHub</a>, feel free to download and try it if you're interested in this area of physic.</p>
Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-3218008772058347246.post-15861454546209338432016-05-02T13:47:00.003+03:002019-05-31T17:38:35.067+03:00How to check how many elements an array has?<p>In C it's possible to omit typing array size if it's fields are provided immediately, so the compiler can easily calculate the size by itself. This is presented below, note empty [] parenthesis.</p>
<pre>
char* sampleArray[] = {
"Hello world!",
"How are you?",
"You like coffe?"
};</pre>
<p>We can also specify the size directly:</p>
<pre>
char* sampleArray[2] = {
"Hello world!",
"How are you?",
"You like coffe?"
};</pre>
<p>Or use the best way:</p>
<pre>
const int SampleArraySize = 2;
char* sampleArray[SampleArraySize] = {
"Hello world!",
"How are you?",
"You like coffe?"
};</pre>
<p>In the first two examples we don't have a variable that would tell us how many elements the array has. Sure, we may hardcode it, but it's not a good idea from a maintainability point of view.</p>
<p>We may calculate the size of above array by using a simple trick:</p>
<pre>int sampleArrayLength = sizeof(sampleArray) / sizeof(sampleArray[0]);</pre>
<p>Note that it will work with all built in types and if the size or even the type of an array will be changed in the future, this line will still be correct.</p>
<p>Below you may see a simple use case.</p>
<pre>#include <stdio.h>
int main()
{
char* sampleArray[] = {
"Hello world!",
"How are you?",
"You like coffe?"
};
<b>int sampleArrayLength = sizeof(sampleArray) / sizeof(sampleArray[0]);</b>
printf("someStrings array has %d elments counting from one.\n", sampleArrayLength);
for(int i = 0U; i < sampleArrayLength; i++)
{
printf("#%d element: %s\n", i, sampleArray[i]);
}
return 0;
}</pre>
<pre>sh-4.3$ main
someStrings array has 3 elments counting from one.
#0 element: Hello world!
#1 element: How are you?
#2 element: You like coffe?</pre>
<p>Unfortunately, it will not work for arrays passed as pointers - for them, we need to pass size of an array as an additional argument.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3218008772058347246.post-64681811939135942282016-05-02T13:20:00.000+03:002019-05-31T17:38:41.037+03:00How to check how many elements an enum has?<p>While C language doesn't offer build in method to check how many elements an enum has, it's still possible to obtain this information by using a simple trick.</p>
<p>The idea is to add a dummy element at the very end, since numeric enums values are 0, 1, 2, 3, 4, 5, ..., the numeric value of last element will be also the amount of elements that this enum has.</p>
<pre>
#include <stdio.h>
typedef enum Fruit {
FRUIT_APPLE,
FRUIT_ORANGE,
FRUIT_BLACKBERRY,
<b> /* place new elements below */
/* guard */
FRUIT_LAST_ELEMENT</b>
} Fruit;
int main()
{
<b>int fruitEnumLength = (FRUIT_LAST_ELEMENT - 1);</b>
printf("Fruit enum has %d elments counting from zero.\n", fruitEnumLength);
return 0;
}
</pre>
<pre>
sh-4.3$ gcc -o main *.c
sh-4.3$ main
Fruit enum has 2 elments counting from zero.
</pre>
<p>This technique may be useful for sanitizing input data or for writing tests.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3218008772058347246.post-89084912260133502222016-04-17T01:37:00.000+03:002019-05-31T17:38:52.907+03:00Making your own PCB cleaner mixture<p>Commercial PCB washing solutions are relatively expensive, much cheaper and still powerful one can be prepared at home. It's based on <a href="https://en.wikipedia.org/wiki/Trisodium_phosphate">trisodium phosphate</a>, highly alkaline substance able to reduce oxides and react with grass forming soaps. <a href="https://en.wikipedia.org/wiki/Soap">Soaps in chemical meaning</a>, not something we buy at store.</p>
<p>A sample PCB smashed into two pieces - on the left original state, on the right washed up.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlMvMfYOXRkTHPp-48EqtPgzTW2zjGFzfvS7WsnTFUygZKK7erm6npUWe226YI0DfeYNA58XpuYRC-ue_V852aLYcS7CLRpCyi0U7peAUfEc_ut9SrMU1H-3NTXppD5XGCSYRAckcSXECb/s800/IMG_2358.JPG" alt="DIY water based PCB solvent: before and after "/>
<p>Ingredients</p>
<ul>
<li><a href="https://en.wikipedia.org/wiki/Trisodium_phosphate">trisodium phosphate</a> - 1,5g</li>
<li>water - up to 200ml</li>
</ul>
<p>The procedure is simple - a PCB is just placed into the solution and shaken from time to time to speed up the cleaning. Heating is not needed.</p>
<p>I'm using a cheap ultrasonic washing machine - I still don't know if it's working or if it's just a placebo and a bit of a noise, but it seems that at least it mix the water. I've placed the mixture into a glass and then placed it into the water in the washing machine. This is less efficient, but device is easier to clean after use.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjdH1oFIKFN0jgTBO_2Gbzqlizbszwe1FO98n3cIGehkZH2tZIVfIIZv5w6JGSu87955YYAvvfpuZEyf4IBoQSLDSgq_jLVTJfDiTP6077I-h1dTpjls4xQkjHpUKyTYzlZlC4q1Zd7ff-/s800/IMG_2352.JPG" alt="DIY water based PCB solvent: ingredients"/>
<p><b>Note: trisodium phosphate is highly alkaline - it's visible on below below on below <a href="https://en.wikipedia.org/wiki/Universal_indicator">universal indicator</a>. Use protective glasses and gloves.</b></p>
<p><b>In case of skin contact, wash the solution wash it with a lot of water. In case of a skin contact with the powdered substance whip it by using a rug and then wash it.</b></p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPut0SEx75bIPwgacCtFUXYIbZZ7JPWfkwMSn6v9hy99hCzVdv5nuK8jkCrHL3Ogr-3lYgP5pygbSKTaMEYA4nmhlZqqMvFAW6w1R8DMNnIJMtvfL5h92QkXnenaCy17K94stubz1FaO05/s800/IMG_2354.JPG" alt="DIY water based PCB solvent: universal indicator"/>
<p>Trisodium phosphate was widely used till 70's, it's an inexpensive and effective cleaning agent, but is not environmental friendly.</p>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-3218008772058347246.post-73024649708338378812016-04-10T22:48:00.004+03:002019-05-31T17:38:59.824+03:00Home-made mixture for chemical PCB tinning (alcaline bath)<p>Today I will present a method for PCB tinning that uses alkaline bath. What does alkaline bath mean? It says that the solution that we're using for tinning has this pH, in opposition acid bathes also exists - one of the example <a href="http://robertgawron.blogspot.com/2016/04/galvanic-pcb-tinning-by-using-home-made.html">I presented in my previous post about PCB tinning at home</a>.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhacn3j2-p8VqkUOEMiGllpupmINezyLeYjB1aztYini6f07xeo-rgq_m_RuVaZQ12i0GkdgwXpahyzEZiaRF0gBMOAUtWKbzEE7QFGHv7TqoSbwEn_uvLb4DYtH5jm4ek1NjK1ecBtCRNc/s800/IMG_2325.JPG" />
<p>This method is less expensive that the acid one, the results of both are comparable, but because of how a relatively dangerous alkaline bath is, I don't plan to use it. If you're searching a method to tin your PCBs, I would <b>strongly</b> suggest either <a href="http://robertgawron.blogspot.com/2016/04/pcb-tinning-using-lichtenbergs-alloy.html">using Lichtenberg's alloy (described here)</a> or <a href="http://robertgawron.blogspot.com/2016/04/galvanic-pcb-tinning-by-using-home-made.html">chemically tin them by using acid bath</a>.</p>
<p>Ingredients:</p>
<ul>
<li><a href="https://en.wikipedia.org/wiki/Sodium_hydroxide">Sodium hydroxide</a> - 3 parts,</li>
<li><a href="https://en.wikipedia.org/wiki/Tin(II)_chloride">Tin(II) chloride</a> - 1 part,</li>
<li>metalic tin - 1 part.</li>
</ul>
<p>Instead of pure metallic tin, a solder can be used, to increase its reactive surface, it can be melted on a small scrap of a laminate.</p>
<p><strong>Note: NaOH is highly aggressive substance, it can easily permanently damage eyes or skin. Dissolution of an alcaline is strongly exothermic which means that water heats up, it can even start boiling and splashing dissolved NaOH!</strong></p>
<p><strong>Note: protective glasses and appropriate gloves should be used.</strong></p>
<p><strong>Note: don't use any containers, spoons or other small tools that you are also using for cooking, have a separate set for tinning.</strong></p>
<p>PCB and tin (or mentioned above laminate) is placed in a high beaker. 100ml of water is added, then <b>extremely slowly</b> 1/2 teaspoon of NaOH and SnCl<sub>2</sub> mixture is added. Mixture is heated (not boiled!) in <a href="http://robertgawron.blogspot.com/2015/07/extracting-potassium-from-cigarettes.html">heated bath similar to presented in this post</a>. Tinning takes 10-20 minutes.</p>
<p>I haven't use polishing paste, so the surface isn't smooth and glossy, but technically it doesn't matter.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrKXta1QhsrShhoUrsrrZJsfFuqLuNIW9gg2ZWB5rkTOhCkYEYkQVBHKEcfRsRXmqZRGrWipyWpNKMjfzd8UAGBR7mSAGdl0FFIGrNKqew2VbVK5Is_Wi4vB8NRnQyuuzXePECdGkwKBVT/s800/IMG_2329.JPG" />
<p>Solder wets surface very well, it's visible on below image.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7Xak0qYCqH1Wngy_hX9n0j739Tq-Ax-N5L8-n4nTP1gCebkHeI7Spa-2ZPokpU1h_E-8mFnJs7t62Wj3TdVmEsL8R0zEH98bgE0J-uAmcO3G5EMLxmu7nGErxxntt4Ijbxidu-o57fWtN/s800/IMG_2340.JPG" />
<p>To summarize, despite good results and low proce, I think that it's too dangerous to tin a PCB this way.</p>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-3218008772058347246.post-70965437982384112082016-04-09T21:32:00.002+03:002019-05-31T17:39:02.776+03:00PCB tinning using Lichtenberg's alloy<p>The Lichtenberg's alloy is an interesting way of home PCB tinning - it's inexpensive and there is no need to polish cooper or use specialized tools and chemicals. The negative side is that the alloy is hard to obtain, fortunately it's not expensive. For some countries, it might not be possible at all to buy it.</p>
<p>The alloy contains 50% of bismuth, 30% of lead and 20% of tin, but what makes it interesting is that its melting point is 95-100°C. It means that it melts in boiling water - that's the idea if this technique.</p>
<p>Below you may see drops of The Lichtenberg's alloy.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP4lSr1IGQ0zDuAFRT9TVPxtDDFS2kNdGXGMSaYhtDCbx3AJ2s-dkMu6dtMt37ytyylm9utUo_nwGwwVJeIzglBsGDAervkf1VJYLcVNDjDs2P7aBf1KjrpTPo7CjCfTRY7RaWZwMeY3tF/s1600/IMG_2313.JPG" />
<p>We will need a couple of grams of the alloy, pan with lid, a tablespoon of citric acid, silicon spoon and old tweezers or similar tool. </p>
<ul>
<li>Fill pan with tap water to 1/2 - 1/3 of volume, put inside the alloy and your PCB, cover the pan with lid to speed up heating.</li>
<li>When the water boils, use tweezers to immobilize the PCB - squeeze it to the pan. Dispatch alloy on whole copper surface by using a spoon. Put the lid again.</li>
<li>After a couple of minutes, immobilize the PCB again and by using a spoon, remove alloy excess from the PCB.</li>
<li>Clean the PCB in water, dry it by using a rag.</li>
</ul>
<p>Citric acid is used here in two ways: as a flux and to decrease boiling temperature.</p>
<p><b>Note: don't use pans or spoons that you are also using for cooking, have a separate set for tinning. Please keep in mind that Lichtenberg's alloy contains lead, the method involves citric acid, a product of those (lead citrate) is (at least) unhealthy if digested.</b></p>
<p><b>Note: several similar alloys exists (e.g. Lipowitz's alloy), probably they could be also used, but always check theirs recipe. Especially make sure you don't use something that contains cadmium!</b></p>
<p><b>Note: don't spoil on your body any boiling water during above procedure.</b></p>
<p>Below is an example of a PCB tinned by using this method, it's a <a href="http://robertgawron.blogspot.com/2015/07/how-to-make-usb-li-ion-charger.html">USB Li-Ion battery charger</a></p>
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYloQX8K2KAv41-7JehFTX4LMW93tOSRY1xKATTWZMIWUWdN-Wm15eL2tFFylnTJJL7O8hc6DrHHaXYh9aRq31LSotcx2j1Fzokz8CuqnYu_Sikj6oWPRdCAhzFooeOsbwrZhLbNavUFGk/s1600/IMG_2060.JPG" />
<p>If you liked this idea, you may also check the <a href="http://robertgawron.blogspot.com/2016/04/galvanic-pcb-tinning-by-using-home-made.html">article about inexpensive chemical PCB tinning</a>.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3218008772058347246.post-80103014882816259582016-04-05T21:44:00.000+03:002019-05-31T17:39:05.225+03:00Home-made mixture for chemical PCB tinning (acid bath)<p>While it's possible to buy ready to use tinning formulas, making your own is much less expensive. Various recipes exist for tinning copper, today I will present a simple one that uses ingredients available at online chemical stores. It's one of acid bath methods.</p>
Ingredients:
<ul>
<li><a href="https://en.wikipedia.org/wiki/Thiourea">thiourea</a> - 12,5 grams</li>
<li><a href="https://en.wikipedia.org/wiki/Tartaric_acid">tartaric acid</a> - 8,8 grams</li>
<li><a href="https://en.wikipedia.org/wiki/Tin(II)_chloride">tin(II) chloride</a> - 1,3 gram</li>
<li>tap water - up to 250 ml</li>
</ul>
<p>Simply put PCB into the solution and wait a couple of seconds, the more time the PCB is in the solution, the thicker a tin layer is. It's not needed to heat up the solution - room temperature is sufficient.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3l9MMjZtttt5NMAW_wdpFijjS9cgA2ceYGvciQWf0JW5zwCsA-KZi9Zgtm0OwSfBoqp6zCpma01KB5gRTLKMomsPR5rN4iFFbWn19ZSBJRxeMjhUAZrFRowxIVrgn6pHBuVEj0ALsEG5C/s1600/IMG_2291.JPG" />
<p><strong>The substances are irritating, if you want to apply this method at home, please use gloves and store ingredients and mixture away from children.</strong></p>
<p>The first PCB that I tinned this way is presented below. Solder wets the surface easily! Next time I will use polishing paste before tinning - this should help to obtain smooth and shiny surface.</p>
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuTQUpIl7MhmbbR13KrhZOOnimr-et5h2bieGoUGTALH8zn5UheMPz7DBdpV470eNhC6_ORuV_1hIKRW9mh58Km7OvCsYRLIqUx7oaIK-XiaMrHBRCG6l0ofiHrXitQtpgeR5bXUPPRPoC/s1600/IMG_2302.JPG" />
<p>Here is the device before testing it - it's <a href="http://robertgawron.blogspot.com/2015/04/dkp-50-dosimeter-radioactivity-detector.html">a driver for a dosimeter based on DKP-50</a>. Not the tidiest construction, but still looks nice.</p>
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip38IXRGFyUA63ANSde7TZ5U2Vz59KhSYhqjL-xc2ITzvPzt9PnMO1mm8Q9iIBBMz0mhAyvCWM6prFigYZ1bLWWlbw5lcmXh9yAI6_3uSklH-U1Wj_yiarECUGTFk82OnwT3jrXPpqBFBm/s1600/IMG_2311.JPG" />
<p>In the next post I will present <a href="http://robertgawron.blogspot.com/2016/04/pcb-tinning-using-lichtenbergs-alloy.html">PCB tinning by using Lichtenberg alloy</a>. You may also check <a href="http://robertgawron.blogspot.com/2011/02/coating-with-copper-by-using.html">related previous post about galvanic copper plating</a>.</p>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3218008772058347246.post-39490541002387112442016-03-27T22:18:00.001+03:002019-05-31T17:39:07.673+03:009V/1kV DC/DC converter<p>Currently I'm working on a device to electrocute home insects like cockroaches, progress is small because they are smarter than I thought, but that's a different story. For that project I had to find a source of sufficient high voltage and output power. Presented in previous post <a href="http://robertgawron.blogspot.com/2016/03/5v400v-dcdc-converter.html">5V/400V converter had insufficient voltage and power</a>, another option, <a href="http://robertgawron.blogspot.com/2015/03/high-voltage-power-suply-10-30kv-made.html">flyback transformer</a> was too dangerous to be used here.</p>
<p>Finally, I have made a new high voltage supply based on an inverter transformer and voltage doubler. It seems to be ok for this job, but it can be used in various other applications so I'm presenting it in a separate entry.</p>
<p><b>Warning! the device produces high voltage that can be lethal, if you want to build it, please take cautions.</b></p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoEKvkitE9KfEsVm6eNsUaWPIxOYY35hItCKsUFlUjCqW8-SXiD9GP_BtZoihj2KLyfKRyL9OggXhvrgTVgMr7qo2vnQkl4zssWLKDELof_7YV8cPG02I0XtxzzK0SVuaOGLP5FpXNUHK0/s800/IMG_2274.JPG" />
<p>The transformer was salvaged from old LCD monitor, it was used there to power fluorescent tube. It costs around 6$, so they are not expensive. Unfortunately I couldn't find Eagle component library for it, so I had to make a new one. Q1 initially hasn't had a radiator, but later I added a small one because it was getting warm.</p>
<p>Full output voltage is present on R11, so it was protected against accidental touch by using a shrink tube. It's not the best way, but it's still better than nothing. All connectors have latches to avoid accidental slip out - important, especially for high voltage ones.</p>
<p>High voltage traces have bigger clearance to prevent spark gaps. Positive power supply rail has bigger width, because the current is around 330mA.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjk-1Oq4z3xIQoU_CmtZFPR1UFw4OhW2pnzPkLEWCIy4C7seXoHwVxjn5rwn1MPRMZrvaSdMCewUSMkVjxCXuT3e0cn1F4dVUxCzV7dUt0ZX4ryA8dyVzVz265wXi1wbx36M82C_bZ53oRc/s800/IMG_2278.JPG" />
<p>As visible on the rendering, by an accident I swapped top/bottom layer of two diodes. Opss!</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFPM8ZvUk1XP7JTO3Tdo_28RBSJPRhyphenhyphenSbdNDvFGGvNGDFqels1_RaNd8JwV7pRKdLL6kpx_yVVbAp8mHWc7o7cDQHOHXQxJXi04f-x6RsMY3It3EB2Vf2dQrN8EPXxEQ8k8yh3Gao9tm1a/s800/top.png" />
<p>A square generator is made from IC1A and IC1B, frequency depends on C1, R3, R4, pulse width depends on an R3 and R4 ratio. The signal is buffered by using IC1C and IC1D. Voltage doubler is made from C9, C10, D4, D5.</p>
<p>Output voltage = 1kV is at frequency around 11-14kHz, to minimize power consumption, I decided reduce output voltage to around 850V, this is equivalent to 5kHz from the generator.</p>
<p>If nothing is connected to the output, then even after power was turned off, C9, C10 can store enough power to provide unpleasant shock. To protect against that, discharge resistor R5 was added. C9 doesn't have one, so it keeps a high charge even after the device was powered off.</p>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSL0q9az_d1BOM8pFU5KZkN6e4XDIoAZM_0sFo4YuTU08Qdxqp3w3TxpUx2TQ4rdzhC8qHuX950AzvfX5TDiYuekhSeO4iyQAaN1vRK7PZSwEkZkN5_prLpcVAeIHjnNlTjW5fBjSmgz2D/s1600/insectkiller.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSL0q9az_d1BOM8pFU5KZkN6e4XDIoAZM_0sFo4YuTU08Qdxqp3w3TxpUx2TQ4rdzhC8qHuX950AzvfX5TDiYuekhSeO4iyQAaN1vRK7PZSwEkZkN5_prLpcVAeIHjnNlTjW5fBjSmgz2D/s800/insectkiller.png" /></a>
<p>Input voltage = 9V DC, power consumption = 3W.</p>
<p>R3, R4, C1 may be chosen differently in order to provide a a bit lower/higher voltage and smaller power consumption.</p>
<p>Below is the signal on Q1 gate.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_3j46QucEFSVKj9ILCQqD0pAKBFEy-jVTkB1VjdJR5I3x_NcxXs6ro373qiQ6l3ZG9hdpupYCdVUuKgE38Skc_aEX1F4OdTCzmii9a5vovxyLuH7WyLIK-CRkfhDXc_VgbC9katUqZhpz/s800/DS1Z_QuickPrint31.png" />
<p>Output voltage changes over time mainly due to temperature changes, it's visible on below picture. No load, temperature of room, voltage on the output. Graph was made using <a href="https://robertgawron.blogspot.com/2018/09/collecting-and-processing-data-from.html">scripts that I presented in this post</a>.</p>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirMWUHJpG9_aO5LB54rhGxVAs-MnXdgTt6B7nu2wBfYDxwz0wm0vl5pjnucsLL_HANhOBiI6egowsjHPGD1A9-rRiWVgeKYCMra4QTv_0jk7sZ6JU1QjKJrUzYi5SvtOEZs2WXpXwpaWDf/s1600/results.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirMWUHJpG9_aO5LB54rhGxVAs-MnXdgTt6B7nu2wBfYDxwz0wm0vl5pjnucsLL_HANhOBiI6egowsjHPGD1A9-rRiWVgeKYCMra4QTv_0jk7sZ6JU1QjKJrUzYi5SvtOEZs2WXpXwpaWDf/s1600/results.png" data-original-width="800" data-original-height="500" /></a></div>
<p>Please ignore SV1 and R1 - this part is completely wrong - pin 1 of IC1A should be connected to Vdd or to pin 2 of the same gate. This area was supposed to turn on or off the generator by using an external control module, but it should be connected with pin 8 of IC1C and 12 of IC1D. In the current implementation, when the generator is disabled, t1 is fully opened. Dummy error.</p>
<p>Eagle files for this project can be <a href="https://github.com/RobertGawron/snippets/tree/master/9Vto1kVConverter">downloaded from my GitHub repository</a>.</p>
<p>At the end, just to show what I'm working on now, below is a movie of an electrocuted cockroach. Don't watch if you are sensitive!</p>
<iframe width="800" height="450" src="https://www.youtube.com/embed/pGsyhq8si3Y?list=PLPj1nQMD9zwwlSvJDf78f0oB2vkQUEBM9" frameborder="0" allowfullscreen></iframe>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-3218008772058347246.post-65561776864537065302016-03-13T14:11:00.002+02:002019-05-31T17:39:10.234+03:00Conway's Game of Life - online JavaScript version<p><a href="https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life">Game of life</a> is an example of a system with very simple rules but unpredictable state in the long term.</p>
<p>Each square represents a living space available for a single cell. If there aren't enough cells in the neighborhood, the space is empty, if the cell was present there it dies from loneliness. If in the neighborhood is enough of other cells, the cell can survive in its square, or a new cell is born if it was empty before.</p>
<p>It's interesting to notice that we can't compute the n-th iteration directly, we have to go through all previous iterations.</p>
<style>
/* Created by Robert Gawron 2007-09-25 10:33:21 */
.gameOfLifeControls
{
font-size:xx-large;
};
#GameOfLifeWindow
table
{
border-collapse: collapse;
height:800px;
width:800px;
}
#GameOfLifeWindow
td
{
border:1px solid #aaa;
padding: 1px;
}
</style>
<script type="text/Javascript">
var cols = 70
var rows = 70
var isInitializedGameOfLife = 0
var stop_timer = 0
var cellsLocations = new Array()
function playGameOfLife()
{
for (var i = 0; i < rows; i++)
{
for (var j = 0, n = 0; j < cols; j++, n = 0)
{
// right
if (j != 0)
{
n += cellsLocations[(i * cols) + j - 1]
}
// left
if (j < (cols-1))
{
n += cellsLocations[(i * cols) + j + 1]
}
// left down
if ((j > 0) && (i > 0))
{
n += cellsLocations[(i - 1) * cols + j - 1]
}
// down
if (i > 0)
{
n += cellsLocations[(i - 1) * cols + j]
}
// right down
if ((i > 0) && (j < (cols - 1)))
{
n += cellsLocations[(i - 1) * cols + j + 1]
}
// left up
if ((i < (rows - 1)) && (j > 0))
{
n += cellsLocations[(i + 1) * cols + j - 1]
}
// up
if (i < (rows - 1))
{
n += cellsLocations[(i + 1) * cols + j]
}
// right up
if((i < (rows - 1)) && (j < (cols-1)))
{
n += cellsLocations[(i + 1) * cols + j + 1]
}
var id = i * cols + j
// shuld it live?
if(!cellsLocations[id] && (n==3))
{
changeCellState( id, true)
}
// or should it die?
else if((cellsLocations[id] == 1) && !(n==2 || n==3))
{
changeCellState( id, false)
}
}
}
if(!stop_timer)
{
setTimeout('playGameOfLife()', 100)
}
}
function randomMapGameOfLife()
{
initGameOfLife()
// TODO add input form about number of cellsLocations
var activeCells = 380
for (var i = 0; i < activeCells; i++)
{
var index = rows * cols * Math.random()
changeCellState(Math.round(index), true)
}
}
function pauseGameOfLife()
{
stop_timer = !stop_timer
if (!stop_timer)
{
playGameOfLife()
}
}
function initGameOfLife()
{
if(!isInitializedGameOfLife)
{
isInitializedGameOfLife = true
var div = document.getElementById('GameOfLifeWindow')
var tbl = document.createElement('table')
var tb = document.createElement('tbody')
for (var i = 0; i < rows; i++)
{
tr = document.createElement('tr')
for (var j = 0; j < cols; j++)
{
var td = document.createElement('td')
var id = i * cols + j
td.style.width = '10px'
td.style.height = '10px'
td.setAttribute('id', id)
tr.appendChild(td)
}
tb.appendChild(tr)
}
tbl.appendChild(tb)
div.appendChild(tbl)
}
else
{
stop_timer = false
}
killEmAll()
}
function killEmAll()
{
for (var i = 0; i < (rows * cols); i++)
{
changeCellState(i, false)
}
}
function changeCellState(id, val)
{
cellsLocations[id] = val ? 1 : 0
var plant = document.getElementById(id)
plant.style.background = !val ? '#e0e0e0' : '#333'
}
</script>
<p class="gameOfLifeControls">Controls: <a onclick="randomMapGameOfLife()">generate new map</a> / <a onclick="playGameOfLife()">start</a> / <a onclick="pauseGameOfLife()">pause-unpause</a>.</p>
<div id="GameOfLifeWindow"></div>
<p>I wrote this implementation almost ten years ago, so it may not be how it should be done today, especially the table should be replaced by canvas, but it's still usable and shows the concept.</p>
<p>If you are interested, how it works, please take a look on the source code of this page.</p>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3218008772058347246.post-43294130509244784862016-03-12T21:56:00.002+02:002019-05-31T17:39:12.525+03:00Fractal way of map generation by using diamond-square algorithm<p><a href="https://en.wikipedia.org/wiki/Diamond-square_algorithm">Diamond-square algorithm</a> is a simple way to generate maps by using fractal approach. The idea is to generate recursively a point based on the values of its neighbors and an additional fluctuation.</p>
<p>The main disadvantage is that landscapes aren't realistic and there exist visible edges created during recursive slicing of the terrain during recursive computing</p>
<p>Below you may see how the <a href="https://en.wikipedia.org/wiki/Diamond-square_algorithm">diamond-square algorithm</a> works. Availability to change perspective is not part of the algorithm, but I've added it to make the visualisation more user-friendly.</p>
<script type="text/Javascript">
// basic data structures
function Point2D(_x, _y)
{
this.x = _x
this.y = _y
}
function Point3D(_x, _y, _z)
{
this.x = _x
this.y = _y
this.z = _z
}
function Edge(_p1, _p2)
{
this.p1 = _p1;
this.p2 = _p2;
}
function screen(canvasID, terrain)
{
var canvas = document.getElementById(canvasID)
this.ctx = canvas.getContext("2d")
this.a = canvas.width
this.terrain = terrain
this.azimuth = 33;
this.elevation = 30;
this.step = 5;
this.bckColor = '#e0e0e0';
this.scaleFactor = this.a / 4;
this.near = 600; // distance from eye to nearest plane
this.nearToObj = 900; // distance from nearest plane to center of object
this.move = function(direction)
{
switch(direction)
{
case 'right':
this.azimuth -= this.step
break;
case 'left':
this.azimuth += this.step
break
case 'down':
this.elevation -= this.step
break;
case 'up':
this.elevation += this.step
break
}
this.clear()
this.count2DView()
};
this.count2DView = function()
{
var edges = this.terrain.getEdges()
for(var i = 0; i < edges.length; i++)
{
this.drawLine(this.movePoint(edges[i].p1), this.movePoint(edges[i].p2))
}
};
this.movePoint = function(point)
{
var theta = Math.PI * (this.azimuth / 180.0)
var phi = Math.PI * (this.elevation / 180.0)
var cosT = Math.cos(theta)
var sinT = Math.sin(theta)
var cosP = Math.cos(phi)
var sinP = Math.sin(phi)
var cosTcosP = cosT*cosP
var cosTsinP = cosT*sinP
var sinTcosP = sinT*cosP
var sinTsinP = sinT*sinP
var x0 = point.x
var y0 = point.y
var z0 = point.z
// compute projection
var x1 = (cosT * x0) + (sinT * z0)
var y1 = (-sinTsinP * x0) + (cosP * y0) + (cosTsinP * z0)
// adjust
var z1 = (cosTcosP * z0) - (sinTcosP * x0) - (sinP * y0)
x1 = x1 * this.near / (z1 + this.near + this.nearToObj)
y1 = y1 * this.near / (z1 + this.near + this.nearToObj)
var p = new Point2D(x1 + this.scaleFactor, y1 + this.scaleFactor);
return p;
}
this.clear = function()
{
this.ctx.fillStyle = this.bckColor
this.ctx.fillRect(0, 0, this.a, this.a)
};
// p1 and p2 are objects of Point2D
this.drawLine = function (p1, p2)
{
this.ctx.beginPath()
this.ctx.moveTo(p1.x, p1.y)
this.ctx.lineTo(p2.x, p2.y)
this.ctx.stroke()
};
}
function fractalTerrainGenerator(width)
{
// all constants choosen empiricaly, may be modified to obtain better results
this.len = 64; // how many points should the matrixe hav (len x len)
this.zoom = width / (this.len-1)
this.str = 250 // elevation
this.d0 = 50 // maximum fluxtuation
this.r = 0.3181 // smothing factor
// 3D points
this.points = new Array(this.len)
this.start = function()
{
for(var i=0; i < this.len; i++)
{
this.points[i] = new Array(this.len)
for(var j = 0; j < this.len; j++)
{
// default values
var x = i * this.zoom
var y = j * this.zoom
var z = 0
this.points[i][j] = new Point3D(x, y, z)
}
}
// generate fractal terrain
this.countSquare(0, 0, this.len, this.d0)
};
this.getEdges= function()
{
var edges = new Array(this.len * this.len)
var edgeCounter = 0
for(var i = 0; i < this.len; i++)
{
for(var j = 0; j < this.len; j++)
{
if(j != this.len-1)
{
edges[edgeCounter++] = new Edge(this.points[i][j], this.points[i][j+1])
}
if(i != this.len-1)
{
edges[edgeCounter++] = new Edge(this.points[i][j], this.points[i+1][j])
}
}
}
return edges;
};
this.countSquare = function(i, j, p, d)
{
var mid = new Point2D((i + (p / 2)), (j + (p / 2)))
var pa = p - 1
// height is a mean of significant points
z = (this.points[i][j].z + this.points[i+pa][j].z
+ this.points[i][j+pa].z + this.points[i+pa][j+pa].z) / 4
// intrduce fluctuations
z += this.myRandom(z / d)
this.points[mid.x][mid.y].z = z
// up
this.points[mid.x][j].z = this.countBorderPoint(
this.points[i][j].z,
this.points[i+pa][j].z,
this.points[mid.x][mid.y].z,
this.points[mid.x][mid.y].z, d)
// down
this.points[mid.x][j+pa].z = this.countBorderPoint(
this.points[i][j+pa].z,
this.points[i+pa][j+pa].z,
this.points[mid.x][mid.y].z,
this.points[mid.x][mid.y].z, d)
// right
this.points[i][mid.y].z = this.countBorderPoint(
this.points[i][j].z,
this.points[i][j+pa].z,
this.points[mid.x][mid.y].z,
this.points[mid.x][mid.y].z, d)
// left
this.points[i+pa][mid.y].z = this.countBorderPoint(
this.points[i+pa][j].z,
this.points[i+pa][j+pa].z,
this.points[mid.x][mid.y].z,
this.points[mid.x][mid.y].z, d)
// terrain fluctuations in next iteration will be smother
d *= Math.pow(2, -this.r)
p /= 2
if(p > 1)
{
// upper left
this.countSquare(i, j, p, d)
// upper right
this.countSquare(i+p, j, p, d)
// lower right
this.countSquare(i, j+p, p, d)
// lower lef
this.countSquare(i+p, j+p, p, d)
}
};
this.countBorderPoint = function (a, b, c, d, seed)
{
var arr = [a, b, c, d];
var x = 0;// suma wszytkich
var y = 0;// ile bylo > 0
for(var i = 0; i < arr.length; i++)
{
if(arr[i] > 0)
{
x += arr[i]
y++;
}
}
return ( (y!=0) ? (x/y) : 0 ) + this.myRandom(seed)
};
// random number in [0, range]
this.myRandom = function (range)
{
return Math.random() * range
};
this.start();
}
// user API
function dsCreate(canvasID)
{
var canvas = document.getElementById(canvasID)
var windowSize = canvas.width
terrain = new fractalTerrainGenerator(windowSize)
screen = new screen(canvasID, terrain)
dsMove()
}
function dsMove(dst)
{
screen.move(dst)
}
</script>
<style>
.terrainFractalMenu
table
{
border:none;
}
.terrainFractalMenu
a
{
font-size:larger;
color:#333;
text-decoration:none;
}
.terrainFractalMenu
td
{
width:90px;
text-align:center;
}
.terrainFractalMenu
{
background:#eee;
}
#terrainFractalWindow
{
background: #e0e0e0;
padding: 0;
margin: auto;
display: block;
margin-top: 20px;
margin-bottom: 20px;
}
</style>
<!-- Is it semantically correct to use table here? Probably not, but it's an old code. -->
<center>
<table class="terrainFractalMenu">
<tr>
<td></td>
<td class="terrainFractalMenuItem"><a href="JavaScript:dsMove('up')">up</a></td>
<td></td>
</tr>
<tr>
<td class="terrainFractalMenu"><a href="JavaScript:dsMove('left')">left</a></td>
<td class="terrainFractalMenu"><a href="JavaScript:dsCreate('terrainFractalWindow')" >create new</a></td>
<td class="terrainFractalMenu"><a href="JavaScript:dsMove('right')">right</a></td>
</tr>
<tr>
<td></td>
<td class="terrainFractalMenu"><a href="JavaScript:dsMove('down')">down</a></td>
<td></td>
</tr>
</table>
</center>
<canvas id="terrainFractalWindow" width="800" height="800"></canvas>
<p>To check exactly, how the scripts are working please take a look on the source code of this page.</p>
<p>Above scripts were created a couple of years ago, they may not be aligned with the modern way of doing things in JavaScript. The code can be hard to read, I've written it when I was a student, back in those days I've been in love in short variable names and lack of comments.</p>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-3218008772058347246.post-84407370927924038532016-03-12T14:49:00.001+02:002019-05-31T17:39:14.754+03:00Julia set, Cantor set and Fern fractal implemented in JavScript<style>
.fractalWindow
{
background: #e0e0e0;
padding: 0;
margin: auto;
display: block;
margin-top: 20px;
margin-bottom: 20px;
}
.drawFractal
{
font-size: 120%;
color: #333;
}
</style>
<p>In the previous post, I presented a simple fractal - <a href="http://robertgawron.blogspot.com/2016/03/bifurcation-diagram-of-logistic-map.html">bifurcation diagram of the logistic map</a>. Today I will show more fractals and their implementation in JavaScript, they are embedded below so it's possible to run them on this page.</p>
<h2>Julia set</h2>
<p>The equitation for <a href="https://en.wikipedia.org/wiki/Julia_set">Julia set</a> is given for <a href="https://en.wikipedia.org/wiki/Complex_number">complex numbers</a>:</p>
<center><p>f<sub>c</sub>(x) = x<sup>2</sup> + c</p></center>
<p>This implementation uses random numbers to create the fractal.</p>
<p><a href="JavaScript:drawJuliaFractal('canvasJulia')" class="drawFractal">Click to draw Julia set. This can take a while.</a></p>
<canvas id="canvasJulia" width="800" height="800" class="fractalWindow"></canvas>
<pre>function drawJuliaFractal(canvasID)
{
// get canvas to be able to draw into it
var canvas = document.getElementById(canvasID)
var ctx = canvas.getContext("2d")
var width = canvas.width
var height = canvas.height
<b> var c_r = -0.73
var c_i = 0.19
var step = 0.002
// z= a+bi
for(var a = -2; a < 2; a+=step)
{
for(var b = -2; b < 2; b+=step)
{
var za = a
var zb = b
for(var n = 0; n < 160; n++){
var za_temp = (za * za) - (zb * zb)
zb = 2 * za *zb
za = za_temp
// add c constant
za+=c_r
zb+=c_i
}
if(Math.sqrt((za * za) + (zb * zb)) < 2)
{</b>
var zoom = width / 3
var x_print = (zoom * a) + (width / 2)
var y_print = (zoom * b) + (height / 2)
putPixel(ctx, x_print, y_print)
}
}
}
}
</pre>
<h2>Fern fractal</h2>
<p>Unfortunately, I don't remember the direct mathematics formula.</p>
<p>This implementation uses random numbers to create the fractal.</p>
<p><a href="JavaScript:drawFernFractal('canvasFern')" class="drawFractal">Click to draw Fern fractal.</a></p>
<canvas id="canvasFern" width="800" height="800" class="fractalWindow"></canvas>
<pre>
function drawFernFractal(canvasID)
{
// get canvas to be able to draw into it
var canvas = document.getElementById(canvasID)
var ctx = canvas.getContext("2d")
var width = canvas.width
var height = canvas.height
var max_step = 20000
var x = 0
var y = 0
<b> for(var i=0; i<max_step; i++)
{
var r = Math.random()
if(r <= 0.01)
{
x = 0
y = 0.16 * y
}
else if(r <= 0.08)
{
x = (0.2 * x) - (0.26 * y)
y = 0.23*x+0.22*y+1.6
}
else if(r <= 0.15)
{
x = (-0.15 * x) + (0.28 * y)
y = (0.26 * x) + (0.24 * y) + 0.44
}
else
{
x = (0.85 * x) + (0.04 * y)
y = (-0.04 * x) + (0.85 * y) + 1.6
}</b>
// scale fractal to best fit to the canvas object
var zoom = width / 10
x_print = width - ((x * zoom) + (width / 2))
y_print = height - (y * zoom)
putPixel(ctx, x_print, y_print)
}
}
</pre>
<h2>Cantor set</h2>
<p>The equitation for <a href="https://en.wikipedia.org/wiki/Cantor_set">Cantor set</a> is given by formula:</p>
<center><p>C<sub>n</sub> = C<sub>n-1</sub>/3 ∪ (2/3 + C<sub>n-1</sub>/3), C<sub>0</sub> = [0,1]</p></center>
<p>This implementation uses recursion to create the fractal.</p>
<p><a href="JavaScript:drawCantor('canvasCantor', 0, 0, 800)" class="drawFractal">Click to draw Cantor set.</a></p>
<canvas id="canvasCantor" width="800" height="800" class="fractalWindow"></canvas>
<pre>
// Note, initial invocation should be with xb = canvas width
function drawCantor(canvasID, level, xa, xb)
{
// get canvas to be able to draw into it
var canvas = document.getElementById(canvasID)
var ctx = canvas.getContext("2d")
var width = canvas.width
var height = canvas.height
<b> var level_max = 10;
if(level < level_max)
{
// put bar
var bar_height = 3
for(var i = xa; i < xb; i++)
{
var h = level * 6
for(var j = h; j != (h + bar_height); j++)
{
var y_print = j +( height / 2)
putPixel(ctx, i, y_print)
}
}
// call itself to print two child bars
drawCantor(canvasID, level+1, xa, xa+ (xb-xa)/3)
drawCantor(canvasID, level+1, xb - (xb-xa)/3, xb)
}</b>
}</pre>
<p>To check exactly, how the scripts are working please take a look on the source code of this page.</p>
<p>Above scripts were created a couple of years ago, they may not be aligned with the modern way of doing things in JavaScript.</p>
<script type="text/Javascript">
// put pixel on the canvas, ctx is canvas handler
function putPixel(ctx, x, y)
{
var dotColor = '#333';
ctx.save();
ctx.fillStyle = dotColor;
ctx.fillRect(x, y, 1, 1);
ctx.restore();
}
function drawJuliaFractal(canvasID)
{
// get canvas to be able to draw into it
var canvas = document.getElementById(canvasID)
var ctx = canvas.getContext("2d")
var width = canvas.width
var height = canvas.height
var c_r = -0.73
var c_i = 0.19
var step = 0.002
// z= a+bi
for(var a = -2; a < 2; a+=step)
{
for(var b = -2; b < 2; b+=step)
{
var za = a
var zb = b
for(var n = 0; n < 160; n++){
var za_temp = (za * za) - (zb * zb)
zb = 2 * za *zb
za = za_temp
// add c constant
za+=c_r
zb+=c_i
}
if(Math.sqrt((za * za) + (zb * zb)) < 2)
{
var zoom = width / 3
var x_print = (zoom * a) + (width / 2)
var y_print = (zoom * b) + (height / 2)
putPixel(ctx, x_print, y_print)
}
}
}
}
function drawFernFractal(canvasID)
{
// get canvas to be able to draw into it
var canvas = document.getElementById(canvasID)
var ctx = canvas.getContext("2d")
var width = canvas.width
var height = canvas.height
var max_step = 20000
var x = 0
var y = 0
for(var i=0; i<max_step; i++)
{
var r = Math.random()
if(r <= 0.01)
{
x = 0
y = 0.16 * y
}
else if(r <= 0.08)
{
x = (0.2 * x) - (0.26 * y)
y = 0.23*x+0.22*y+1.6
}
else if(r <= 0.15)
{
x = (-0.15 * x) + (0.28 * y)
y = (0.26 * x) + (0.24 * y) + 0.44
}
else
{
x = (0.85 * x) + (0.04 * y)
y = (-0.04 * x) + (0.85 * y) + 1.6
}
// scale fractal to best fit to the canvas object
var zoom = width / 10
x_print = width - ((x * zoom) + (width / 2))
y_print = height - (y * zoom)
putPixel(ctx, x_print, y_print)
}
}
// Note, initial invocation should be with xb = canvas width
function drawCantor(canvasID, level, xa, xb)
{
// get canvas to be able to draw into it
var canvas = document.getElementById(canvasID)
var ctx = canvas.getContext("2d")
var width = canvas.width
var height = canvas.height
var level_max = 10;
if(level < level_max)
{
// put bar
var bar_height = 3
for(var i = xa; i < xb; i++)
{
var h = level * 6
for(var j = h; j != (h + bar_height); j++)
{
var y_print = j +( height / 2)
putPixel(ctx, i, y_print)
}
}
// call itself to print two child bars
drawCantor(canvasID, level+1, xa, xa+ (xb-xa)/3)
drawCantor(canvasID, level+1, xb - (xb-xa)/3, xb)
}
}
</script>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-3218008772058347246.post-42070023552350049242016-03-11T23:05:00.000+02:002019-05-31T17:39:17.254+03:00Bifurcation diagram of the logistic map [online version]<p>One of the reasons why mathematics is so amazing is that even a simple at first glance concepts have interesting behaviors and features. I think that <a href="https://en.wikipedia.org/wiki/Bifurcation_diagram">the bifurcation diagram</a> of <a href="https://en.wikipedia.org/wiki/Logistic_map">the logistic map</a> is a great example.</p>
<p>The logistic map is given by the equitation:</p>
<p style="text-align:center;">x<sub>n+1</sub> = rx<sub>n</sub>(1 - x<sub>n</sub>), x<sub>0</sub> < 1, r ∈ (0,4]</p>
<p>Below you may generate its <a href="https://en.wikipedia.org/wiki/Bifurcation_diagram">bifurcation diagrams</a> for different ranges and for different values of the x<sub>0</sub>. It's amazing that those <a href="https://en.wikipedia.org/wiki/Fractal#Characteristics">diagrams have fractal nature</a> - self-similarity is even visible at first glance.</p>
<p>X-axis represents values for different r values, Y-axis represents x<sub>0...n</sub> element value, n < 90 because in real world we can't show elements <i>ad infinimum</i>.</p>
<style>
#bifurcationDisplayArea
{
background: #f0f0f0;
padding: 0;
margin: auto;
display: block;
margin-top: 20px;
margin-bottom: 20px;
}
#bifurcationDrawButton
{
margin-top: 15px;
background: #fbfbfb;
}
</style>
<p>
r<sub>start</sub>>0: <input type="text" id="ra" value="2.95"/>
r<sub>stop</sub>≤4: <input type="text" id="rb" value="4.0"/>
x<sub>0</sub><1: <input type="text" id="a" value="0.9"/>
<input id="bifurcationDrawButton" type="button" onclick="drawBifurcationDiagramOfLogisticMap()" value="Draw bifurcation diagram of the logistic map"/>
</p>
<canvas id="bifurcationDisplayArea" width="800" height="600"></canvas>
<script>
function drawBifurcationDiagramOfLogisticMap()
{
var canvas = document.getElementById("bifurcationDisplayArea")
var ctx = canvas.getContext("2d")
// clean canvas
ctx.clearRect(0, 0, canvas.width, canvas.height)
// parse input parameters
var ra = parseFloat(document.getElementById("ra").value)
var rb = parseFloat(document.getElementById("rb").value)
var a_x = parseFloat(document.getElementById("a").value)
var width = canvas.width
var height =canvas.height
var max_iterations = 90
var step = 0.0004
for (var a_r = ra; a_r < rb; a_r += step*(rb-ra))
{
for (var i=0; i < (max_iterations * a_r); i++)
{
a_x = a_r * a_x * (1 - a_x);
putPixel(ctx, width*(a_r-ra)/(rb-ra), height * a_x)
}
}
}
function putPixel(ctx, x, y)
{
var dotColor = '#333';
ctx.save();
ctx.fillStyle = dotColor;
ctx.fillRect(x, y, 1, 1);
ctx.restore();
}
</script>
<p>The script was originally created a couple of years ago, so it may not be aligned with the modern JavaScript way of doing things. If you are interested how it works, please take a look on the source code of this page.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3218008772058347246.post-29251244872879465332016-03-05T15:02:00.000+02:002019-05-31T17:39:19.826+03:005V/400V DC/DC converter<p>A small and cheap 5V/400V DC/DC converter can be useful in many DIY projects, e.g <a href="http://robertgawron.blogspot.com/2015/02/homemade-geigermuller-counter-part-i.html">Geiger–Müller counters</a>. I will present here one of such DC/DC converter based on popular MC34063 chip in step-up configuration.<p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1FhV7FvgBeh6P8Sg5jnUIfrHGSVdzB8dbguPDE0kVHfCFMb8Ka5SjJgpzkXEq8VWQwsZTLxpn5IN_jcYtVZGCObSl83ALiwKhc3cc5Mmv1QKV-8dUmd_Lm74duhL_5c2ohVc37kwiZChi/s800/high_voltage__pcb_top.JPG" />
<p>One big limitation of this device is little output power, but for many applications this won't be a problem. Another problem is poor temperature stability, but this could probably be improved by using low tolerance C1, R7-R11.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibYdJzQIlifubhnPR18ha3Xg1nHpT6uGhJ5JItdcNym4rPOQq2D8PkOFUQ7OAkH3iVjhVnmXkxJoCCZ4s0d8FyEcJf3JMIUakuhCvrvxBpYR1f1NMaEhfbx_SrclX3mzcGzPgAvuwW8HpZ/s1600/high_voltage_dc_dc_converter.png" />
<p>Q1, L1, D2 are coil-based step-up converter. Q1 should be a power MOSFET rated a bit more than the output voltage. Empirical tests have shown that Q1 didn't heat up, so I didn't mount it on a radiator. D2 and C4 rectifie output voltage, they also should be rated for bigger voltage than the output. To improve performance, D2 can be replaced by a Schottky diode, capacitance C4 can be increased. R3-R11, C3 provide output feedback to the MC34063. S1 is used to select output voltage if needed.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjm0fLvULUWG1sWQk8B-hD_iNFwHsJKEyD2mAR5EowLatheIfEBsM9pDn63aIujbtO55q4xGHEPH_fSwl3GaDOdO2g5Jm9VMgR0PsPz5OSKyfZUgwtOAft7r-w7v_Cvo0YdnSbxf0cN3bT/s800/high_voltage__pcb_bottom.JPG" />
<p>Idle power consumption is 85mW. Below presented fluctuation in output voltage at constant temperature and constant load.</p>
<p>Unfortunately, the device output voltage highly depends on room temperature, the lower the temperature, the higher is output voltage. Example of this is visible on below picture. Temperature measured near the transistor. Negative spike of temperature visible on the picture was created using canned air spray - easy way to temporary decrease temperature. The picture was generated using <a href="https://robertgawron.blogspot.com/2018/09/collecting-and-processing-data-from.html">set of scripts that I presented in one of my posts</a>.</p>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSjUpAFLajbrF9BtrbYKJSIAfPeJ2-48Uf6LO3ULYYiK0r09kamcfEgfhDltf330yHx1feuoPK1HfbkH0N3r57dxJSJJ4RMscdqtEIbCTxF-PDt1yf52xU77S152oxpj-qLssabEa1nIIH/s1600/results.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSjUpAFLajbrF9BtrbYKJSIAfPeJ2-48Uf6LO3ULYYiK0r09kamcfEgfhDltf330yHx1feuoPK1HfbkH0N3r57dxJSJJ4RMscdqtEIbCTxF-PDt1yf52xU77S152oxpj-qLssabEa1nIIH/s1600/results.png" data-original-width="800" data-original-height="500" /></a></div>
<p><strong>Such high output voltage can be dangerous (even while the maximum curent iof this converter s small), so if you make the same or similar device, please be careful.</strong> If you are interested in higher voltage, you ma take a look on <a href="http://robertgawron.blogspot.com/2015/03/high-voltage-power-suply-10-30kv-made.html">High voltage supply (10-30kV) made from CRT television flyback transformer</a>.</p>
<p>Eagle files for this project can be <a href="https://github.com/RobertGawron/snippets/tree/master/5Vto400VConverter">downloaded from my GitHub repository</a>.</p>Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-3218008772058347246.post-32685025149496861612015-09-14T12:48:00.001+03:002019-06-23T20:29:45.859+03:00DP-70 dosimeter<p>DP-70 was a chemical dosimeter used in the Polish army during the Cold War. A dosimeter is a device used to measure the amount of radioactive radiation absorbed by a body, in this case, by soldiers.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn1XSu2KRRmoz7IdVSF8HFrmd5GGfjybevXOte7M_vnHRYbtGzM8rz3L0GyUwCmTvhDL7zknIQXh-LPpzaRlubLn5ZUnln-UyeNcbPSacPIIHr5jOemXmoyUhGNRaO_xsMeT-YqzQr1ir4/s800/IMG_2232.JPG" alt="DP-70 dosimeter"/>
<p>DP-70 has a form of a small metal cylinder (to protect the device in hard, combat conditions) that covers an ampule with a transparent liquid. This substance change color proportionally to absorbed radioactive radiation.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipQv82Cwm1F4AN7jBkV4c4M91OBTH7ccFlJfpPEBoPL0X7c0a_j4gXxOtSRvnhWB0TtaX-TFmBCtrOTTuqUrSUbTB0DIqHujbT-hK32YHtsThIwGDe-6YJ_CuSnpaXhjqapn98FJoWLKBc/s800/IMG_2242.JPG" alt="DP-70 dosimeter"/>
<p>It's a simple device, but has two major drawbacks - it can't be used by colorblind persons and is not precise. Due to those two factors, the device was replaced by more modern <a href="https://robertgawron.blogspot.com/2015/04/dkp-50-dosimeter-radioactivity-detector.html">DKP-50 dosimeter</a>.</p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7_OIvolSBOhdtjRlRLVZJaewTsiLsyJxwgsbiB7Q-RNqErkv1rH0wL_VQNsTyLJckgspaHj8Sbfq9KtDz484Lr8Ad1wn3vZSk1-oEWt8VMdBIny1u7bj-gcPje46xjmagam3fM_5P6ONb/s800/IMG_2234.JPG" alt="DP-70 dosimeter"/>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWpVZUKHuy_Igmev9qtkVwLYUxDEfXXUpQ4PNHiMlaPOHRSgspXIxXx9DRcFJrdewwyaF-rqWrlPKbXXLsypLoiRvZPiuZmkSfbDj9N0fLxE5LDi6CY9UUQs0TF9OMYVQcKeoytbLArayU/s800/IMG_2240.JPG" alt="DP-70 dosimeter"/>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_oHO7irD6Svm-fJlkYbHP9-9FazXGvQpOFNgFeEHm6moSyWGUc_QlAFWOlO7-VC1Qkv-BiKcf_EwD-qOUha8vZGoJcIhod0OcgWYmeSdYwmnJzTIwn98fa49PQSN9UE7a3w2aJ7eYow9f/s800/IMG_2245.JPG" alt="DP-70 dosimeter"/>
<p>It can be bought for around two euro, unfortunately it's designed to measure ranges present during nuclear war, so it's far too insensitive to make any experiments with environmental radioactivity.</p>
Unknownnoreply@blogger.com0