Wednesday, November 6, 2019

Kitchenaid Slow Cooker Sous Vide Modification

******************************************************************************
NOTE:  If anyone reading this post is inspired to try something similar, you MUST be aware of potential hazards associated with DIY modifications that use 110VAC (household AC) and temperature controllers that could cause a fire hazard.  This hazard could be the result of your system or temp controller being improperly configured, improperly wired or used in an inappropriate manner.  What I describe below is for educational purposes only, and anyone building something based on this post is fully responsible for ensuring that it meets local electrical codes, and being aware of its potential for electrocution or fire.  Also, see the last paragraph in this post for more details on potential failure modes.

*********************************************************************************

So we had this highly-rated slow cooker that we were using for making CBD-infused coconut oil for salves.  Besides CBD, cannabis plants contain a number of other beneficial compounds called Terpenes.  They are somewhat volatile so it is important to keep the processing temperature as low as possible.  Some terpenes you might recognize are turpentine (not so pleasant for topical use), lemon oil, orange oil and a number of similar terpenes that find use in cooking or medical applications

Unfortunately, the slow cooker's temperature controller went crazy and would heat the contents of the slow cooker to the boiling point regardless of the temperature setting.  This particular cooker had 4 settings -- Keep Warm, Low, Medium and High.  It became no good on any of them.  So what to do?  Well, I so happened to have an STC-1000 temperature controller on hand.  I originally got it to make a temperature controlled cabinet for making my own cured sausages and meats.  It turns out that our basement is the right temperature anyway so the controller wasn't needed.

I took the slow cooker apart and found the heater connections, then cobbled something together to see how the controller would work to maintain the right temperature.  At first, I went with a fancy spring-loaded temperature sensor that pressed against the bottom of the slow cooker crock, but the thermal path from the heater to the sensor was too good, so the contents of the crock didn't get anywhere close to the set point.  I found it was necessary to immerse the sensor in the crock itself.  For making CBD extract (or sous vide) this isn't a problem, because in both cases the "product" is in a jar or bag so the water in the crock doesn't come in contact with the stuff we're cooking up.

The in-the-crock temperature sensor worked just fine so I proceeded to make a more robust setup.  I bought a plastic enclosure and a pair of male/female DB9 connectors, then machined holes in the enclosure to accommodate the controller and connector.  I also had to do some creative machining (and carving) for the power cord's strain relief.  Unfortunately, the strain relief wasn't quite the right size for the power cord so it wasn't properly captured by the strain relief.  To address this, I did two things:  I squirted a good dollop of silicon caulk into the strain relief to glue the cord in place, and I also put a tie-wrap around the cord on the inside of the enclosure, right next to the strain relief.

Today I had an opportunity to check the whole thing out.  As in situations where 110VAC is present, there's a chance that sparks and smoke (or flames!) could come out of the box, but all went well.  Here's a photo of the setup working to maintain about 160F in the crock:


One thing I didn't realize about the STC-1000 is that it ONLY supports degrees Centigrade, not Fahrenheit so now it is a METRIC slow cooker  :)

CAVEATS

The STC-1000 will go into an error state and shut down if it loses connection to its temp sensor so that is one failsafe.  However, if the sensor isn't put into the crock, or if it inadvertently comes out of the crock, the controller won't know that and will keep on heating until the water boils.  This isn't too bad (yet): but once the water boils away it will continue to heat up and could become a fire hazard.  Therefore, as it's currently configured it is NOT ready for unattended use.  The controller itself could also fail so that's a potential issue as well.  To address the over-temp problem I will buy a thermal-cutout switch that will be wired in series with the heater (and installed into the slow cooker) so it will interrupt the power if the temperature rises too much. This kind of secondary fault protection based on a mechanical thermostat (instead of electronic) is commonly found in laboratory ovens, and I thoroughly approve of this kind of protection.  Don't make or use one of these modified slow cookers unless you include a thermal cutout switch!!!

Thursday, July 11, 2019

Troubleshooting wireless sensors

Over the years we have acquired a number of wireless sensors -- remote temperature sensors and motion detectors.  All of the ones that have failed spent time outside, something they (according to the manufacturers) should be able to handle.  While most seem to have failed due to moisture related problems, one of the motion sensors was colonized by ants.  It started sending out signals almost continuously because the ants were crawling across the surface of the sensor.  After cleaning out the ants and their nesting crud, the sensor stopped working -- sort of.

All these sensors SHOULD have been working, because the red or blue LED "transmit" lights would flash -- but their receivers weren't picking anything up.  One of the sensors appeared to have a greatly-reduced transmit range.  So what was going on?

