Thursday, August 15, 2024

Ripple/Noise Eater, some simulation results

 In my last post I simply described the approaches I explored.  This post shows some simulation results.  The first image below shows the performance of a simple capacitance-multiplier circuit.  It attenuates 60Hz ripple by about 24 dB:


Its main advantage is that it is very simple, using a single transistor to do the job.

And here is the simulation result for my opamp-based version:


This design attenuates 60 Hz ripple a bit more than 72 dB.  That's pretty good.  The design is interesting because the capacitors C2 and C3 are the primary determiners of the circuit's gain, and it is independent of the frequency -- because the ratio of their impedances over frequency remains constant.  The 20 megohm resistor is mostly there to provide bias current for the opamp's inverting input.  It does introduce some rolloff in the circuit's performance at very low frequencies but its impact on noise+ripple at or above 60Hz is negligible.

In a real-world design I would add some protection diodes.  One across the transistor's collector and emitter pins and two connected to the opamp's inverting input.  One connected to the opamp's positive supply and one to either ground or its negative supply.  I probably would choose the negative supply to balance the two diode's leakage currents, but it probably isn't too critical since the opamp is AC coupled to the transistor's base -- so a DC offset on its output wouldn't affect circuit operation.   Unless the offset is so large that the opamp output voltage is close to railing.  But a good diode's leakage current won't be high enough to do that, even with the 20 megohm feedback resistor.

Not shown here, I also looked at the circuit's response to a transient current load to check its response.  I didn't want the circuit to exhibit a lot of ringing, or, worse, burst into oscillation.  It does exhibit a bit of undershoot/overshoot but that disappears when I place a 10nF capacitor between the output and ground.




Wednesday, August 14, 2024

An effective "ripple eater" design

 This post is regarding something that the Theremino approach towards high-resolution XRF spectroscopy emphasizes.  That is the noise+ripple voltage on the PMT (photomultiplier tube) high voltage supply.  They indicate that it should be in the microvolt range because the PMT gain is very dependent on its supply voltage.  This can be a significant problem because the PMT voltage can be in the 1,000 volt range, so we're looking at something on the order of 10^-6/10^3 or a ratio of 1:10^9.  This is a very demanding requirement.  Their approach is to use a passive multiple-order RC filter chain, but this also introduces a large phase shift vs. frequency ( in addition to gain vs. frequency) that is difficult to control in terms of circuit stability.  So its response to a pulse-style load isn't all that great, either.  Thus a lower-order filter scheme looked more attractive in terms of better response to impulse-style loads (as in, the signal generated by a PMT+scintillator when presented with a single x-ray photon).

I've found a few descriptions of a 1-transistor circuit called a "ripple eater" but the circuit wasn't all that intuitive to me.  I also suspected it wasn't the best-possible approach so I tried a couple of different schemes to see what was possible.  But the nice thing was that it offered the possibility of greatly reducing the HV supply's ripple+noise while reducing the order of the filter ... which also would improve the transient response of the HV supply.  So I tried a few different approaches.  The first was a relatively simple "capacitance multiplier" circuit -- basically, an emitter follower driven by an RC low-pass filter.  The idea behind this is that the transistor's base current is low so we can use a very high-value R in the base-input RC low-pass filter.  One very significant limitation with any kind of HV low-pass filter is the fact that high-value and high-voltage capacitors can get VERY expensive, so I limited my options to a maximum of 47 nano-farads.  My SPICE simulation showed that about the best "ripple eater" attenuation I could get with this simple circuit was in the neighborhood of 30dB.  Not too bad, in fact about a reduction of 1000:1.

But we can do much better than that if we use a high-gain, low-noise operational amplifier in a special kind of summing-node application.

More on that soon.

Friday, August 9, 2024

