HRM data to QC

ginsu777's picture

hi. i am new here and I am obsessed with turning my HRM data into real-time graphics. I have the sparkfun polar board and it is all working quite well in processing over the serial/usb port (FTDI drivers)

i am trying to use the serial IO plugin to get the heartrate and graph to display in QC. any help would be appreciated, and I look forward to sharing what I have learned.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

dust's picture
Re: HRM data to QC

well its defiantly posible as there are a few kineme users that have been using the serial patch to get various sensor data and or micro-controlling data into QC. check out

ginsu777's picture
Re: HRM data to QC

thanks for the reply. i saw that page but it seems like they were using the OLDER version of serial IO and in any event, it does not work.

I am really at a loss as I can get the thing to work within its own little processing program, and just talking to it via terminal on OSX, but other than that, no data can be passed along. I just dont get it, and need help to move forward. hopefully someone can get me pointed in the right direction.

if it will help someone else's project, the info for teh board and the startup code is located here:

Serial IO screen shot
Serial IO screen shot148.68 KB

cybero's picture
Re: HRM data to QC

Are you running sans jumpers?

If not, I think your baud rate might be wrong.

9600 is the norm ref default, but needs to be altered when jumpers are set, and that will differ according to what is being set jumper wise and why they are being set.

Just hazarding a guess here BTW.

Those settings you've entered might be AOK in fact.

If you are on the newer version of Arduino, then you'll probably need to amend your settings as appropriate for that version of the Arduino board.

Mansterri's is going to be based upon an earlier version of Arduino I guess, from what you've said.

Do you need to check the clear buffer checkbox on the Kineme Serial Input - where else will you get your flow control from?

Not to sure about the length of the break string either, I think that and the clear buffer is what you might need to tweak further, in fact I think I'm now persuaded that the norm ref 9600 should be AOK [and I'm guessing there's no special jumper settings on your board now]

ginsu777's picture
Re: HRM data to QC

no jumpers - no arduino! I am using only the HRMI Board, into the mac via a usb which then i am using the FTDI drivers, so it shows up as a serial port /dev/cu.yadayada all the serial port things work fine. i can see the data zipping by as i run the processing sketch

in the QC, i have an output to send commands like "G1" to the board, in a terminal (quickTerm) that usually returns the mode, a clock number, and the heart rate. but i get nothing in QC. no way to even type the commands in and see them appear. its just so frustrating because the app the guy wrote in processing works fine. its pretty well documented, but i CANNOT figure it out.

some help here would be so awesome, so I just hope someone reads this after going through something similar, or maybe is in the mood to help a newb.

cybero's picture
Re: HRM data to QC

Have you tried contacting the authors of the program?

have you tried checking that unchecked Buffer control?

ginsu777's picture
Re: HRM data to QC

I will try the flow control check, but I have tried just about every combination. I can visually see if Serial IO is talking to the board, because two leds will flash if it sends heart rate data -- no joy. I contacted the author (Dan Julio), and here is what he had to say:

Unfortunately as far as I know, without some custom programming, there is no way to have more than one program use a serial port at a time. I don't know how to use Quartz Composer but if there is any way of having it emit some diagnostic messages then you should be able to narrow down why it isn't communicating successfully with the HRMI. I am assuming that it can actually generate data on the serial port as well as receive it.

The HRMI always responds to commands so you'll have to have some program (your quartz composer program through the SERIALio plugin) send requests commands to the HRMI and the process the resultant data. I'm not sure what the "Break String" is in your image. The HRMI requires a particular sequence of byte values, for example 'G' followed by '1' followed by the carriage return character (decimal value 13 or hex value 0x0D).

I also cannot answer why you seem to be getting raw data. I'm pretty sure the HRMI firmware is operating correctly so I can only surmise that it is not seeing what you think you are sending.

If I were you, I would do two things:

1-I would play with a terminal emulator and the HRMI so that I understood the command syntax and expected results (e.g. request some heart rate value and get responses).

2-I would look into adding some sort of diagnostic information to Quartz Composer at the levels it uses to communicate with the HRMI to make sure the bytes being sent/received where as expected.

Perhaps there are some online forums where Quartz Composer users with experience with the serial port could also give you some good feedback.

