So this has already been done?!
R
So it would seem
. However, I haven't seen any results that might suggest this kind of DIY approach is actually useful. I have to think it's possible because there are lots of XRF vendors using very similar technology. Here's the thing, though. In the world of X-ray spectroscopy, it's not just a matter of finding the energy peaks, parsing out the relative intensities for the percentage of content and calling it good. An element emitting higher-energy X-rays will, in turn, excite X-rays from other materials present. So there are complex interactions. A lot of this has been modelled based on the analysis of EDX/WDX data, but, just to make things even more complicated, each element can have a number of different energy levels that, in a number of cases, produce energy peaks that overlap.
I know this may seem an unlikely coincidence, but the mousepad I'm currently using is one I got from ThermoScientific as a freebie: and it's a periodic table that has information about EDX/WDX elemental analysis. A cool thing about this chart shows the "overlaps", where the emission from one element can overlap the other -- making it more difficult to distinguish the two. Case in point: the K-alpha line for iron at 6.4KeV is close to manganese at 5.89Kev. Definitely problematic, because manganese is used in many alloys. The L-alpha lines are .636 and .704Kev for Mn/Fe respectively so no joy there. Vanadium's K-alpha is close to Chromium, and Manganese is close to Chromium. Ugh! To resolve this, commercial tools use sophisticated data-extraction programs to produce a least-errors fit to all the data (not just the peaks). The situation for iron and manganese is problematic, but cobalt isn't much better because it is on the other side of iron in the periodic table. Nickel is better (some) because its K-alpha line is about 1Kev higher than iron.
A work-around might be a kind of fingerprint analysis, where different alloys are characterized and then used as a comparison to the unknown alloy. That would be my best-case approach. It's limited by the "dictionary" of alloys you have characterized but that could rapidly grow in the context of an open-source effort. Of course, a reliable open-source approach would include a rigorous method of calibrating the tools so DIY'er A can depend on the results produced by DIY'er B...and so on.
On a slightly different note, I am thinking that the "5V switch" control line in the Arduino MCA circuit is likely being used to implement a type of sample-and-hold circuit. Once a pulse enters the measurement system, it sends a signal to the Arduino which then turns the peak-hold detector off so a particular photon event can be accurately captured. If not, suppose in the meantime an even-higher-energy photon strikes the scintillator. The higher pulse peak is captured by the peak detector. This will result in a skew of the data, favoring higher-energy x-rays.