TI Sensor Tag - Gyroscope

Discuss mobile apps for Texas Instruments products.
klemens2014
Posts: 12
Joined: 16:22, 17 Sep 2014

TI Sensor Tag - Gyroscope

Postby klemens2014 » 16:31, 17 Sep 2014

I tried this excelent example TISensorTag and it works fine once I created signed android app from it. I added some code like computing temperature in C etc. One problem I have now is with the gyroscope data. It returns only the x value, the other values are alwyas zero (like in the image too). I assume this due to the fact that one needs to specify which axis one wants to read. TI states:
"NB: Gyroscope is special as it has a different "enable-code" from the other sensors. Gyroscope is unique in that you can enable any combination of the the 3 axes when you write to the configuration characteristic. Write 0 to turn off gyroscope, 1 to enable X axis only, 2 to enable Y axis only, 3 = X and Y, 4 = Z only, 5 = X and Z, 6 = Y and Z, 7 = X, Y and Z."
I found no way to set the configuration characteristic in the JS code. The senor is initialised in the example as:
function initialiseSensortag()
{
sensorTag
.statusCallback(statusHandler)
.errorCallback(errorHandler)
.keypressCallback(keypressHandler)
.irTemperatureCallback(irTemperatureHandler)
.humidityCallback(humidityHandler)
.barometerCallback(barometerHandler)
.accelerometerCallback(accelerometerHandler, 100)
.magnetometerCallback(magnetometerHandler, 100)
.gyroscopeCallback(gyroscopeHandler, 100)
.connectToClosestDevice();
}

Is there a wa to set the Gyroscope config characteristics? Or more general to set any of these: <Data> , <Data Notification> , <Configuration> , <Period> for a gicen sensor instance?
Thanks!
Klemens

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: TI Sensor Tag - Gyroscope

Postby micke » 09:13, 18 Sep 2014

Hi Klemens,

Of course you are right that the the gyroscope config is incomplete, I missed that when writing the library. Will add this so that you can supply a parameter with the axes to enable.

I found a problem which is that the characteristic for the period for the gyroscope notification is not present. This means you cannot set the update rate of the gyroscope. Need to investigate this further.

To get more fine control over the sensor settings, it would be possible to add a function in ti-sensortag.js that allows that.

Thanks for great input, let's stay in touch!

Best regards, Mikael

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: TI Sensor Tag - Gyroscope

Postby micke » 09:20, 18 Sep 2014

Hi again, just a quick question, you mentioned you created a signed Android app to make the app working. Did it not work with Evothings Client?
Best, Mikael

klemens2014
Posts: 12
Joined: 16:22, 17 Sep 2014

Re: TI Sensor Tag - Gyroscope

Postby klemens2014 » 09:26, 18 Sep 2014

Thanks!

I am currently trying to write some code which converts the received data to physical values. This turns out to be a little bit weird in JS as the C/Java examples of TI sometimes require getting some parameters from the sensors, e.g. baromenter callibration values. And also at least some bit manipulations to get the final values when reading the examples of TI.

Klemens

klemens2014
Posts: 12
Joined: 16:22, 17 Sep 2014

Re: TI Sensor Tag - Gyroscope

Postby klemens2014 » 09:42, 18 Sep 2014

I think it would work with EvoStudio too. I tried your version with EvoStudio and this worked perfectly. The reason why I created a signed app was that I wanted to test it easily on different Android mobiles or send it to friends for testing. And when I produced an unsigned version with Cordova, Android prevented the installation for whatever reason.

I am also trying to get this app together with a Samsung Gear Live watch connected to compare measures produced there with the TI sensor, send notifications there and this requires some manipulations in the apk file so that the wear part is loaded towards the watch using Android wear (also Android describes this as "very easy", in reality a feature which makes some head aches and requires resyncing the apps, no debugging then ...). Something at least for the moment cordova does not support.

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: TI Sensor Tag - Gyroscope

Postby micke » 10:20, 18 Sep 2014

Hi Klemens,

Thanks a lot for the update! Sounds like a very cool application you are developing!

Regarding calibration of the barometer, that is another thing that needs to be added to the SensorTag library. Think it would be a good idea to expose a function that lets you do general BLE requests (as you suggested), or at least document how to do this, so that it is possible to do things not available in the library(would also be good for future needs).

Will continue looking into this.

Best, Mikael

klemens2014
Posts: 12
Joined: 16:22, 17 Sep 2014

Re: TI Sensor Tag - Gyroscope

Postby klemens2014 » 12:23, 19 Sep 2014

After applying the following change in ti-sensortag.js all gyroscope values are read:

Code: Select all

      /**
       * Private. Helper function for turning on sensor notification.
       */
      instance.sensorOn = function(
         configUUID,
         periodUUID,
         periodValue,
         dataUUID,
         notificationUUID,
         notificationFunction)
      {
         // Only start sensor if a notification function has been set.
         if (!notificationFunction) { return }

         // Set sensor configuration to ON.
         if (sensortag.GYROSCOPE_CONFIG == configUUID) // wk: enabale all axis for Gyroscope
         {
            configUUID && instance.device.writeCharacteristic(
               configUUID,
               new Uint8Array([7]),
               function() {},
               instance.errorFun)

         }
         else
         {
            configUUID && instance.device.writeCharacteristic(
               configUUID,
               new Uint8Array([1]),
               function() {},
               instance.errorFun)
            }

         // Set sensor update period.
         periodUUID && periodValue && instance.device.writeCharacteristic(
            periodUUID,
            new Uint8Array([periodValue / 10]),
            function() {},
            instance.errorFun)

         // Set sensor notification to ON.
         dataUUID && notificationUUID && instance.device.writeDescriptor(
            dataUUID, // Characteristic for data
            notificationUUID, // Configuration descriptor
            new Uint8Array([1,0]),
            function() {},
            instance.errorFun)

         // Start sensor notification.
         dataUUID && instance.device.enableNotification(
            dataUUID,
            function(data) { notificationFunction(new Int8Array(data)) },
            instance.errorFun)

         return instance
      }

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: TI Sensor Tag - Gyroscope

Postby micke » 13:48, 19 Sep 2014

Hi Klemens, thanks for the fix!

I have now updated the ti-sensortag.js library and the example code in index.html with a parameter to configure the axes of the gyroscope. Updated code is here:

https://github.com/divineprog/evo-demos ... ISensorTag

Also period is now working for gyroscope. Somehow it failed when I tested a while ago, perhaps I was using a SensorTag with old firmware. Tested successfully with firmware version 1.5.

Best, Mikael

klemens2014
Posts: 12
Joined: 16:22, 17 Sep 2014

Re: TI Sensor Tag - Gyroscope

Postby klemens2014 » 13:52, 19 Sep 2014

Cool! Thanks! I am currently also working on the problem getting the calibration values for the barometer. Once I have it I'll show the code. Should not be to complicated.

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: TI Sensor Tag - Gyroscope

Postby micke » 14:47, 19 Sep 2014

Great you are looking into barometer calibration, thanks!


Return to “Texas Instruments”

Who is online

Users browsing this forum: No registered users and 9 guests