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.
This discussion has been closed.
Comments
DownloadAsync
functions call the same underlying function but with different default parameters.