Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

OpenAnt at higher Samplerates

Rank

Total Posts: 4

Joined 2020-01-07

PM

Hello (Ant) World!

I'm having a ROTOR 2INPower Powermeter from which I would like to read data from. My objective is to do this with a raspberry. Online I found the OpenAnt library (https://github.com/Tigge/openant) which I managed to get running.

The Powermeter now has a particular Fast-Mode in which it sends Torque Data at a rate of 50Hz, which is awesome. I'm also receiving the data that I want but only at a rate of maximal 15Hz (rate is changing between 1Hz and 15Hz, checked with receiving timestamps). With the Software of Rotor all 50Hz data is received resulting in beautiful smooth graphs. I also checked with Antware II: which allows me to receive all the data (it seems it even sent with more than 60Hz).


So... the data (broadcast) I want is there and readable. I'm just not managing to receive all of it with OpenAnt. The only parameter I'm able to vary (as far as I know) regarding the sample rate is the channel period which I set to 655 (~50.02Hz). This works with Antware II.

Any experiences or suggestions? Maybe its a speedproblem with the raspberry? I don't need to stick to OpenAnt if there are powerful alternatives.

Thankful for any input!!!

-Morten      
Rank

Total Posts: 13

Joined 2019-09-26

PM

I don't know much about raspberry pi but i have always been under the impression that the hardware that is usually used with it is under powered. possible that your hardware just can't keep up with 50 Hz?

it might be a good idea to just make sure you can receive the data at that rate, just detect it and throw it away to see if you can. if you can then likely there is too much post processing with the data before the next sample can be processed and it gets lost making it appear as if the device is not sending it.

just a thought.      
Rank

Total Posts: 4

Joined 2020-01-07

PM

All "processing" and data handling is done by the ANT+ Stick which is the same I was using under Windows where I'm able to receive the data at full speed with their Software and the ANTwareII application.

So the only workload of the raspberry is to read very short Datamessages from the ANT+ Stick. I really doubt that this is too much workload for the raspberry.

With our project we run complex calculations an read many different sensors at a rate of 100Hz without any problems or instability. So I really assume that the raspberry is strong enough.

Of course these calculations are not running during my ANT+ testing for now.... I'm curently just tracking the raw-data (no processing).

Looking at the samplerates makes me think that certain messages are just skipped by the ANT+ stick which might be a problem of the openANT library.... but still not having any ideas how to solve it.
     
RankRankRankRank

Total Posts: 370

Joined 2012-06-27

PM

There is no difference in the functionality the ANT+ USB stick provides to ANTwareII versus openant beyond what openant limits itself to.

If you are able to get 50 Hz data in ANTwareII, you should be able to in openant.

I would suggest checking how often you are getting past the "if message is None:" check in
_worker (https://github.com/Tigge/openant/blob/master/ant/base/ant.py). You should see this happening at ~50 Hz.

Also, check if you are getting caught by
"# Only do callbacks for new data. Resent data only indicates
# a new channel timeslot.
if not (message._id == Message.ID.BROADCAST_DATA
and message._data == self._last_data):" This may explain why you are seeing the rate change. Depending on the encoding format of the data being transmitted, the packet content may not change at 50 Hz.

Check you are handling both broadcast and acknowledged data as well.

Ian

     

Signature

Ian Haigh

Rank

Total Posts: 4

Joined 2020-01-07

PM

Thank you for pointing me in the right direction!

I´m still not completely where I want to be but I´m getting closer.

In the worker method you mentioned there is a check:

"if message._id == Message.ID.BROADCAST_DATA:"

directly folllowed by a "time.sleep(0.1)".

I commented the sleep and now I´m receiving data much quicker.

I´ll post my modifications after I´m happy. But thank you for your advise so far!      
Rank

Total Posts: 4

Joined 2020-01-07

PM

If somebody has a similar issue. Here is what I´ve been doing to solve my problem. I´m not completely sure if it will cause problems somewhere else. But for now it seems to work.

As additional info: I´m using Python 2.7 on a Raspberry 3 Model B

The following modifications have been done in the file: ant/base/ant.py of the openANT package

The main thing preventing higher sample-rates is a sleep located in the _worker(self) function
Line 167:  #time.sleep(0.1) 


With this modifications you will receive data at full speed.

But in my case I still didn´t receive the data at full speed at the endpoint because data is put in and out in various queues causing quite a delay. In the _main(self) function I changed this:
Line 192: (event_typeevent) = self._events.get() 


After this there is another queue in the node file.
The following modifications have been done in the file: ant/easy/node.py of the openANT package

In the _main(self) function I changed this:
Line 116: (data_typechanneldata) = self._datas.get() 



After this changes I was able to receive the full sample rate in my "on_data(self, data)" function. Not sure what caused the delay with the given parameters (especially as these are the default params) in the queues... but for me it works now.

I hope this is helping somebody else someday.

Cheers Morten