Another XRF Update

 I've used my improved hardware setup (a Scionix PMT/Scintillator detector) to further improve other S/W and H/W components of my experimental XRF system.  I started using the detector and full-bore Theremino-style filter/amplifier setup, but the results weren't all that much better.  I began to suspect some software problems, particularly with regard to the triggering function, so totally re-wrote that portion, switching from a rolling average scheme to a majority-vote approach, where 8 pulses had to exceed the trigger voltage in order to initiate a pulse-detected signal.  That by itself resulted in a significant improvement in the quality of the XRF spectra I was getting.  At that point I was using some Thorium-doped welding rods as test sources.

The other change is that I reviewed the baseline noise coming out of my relatively simple filter + transistor amplifier design that's totally based on the Theremino design.  I had favored it over a low-noise operational amplifier design because the noise voltage coming out of the opamp design was much higher:  but that turned out to be due to the fact that it had much higher gain.  I missed that crucial difference.  Once I reduced the gain in my simulations, the opamp-based design performed substantially better than the discrete transistor design.  So I designed a new filter/amp board using an opamp.  The results were better, but not as good as I had hoped for.  Additional investigation showed that the final RC low-pass filter, which in the Theremino design is just a relatively large capacitor hanging off the emitter of the buffer transistor, was much too "strong" -- the Theremino's emitter-follower's output resistance is pretty low, so even a relatively large capacitor wouldn't exhibit the low-frequency rolloff that my "improved" design did.  So I reduced the value of the capacitor in my new circuit -- and suddenly my XRF spectra became a LOT better.  At this point I can get a pretty decent XRF spectrum for Cadmium at about 23Kev.

But 23Kev is a long ways away from the ~5.6Kev iron XRF peak.  And THAT has remained elusive, because the protective window over my sodium iodide scintillator crystal (in the Scionix detector) appears to crap out somewhere below Cadmium.  I've tried detecting lead, at about 10Kev, and see a small peak -- but that's about the end of the road.

So at this point I have concluded a few things.  First, the Scionix setup was very valuable in terms of improving my software.  If nothing else, it's worth keeping for that alone.  The second is that I need to come up with a different low-energy xray detector.  One approach could be a cooled silicon PIN photodetector.  I've found some made by Osram and Hamamatsu that are fairly large-area, about 3x3mm, with relatively low dark current and relatively low capacitance.  Not too expensive, either.  Cooling them with a 2-stage thermoelectric cooler (TEC) would reduce the dark current and improve the SNR.  So that's one approach, but has its problems when it comes to dealing with condensation.  I want to run the PIN diode well below 0C, so will need to enclose the detector with some desiccant -- or evacuate the interior -- to prevent condensation.  That's do-able, but raises the bar for other folks who want to reproduce this.  Alumina desiccant is good enough and pretty cheap so that probably is the easiest and cost-effective approach.