Awhile back I bought a cheap SDR -- a software defined radio -- to play with.  It is an RTL-SDR, basically a USB dongle with an antenna and can receive RF from 500KHz to 1.7GHz.  I got it to use as an ultra-cheap spectrum analyzer, but it's very slow when used for that purpose.  This is mainly due to the design's relatively narrow RX bandwith (about 1MHz).  However, there's a simple application for it that can be used to troubleshoot wireless sensors.  It's called "rtl_433", and was written to listen to and decode wireless sensors.   Another handy utility is "gqrx", which has a RF spectrum display and a waterfall display.  A waterfall display shows the intensity of received signals over time -- the horizontal axis is frequency, and the vertical axis is the intensity over time (about 30 seconds are shown).  This is handy for pinpointing periodically-sent signals, like the type generated by wireless sensors.


The above shows the output of gqrx.  The small vertical red stripe in the waterfall portion is a burst of RF data sent by a wireless sensor.  In this case it's an Acurite temperature sensor.

The waterfall display shows this wireless sensor is transmitting close to the specification, which is 433.920MHz.  But the bad wireless sensors were all transmitting at significantly different frequencies:


-In this case, about 432.58MHz.

This is where the other utility, "rtl_433" comes in handy.  You can specify the frequency it listens to by calling it this way:  "rtl_433 -f 432580000" (the frequency parameter is passed in Hz).  I was able to get data from some sensors, but not all of them, by doing this.  BTW, rtl_433 should be called from the command line so it is NOT a graphically-oriented application.  I'm using Linux at home so I'm accustomed to using command line programs in a terminal window.

The sensors that were sending data (just at the wrong frequency) mostly likely had a frequency shift due to "crud" buildup under or around the transmitter components.  To test this, I soaked one in very hot water after opening the case up (and removing the batteries).  To help the circuit board dry faster I rinsed the board with isopropyl alcohol, then left the board to dry in the sun for a few hours.  I reassembled everything and checked the transmit frequency -- right back to where it should be.  After resetting the receiver unit, it started picking up the sensor.  Success!

Now I need to figure out why the other units aren't sending data, despite having a functioning transmitter.  That may be a more serious problem, but one clue is that the amplitude of the transmitted signal is quite a bit lower compared to a good unit.  I suspect the RF is not being modulated, perhaps due to more-robust "crud" on the circuit board.  Time to look at the board more carefully.....






Wednesday, June 12, 2019

Detecting deepfake videos: Saving our structures of trust

Digital watermarks.  Currently used for purposes of detecting violations of media copyright laws. 

OK, it's more complicated in the context of political personages:  but elected people capable of initiating horrendous acts like initiating nuclear war MUST insist on all media with them in has to contain a secure watermark, similar to a public key, that says the media was approved by them.  If it doesn't, or if it doesn't meet the watermark tests, they didn't say it, weren't there, or didn't do it.

News organizations will have a time with this approach, since they want to broadcast videos they generated of public figures -- but a similar method of including watermarks to identify the source could help inform consumers about the veracity of the information.  Maybe this could act as a way to counter the current mantra of "fake news" that is so present now.  An issue here is the possibility of some political figure saying something really stupid that (1) they don't personally watermark and (2) is extremely inflammatory in a military sense.  How to deal with this?  The news org adds its own watermark so others can determine it's news from a legit source but not necessarily policy from the people in the video.

Social media companies like F***book, G*ogle and the like will be required to use S/W to verify the veracity of videos, if they don't they get hit hard.  They ARE interested in the truth, right??? (not)

Other public figures will likely want to come on board so they can't be subject to specious media -- videos, audio, photos -- and that increases the chances that fakes will be quickly identified.  In an ideal world deep fakes will be confined to an advertisement tool that will quickly become passe'.

A recent PBS news broadcast mentioned various types of video-analysis approaches that can, at present, detect fakes.  But that approach will eventually prove to be useless -- the bad guys will figure out what the good guys are doing, and will improve their software to counter.  So there will be the equivalent of an arms race, and continuing controversy on what is real and what is not.

As technology continues to create problems, it is necessary to adapt while maintaining the precepts outlined in our constitution and amendments.  It's nuts to insist on a "pure" interpretation of those documents, given how technology has (and will) continue to change.  I could go into many other aspects of change that those old white guys (some slave owners among them) could not have dreamed of:  so we need to get over a purist approach of "if they didn't talk about it, we don't, either".  The basic concepts laid out are good, but in today's environment they need to expanded to cover current issues.  And that must be continued as humankind continues to evolve in a technological, social and genetic frame.

Now that the genie is out of the bottle, it is necessary to tattoo the genie so he/she/it can't get away with deceiving the more intelligent among us.

Unfortunately that seems to be the minority.