Sorry I'm not more help but I have no experience with Quartz Composer.

dust's picture
Re: HRM data to QC

i just looked at your screen shot. your not going to be able to visualize andy data by hooking the data output of the serial patch to the render input of the render in image patch. the render input is a boolean true or false meaning only the number 0 or 1 will do anything. what this does is basically turn the render in image patch on or off you need to be using a image with string patch or something equivalent

ginsu777's picture
Re: HRM data to QC

I understand. that is why i was testing with a simple keyboard input library, which worked perfectly to display either a 0 or 1 on the screen. I incorporated all your advice, but I still cannot send an instruction to the board. here is what the Console says after I start up the Quartz preview, take a look at some things, and then shut down the preview window:

2/27/10 2:11:01 PM   Quartz Composer[1076]   KinemeSerialInput: Opening /dev/cu.usbserial-A800crOP
2/27/10 2:11:01 PM   Quartz Composer[1076]   KinemeSerialO: openDevice: opening /dev/cu.usbserial-A800crOP
2/27/10 2:11:01 PM   Quartz Composer[1076]   KinemeSerialIO: openDevice: Configuring device
2/27/10 2:11:01 PM   Quartz Composer[1076]   KinemeSerialIO:  9600 baud rate configured
2/27/10 2:11:01 PM   Quartz Composer[1076]   KinemeSerialIO: Current Configuration:
2/27/10 2:11:01 PM   Quartz Composer[1076]      * Parity: No
2/27/10 2:11:01 PM   Quartz Composer[1076]         * Type: Even
2/27/10 2:11:01 PM   Quartz Composer[1076]      * Data Bits:  8 bit
2/27/10 2:11:01 PM   Quartz Composer[1076]      * Stop Bits: 1
2/27/10 2:11:01 PM   Quartz Composer[1076]   KinemeSerialIO: configDevice: Disabling Parity
2/27/10 2:11:01 PM   Quartz Composer[1076]   KinemeSerialIO: configDevice: Enabling 8 Data Bits
2/27/10 2:11:01 PM   Quartz Composer[1076]   KinemeSerialIO: openDevice: Configured.  Adding to dictionary.
2/27/10 2:11:01 PM   Quartz Composer[1076]   KinemeSerialIO: openDevice:  all finished up!
2/27/10 2:13:49 PM   Quartz Composer[1076]   KinemeSerialIO: closeDevice: Last user of 12 closed.  Cleaning up
2/27/10 2:13:49 PM   Quartz Composer[1076]   KinemeSerialIO: closeDevice: All devices closed.  Cleaning up.

I really just need to find out how to send data to the device like I can when I use the terminal program or the processing sketch -- it works just fine there.

whats the difference between DATA and BINARY DATA. I want to send the command "G7" to the device, which will return three pieces of data: the device mode, the clock number (sequential, random seed), and then the last 7 HR readings in the buffer. Any ideas? I have hit the wall on this.

serial IO settings
serial IO settings180.13 KB
Working QuickTerm settings
Working QuickTerm settings77.55 KB

cybero's picture
Re: HRM data to QC

Binary data is data of any type that is encoded in binary form, 0's and 1's, usually for efficient storage and recall. So far as Unix is concerned, all computer files are binary. So far as other systems are concerned, programmers can set a switch to say what their file type definition[s] are - text or binary.

The usual distinction is made between files of pure binary data [.bin] , files of binary data with textual and file format information [too many to mention] and then binary files of purely textual information - often considered as being entirely separate in type from the pure binary data file types.

Perhaps the easiest distinction is that pure binary is what best suits the machine and formatted & / or plain text files suit the end user.

Such distinctions are, in the final analysis, false, in effect :-), despite any shuffling of the pea under the cup by programmers. All files on a computer system can be considered as binary encoded.

Data streams from a device can be either be unprocessed data, or binary data.

As binary data it is meant to be suited to be transferred between machine reading devices. These devices have to find the file to be mutually compatible or else the machine read transfer shall fail.

