MATLAB Answers

0

Capturing heart rate from USB ANT+ dongle and chest strap

Asked by Marc Lalancette on 20 Jul 2014
Latest activity Answered by Peter Gamma on 2 Dec 2019 at 18:30
Hello,
I'm trying to figure out the simplest way to acquire data live from my heart rate monitor (chest strap), which communicates wirelessly with the PC through an ANT+ USB dongle. I really don't know much about drivers but I think I have to use the Instrument Control Toolbox and make a Matlab driver for this? Unless the Data Acquisition Toolbox can get the USB data directly? Any tips would be appreciated!
Edit3: As explained in an answer below, some ANT dongles can work with virtual COM port drivers, and thus Matlab can interface with them as a serial port. Unfortunately, the chip in my device is Nordic nRF24AP2-USB which includes USB and does not provide a VCP driver. Thus to interface with it I need to use their API. The way I think I can do this is with MEX files, but I'm still wondering: does the Instrument Control Toolbox provide anything that would make this easier?
Thanks! Marc

  0 Comments

Sign in to comment.

5 Answers

Answer by Star Strider
on 21 Jul 2014
 Accepted Answer

You don’t necessarily have to use the Instrument Control Toolbox or the Data Acquisition Toolbox. You didn’t say what OS you have, but if you plug the USB dongle into your computer — and the Force is with you — Windows should find the driver for you and install it. (You may have to try different USB ports. All of mine function correctly, but for some reason, only the ones on the right side of my relatively new HP laptop will trigger the Windows search behaviour.)
Set the USB interface up as a serial port. See the Serial Port Devices documentation for details.
I didn’t do exactly what you are doing, but about five years ago I got a fingertip plethysmograph (measures pulse contour, oxygen saturation, heart rate, and a few other things) that had limited offline data storage and a direct connection with a USB cable, and after finding the details of the hardware and its communications protocol online (PDF documentation from an Internet search on the hardware Windows identified), was able to get all the information from the device and display it in real time. I had to do a lot of experimenting, but I got it to work.
I have a couple routines from that effort that may help get you started. I’m attaching them here for your reference. (Unfortunately, I don’t remember the details of the logic behind them. I believe I got some of the information in them from the hardware and driver documentation, so it’s best you use that information for your hardware and driver in your application.) They were written for a Windows 7 machine in R2009b, so there could be version differences as well.

  10 Comments

I managed to find some information on ANT by searching for your nRF24AP2-USB chip (that also seems to have the drivers) and on the Nordic developer resources Software and Downloads site. The ANT Message Protocol and Usage and Interfacing with ANT General Purpose Chipsets and Modules (I can’t link to them directly) are likely to be the most informative, but that’s not saying much. They’re nowhere near as straightforward as my pulse-oximeter, and the documentation does not have any discernible references to simple USB interfacing, at least that I could find. There are several examples of C scripts, so if you’re going the MEX route, they could help.
The second document however gives an Alberta address for what is apparently their Canadian affiliate (228 River Avenue, Cochrane, Alberta, Canada T4C 2C1), so contacting them directly may be an option. ANT seems also to have its own proprietary interface software environment, probably to make it easier for developers. Getting access to it may be challenging, because Nordic wants you to establish an account with them to log in to get the information and software. I get the impression that the USB interface capability is possible, but due to the complexity of the ANT hardware, might be challenging to implement.
Yup that pretty much echoes what I saw yesterday, they don't seem to have a VCD driver. However, I have signed up as an "ANT adopter" so I have access to all the documentation of the ANT API, code examples etc. So I think for the mex option, I'll have all the information I need from ANT. Still, since that does seem like a lot more work, and there is one report of making the Nordic chip work with the FTDI drivers, I'll give that a shot first.
I didn’t sign up (no reason for me to) so I didn’t explore those options. The FTDI drivers seem to be much more straightforward — similar to my pulse-oximeter drivers from what I saw — so that is definitely the way to go if you can possibly get it to work. I get the impression that ANT isn’t eager to have others develop software for their devices, or maybe with all the RF networking stuff in ANT (they thought of everything, including encryption), it’s simply difficult to do it.

Sign in to comment.


Answer by Marc Lalancette on 25 Jul 2014

I finally got some details on the ANT forum, which I will paraphrase here to my limited understanding level:
Some ANT USB dongles use a Nordic chip for ANT, but a separate chip for USB; that second chip either from SiLabs or FTDI, thus the possibility of using a VCP driver. Other dongles use a Nordic chip which has USB integrated, and that "requires writing code to interface with". This is the case for my dongle "ANT USB Stick 2", which uses the nRF24AP2-USB chip with USB integrated, that uses the driver libusb.
Thankfully, there are quite a few code examples for me to look at, in particular from the ANT developer site. If I get this to work, I'll probably post the code on the file exchange, but it could take a little while.

  1 Comment

That’s what I suspected from what I read. I would definitely encourage you to write a function for the File Exchange for your application.
The reason I didn’t formalise my pulse-oximeter functions and put them up is that there have never been any Questions that I’ve seen that asked for them. (Besides, they were relatively easy to figure out and code from the online documentation, so I suspect others had no problems with it either.)

Sign in to comment.


Answer by Peter Gamma on 7 Jul 2019
Edited by Peter Gamma on 21 Nov 2019 at 5:50

  0 Comments

Sign in to comment.


Answer by Peter Gamma on 19 Nov 2019 at 4:16

  0 Comments

Sign in to comment.


Answer by Peter Gamma on 2 Dec 2019 at 18:30

There is also a discussion in the GoldenCheetah Group about this topic:
GoldenCheetah supports ANT+ sticks, has a real-time mode and is open-source.
The accepted Answer by Star Strider on 21 Jul 2014 is complicated. I suggest to add Lab streaming layer LSL to GoldenCheetah by contributors. Lab streaming layer LSL is a well documented and supported live-stream solution from the Swartz Center for Computational Neuroscience. As far as I know GoldenCheetah is the only open-source windows software which can handle with the ANT+ protocol.
Is there an easier solution to this problem?

  0 Comments

Sign in to comment.