Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Sample calculate Cadence VB.NET

Rank

Total Posts: 6

Joined 2013-10-08

PM

hi
you can have a small example of the calculation of the cadence in VB.NET

and this part of my code:
________________________________________________

usPreviousTime1024 = CByte(response.messageContents(4))
usPreviousTime1024 = usPreviousTime1024 + CByte(response.messageContents(5))
usPreviousEventCount = CByte(response.messageContents(6))
usPreviousEventCount = usPreviousEventCount + CByte(response.messageContents(7))

'Update cumulative event count
If (usEventCount > usPreviousEventCount) Then
usEventDiff = usEventCount - usPreviousEventCount
Else
usEventDiff = (&HF000; - usPreviousEventCount + usEventCount + 1)
ulAcumEventCount += usEventDiff
End If

' Update cumulative time (1/1024s)
If (usTime1024 > usPreviousTime1024) Then
usTimeDiff1024 = usTime1024 - usPreviousTime1024
Else
usTimeDiff1024 = (&HFFFF; - usPreviousTime1024 + usTime1024 + 1)
ulAcumTime1024 += usTimeDiff1024
End If



' Calculate cadence (rpm)
If (usTimeDiff1024 > 0) Then
'ucCadence = ((usEventDiff * &HF000;) / (usTimeDiff1024)) ' // 1 min = 0xF000 = 60 * 1024
ucCadence = CULng((usEventDiff) * &HF000;) / (usTimeDiff1024)
Else
End If      
Rank

Total Posts: 5

Joined 2014-11-25

PM

Hell Rino, thank you for posting this.

There are not many using VB.net for their ANT+ applications so this is great to see. I would be very interested in seeing the rest of your source if you would be willing to share.

Thanks!