As unprocessed data, you might expect an ordered [if you're lucky] or an unordered [more often likely] list of results.

cybero's picture
Re: HRM data to QC

BTW, shouldn't you be flagging Binary Send Signal?

ginsu777's picture
Re: HRM data to QC

thanks for providing that reply. however, I am most interested in the difference of DATA and BINARY DATA within the context of the Serial IO plugin. I have done more testing, and I was able to manually send these commands from QC while it was running, and I can get the TX light on the HMRI board to light. However, there is no place for FLOW CONTROL in the serial io plugin. Is this an issue, and how can I change it?

the bad news is that the RX TX sequence does not take place, so it would seem that the instructions are being sent to the device, but its not able to talk back the the INPUT part of the program I know the TX / RX bit seems backwards, but why else would a device on the serial respond to outgoing commands by flashing its TX without flashing the RX (which would represent it taking a reading from the chest strap; which oddly enough I wear all the time while I am working on this.

Additionally, I can send the DATA as "G3" or as "0x47 0x03" and both will make the TX led light. However, I think the problem is boiling down to two main things:

ONE: on the OUTPUT side, I am not sure how to send a to go along with the "G3", which is why the binary bit got me excited as I am sending the CR as "0x03" (i got this info from the card's documentation) I need to figure out how to properly send the CR after the command -- one way or another

TWO: on the INPUT side, it seems that the BREAK STRING is rather elusive. I have tried a bunch of different combinations (/r/r, /r/n, /r/n/r/n, etc..) and nothing works. might this be the issue? Also the CLEAR BUFFER thing has me confused, and I also read something where someone added a counter as a "data sink" and I am not sure if that will help????

I cant tell, but I know that I am VERY VERY close and I want to figure this out soon so I can focus on improving the look at feel of the output (create a pulsing heart, color-coded HR zones, etc)

Does anyone have any more insight?

oh, and the mods might want to move this to the proper area, as it might help someone figure out a similar problem. thats just how the discussion went here. :)

I am attaching a grab of the current data fields that can get the card to blink MANUALLY when I click on the SEND SIGNAL tickbox.

data/binary data fields and setup
data/binary data fields and setup192.82 KB

ginsu777's picture
Re: HRM data to QC

cybero wrote:
BTW, shouldn't you be flagging Binary Send Signal?

could you please explain further?

dust's picture
Re: HRM data to QC

there have been varying reports on the serial out from QC. given the disparity of serial devices it is understandable as to why there are varying results. i honestly have not messed with sending data out from QC via the serial patch. from all practical standpoints the serial out patch does exactly what it says. its up to you to know what your device is expecting as data input.

im not sure why you are trying to write to the board in the first place. it seems to me you want to just use qc to visualize the heart rate.

so what i would do is flash(upload) the basic arduino sketch onto the board. inside the loop of the sketch it is doing a Serial.print() which is printing all the data from your sensor back to the board. The data that will print in QC's serial input patch will be this data.

you will either want edit the sketch in processing to just Serial.print() the data you want to visualize or in QC. or explode the whole string with a string components patch in qc using " " as your delimiter. where " " is a blank space. so qc will parse out the strings you want to visualize.

on the most basic level all you need to do is upload the sketch and hook up image with string patch to the data in qc to visualize the data. then use the above mentioned string components method to sub string the variables you want to graph in QC>

ginsu777's picture
Re: HRM data to QC

thanks alot. I am trying to talk to the board because it wont send the data until you ask for it - and when you ask for it a certain way. I basically wanted to ask it to send me the AVG HR once every second (G1 ) like the creator's code already does, and then just loop it. That was my plan, but it seems like I cant get the board to respond to command I am sending it from the serial IO thing. Its just that I feel I am so close, maybe I am miles away and just dont know it.

your solution makes sense to me, but I am not sure if I can flash the board, because it is not an arduino, its a stand-alone board i bought from sparkfun with the polar RX chip on it (among others). if i can flash it then re-flash it with the original if things get messed up, then no problem. i have flashed lots of stuff before. But, how would I flash the board? use the Arduino software versus the Processing software? Didnt know that was an option.

I looked at the processing code, and it does mention the things like using ' ' as the delimiter and all of this. It also uses TXRX and all sorts of java libraries, etc - so I am totally over my head. I just want the thing to send me a number every second so i can display it in various ways. It shouldn't be this hard. UGH !!!

cybero's picture
Re: HRM data to QC

At this point I am really taking a stab in the dark with this, but I think lack of Flow Control is a stumbling block, though kineme are well able to confirm that.

My understanding BTW, is that the Binary Send Signal does need to be flagged, but I might be entirely wrong about that.

dust's picture
Re: HRM data to QC

im pretty sure you can write from processing to the board with the serial libraries. or you can use the simple_unix.c code to flash from the terminal or something.

i think your best bet is set a hardwired button to an analog input to trigger (g1) instead of relying on a software button. then just get the returned string from the serial patch in qc.

just look at the boards developer pages or check out what sparkfun recommends to flash the board. there might be an application built for it ?

without knowing what code is on the board then it will be pretty hard to tell you what the to send out the serial patch from qc.

for instance the processing code is expecting 3 values. the hrmi address, 'G', and the number of entries

hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries);

where as the unix code expects

SendCommand, "G%0d\015", NumEntries

where send command is an array[] that holds the char code, and G\015 is the line break.

so i would try to both.

for instance

send out serial form qc in the data field try

127, 'G', 20

where 127 is the address and 20 is representative of the number of values your expecting.

you could try

sprintf(127, 'G', 30)

like i said without flashing the thing with a particular code and knowing what command that code is expecting then its just a shot in the dark.

try 'G/n'

try 'G/015'

like i said these are guesses based on the code you provided in the link.

so if you last ran the board with the processing sketch try

try using this in the data field of the serial out from qc.

hrmiCmdArg(127, 'G', 20);

if you run the simple processing sketch then you should be able to send

'G' '1' 'CR'

maybe as G113 in data field

or G\n1\n13\n

or println('G');println('1');println(13);

just remember the G and 1 are char code and constant CR is a number not char.

your pretty close

ginsu777's picture
Re: HRM data to QC

thank you for all those TOTALLY useful methods to try. I will try them all and report back here!

ginsu777's picture
Re: HRM data to QC

NOTHING worked. nothing. its the CR entry. it jsut wont ake. maybe its the whole line i just dont know. so frustrated. so upset. wasted 4 days on this. why quickTerm works and nothing else does is beyond me. I wonder what QuickTerm is sending to the device that is different?

All I have to type in quickTerm is G3 (then hit return) and I get all the data i want MODE - CLOCK - HR1 - HR2 - HR3


Here is what the javascript says (i think i got the right section.. I have attached the entire javascript file)

public void GetHrData(int numVals)
  if (numVals > MAX_REQ_HR)
    reqVals = MAX_REQ_HR;
    reqVals = numVals;
  validData = false;
hrmi_graph.java_.txt20.93 KB

smokris's picture
Re: HRM data to QC

The character "3" (0x33 encoded in ASCII) and binary value 3 are not the same thing. You want to output the literal string "G3" followed by a CR, not "G" followed by binary 3 followed by CR.

Use the following as Binary Data in the Serial Output patch:


For the Serial Input patch, set Break String to:


You should receive a space-delimited string with your values. You can then use the String Scanner patch to extract these values into numbers QC can deal with.

Flow Control doesn't matter in this case.

ginsu777's picture
Re: SUCCESS !!! HRM data to QC

First off, THANK YOU THANK YOU THANK YOU! I spun my wheels for quite a long time on this, and while I did learn some stuff, it was mostly just senseless searching and desperate attempts.

I attached a screen shot of the thing working. the only difference was that the Serial Output break string is \r and not \n

i havent used the string scanner yet to strip away the leading numbers, and I need to automate sending the command every 2 seconds, but I should be able to do that (any way to test all that stuff WITHOT my HRM and the USB gizmo being all hooked up?

So in short, thank you so much to everyone who gave me so much help, and extra thanks to SMOKRIS for delivering a solution. The person who created the board and wrote the code couldn't even help me. So, thank you, and I look forward to learning how to make a cool graphical overlay, or turn the numbers various colors based upon heart rate ranges, etc...

I'll be happy to do more creative work, and I hope to share it all with you here. thanks again.

WORKING Polar HRM to QC !  :)
WORKING Polar HRM to QC ! :)379.67 KB

