0

~2.5Hz oscillation on CPX capacitance readout?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

~2.5Hz oscillation on CPX capacitance readout?

by flyingcheesehead on Mon Feb 22, 2021 7:20 pm

Hi all,

This was buried in a previous thread and I'd like to get an answer.

I'm doing the 4H Clover Soil Sensor Mini Kit and trying to calibrate things, but I'm getting readouts on pin A1 that don't make sense to me. Expected values from this page are 890 for nothing connected, 2160 when the lead and nail are connected, and 2600 when inserted into a pot of relatively dry soil.

The values I see in the console are in the low 220s range when nothing is connected, and seem to be fairly solid. When I connect the lead and nail and put them in the dirt, in the console it kinda goes nuts but looking back through the data, it's oscillating from a value of 1016 or 1017, down to values from anywhere between about 0 and 280, and back up to 1016/1017 with a peak-to-peak period of about 0.4 seconds.

Why am I seeing this ~2.5Hz oscillation? And why are my values so far off from the expected ones?

Thanks!

flyingcheesehead
 
Posts: 13
Joined: Wed Jan 13, 2021 5:39 pm

Re: ~2.5Hz oscillation on CPX capacitance readout?

by flyingcheesehead on Fri Feb 26, 2021 11:01 pm

Anyone?

I had really high hopes for the Circuit Playground and was planning on ordering more of them, but if I can't get the first project to work and there is no support, maybe I'll have to look elsewhere. :(

flyingcheesehead
 
Posts: 13
Joined: Wed Jan 13, 2021 5:39 pm

Re: ~2.5Hz oscillation on CPX capacitance readout?

by flyingcheesehead on Sun Mar 07, 2021 12:37 pm

Does anyone from Adafruit actually monitor these "support" forums and follow up, or are they just taking advantage of the community for support? I'm really disappointed that I haven't gotten a single answer to my question, not even a suggestion or a question. :(

flyingcheesehead
 
Posts: 13
Joined: Wed Jan 13, 2021 5:39 pm

Re: ~2.5Hz oscillation on CPX capacitance readout?

by flyingcheesehead on Mon Mar 08, 2021 3:33 am

Well, in an attempt to address this myself and get more familiar with MakeCode, I've created a program that will help measure the base values necessary to set thresholds in other programs.

First point to note: There is a "Calibrate" command. I'm guessing that needs to be used in the On Start section to avoid some of the issues I was seeing before with the numbers in the console oscillating. So, rather than leave the A1 pad wide open and then add the clip and such as before, I'm attaching everything before I boot the CPX.

Here's the measurement program:

https://makecode.com/_Kd5ihJdb4bk8

You'll need to set a Hi_Value and Lo_Value in the startup section that are way outside your expected range. I chose 0 and 5000 since I hadn't seen anything nearly as high as 5000 even mentioned, and I'm not sure what the theoretical maximum value is, as it doesn't appear to be in the docs. I did see 0, but nothing less than 0 while looking at the console readouts before.

The program works by using the built in LEDs to give you a readout. I have it set with 10 colors (essentially the resistor color code, though I had to take some liberties with black, brown, and gray) and of course the CPX has 10 Neopixel LEDs so I can measure 100 steps. Since my Lo_Value is 0 and Hi_Value is 5000, that means I can measure with a resolution of 5000/100=50.

On boot, it will start with all green pixels, with an animation going to blue during the initialization. At the end of the initialization, it will show the colors, in order, for three seconds so that you have a basis for comparison once the measurement starts. Note that I have not tested nor addressed the case of having more than 10 colors in the array.

After the boot, it will continuously measure pin A1. All of the pixels will be lit, in one of two colors. The color is your "tens digit" (or whatever your number of colors is as the base, ^1 digit). The number of pixels colored in the next color up is your "ones digit" (base^0).

You can use this to figure out what "step" your value is on. Mine is showing two "black" pixels (color 0) and 8 "brown" pixels (color 1), indicating that it's on step 8 of 100. (Note: There's a bit of a bug in my logic that is not representing things how I intend to but the fix will have to wait for another day.) Since my steps are 50 as shown above, that means my value is in the 400-450 range.

To narrow it down, I changed my Lo_Value to 300 and my Hi_Value to 1500. Total range 1200, step 12. This time I had all 10 pixels "brown" indicating a value around 420 (Lo_Value + Step_Value*Step_Size, or 300 + 10*12). Finally, I changed the Lo_Value to 360 and Hi_Value to 460, range 100, step 1. The display is a lot more finicky with these settings, but that's to be expected as we've really narrowed the resolution down. This time, I had 5-8 blue pixels and 2-5 purple pixels, indicating a value between 422-425 (360 + 72*1 for example).

The bug I mentioned earlier: The lowest possible value of 0 will have all the pixels lit in "black" (which is, in reality, the dimmest I could light the LEDs) and the steps above 90 will have an indeterminate result because there is no "next" color after white. My intention was to start with "off" pixels and light up "black" pixels for steps 1-10. I don't want to add another color to the array, though, since that will mess up the math in a few other places. I'll work on a fix for that later, but for now I hope this helps anyone who has the same issue as I did... Please post here if this was helpful to you!

flyingcheesehead
 
Posts: 13
Joined: Wed Jan 13, 2021 5:39 pm

Re: ~2.5Hz oscillation on CPX capacitance readout?

by flyingcheesehead on Thu Mar 11, 2021 1:00 am

The aforementioned bug in the capacitance value finder has been squashed: https://makecode.com/_XvtJ6Rh3VXFh

I've gotta say, though I'm pretty disappointed with Adafruit overall. Never got a single answer to any of my questions, and the overall experience wasn't what I hoped for. It appears that Adafruit's mission is educational, and that's what I was going for, but my son was thoroughly unimpressed and, if anything, seems LESS interested in coding and engineering than when we started instead of more.

The products are great, but the support makes the difference between "awesome experience that encourages the next generation of engineers" (what I was hoping for) and a complete failure at that mission. I hope Adafruit gives more support to their customers in the future. I was originally planning on buying a bunch more stuff, but I'll be casting a wider net next time I'm in the market for electronics.

flyingcheesehead
 
Posts: 13
Joined: Wed Jan 13, 2021 5:39 pm

Please be positive and constructive with your questions and comments.