Calculating speed (on the speed/cadence sensor)

513 views
Skip to first unread message

Rob Jordan

unread,
Nov 3, 2013, 3:51:23 PM11/3/13
to python-ant-...@googlegroups.com
Hi all,

I'm trying to get a speed out of the 07 raw message demo file.

I figure that I need to use the different integers given by the payload bytes?

ord(msg.payload[8]) would give "cumulative speed rev count MSB"
and 
ord(msg.payload[7]) would give "cumulative speed rev count LSB"?

and 6 and 5 for the bike speed time event...
(section 6.2 of  the ant+ device profile for the speed and cadence sensor)

I've figured out how to combine these to a hex number and then converted this back to an integer.

I also use the n-1 (rev count and time event) from a list to use in the following formula:

speed (m/s) = (2.07 * (rev_c - rev_p) * 1024)/(time_c - time_p)

2.07 is the wheel size
rev_c is current rev count
rev_p is past rev count (n-1)

The strange thing is the speed is always pretty much fixed at 24.359????


the parameters of the usb are:
ID is 121 (for the combined speed and cadence sensor - GSC10?)
ChannelPeriod is 8086
freq = 57

any clues would be really help me out or even tell me that I'm doing it totally wrong!

thanks,
Rob

Rob Jordan

unread,
Jul 18, 2014, 1:37:04 PM7/18/14
to python-ant-...@googlegroups.com
I thought I'd have another go at cracking this, not managed it,
I asked the question on the ant+ forum to see if they could help:


I've been stuck on this for ages but thought I'd had a break through only to get stuck again, I'm hoping you can get me over the brow of the hill.....

My mission is to gain a speed reading from the garmin sensor.
I've read the profile doc and understand the equation.

I've managed to put the hex values together to give the wheel revolution count. I watch these tick by on the screen as I spin the wheel on the bike. The issue is the time doesn't seem to update with the current time stamp when the wheel passes the sensor. The time count only increases by 257 (of 1/1024).


Below is a snapshot of some of the data I collected.
(the wheel is spinning slowly hence the rev count is not changing on every reading)

For background info i'm using Ant.core on python (demo 07_rawmessage3 if this means anything to anyone) with a garmin speed/cadence sensor and a garmin usb stick.

revs count time count time change
32686 8367790 
32686 8367790 0
32686 8367790 0
32686 8367790 0
32687 8368047 257
32687 8368047 0
32687 8368047 0
32687 8368047 0
32687 8368047 0
32687 8368047 0
32687 8368047 0
32688 8368304 257
32688 8368304 0
32688 8368304 0
32688 8368304 0
32688 8368304 0
32689 8368561 257
32689 8368561 0
32689 8368561 0
32689 8368561 0
32689 8368561 0
32690 8368818 257
32690 8368818 0
32690 8368818 0
32690 8368818 0
32691 8369075 257
32691 8369075 0
32691 8369075 0


this is how I'm getting my time integers in python....

        time_c = ord(msg.payload[6])
        time_c_hex = hex(rev_c)

        time_c1 = ord(msg.payload[5])
        time_c1_hex = hex(rev_c1)
        
        time_c_int = int(time_c_hex,16)
        time_c1_int = int(time_c1_hex,16)
                
        time_c3 = hex(((time_c_int) << 8) | (time_c1_int))

        time_c = int(time_c3,16)
Reply all
Reply to author
Forward
0 new messages