dust's picture
Re: SUCCESS !!! HRM data to QC


here is a clock it will help you automate the command

counter.qtz30.23 KB

ginsu777's picture
Re: SUCCESS !!! HRM data to QC

looks great! thanks alot. So how do I get it to "click" the SEND BINARY box every 2 seconds, or every 1 second, etc... I am assuming I keep the SEND BINARY DATA box checked and just put the clock into it as an input? Did some googling and nothing is turning up.

dust's picture
Re: SUCCESS !!! HRM data to QC

in that clock example, im using counting ms or counting a 1 second loop which triggers an increment on a counter that is used to tell time. you would want to change the 1 second conditional from .9 to 1.9 or change it to 2 with a tolerance of .1 and change condition to equals. then connect the output of the conditional to the send. then disregard the rest. even better i just changed for you and connect to serial out.

so no you don't feed the clock into the send because that will only trigger the send when it reaches 1 second. boolean or check boxes are true or false, one or zero. where one is on, and zero is off. so when the clock reaches 1 it will trigger the send but then it will keep counting up and not trigger again unless you reset the clock so the best thing to do is use a stop watch and conditional logic which trigger a boolean truth if the condition is set to 2 in which case you feed the stop watch the truth value to reset and start count over and send the conditional truth to send or check box as its expecting either true or false.

