Capturing heart rate from USB ANT+ dongle and chest strap

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

 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

Thanks Star Strider, I'm curious where you got your device, sounds like an interesting thing to play with.
I also found a post on ANT+ forums earlier that mentioned the CP210x USB to UART Virtual COM Port (VCP) driver (same chip your device had apparently), so I installed the driver and tried to have it show up under ports in device manager, unfortunately unsuccessfully. Similarly, I don't see it listed in the registry output from your functions, I only see the "normal" driver for the USB dongle, which comes back even if I uninstall it and select to delete the driver... But this seems to be the way to go. I'll have to figure out how to make it work. Oh and I'm on Windows 8.1.
Since it's the same chip as you, perhaps you'd be willing to share more of your code to get and display the data? It looks like serial isn't too complicated though, so I should figure that part out if/when I get the VCP driver to work.
If anything else comes back to you that may be helpful, please do share! Cheers
My pleasure!
I got the plethysmograph mail-order from the U.S. affiliate of some Chinese company back in 2009. I have to find it and unpack it (moved), but I believe it is the CMS Model 50-E Fingertip Pulse Oximeter. It’s quite good from a hardware perspective, since the signals are sampled frequently and precisely enough to produce reliable waveform data. (I had intended to use its pulse waveforms to assess arterial elasticity, but that project got put on indefinite hold.) It came with software that I could not get to communicate with MATLAB, and since getting the data into MATLAB was the whole point, I uninstalled the software and drivers, plugged the device in a USB port, Windows found the correct driver, and all was well.
The functions I attached are essentially the ‘guts’ of the code that connects the device through the USB port and serial emulator to MATLAB. I had to do some experimenting to get it to download the data from the plethysmograph, since that is distal to the driver itself and the USB hardware/firmware. It would probably not be the same code for your heart rate monitor.
I would go with the driver your USB dongle managed to download. That is likely the one that actually connects the EKG hardware to your computer, and eventually to MATLAB. I do not suggest going by what the ANT+ fora say, since the driver hardware between different ‘ANT+’ devices may differ. ‘ANT+’ is a wireless network technology that is likely distal to the driver and USB hardware/firmware itself. The USB hardware/firmware and drivers may differ between manufacturers. You will probably have to to go online to find the PDF documentation for your particular driver and hardware/firmware, and you should have the necessary data about the driver available to you so you can do an Internet search for the PDF documetation. It should be under ‘USB Devices’ in ‘Device Manager’, and you likely will have to have the device connected at the time to find that information. If you already know what that is and you have the documentation, then changing my interface functions (if necessary) should not be a significant problem. It is not a good idea (personal experience here) to download drivers for hardware you don’t have. It might be a good idea to uninstall the ones you downloaded and installed that do not seem to work. Be very careful with that, though!
I don’t have your hardware or your driver details, but if you look up the PDF documentation for the driver and USB interface hardware/firmware and attach it here or to your original post, I might be able to help. I have a Win 8 computer here (haven’t upgraded to Win 8.1 because of persistent rumours of driver incompatibilities, although they may now be fixed) so I don’t know if my code would run my plethysmograph on this computer without modification.
Let me know, and I’ll do my best to help.
Thanks, I've updated my question. It's not as simple as using the intended driver from ANT unfortunately, which is not a COM port driver from what I understand.
I got a lot of valuable information from the PDF application documentation on the chip in my pulse-oximeter. I used that to write the two functions I attached. I suggest that you search online to see if you can find similar documentation for your interface chip. I have no information on your device or its hardware, so I can’t help you interface it.
I had to uninstall the software and driver that I had installed that came with the pulse-oximeter because it wouldn’t work with MATLAB, even with the functions I posted. With the software and drivers that came with the device no longer on my system, my functions worked fine with MATLAB. If you have installed software and drivers that came with your device, uninstalling them, having Windows find, identify and install the appropriate drivers, and then consulting the application documentation for the USB interface chip should go far in solving your problem. However if it doesn’t use a virtual serial port as my pulse-oximeter does, I’m not sure what to suggest.
I understand all that. From what I can tell though, all the functions you've posted do is search the registry for which com port the device uses. That can be done by looking in Device Manager once the driver is installed properly. Unfortunately, what you just suggested doesn't work for my device as Windows automatically installs the proper device drivers which are not a virtual serial port drivers (no port in registry entry). And so far I have no official confirmation of which chip the device uses, but from the ANT forums and my attempts to install drivers, it's likely FTDI. My current problem is that I get the error reported above in Matlab, so I need to figure out what is using the port, or why Matlab thinks it's busy or non existent... Or find another way to interface than serial(). I might have a look at the ANT C API this weekend, might not be as complicated as I think.
I don’t have all the information I need to help you with your USB interfacing problem. I refer you to FTDI Application Note AN_107. It might have the information you need.
Thanks again, somehow I had missed that document. I hadn't installed the drivers properly I think. I've managed to uninstall the other drivers and prevent Windows from automatically installing the "normal" one. However, I've now found that the chip is nRF24AP2 by Nordic, so I'm confused by that post on the ANT forum saying he used FTDI VCP drivers (<http://www.thisisant.com/forum/viewthread/2082/)>. But I didn't see any VCP drivers from Nordic. So I might try once more with FTDI drivers and if that doesn't work, I'll probably look into making mex files.
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.

More Answers (1)

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.

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!