Snowboard‎ > ‎2. Examples‎ > ‎

Snowforce: code to read force matrix sensor

This examples shows you how to read and visualize force map data from the attached matrix sensor.

Required Hardware and Software

  • Snowboard
  • Matrix Sensor 1610 or 1007
You can find two connectors on Snowboard. One is for the Matrix Sensor 1610 and the other is for Matrix Sensor 1007. In this tutorial, we assume to use Matrix Sensor 1610.
 

Connection

Connect the Matrix Sensor 1610 or 1007 to Snowboard. 
 
Snowboard is then connected to a PC.

Upload Firmware

1. Run Arduino IDE.
 
2. In Tools-Board, choose Arduino Leonardo.
Snowboard 2 users need to choose their own Arduino in this step.
 
3. In Tools-Port, choose an appropriate port which your Snowboard is attached.
 
4. Go to File-Examples-Snowboard and choose snowforce to open the example.
 
5. Switch to the example and click the upload button.
 

Visualization

1. Go to the unzipped folder you create during the installation, find and double click snowforce.exe.
 
The application will run, automatically find Snowboard, and visualize force map from the matrix sensor.
  • If you are using the Matrix Sensor 1007, you need to replace the whole contents of surf.ini with those ini surf_10x7.ini. These ini files can be found in <extracted folder>/processing/snowforce/data.
  • By default, the application assumes that the Snowboard is connected to the first COM port. If there are several COM ports in your PC, the this application will not run correctly. In this case, open surf.ini and find the following line and change its value to an appropriate port number.
port=auto
For example, if Snowboard is attached to port 5, the line will be
port=COM5
  • For more detailed information about the visualization application, see Snowforce page.
 

Arduino Code

In the program below, the first thing you do is to declare Snowforce class instance with the line
Snowforce snowforce;

In the setup, you will tell Snowboard to start I2C and serial communication. I2C is for internal communication between Arduino component and force touch controller in Snowboard. By starting serial, your Snowboard is ready to send data from the touch controller to a PC.
Wire.begin();   // start i2c communication
Serial.begin(115200);  // start serial for output

After that Snowboard will tell the controller to initialize itself.
snowforce.begin(); // start tactile sensing part of snowboard

In the main loop, when Snowboard gets an arbitrary data from PC via serial it will read force data and send it to PC. Actually, only following two lines are required to get data from a matrix sensor.
byte data[160] = {0, };
snowforce.read(data);

data[] represents 2D force map obtained from a matrix sensor and has the following strucure:
data[0]: Force signal of (D0, A0)
data[1]: Force signal of (D0, A1)
...
data[9]: Force signal of (D0, A9)
...
data[150]: Force signal of (D15, A0)
data[151]: Force signal of (D15, A1)
...
data[159]: Force signal of (D15, A9)
where (Di, Aj) indicates the crossing point of ith drive line and jth sense line on the matrix sensor. See Snowboard product page to know pin map.

/*
 Snowforce.ino
 Copyright (c) 2014 Kitronyx http://www.kitronyx.com
 GPL V3.0
*/
#include <Wire.h>
#include <Snowforce.h>
Snowforce snowforce;
void setup()
{
    Wire.begin();   // start i2c communication
    Serial.begin(115200);  // start serial for output
    snowforce.begin(); // start tactile sensing part of snowboard
}
void loop()
{
    // pressure mapping data
    // tactile sensing part always give maximum
    // number of data (10x16 = 160)
    byte data[160] = {0, };
    // send data only pc wants it
    if (Serial.available() > 0)
    {
        int inByte = Serial.read();
       
        snowforce.read(data);
        for (int i = 0; i < 159; i++)
        {
            Serial.print(data[i]);
            Serial.print(",");
        }
        Serial.println(data[159]);
    }
}







Comments