2SBool.qtz2.98 KB

ginsu777's picture
Re: SUCCESS !!! HRM data to QC

Wow, DUST, I cannot thank you enough. that worked PERFECTLY right out of the box! I also installed a little pulsing alpha thing tied to the string, so the HR that is sampled every 2 seconds is PULSED on the screen -- (the only thing is that I lost the color for some reason, its only black and white.)

So the next step is to get some sort of lower third background that has a pulsing heart, and cumulatively GRAPH the HRs returned by the program -- as time moves on from left to right, like a CNBC stock ticker... Then the final piece will be to incorporate the ability to accept other video inputs (probably from firewire) like over the air DTV or whatever I can pipe in.

I am attaching the entire file here (just include your own .mov) SO HAPPY, and I look forward to getting the graph thing built soon!

HeartViewWORKING.qtz10.77 KB

ginsu777's picture
Re: HRM data to QC

I'm trying to build this thing up, but I would like to show it off to some of the folks that helped me. however, I can't export it to QT with the HR display -- the resultant file only shows the video. I made sure the qc program was getting the HRMI data, etc.. and its showing up on the preview, but not the export. Am I missing a setting somewhere?

smokris's picture
Re: HRM data to QC

QuickTime runs Quartz Compositions in Safe Mode, which disables potentially dangerous patches from running in sandboxed environments.

Since we have no way of ensuring what kind of device is attached to the serial port (it could be a Therac-25 for all we know), we've marked the Serial IO patch as unsafe.

To make a stand-alone version of a composition (without having to abide by the Safe Mode restrictions), you can either use Xcode to build a Cocoa application to encapsulate it, or use our QuartzBuilder.

ginsu777's picture
Re: HRM data to QC

ok, i never realized that. learning is fun. Well, since you all helped me with all of this, i created a version of the qtz that takes your internal isight as the video input and puts the HR in the lower corner. So, if you want to buy the HRMI board and a polar chest strap (see links), plug them in and run the attached QComp.

Sparkfun HRMI Polar Chest Strap

enjoy! and look for improvements to the graphics, and the flexibility of the application. Right now, I am using xcode tools to make an app, but am not quite sure how to include the video files (or point to them as files on a DVD that I burned, etc..) Maybe I could build a menu in front of the app that would allow you to choose which video workout you wanted to do, and then you could pick that workout. It would run the same QC but with a different video source. sound good?

Also, how do I make apps that go fullscreen?

HeartViewCAM.qtz98.08 KB

dust's picture
Re: HRM data to QC

cool yeah that could be fun. there was a grad student last year at my school that did a hrmi project. she hooked up a hrmi to an arduino and camera some how and road her bike around and took pictures based on her heart rate. i suggested she recorded her heart rate every day as she went up 4 flights to the lab then once she got enough data sets to sum and create an average mean or what have for each pulse with a tolerance setting so maybe when she got to the top she could could have the door open automatically or something. im working on a sensor project with xbee right now as part of a wearable meta matching system, got the boards talking over wireless serial just need to get flashing working via bluetooth with an iphone without hacking. some day i will get one of these things so the patch might come in handy. i got some things from sparkfun a few months back. a pod breakout and some servos etc.. there are all kind of cool things on that site.

