Missing Y Data from Logger

Hello all,

I've been going through the tutorial and have made a simple logging app based on the C# UWP FreeFall App. The app connects to my MetaWearC and MetaMotionR boards. I can start logging, download the data, and process it, but I am getting all zero data for my Y accelerometer axis. ex.   { X: -0.331g, Y: 0.000g, Z: 0.054g}  
In rare cases I do get Y data, which makes me think it could be a race condition? The MetaBase Android app works and I'm getting Y data from it, so I know the boards are OK. I've tried various data rates and ranges - no effect. I'm sorry the code isn't very readable below, but I've outlined a simplified example of my order of operators:

var accelerometer = metawear.GetModule<IAccelerometerBmi160>();  //Access the acceleration module
accelerometer.Configure(odr: sensorRate, range: sensorRange); //Configure the sensor using float variables (usually 200, 4)
metawear.GetModule<ILogging>().Stop(); //Stop logging in case it's running from a previous attempt that crashed
await metawear.GetModule<ILogging>().ClearEntries(); //Clear any entries. I added an await here since I figured this takes time.
await accelerometer.Acceleration.AddRouteAsync(source =>source.Log((raw_data) => DataHandler(raw_data)); //setup my logger
accelerometer.Acceleration.Start(); //start the sensors for logging
accelerometer.Start();
metawear.GetModule<ILogging>().Start(); //start logging
//Allow time to elapse here
 metawear.GetModule<ILogging>().Stop(); //stop logging and sensors
accelerometer.Stop();
accelerometer.Acceleration.Stop();
 await metawear.GetModule<ILogging>().DownloadAsync(...); //async download

//Here's my data handler, which stores incoming data to a list for future parsing
        private void DataHandler(IData RawData)
        {
            AccelData.Add(RawData);
        }

//The data is parsed:
foreach (IData pt in AccelData){
                span = pt.Timestamp.Subtract(AccelData[0].Timestamp);
                elapsedtime = (double)span.TotalMilliseconds / 1000.0;
                System.Diagnostics.Debug.Write(pt.Value<MbientLab.MetaWear.Data.Acceleration>().ToString()); //No Y data
                PlotSeries[0].Points.Add(new DataPoint(elapsedtime, (double)pt.Value<MbientLab.MetaWear.Data.Acceleration>().X));
                PlotSeries[1].Points.Add(new DataPoint(elapsedtime, (double)pt.Value<MbientLab.MetaWear.Data.Acceleration>().Y));
                PlotSeries[2].Points.Add(new DataPoint(elapsedtime, (double)pt.Value<MbientLab.MetaWear.Data.Acceleration>().Z));
}

As you can probably tell, I'm a novice in UWP so any help is appreciated.
Thanks in advance.

Comments

  • Try streaming the data on your UWP app first to see if everything is properly working.


  • The streaming works no problem. I will run through my code again. Any ideas? 
  • I 'fixed' the problem. I changed which DownloadAsync method I used and I'm getting all the data:

    I was used this:
    await metawear.GetModule<ILogging>().DownloadAsync(100, async (nEntries, totalEntries) => await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    System.Diagnostics.Debug.Write(String.Format("Progress Update= {0}/{1}\n", nEntries, totalEntries));
                    Sensor.DownLoadProgress = (100.0 - 100.0 * (double)nEntries / ((double)totalEntries));
                })
    The Dispatcher was there because 'Sensor' ViewModel was using INotifyPropertyChanged to update my view in real time to update the progress bar.

    Now I just use this:
    await metawear.GetModule<ILogging>().DownloadAsync();
    No more fancy progress bar, but at least I have data now. 
  • Hrm, that doesn't make sense as both DownloadAsync functions call the same underlying function but with different default parameters.

    This log and download code snippets are working fine with my board:

    private async Task Start(IMetaWearBoard metawear) {
    var accelerometer = metawear.GetModule();

    accelerometer.Configure(odr: 200f, range: 4f);
    await accelerometer.Acceleration.AddRouteAsync(source => source.Log(data =>
    System.Diagnostics.Debug.WriteLine(string.Format("time: {0}, data: {1}", data.FormattedTimestamp, data.Value()))
    ));

    metawear.GetModule().Start();
    accelerometer.Acceleration.Start();
    accelerometer.Start();
    }
    private async Task Stop(IMetaWearBoard metawear) {
    var accelerometer = metawear.GetModule();

    accelerometer.Stop();
    accelerometer.Acceleration.Stop();

    var logging = metawear.GetModule();
    logging.Stop();
    await logging.DownloadAsync(100, (nEntries, totalEntries) => System.Diagnostics.Debug.WriteLine(String.Format("Progress Update= {0}/{1}", nEntries, totalEntries)));
    }
This discussion has been closed.