Flexsensors- and Logarithms. Scary!

This entry is about trying to fit math to data- without the benefit of knowing how already Though my dad- and actually, I, were both math teachers. Neither of us scientists. 

I just wasn't very good, at math,  having been crippled by an alternative junior high math education (consisting of playing cards and handball), and probably not any natural aptitude. I have the same natural lack of aptitude at sports- my dad being a coach to like ten different sports. I hesitate to make a connection. 

Though oddly, lacking ability, or much insight, I REALLY like math. Unlike sports- which remain a mystery to me. I have a math library. A shelf of books. I look at it. Hoping by some secret and cosmic osmosis it will all transfer over- because I sure as hell don't understand them when I read them. But I like it.

And apply it when I can, like here, with bees.

This  problem began with the conviction that I needed to weigh my hives. So I could see change. So I tried putting bathroom scales under them, and weighing them when I inspected them, and making machines, a lever with a big chain, then, more of a technical one with wires and pulleys.

But I was aware that the rest of the world was way smarter than that- and because the Arduiono microcontroller seemed to be the front runner- I thought I'd try to learn it, and then add force sensors. All the while totally aware that this was probably pointless- I'd never know enough to know how really- and abandon it- like pretty much every little piece of technology around me.  Still :  the siren song of technology- and being a problem solver (as opposed to problem maker, my other job (and way better at it))- sucked me in. I can do this.

Data, of course, is the greatest siren of all. If we know enough facts, and can somehow understand them, then we of course, can become masters of the universe. By outwitting facts, before they can happen. Look for trends. Say: hah! hah! - I see a trend- and its not good- and clip it in the bud. This is true with bees- looking for trends- and acting on them.

(As an aside- our problems- all of them- our sins at least- began with Data. Its in the bible. Eve ate from the tree of knowledge (I'd say that's data! it wasn't "wisdom", obviously)- and it all went downhill. Oddly, 6500 years later Steve Jobs chose a bitten apple to represent his company- which is devoted, of course, to gathering, processing, and disseminating data. Does this mean we are about to be kicked out of one more garden of Eden? Lots of data, no wisdom? I need to do some tests!)

I bought 4 Flexsensors. They look like a long piece of clear tape with a round thing on one end and three wires on the other. Now that I know about them, it turns out, they are not that great for what I want to do with them- though they are 20 bucks a pop. Still- this is about the process. Here is one:FlexiForce A201 Force Sensor

Now it gets complicated. This sensor is a piezo resistor. When you push on it- like lots of things- it gets harder to run electricity through it. So if you put it under a weight- the resistance lessens, and you can measure the change, and equate it to a change in weight. Easy enough.

However- the way it reacts- to pressure- isn't necessarily linear. Super important. That means, if the resistance doubles, one would expect the weight to double.  Well- it turns out- this is not the case with this one. 

Which suddenly kicks in MATH. My readings were all over the place- I'd put on 2 pounds, and it would say I put on 20 - and nothing seemed to equate. So I graphed it. Set up my sensors, added weights (4 lbs packs of sugar, and 5 gallon buckets of water-3 of them...). 

How can I best explain this? The response wasn't  linear- it appeared to be exponential.  The manufactuter said it was the inverse of a linear equation (1/x) - which does graph a curve. But I did not find this to be true. If you inverse your data, and its response was initially 1/x, then you get this dead on straight line. Which I expected. But no- I got another curve. Which means- well- it could means all sorts of things, as there are all sorts of curves (starting with f(x) = x squared.) 

And so I started graphing the responses with Plot.ly. Its a graphing website. (When I signed up, I got an email from the guy who runs it.  He asked if I needed any help. A great site. ) And that's what the graphs are below. The basic thing was trying to get it all to work into a linear response.  It took awhile I had to look in some math books!

To make this long story short- I don't think I figured it out yet. Dammit. But what I did figure out- is that it involves taking logarithms. To get a linear response from the output, I need to take a reading, multiply it by 230, then subtract 71, then put it to the power of 10 (that what a logarithm is), and that's the weight. Sort of. I have to write it in Arduino code.

Oh god this is boring- I personally love it- but can't explain it enough- its like this combination of looking at real data- stuff one measures, writes down on graph paper, and then tries out on different equations til it makes sense- and then one goes backwards to figure out the math relationship.  Crazy. I have a smallish brain- and know it- and insight doesn't come quick, so if I can get all the way to making a curved line straight, I am pretty happy.

I guess i sort of made a personal breakthough here- sifted through data, and started (not finished) to understand how one thing responds to another thing and how that means something. Master of the Universe!

Next up- I actually apply this knowledge and write the program that allows me to stick these sensors under hives and watch the weight change as they gather nectar.

Here are a few graphs. Enjoy them if you can.




This graph- which is  linear- was the first one I saw where I realized that if I put the data on Log paper- it would go straightish. Not perfect.  Y xis is arduino non-scalable response- x axis is the log of the weight. If I taok the log of the weight- at any base- I got this straightish line!

 If one measures without Logs- its a curve. Though what sort of curve? The orange line is the line of the actual measured resistance- in ohms- as one increases the weight. I would have thought these would match each other. Not sure why they don't.

And this is the linear line (as it is on Log paper)- graphed as a straight line- and a "line of best fit" showing what the equation was for f(x). Then I had to turn that backwards- as I get a "y" value- and have to find "x". Which means anti-logs.


Comments