The other approach is totally different in terms of the detection mechanism.  It uses a gas proportional counter, sort of similar to a Geiger counter, but it's operating voltage is lower so the pulses it generates are proportional to the incident photon energy, rather than being avalanche-multiplied to the point where the tube is saturated (this the Geiger mode).  It's best suited for lower-energy xrays, which is exactly where I want to be in terms of the analysis work I want to perform (figuring out what kind of steel alloy I've got).  If you've got a lathe the detector should be relatively easy to make.  But it requires a continuously-flowing gas mixture of argon and carbon dioxide.  That' not such a big deal, it is about the same as what's used when MIG welding -- but it would be an additional cost for someone who doesn't already have a MIG welding setup.  It also requires a high voltage power supply -- but I already have that, since I needed one for my photomultiplier.  I do NOT have a MIG welding setup, so for now I'm concentrating on a silicon PIN diode.  But keeping this approach in my back pocket.

Saturday, April 20, 2024

Why I love linux

 Linux has an incredibly wide range of useful little applications.  I have a good example of a recent need that was answered by one of them.

Our old Brother HL-5450DN laser printer started having a problem with paper jams.  The troubleshooting guide(s) I went through pointed toward either the toner or fuser components, so I started with replacing the toner -- it's a fast and easy thing to do, plus the old toner cartridge was close to its EOL anyway.  At first that seemed to solve the problem, but not long afterwords the paper jams started again -- and very consistently.  So either we replaced the fuser unit or got a new printer.  Since we try very hard to keep stuff out of the landfill, I went with the first option.  I found a 3rd party fuser on Amazon for a pretty good price (most reviews were positive), and a youtube video on how to R&R the fuser.

The replacement process went very smoothly, and the printer jamming problem appears to have been resolved (fingers crossed).  However, this printer keeps track of the number of prints that go through the machine, and that includes the fuser unit.  At 100,000 pages the printer firmware will start to object to having that "old" fuser unit.  So I needed to tell the computer that the fuser had been replaced.

More online searching revealed references to some utilities that are supposed to do the job:  but I wasn't able to actually FIND any to download.  In addition to that, they are all Windows-centric.  I did find the CDrom that came with the printer, but I didn't find any maintenance-specific applications on it.

My online searching DID find a very useful set of Brother-specific PJL files that are used to perform these kinds of maintenance functions.  PJL stands for "Printer Job Language", and it appears that most network-capable printers understand it.  So what I needed was a way to send the fuser-reset PJL script to our printer.  That's where the "nc" utility came in handy.  nc is linux shorthand for "netcat".  The "cat" command is a linux command that sends text to files or other scripts, so "nc" can send text to networked devices.  This sounded like the ticket.  So I tried sending a little text file to our printer:

nc <ip-address-of--our-printer> 9100 < hello.txt

...and the result was a printed sheet of paper with the words "Hello World!" on it.  BTW 9100 is the port number that's used by most printers for PJL files.

So with this result I substituted the fuser-replacement script I had found for "hello.txt".  I got a "nice" answer from the printer, so I used my browser to access the printer's web page, went to the maintenance section and -- voila! -- the fuser lifetime had been reset to 100%, and the # of replacements had increased from 0 to 1.  It had worked.  And without messing around with any vendor-specific/OS-specific maintenance utility.  If I had actually been able to find it and get it to work under Wine.

Wednesday, March 20, 2024

Voltage Quadrupler for Silicon Photomultiplier (XRF scintillator-detector)

 A Silicon PhotoMultiplier (SiPM) requires about 25-30V to bias it into its avalanche-gain region, so some kind of voltage step-up circuit is needed to boost the power supply voltage.  My current electronics use +/- 10 volts so I need a voltage quadrupler, followed by a low-noise voltage voltage regulator.

I had experienced some noise-injection problems from the boost circuit used in the PocketGeiger, probably from the inductor.  It has to run a noticeable amount of current through the switching regulator's inductor because it also is used to boost 5V to the 9V needed to run the other electronics.  For this reason I have decided to try a charge pump-based voltage multiplier.  This type of circuit can't supply a large current, but the average current drawn by the SiPM will be very small so it should work OK.

I went with a Dickson-style voltage multiplier that uses two inputs that switch between 0 and +10.  The two inputs are 180 degrees out of phase, so a CMOS buffer would work well for this.  Here's an LTSpice simulation of the voltage multiplier:


Due to the relatively small capacitors it takes awhile to come up to its full voltage output.  The simulation was done using 1N914 diodes to get an idea of what the actual voltage output would be, because the voltage drop across each diode reduces the output voltage somewhat.

Since the in-phase and out-of-phase inputs should be balanced for best performance, the oscillator in my actual voltage multiplier needs to have a 50:50 duty cycle.  But this isn't all that easy to achieve.  Most CMOS oscillators based on inverters do NOT have a 50:50 duty cycle.  The other thing I didn't like is that the "best" oscillator I found uses 3 inverters, which used up more gates than I wanted -- producing an unbalanced drive capability for the two inputs to the charge pump.  I really needed a 2-gate oscillator with a guaranteed 50:50 duty cycle.

I recalled that the old transistor-based astable multivibrator produced a pretty good 50:50 duty cycle, so I designed one using two CMOS buffer/inverters, and simulated it using LTSpice.  The circuit initially didn't work because the Spice simulation uses buffers that are exactly the same -- there's no circuit imbalance to get the oscillator going.   I found it necessary to use a pulse generator to kick things off.  The pulse generator just outputs 1 pulse so it doesn't interfere with the simulation after it turns off.

Here's the result:


Since one of the outputs has a 50:50 duty cycle and everything is symmetric, the other output has a  50:50 duty cycle as well.  My initial choice for the R's and C's didn't oscillate at 10KHz, my target frequency, but it was easy to come up with a correction factor (based on the CD4049 Spice model).  That said, my calculations produced:  F = .417/(RC).  This was for a 10 volt supply voltage.  If I drop Vcc to 5V the frequency drops a bit -- to around 7.7KHz.  This is because the buffers' threshold voltage doesn't change as Vcc changes.  Based on the application, the frequency variation would be less of an issue than the fact that the voltage multiplier's output would drop by a factor of 4.  So....no big deal.

My circuit frees up an inverter, only uses one more component than the 3-gate oscillator and has a duty cycle that is much closer to 50:50.  Pretty much a win as far as I'm conerned.

The main variation in the duty factor would be due to tolerance-related variations in the external R's and C's.  Easily addressed by using parts with tighter tolerances, or adding a trimming resistor in series with one of the R's.  The latter approach is NOT preferred because trimmers are more expensive than resistors, and, of course, it's necessary to adjust the trimmer.  Expense would be a hobbyist AND commercial-product related concern, the time needed to adjust the trimmer would be an issue for a commercial product.
 

Friday, March 15, 2024

Gamma Ray Spectroscopy/XRF update

 It's been quite awhile since I posted anything regarding my efforts toward coming up with an inexpensive XRF system.  I have built a lot of hardware and written a lot of software toward that goal, and....so far, have come up empty.  At this point I think it's due to the PIN xray detector -- it's just too noisy, and doesn't appear to have much, if any, energy resolution.  I worked on it pretty hard but....have come to the conclusion that it's not the way to go.  This decision was further cemented by my discovery that the detector is no longer being offered for sale as a standalone device.  It, or a similar-area device, can still be purchased but only in combination with a CsI(Tl) scintillator crystal.  Naturally, it also is more expensive.  And, since it has a very high dark current I still would expect it to be pretty noisy.

For these reasons I bought a used PMT/Scintillator off ebay.  It is a unit much like this, and can be a very good value if the PMT and scintillator are in good shape.  As-is it's not all that great for XRF usage but there is some good online information on how to modify one so it's compatible with the Theremino hardware and software.  But being a retired electrical engineer and dyed in the wool DIYer I decided to build my own high voltage power supply for the PMT, using a CCFL inverter board to convert 12 volts to 800-900 volts.  Due to lots of EMI coming out of the inverter and the necessity of achieving microvolt-level noise on the HV line that turned out to be quite a challenge.  I ended up using two separate 12V supplies -- one for the CCFL inverter, and a second one for the HV controller board.  The CCFL inverter was modified so its output could be better-controlled, and isolated from the controller board with an optoisolator.  I also made two aluminum enclosures for the inverter and controller, to further reduce EMI coupling from the inverter.

The whole thing was screwed down to a piece of wood, so this is a true "breadboard" style of construction:



The optoisolator circuit is between the two boxes.  The item with the blue tape on it is a home-made inductor to further isolate noise coming from the CCFL's control input line.  I modified the CCFL board by isolating the center tap of the transformer primary.  It normally is connected to the board's +12.  All of the online descriptions of using a CCFL as the heart of a HV power supply simply vary the supply voltage provided to the inverter board, but the one I bought would shut down if the supply went much below 12V.  I also lifted both of the secondary output pins because that completely isolated the CCFL's power supply from its HV outputs, which are routed to the controller board's HV rectifier/capacitor/filter network.

I used LTspice to design the optoisolator.  Here's the circuit diagram and simulation for one of my earlier versions:


The final design also includes a diode-connected PNP transistor in the emitter leg of the power transistor, to improve the low-current linearity of the circuit.  This is important because it turns out that my CCFL inverter doesn't need much input voltage to generate 900 volts.

Here's a photo showing my test setup, minus the HV power supply:


The Am-241 sources, detector and signal conditioning stuff is inside the aluminum box on the right.  The lead shielding is on the inside.  I'm using a Teensy 4.1 with a home-built 1MSPS 16-bit ADC to acquire the pulses.  The Teensy and ADC are behind the computer.  I'm using the Arduino IDE to develop the S/W.  I also am using a little Adafruit TFT to plot the spectums (when I get any that make any sense!).

Regarding the ADC, I figured out that the Teensy 4.1 has 16 contiguous I/O bits in one of its GPIO registers so that made it relatively easy to interface a fast 16 bit ADC to it.  Here's a photo of the ADC board, although in this case it's connected to a T4.0, which only has 8 contiguous bits available -- so the S/W has to grab 16 bits in two 8-bit "gulps" and combine them:

That's all for now.  I'm currently in the process of modifying my PMT's voltage divider.  Once that's done I will be pretty close to trying out the whole system with a detector system that is known to work well for XRF.  From there I get to see if my software is working right....


 

Wednesday, November 8, 2023

Creamy & Smooth Oat Milk

 This recipe is a variation on ones I found online.  I think it has a much nicer mouthfeel compared to other recipes, because in addition to the oats it contains fat of some kind, like butter or coconut oil (I actually like the coconut oil better).  It also is cooked slightly.  My recipe also adds a small amount of salt and sugar, but they are optional (but recommended).

Creamy Oat Milk

Makes approximately 1 quart of oat milk

2/3C rolled oats.  Not quick (pre-cooked) oats.

1/2 tsp salt

1 tsp sugar

1/2T butter or coconut oil.  They don't have to be in liquid form.

4C water, divided

Optional flavorings:  vanilla or almond extract.  I haven't tried cocoa powder, it probably would require more sugar to balance the bitterness contributed by the cocoa.  Dutch Process cocoa would be less bitter.  These flavors should be added after the oat puree is strained.

1.  Put the oats in a blender.  Add 2 cups water at room temperature, cover with the blender lid and allow to soak for 30 minutes.

2.  Blend on high for 30-60 seconds.  Strain into a bowl with a fine-mesh strainer, using the back of a large spoon to gently press down on the pulp.

3.  Add the remaining water, salt, sugar and fat to the bowl.

4.  Heat on High in a microwave oven, long enough to raise the temperature of the oat milk to 140F.  See Note below.  This step gelatinizes the starch, which gets rid of the gritty mouthfeel.

5.  Use a whisk to blend in the now-liquid fat.  The idea here is that the fat will form something like a roux where the fat globules are surrounded by starch so they will form a relatively stable emulsion.

Higher cooking temperature and more fat might make something closer to cream rather than milk, but if you over-do it you will likely end up with something that is more like pudding instead of milk.

Pour into a 1 quart jar and store in your refrigerator until ready to use.  Shake well before using.  Keeps for about 1 week.

NOTE  Our microwave oven takes about 5 minutes to heat the oat milk to 140F, but ours is an older, lower-powered one.  To check your microwave, place 4 cups of tap water in a bowl and "nuke" it for 4 minutes.  Stir to equalize the temperature and measure the temperature of the water.  If the temperature is higher than 145F, decrease the time by 30 seconds and try again.  If lower than 140F, increase the time by 30 seconds and evaluate the result.  You want to run enough room-temperature water in the bowl so it doesn't affect the result for each trial run.  The final test is to measure the temperature of a batch of your oat milk, since the actual volume of water will be slightly less than 4 cups.

Once you get the temperature to 140-145F you have characterized your microwave.  Make note of the time for the next time you make this recipe.