• TrillAdd to wiki
  • How to interpret touchLocation() and touchSize() in CustomSlider?

Hi,

In my Arduino/C++ program, I've created a CustomSlider to generate the centroids from a TRILL Flex strip.
It's based on the demo here (https://github.com/BelaPlatform/Trill-Arduino/blob/master/examples/custom-slider/custom-slider.ino), and right now I'm just testing it with the default TRILL Flex strip (i.e. my sliderPads array is just the default ordered array):

const uint8_t NUM_TOTAL_PADS = 30;
CustomSlider slider;
uint8_t sliderPads[NUM_TOTAL_PADS] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29};

void setup(){
	slider.setup(sliderPads, NUM_TOTAL_PADS);
	...
	...
}

I can use slider->touchSize() and slider->touchLocation() to grab the positions, which is working reliably and repeatably!
But I don't know how to interpret the numbers?

e.g. touchlocation seems to have a range of 0..3712, and touchSize is roughly 0..4000 but occasionally much larger.

I assume they are related to the prescaler, scan speed and resolution values but I can't find any documentation anywhere.
How should I interpret these numbers?

Thanks!

George

    gcsalzburg seems to have a range of 0..3712

    that will have a range of 0..(numPads - 1)*(2^SLIDER_BITS), where SLIDER_BITS is by default 7, so 27 = 128 and the range is 0..(numPads-1)*128. In your case with 30 pads that is 0..3712 (inclusive).

    The touch size is the sum of the activation across all pads that make up a touch. Each pad has a maximum activation value of (2numBits - 1), so 4095 at 12 bits (default), but you would only achieve this in DIFF (differential) mode only if the base capacitance was zero and the activation was saturating the sensor's reading, which is pretty much unlikely. The usable range of differential activation with 12 bit resolution is more likely to be around 1000 or 2000 and also depends on the prescaler settings. So, in theory if you had a huge finger that touches all the pads at once and is connected to a huge body which saturates all the pads which otherwise have 0 activation, then you would get a touch size value of ((2numBits - 1)* numPads), i.e.: 4095 * 30 = 122850 in your case. For regular sized fingers connected to regular size bodies you can expect that a touch would comprise 3 or 4 pads and an activation value around 1000 or 2000, so between 3000 and 8000 as a reasonable maximum touch size at 12 bit, depending on surface, geometry, wiring, prescaler settings and how you place your finger on the sensing surface. You can see here some size values I computed empirically by placing one finger on different Trill sensors and trying to "normalize" the reading I got.

    As a further note, the C++ API for Linux produces normalised floating point values based on the above, but on the Arduino side we did not implement that as most Arduino's don't have a floating point unit so such an approach would have a considerable performance hit.

    Perfect, that's exactly the information I needed! Thank you

    3 years later

    Dear all, dear @giuliomoro,

    I just testet the custom-slider.ino example code on the Wemos S2 Mini together with the Trill Craft. I just adapted the I2C pins and the sensor type to TRILL_CRAFT.

    I works in principle, but I noticed, that it only prints results at a rate of only around 2Hz (two console outputs per second).

    When I use the board in CENTROID mode, I get touch location data at a rate of 60Hz and above.

    The pity is now that I would need both the centroids and the raw data for my application.

    Is computation on the esp32 so slow in comparison to the onboard centroid computation of the trill? Are there ways to improve the computation time on the esp32?

    Thanks in advance and kind regards,
    Andreas

    I doubt CPU performance is the issue. The PSoC1 that's on Trill is a 24MHz 8-bit processor and manages to do that just fine over 100 times per second. If there's something wrong with your code, I don't know. Your best bet is to toggle a GPIO across the code block you want to benchmark and look at it on a scope. If it's indeed the data processing that takes 500 ms or so, then move into the code as needed and see if you can find where the bottleneck is.

    Thanks for the answer! It is the original code from the trill repo, except the pin config. I will have a look on the timing, but I assume it is happening in the process method of the custom sensor in the trill lib. Keeping you updated!

    giuliomoro changed the title to How to interpret touchLocation() and touchSize() in CustomSlider? .

    It was my bad, I had to fix a bad solder joint and now it is definitely running at normal speed. Thanks again!