Loghorn / ant-plus

A node module for ANT+
MIT License
138 stars 67 forks source link

Problems with SpeedCadenceSensor, extreme numbers #19

Closed haakonnessjoen closed 4 years ago

haakonnessjoen commented 5 years ago

Hi,

I am having problems with numbers from this. Any idea what could cause this?

I get maybe 5-10 events with numbers that looks reasonable. Then suddenly I get events like this:

SpeedCadenceSensorState {
  DeviceID: 7434,
  CadenceEventTime: 65362,
  CumulativeCadenceRevolutionCount: 1279,
  SpeedEventTime: 0,
  CumulativeSpeedRevolutionCount: 13222,
  CalculatedDistance: 28321.523999999998,
  CalculatedCadence: 7630.816999805938,
  CalculatedSpeed: 446.5095314313867 }

  // Some milliseconds later:

SpeedCadenceSensorState {
  DeviceID: 7434,
  CadenceEventTime: 56336,
  CumulativeCadenceRevolutionCount: 65535,
  SpeedEventTime: 585,
  CumulativeSpeedRevolutionCount: 0,
  CalculatedDistance: 112056.58799999999,
  CalculatedCadence: 69861.7703061405,
  CalculatedSpeed: 196146.9164307692 }

The revolution count is maxed out, and thus the calculated distance and speed is all over the place. Then the next packets all have the same cumulativecadencerevolutioncount, but CumulativeSpeedRevolutionCount is going up and down in numbers. But seems like a much higher number of revolutions than the wheel is actually spinning.

haakonnessjoen commented 5 years ago

Ok. I think I figured it out.. I am using multiple sensors from the same thing. It's a bicycle roller. And I just figured out that each sensor must have it's own channel..

devices.forEach((deviceid, i) => {
    this.sensors[i].attach(i * 2, deviceid);
    this.power_sensors[i].attach((i * 2) + 1, deviceid);
});

So earlier, I used i as the channel number for both data sensors on the same device. Which was my fault. Now that I am giving them unique channel numbers, it seems to work. How many channels can I use on one stick?

Loghorn commented 4 years ago

The number of channels depends on the stick. The property maxChannels gives that information.