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

   

Script to TE PS sweep for power meters not updating values

Rank

Total Posts: 2

Joined 2014-08-26

PM

I'm attempting to write a script that will allow me to run sweeps of torque effectiveness and pedal smoothness in Simulant+. Unfortunately my python scripting skills are pretty weak. I imagine I'm very close but am missing some nuance since the script generates no errors but the values never update.

Any help is appreciated.

# This scripts sets up a bike power sensor to transmit the specified
# range of sweeping values. Refer to the sesnsorSimulation module for additional
# details on the sweeping mechanism
import clr
clr
.AddReference('ANT+ProfileLib')
from AntPlus.Profiles.BikePower import TorqueEffectivenessAndPedalSmoothnessPage
from AntPlus
.Profiles.Common import RequestDataPageCommon
from sensorSimulation import sweeper
from System
.Timers import Timer
import System

eventTimer 
Timer(1000# convert time to milliseconds
sweepTE sweeper()
sweepPS sweeper()

tePsObj TorqueEffectivenessAndPedalSmoothnessPage()

# SWEEP CONFIGURATION - Modify the values in the following four lines to change the sweep characteristics
# Make sure that all of these are doubles (use a decimal point!) so that calculations are accurate
sweepTE.minValue 120.0 # Minimum value in sweeping range, in Watts
sweepTE.maxValue 190.0 # Maximum value in sweeping range in Watts
sweepTE.sweepTime 60.0 # Time to sweep between the minimum and maximum values, in seconds
sweepTE.constantTime 2.0 # Time to spend at a constant speed in the minimum and maximum values, in seconds

tePsObj.LeftTorqueEffectiveness sweepTE.minValue
tePsObj
.RightTorqueEffectiveness sweepTE.minValue


# SWEEP CONFIGURATION - Modify the values in the following four lines to change the sweep characteristics
# Make sure that all of these are doubles (use a decimal point!) so that calculations are accurate
sweepPS.minValue 115.0 # Minimum value in sweeping range, in Watts
sweepPS.maxValue 187.0 # Maximum value in sweeping range in Watts
sweepPS.sweepTime 60.0 # Time to sweep between the minimum and maximum values, in seconds
sweepPS.constantTime 3.0 # Time to spend at a constant speed in the minimum and maximum values, in seconds

tePsObj.LeftCombinedPedalSmoothness sweepPS.minValue
tePsObj
.RightPedalSmoothness sweepPS.minValue

def update
(senderargs):
   
tePsObj.LeftTorqueEffectiveness sweepTE.getNextValue()
   
tePsObj.RightTorqueEffectiveness simulator.LeftTorqueEffectiveness
   tePsObj
.LeftCombinedPedalSmoothness sweepPS.getNextValue()
   
tePsObj.RightPedalSmoothness simulator.LeftCombinedPedalSmoothness

def stopScript
():
   
sweepTE.stop()
   
sweepPS.stop()
   
eventTimer.Stop()
   
simulator.TurnOff()

eventTimer.Elapsed += update
simulator
.TurnOn()
eventTimer.Start()
sweepTE.start()
sweepPS.start() 
     
RankRankRankRank

Total Posts: 120

Joined 2013-05-07

PM

Hi Andrew,

Your script looks about right. You are sweeping the values in the TE&PS; page that you've defined, but not in THE TE&PS; page that is being transmitted.

For that, use simulator.XYZ = ..., where XYZ is the name of the TE&PS; page property in the relevant simulator. Use the "SimulANT+ Scripting Interface.chm" file, browse through to find the relevant simulator, and then the relevant property you want to modify.

Best,
BK