ginsu777's picture
Re: HRM data to QC

funny, I cant add the text "BPM" to the third argument from the text scanner. when I enter anything I want to add, all the text foes away on the screen and I lose the HR. Why ca't I add a prefix or suffix to the arguments? The example in the library shows "@% @%!" as Hello World! -- with the exclamation point.

If I add it in the exact same way, the text goes away.

I am also wondering the best way to allow the user to CHOOSE between 2 or more quartz composer files (i.e. ride 10 minutes, 20 minutes, 30 minutes...) but the only difference is the .mov that get slapped into the video billboard. Should I build 3 qtz and create a menu in xcode, or put some kind of variable in the video file to represent .mov s of varying lengths?

dust's picture
Re: HRM data to QC

here is 4 different ways to explode a sub string they all do the same thing with varying degrees of controlling. to get fine adjustments i usually use string truncate by char but truncating by word does basically the same thing the others do. so there is string scanner where you declare the amount of arguments your string has by %@ %@ and explode, then there is string component the structures out a sub string. have a look.

there are various ways to display different comps but the on the most basic level usually this is done by switching via a multiplexor. her i included an example of this but took it step farther as i made a clickable drop menu system by hit testing strings. basically a hit tester takes the w and h of a sprite and its x and y coords then evaluates the mouse coords against the hit zone then outputs a truth value when hit. to make the drop menu i made the hit zone of the menu header width the length of the menu header and all 3 choices but only made the sprites width the actual width of the word "menu" so that the choices are not presented till you roll over the word "menu". this is also so that the menu choices stay visible when you roll over them. if the hit test and the menu sprite where the same width then when you went to make a choice they would disappear when you went to select as the hit is no longer true for menu selection.

the choices w & h and hit test w & h are the same. then a simple logic "and" check to see if you are over and have clicked the mouse. if you you are over a choice and click the mouse then the java script appropriates the correct index to switch the multiplexor to image you have chosen. i set a queue to fill when the mouse button is clicked which stores the last index value so your last choice is remembered. just attach movies where the images are.

stringPlode.qtz14.79 KB
dropmenu.qtz279.87 KB

ginsu777's picture
Re: HRM data to QC

wow! again, thanks SO MUCH. I will get on this tomorrow afternoon. I tried out the system during a workout and it worked perfectly, so improvements will be building on something stable. I'll report back to share the results (but without the videos due to file size and copyright).

jersmi's picture
Re: SUCCESS !!! HRM data to QC

thought about starting a new post for this, but it refers to dust's counter.qtz comp.

i am troubleshooting some timing stuff, found dust's counter.qtz and was having a look. discovered the seconds wrap at .9 seconds, so the counter runs .1 sec fast. right?

so i am wondering what is the best way to correct this -- what is the best way to make the counter spot on?

i inserted a round with ceiling val set so values >1 trigger wrap around. this makes the timer run slow (loses a few secs per minute).

i also inserted a sample and hold to display the conditional values >1. (question 2:) why does fps stop working when i engage the sample and hold?

counter2_dust_test.qtz30.44 KB

CATDK's picture
Re: HRM data to QC

I've been having trouble getting the serial io patch to output the command I need aswell.

I need to output this: Hex: FF0101 Hex: FF0100 or Dec: 25511 Dec: 25510

The device I have connected turns on just fine when I use "coolterm" to send FF0101 to it. But I've had no luck getting serial io to do the same.

I can tell that I've found the right devicename because "coolterm" can't access the device when my quartz composition is open, because its busy.

I've tried EVERYTHING.

How did you translate to binary data Smokris? and is there any chance you could translate this (FF0101 and FF0100 for me?

ginsu777's picture
Re: HRM data to QC

during my travels online, i think i saw a webpage that would do various conversion for you. try a few of them to see if it works. for me the /r was the big part of the solution.

ginsu777's picture
new thread started.

new thread started.