Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

You are here: Forum Home → ANT+ Forums → ANT+ Simulation Tools → Thread

   

Getting events from a Stationary Bike

Rank

Total Posts: 12

Joined 2017-01-13

PM

I would be grateful if someone could give me some help trying to solve this problem please. The main difficulty I am having is attaching the function to receive events. Also I suspect there is a better way to get the speed from the Fitness Equipment.

Using C#, I am trying to link to a Smart ANT+ Turbo Trainer, reading speed and cadence and setting power. I can't find any examples using the Fitness Equipment (please point me to some if there are any), so I am basing this on the Heart Rate Display Simulator example.

Following the example from the Heart Rate Display, I set up a FitnessEquipmentDisplay
turboTrainerDisplay = new FitnessEquipmentDisplay(channel0, networkAntPlus);

But I can't find a way to I attach a function to recieve the events. I expected something like one of these (neither work) and I am stuck!
turboTrainerDisplay.SpecificStationaryBikePageReceived += turboDisplay_TurboDataReceived;
OR ...
turboTrainerDisplay.DataPageReceived += turboDisplay_TurboDataReceived;

Then turn it on to get the events pumping...
turboTrainerDisplay.TurnOn();


Cadence I expected to come from a broadcast (SpecificStationaryBikePage) page event (in the same way as HeartRate did):
P:AntPlus.Profiles.FitnessEquipment.SpecificStationaryBikePage.Cadence

However I can only see Speed in:
P:AntPlus.Profiles.FitnessEquipment.FitnessEquipmentDisplay.Speed
which is a property rather than a broadcast event so I would have to interrogate for it every time I wanted to look at it. I suspect there is a better way.


With turboTrainerDisplay created above as a FitnessEquipmentDisplay, setting power looks straightforward .. This looks OK but let me know if this is not right.
ushort myPower = 100 * 4; // 0-4000 w units 0.25w - eg set to 100W for testing
ControlTargetPowerPage targetPowerPage = new ControlTargetPowerPage();
targetPowerPage.TargetPower = myPower;
turboTrainerDisplay.SendTargetPower(targetPowerPage);// Sends a Target Power Command (0x31)


Thanks
Steve      
RankRankRankRank

Total Posts: 120

Joined 2013-05-07

PM

Hi AntySteve,

Assuming you are trying to connect to a trainer, I would hook into the SpecificTrainerPageReceived event. In the SpecificTrainerPage parameter passed through the event, there is a Cadence property. Use this if you want to be notified when the cadence changes.

If you are looking to poll the current cadence, you can check the SpecificTrainerPage "SpecificTrainer" property's cadence property to obtain the latest cadence value.

Are you using the .chm file that comes with SimulANT+ to understand the ProfileLib API? The .chm file provides a clear API on what properties and events are accessible and is really the best place to start with an app like this.

For the power command:
1. Confirm with the ANT+ Fitness Equipment Device Profile to see if you are using the correct units.
2. Read the API documentation available in the .chm file mentioned above.
3. Make sure you are comfortable with any default values Profile Lib sets for any page you are sending where not all properties are being set.

BK.      
Rank

Total Posts: 12

Joined 2017-01-13

PM

UPDATED

Thanks to BK for a most helpful answer.

I can now compile and run the programme in C#. So a big thank you for that.

I can't yet get the turbo to obey instructions to set power or resistance. I suspect this is a pairing problem because the LEDs on the turbo do not indicate that pairing has happened. Despite this it will give me the speed, cadence and power - just not let me set it. Any suggestions welcomed.

Regarding the speed: The SpecificTrainerPage doesn't have a speed property, so the only way I can see to get the speed is to poll it from my code via FitnessEquipmentDisplay.Speed. Is that correct or is it possible to get it broadcast?

Regarding the .chm file, the one I have been using is "SimulANT+ Scripting Interface.chm". I was having trouble seeing the contents of this but when I changed my PC to open the chm file automatically using the standard viewer (rather than asking me each time) the content started appearing in the right hand window - magic!


Thanks again
Steve
     
RankRankRankRank

Total Posts: 120

Joined 2013-05-07

PM

Hi AntySteve,

No need to poll. The Fe Display simulator exposes an event that is triggered when a specific Trainer Page or General FE Data Page is received. The General FE Data Page contains speed.

BK