Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Speed and distance received from ANT+ Simulator dont match up exactly

Rank

Total Posts: 1

Joined 2009-02-05

PM

Hi, I am testing code that receives data from the ANT+ simulator's SDM sensor. I have set the simulator to send a speed of 6 MPH on the parameters page. Stride length is set to the default 75cm.

What I am trying to do is to calculate an avg speed over time. My expectation would be in this test that my avg speed over any period of time during this simulator session would be 6 MPH. However it is not, and I don't know what I am doing wrong. I believe I am correctly interpreting distance (including fractional distance) as well as speed (including fractional speed). I accumulate the distance received over time and then take time / distance to compute the average. While it is very close to 6MPH, it is not exact, and in fact fluctuates over the course of the test. It might be 5.86, then 6.12, then 5.93, etc.

Looking closely at the data coming in, I am most suspicious of the distance I am receiving. It veries quite a bit, and it is always expressed rounded to 1/4 of a meter. In other words I see distance coming in each received message as 1.25, 2.5, 1.75, 2.5, etc.

I guess I don't understand two things:

a) in a controlled set of messages being generated by the ANT+ simulator given a fixed speed of 6mph, why would the simulator generate such an array of varying distances? Wouldnt it send me the same meters travelled each time? I understand in real life with a footpod that the data would vary, but I dont understand why it would vary coming from the simulator.

b) I am suspicious that the distance in meters I am getting is rounded by .25 meter. It seems odd that it wouldn't be a more precise number.

Here is how I am interpreting distance:

float fDistanceInMetersWhole = rxBuffer[3];
char cDistanceFractional = rxBuffer[4] & 0xF0) >> 4);
// divide by 16 to get meters
float fDistanceFractional = (float)cDistanceFractional / 16.0;
// add to the whole number distance
float fDistanceInMeters = fDistanceInMetersWhole + fDistanceFractional;

Like I said, the numbers are very close, but given the controlled nature of this test I would expect them to be exact. Also I have code that handles rollovers.

Any help would be appreciated.      
Avatar
RankRankRankRank

Total Posts: 662

Joined 2012-10-09

PM

Are you using the time sent in the messages for your calculations, or are you keeping your own time? When calculating average speed, use the time included in the messages for your calculations, even if you display your own time.

Note that the simulator attempts to simulate stride events based on a timer, and sets the interval for the timer based on the configured speed. The timer used in the implementation of the simulator does have some limitations, so the discrepancy in timing may be causing what you see. You can have a look at the source code of the simulator for more details.