• Trill
  • Increasing Sensitivity in Trill Flex

How do I increase the touch sensitivity in Trill Flex.

I found instructions on how to do it but I dont see it in my example code.

/*
 ____  _____ _        _
| __ )| ____| |      / \
|  _ \|  _| | |     / _ \
| |_) | |___| |___ / ___ \
|____/|_____|_____/_/   \_\
http://bela.io

\example flex-print-slider

Trill Flex Print Slider
=======================

This is an example of how to communicate with the Trill Flex
sensor using the Trill Arduino library.

The Trill Flex sensor is read in Differential mode by default. This is
good for when you are working with custom designed Flex PCBs.
See the `flex-print-raw` example to read each sensor channel independently.

In this example we will use the sensor in Centroid mode to see
touch location and size of touches on the default Flexible Bar sensor.
Touchese will be printed to the serial port for each of the 5 different
simultaneous touches.

You can find our Processing library for visualising here:
https://github.com/BelaPlatform/trill-processing-library/
The accompanying Processing sketch, `TrillFlexSlider.pde`, listens for
touch information on the Arduino serial port* and displays it in a
render of a Trill Flex.

*NOTE: you may need to update the Processing port number (gPortNumber)
to match that of your Arduino.
*/

#include <Trill.h>

Trill trillSensor;
boolean touchActive = false;

void setup() {
  // Initialise serial and touch sensor
  Serial.begin(115200);
  int ret = trillSensor.setup(Trill::TRILL_FLEX);
  if(ret != 0) {
    Serial.println("failed to initialise trillSensor");
    Serial.print("Error code: ");
    Serial.println(ret);
  }
  // Set the sensor into Centroid mode
  // The default for Trill Flex is Differential mode
  trillSensor.setMode(Trill::CENTROID);
  delay(10);
  // when the slider is connected we increase the
  // prescaler to deal with the increased baseline
  // capacitance it brings
  trillSensor.setPrescaler(3);
  delay(10);
  trillSensor.setNoiseThreshold(200);
  delay(10);
  // after any prescaler change, it's always good to update
  // the baseline, too.
  trillSensor.updateBaseline();
}

void loop() {
  // Read 20 times per second
  delay(50);
  trillSensor.read();

  if(trillSensor.getNumTouches() > 0) {
    for(int i = 0; i < trillSensor.getNumTouches(); i++) {
        Serial.print(trillSensor.touchLocation(i));
        Serial.print(" ");
        Serial.print(trillSensor.touchSize(i));
        Serial.print(" ");
    }
    Serial.println("");
    touchActive = true;
  }
  else if(touchActive) {
    // Print a single line when touch goes off
    Serial.println("0 0");
    touchActive = false;
  }
}

In the example setScanSettings() is not used because it uses the default values.

Just add

EDIT: touchSensor.setScanSettings(0, 16);

trillSensor.setScanSettings(0, 16);
delay(10);

before trillSensor.updateBaseline().

    12 days later

    giuliomoro

    I tried inputting it and it says:

    Compilation error: 'touchSensor' was not declared in this scope

    Thanks for the help!

    giuliomoro
    Hey sorry to bother you again, but adding the code seems to have made the sensitivity lower or unresponsive. It doesn't read when my hand swipes across the sensor. How do I increase the sensitivity?

    Thank you so much for the help again!

    ry this:

    
    #include <Trill.h>
    
    Trill trillSensor;
    
    void setup() {
    	// put your setup code here, to run once:
    	Serial.begin(115200);
    	int ret = trillSensor.setup(Trill::TRILL_FLEX);
    	if(ret != 0) {
    		Serial.println("failed to initialise trillSensor");
    		Serial.print("Error code: ");
    		Serial.println(ret);
    	}
      Serial.println("Inited");
      delay(100);
      trillSensor.setMode(Trill::RAW);
      delay(100);
    
      // when the slider is connected we increase the
      // prescaler to deal with the increased baseline
      // capacitance it brings
      trillSensor.setPrescaler(3);
      delay(100);
      trillSensor.setNoiseThreshold(200);
      delay(100);
      trillSensor.setScanSettings(0, 16);
      delay(100);
      // after any prescaler change, it's always good to update
      // the baseline, too.
      trillSensor.updateBaseline();
    }
    
    void loop() {
    	// put your main code here, to run repeatedly:
    	delay(100);
    	trillSensor.requestRawData();
    
    	while(trillSensor.rawDataAvailable() > 0) {
    		unsigned int data = trillSensor.rawDataRead();
        if(data < 10000)
    			Serial.print(0);
    		if(data < 1000)
    			Serial.print(0);
    		if(data < 100)
    			Serial.print(0);
    		if(data < 10)
    			Serial.print(0);
    		Serial.print(data);
    		Serial.print(" ");
    	}
    	Serial.println("");
    }

    Note the increased delay() times with respect to the usual 10ms: when increasing the bit depth the scan times also become longer ( see the table here https://learn.bela.io/using-trill/settings-and-sensitivity/#scan-settings ) and the delay interval between commands must allow for at least one scan to happen between successive commands. setScanSettings sets scan speed and bit depth. At 16 bits, Ultra fast (= 0) speed, that's 2800 µs (2.8 ms) per pad, or 30 * 2.8ms = 84 ms in total, so a sleep time of 100ms should be safe. If moving to "slow" (= 3) speed, that's 22000us (22ms) per pad, or 30 * 22 ms = 660ms int total, so the sleep time should go to about 700 ms.

    When you see everything working as it should , you can switch to Trill::DIFF in setMode() to get differential readings.

    • max likes this.