I currently have no digital watermark.  But in this age, maybe everyone will need one, like a digital fingerprint that no one other than myself can place in a document.  That's an interesting subject in itself, spanning personal freedom issues and ID theft problems. ...

Sunday, May 26, 2019

Solvency

OK, nothing to do with insufficient funds.  I've been experimenting with different solvents and decarbed MJ to see how the fluorescence depends on the solvent.  I don't have any photos (yet).  The table below summarizes my results to date.

Solvent                   Fluorescence color
Hexane                      Red
NMP                         Orange (has a yellow component)
N-Butanol                 Yellow-orange
DMF                          Red (not quite the same tint as hexane)
Propylene carbonate  Yellow-orange

NMP:  n-methyl pyrrolidone
DMF:  dimethyl formamide

All the solvents except hexane are polar, with a varying range of dielectric constants and dipole moments (most on the high side).  Water falls into this category, but cannabinoids aren't very soluble in water.  Cannabinoids do appear to be fairly soluble in hexane, NMP, n-butanol, DMF and propylene carbonate.  I also checked an ethyl alcohol tincture I made some time back, and it doesn't appear to fluoresce at all (it WAS made with decarbed MJ).  Time to try acetone to see how it performs.

The plant material I'm using for this particular set of comparisons has low to zero CBD content (just to keep things simple at this point).  So I don't know if CBD behaves the same or not.  I also don't know the concentration of all the other cannabinoids  this particular clone can contain, so that could be a complicating factor.

Ideally, there's a solvent out there that would produce different-enough fluorescent colors for CBD and THC to be able to distinguish them.  Examination of the molecular structures shows their main differences are on different locations on their molecules, compared to where their carboxyl group WAS (prior to being decarbed) -- so I'm not hopeful this approach will work for determining the THC:CBD ratio for a particular clone.  But it's worth some additional investigation .  The solvents I'm using are relatively inexpensive and available through Ebay or Amazon, and they're not excessively toxic (even ethanol is toxic, if exposure is too high).  Of course, it's a good idea to keep your exposure to solvents to a minimum no matter how "safe" they are claimed to be.  I use chemical gloves and good ventilation to avoid exposure.             

Saturday, May 25, 2019

Home-brew Cannabis potency analysis

Last year, due to an issue with improperly-marked marijuana plants, we ended up with some plants that had zero CBD content.  We are interested in the pain management properties of CBD, not getting high, so last year was a waste of our gardening time, water and garden space.  It was when I started looking into ways of doing my own analysis.  Sending material to a lab is expensive, particularly if you want to test a number of times to optimize your THC/CBD ratio (which depends on the "ripeness" of the buds).  My results, if successful, also could be helpful to others who are depending on getting the right "stuff" for their needs.

I started by looking at current mainstream methods.  Mainstream analysis techniques fall into several categories:  Gas chromatography, liquid chromatography, mass spectroscopy, and IR spectroscopy.  Thin Layer Chromatography kits can be purchased for home use, but they're not very good for quantitative work -- the size of a particular colored blob on the TLC plate is roughly proportional to the amount of chemical (THC, CBD etc.), but in my experience it was difficult to interpret the streaks on the plate.

While mulling over all these approaches, I did find a purely chemical way to at least tell you if your marijuana has some CBD in it.  It's pretty simple, too:  make up a 5% (by weight) solution of sodium hydroxide (A.K.A. lye) in ethanol or rubbing alcohol.    Put 100-200 milligrams of your decarbed bud in a glass vial and add the solution  at least halfway up the vial.  Screw on the cap and shake vigorously.  If the solution turns blue, your marijuana contains CBD.  The darker the color, the more CBD you've got.  THC doesn't turn blue.  With careful solution preparation and careful weighing it might be possible to get a quantitative measure of the CBD, but you'd need a spectrometer to tell you what the absorptivity of the solution is.  You can make a spectrometer using a web cam and DVD (for the diffraction grating).

I also discovered a paper that has a lot of information on cannabinoid analysis.  Its title:  "Chromatographic and Spectroscopic Data of Cannabinoids from Cannabis sativa L.", by Arno Hazekamp, Anja Peltenburg and Rob Verpoorte.  It turns out decarbed cannabinoids have a distinctive red fluorescence when illuminated by UV.  This may be the basis of a commercial THC analysis gadget that is currently selling for around $300 (pure speculation on my part).  The photo below shows three different samples I examined.  Two are decarbed bud and one is UN-decarbed.  Hexane is used as the solvent.


Pretty interesting.  While not shown, I also observed the same fluorescence in cannaoil made with coconut oil.  It glows a very pretty orange color, while pure coconut oil just reflects the purple color of the UV flashlight.  Cannaoil made with un-decarbed cannabis also doesn't glow orange.  The flashlight's peak output is specified to be at 390 nm.

The fact that the decarbed cannabinoids fluoresce suggests the mechanism is related to the site where the carboxyl group was (formerly) attached.  It's a benzene ring structure with an OH attached so technically speaking it's a phenol.  It would be nice if CBD fluoresced with a different color but at least the effect can be useful for a total cannabinoid test.

Searching the web, I found a thread on a MJ forum where the poster had noted the same thing.  The post mentioned some variability in the effect, comparing a commercial extract to a home-brew version.  I suspect the starting materials were different -- one was decarbed, the other, not.  There was speculation that the fluorescence was from chlorophyll, but as can be seen in my photo above, a chlorophyll-loaded UNdecarbed sample doesn't glow orange.  It's the vial on the right.


Monday, May 13, 2019

Spectrometer -- Useful for CBD/THC analysis?


The top spectrum shows the result for a high THC strain and the bottom shows the result for a high CBD strain.  A calibration procedure was used to compensate for variations in the illumination source (a 100 watt quartz-halogen lamp).  The color differences (as seen by eye) are mostly explained by the slight shift in the peaks centered around 625 nanometers -- the CBD color peak is slightly redder.

Conclusion:  I got a nice spectrometer to play with, but the idea of using Fast Blue B dye as a way to distinguish THC from CBD didn't work out.

Sunday, December 23, 2018

Home-brew Spectrometer

Due to a quality control problem at a local marijuana dispensary, we found the high-CBD plants we thought we had actually were unknowns.  This became apparent when the plants got big enough to exhibit their typical growth habit and odor (smell can vary widely among different clone types).  To make it clear:  we want high CBD for pain management.  Not interested in getting high.

Via online searching I found a chemical test for CBD and it showed that just one of the 3 clones contained much CBD -- but, unfortunately, the test is not very quantitative.  It relies on the development of a purple color when the plant material is added to a 5% solution of sodium hydroxide dissolved in alcohol.   The darker the color, the more CBD is present.  But eyeballing is not very accurate.  I started thinking that a spectrometer might improve the accuracy of the test.  In addition to the alcohol-hydroxide test, there is a very sensitive test that will stain THC and CBD slightly different colors.  It is a dye called Fast Blue B, dissolved in water, and is used to develop thin layer chromatography (TLC) plates.  So it MIGHT be possible to determine the ratio of THC and CBD by using Fast Blue B and a spectrometer to resolve the different colors.

But commercial spectrometers are expensive.  Sure, it is possible to find them for less money on Ebay:  but often they need software and a computer, and if the package is complete the price goes up.  The other aspect of this work is to hopefully make it possible for others to do the same measurements on their own material, so a one-off purchase from ebay won't cut it.   As an alternative I found an open-source spectrometer here.  Cost is around $50.  For that you get a web cam, an optical slit, a CD-R disk (to turn into a diffraction grating), a black cardboard box and materials to assemble it all.  I put the thing together and found it wasn't mechanically stable enough to generate repeatable absorption spectrograms.  So I used the essential parts -- the camera and slit -- and built my own spectrometer.  The photos below show the spectrometer I put together.

Exterior showing the slit and lid.  The "hinge" is a length of adhesive-backed aluminum (which is opaque to light).


This is a photo showing the "optical holder" design.  It is a block of oak with a flat-bottomed hole just large and deep enough to glue in a super magnet.  The bottom of the spectrometer is a steel plate, so the blocks stay put -- but are easy to move around to optimize the optical path.

And here is a photo of the interior.  The diffraction grating is glued to one of the optical blocks.  I sawed a slit in the block to provide a robust mounting point for the grating.  The web cam is attached to an optical block using heavy-duty double-sticky tape.  The corners of the enclosure are reinforced with wood blocks that were glued in place.  The top, sides, and ends of the box are made using foam-core poster board.  Black, of course.  I also put a length of the poster board on the bottom, to reduce reflections that would degrade contrast of the spectrum.  I had some black silicone caulk so I ran a bead along the front corners and along the bottom edges as well, to reduce light leaks.

And here is the spectrum of a CFL lamp, obtained using my spectrometer:

Unfortunately, I found the web camera is not compatible with the Public Labs spectrometer software.  At least, not on my linux laptop.  So I found it necessary to write my own program(s) to do the job.  I found a starting point here but it has a fairly serious memory management problem -- it acquires a bunch of frames, and only then performes averaging.  I modified the code to acquire one video frame, then extract ONE line of interest for processing.  This way I can average over any number of frames without running out of memory.  I also wrote a version to get the calibration factors needed to convert pixel positions to wavelengths.  The end result is a system that easily resolves the two green emission lines around 540 nanometers, and has a low noise level in the data.

Now I can move on to testing my THC/CBD measurement idea....