Unlike the previous post, this is not a rhetorical question that I will ask and then answer. I genuinely do not know the answer. I could Google it, of course, but I'd like to see if somebody reading this is able to deduce the correct answer from the available evidence.
So, here's the deal: as an attempt to recover from a rather sedentary couple of months due to computer-based work and some plantar fascitis kind of problem in my foot that's keeping me from playing hoops as much as I'd like, I'm spending a while each day on the exercise bike we have upstairs. While I do a bunch of reading of books and Twitter during my rides to nowhere, I also spend a good deal of time looking at the display on the bike, which includes a pulse rate monitor.
The pulse rate sensor is one of those silver metal jobs that you grab hold of while you're riding, and I can't for the life of me figure out what it's doing. Here's the observed sequence of events, starting when I grab the sensor handle:
- 0:00-0:08: No reading, but a flashing indicator showing that it's looking for a signal.
- 0:08-0:18: It starts out at 72 bpm, and creeps slowly up to around 80.
- 0:18-0:28: It jumps from 80 to 100 bpm, then creeps slowly up to around 110.
- 0:28-0:40: It jumps from 110 to 130 bpm, then creeps slowly up into the 140-150 range, where it holds steady (unless I do something to raise my heart rate significantly, like pedalling faster, or increasing the resistance).
Now, the first bit, I understand- my pulse isn't necessarily synched with the internal clock of the machine, so it needs a little time to identify the beats. After that, though, I'm thoroughly puzzled.
Given the nature of the process, I would expect the early readings to be off a bit, but the steady upward creep is a little harder to explain. If it's just making estimates based on short time periods, then refining them, I would expect it to jump around a lot-- when working with a short sample of a high frequency signal, I usually expect the first readings to include some that are way high, not consistently low.
Given the purpose of the device, I could understand fixing the initial readings to be low, so as to avoid alarming your customers. So, for example, you might build in something to fix the initial measurement at 72bpm, and then use the actual data to refine that. But then I don't understand the discontinuous jumps at 10-s intervals-- if you were just starting from a low fixed point and averaging in measurements of a higher rate, then it should smoothly creep up to the final value.
You could get the discontinuous jumps at 10-s intervals by averaging for ten-second blocks before updating the display, but it updates at much shorter intervals than that-- the reading changes every 1-2 seconds.
So what is this machine doing to produce this pattern of readings? It's very consistent-- I've tried doing this at a variety of different speeds, different points during the cycle, and so on. I can't figure out how you would get this sort of pattern from simple measurement operations, but maybe there's some more sophisticated signal processing trick that does this. So, if you know what it's doing, leave a comment so I can stop worrying about this and read my books in peace.
My guess is that it's designed to do exactly what you said - avoid alarming the customers. It probably has some sort of "governor" software that prevents the bpm display from increasing or decreasing more than a few bpm per second. That way, if the sensor miscounts for a moment, the reading won't shoot up or down (triggering fear of a heart attack), but just go up and down a few beats.
I'd suspect a periodic update of a running average, mainly because I have used a frequency counter that works that way (0.5 s update of total cycles counted in previous 1.0 s).
That is, every 10 seconds it displays the total number of beats measured in the previous minute, with the buffer filled with 72 beats when it is turned on.
Probably an algorithm that changes the moving average length as you get started, with the jumps being a change in the window size. What's it do if you take your hands off and start over, while still exercising?
What I want to know is how it is detecting your pulse? It is a bit of metal so it could be some kind of electric signal? Does your thumbs capacitance or something change as blood flows faster? It is sensing slight pressure changes?
The metal electrodes form a crude ECG/EKG. Steel is not a good conductor to use in biopotentials (silver/silver chloride is de facto electrode of choice). Sweat from your palms form the electrolyte that bridges the ECG signal from your body to the electrodes. The quality of signal is far from ideal so I would expect it to not latch onto your heart rate immediately, but slowly as the sweat builds up and it sets up the redox that converts biopotential to an electrical signal.
Heart rate monitors usually look for the QRS complex and take the inverse of the time between R's. Perhaps a running average since the signal quality is poor and the average would give the illusion that it's accurate. An easy way to detect the R depolarization is a threshold detection and some kind of auto-thresholding would include/exclude a different number of QRS's and change your rate.
As for speculating, as the electrolyte builds up and the connection becomes better then the SNR should go up which means the threshold could be reduced and include more beats. And if that threshold change was every 10 seconds...
Regardless, I wouldn't classify it as accurate and certainly not representative of "real" ECG circuits. Better to use your brain cycles on the wonders of the ECG and the heart instead of a dinky heart rate monitor in exercise equipment. 8)
The 10-second thing is just an artifact of how the programmer fitted the problem into a very simple generic signal processor chip. These chips are event-loop driven. They have a few programmable timers, each of which can fire a code path when it times out (and can be set to automatically reset and count down again).
The most likely explanation is that the full computation was too hard to do for every for every screen update, and had to be split into two parts - a baseline recomputation (slow) and delta-updates (fast).
The programmer put the baseline recomputation onto a second event loop with a 10 second timer. Does the display freeze for a moment just before the baseline jumps?
(Actually, there are three event loops. The fastest one is what's eating almost every available processor cycle, listening to the voltage via the onboard ADC and trying to pick your heartbeats out of the noise. "Put something intelligent on the screen" is only priority #2, and "make it accurate" is #3.)
Lurker, the ECG is typically filtered at 0.5-150 Hz. Sampling at, say, 1 kHz is excessive and not too many modern processors would flinch at 1 kHz. I don't see how you can get a baseline and delta an estimation since you must detect every beat to do either. I don't deny that that algorithm exists but I don't see how you can apply it to heart rate.
You can make an analog circuit for heart beat detection which would make digitizing and determining rate from intervals a snap and wouldn't tax a microcontroller from 10 years ago...
Is your heart beating constantly throughout this process?
The discontinuities seem like it's averaging in a couple estimates from prior samples. At 40s+ you seem to have some stable process, so maybe after the first 8-10s of initialization, it keeps a 10, 20, 30 second running average estimates, maybe initially populated with 72bpm, and displays some weighted average of these longer samples with the shorter samples.
Personally, I'm partial to a exponentially weighted moving average and would try to design it as Z_t=a*X_t + (1-a)*Z_(t-1)+ a*X_t with 'a' being something like 0.2 or 0.1 to trade off between smoothness and responsiveness, and Z_0=72. It only needs one number to hold history (Z_t), but missed beats would probably end up confusing things. It might be fun to update the display with each new beat, since the computer can do the 2 multiplies and add far faster than the 400000 microseconds between each of the 150bpm beats.
Ha, fun post :-) I have one of these things too on our cross-trainer. It shows pretty much exactly the same as you say, except that after peaking at 150, it goes slowly down to 130 again. Before I had that thing, I'd sometimes use a heart rate monitor, one of these things you strap around your chest (these things suck greatly, esp. for women, not recommended), and I'm very puzzled that handlebar monitor has so high readings. In any case, I don't believe a thing that display shows (the calorie count is arguably nonsense too, if that was true I'd long be dead) so I've dismissed the readings as entertainment and all forgotten about it. (I don't use the cross-trainer in summer.)
@Colin, thanks, I was wondering what kind of sampling/filtering rate you be right for ECG. You are, of course, correct in all your points.... except that you are reasoning forward (taking a problem + available technology and designing a competent solution). I am reasoning backwards from what appears to be evidence of an incompetent solution, and assuming that either the programmers or the company managers were morons:
Think WinModems. Think 20% tolerance on cheap resistors and no factory calibration. Think corporate bureaucracy and not knowing what the end-product is, working with no overtime in a cubicle while the hardware is designed in Bangladesh by somebody who doesn't speak English. Think salesdroids signing contracts to ship product next month when all you have is a buggy demo. Think &%$#ing MBAs and their &%$#ing expense accounts.
(With apologies to fans of Trainspotting, and to our host if I've crossed the profanity line. Normal programming will now resume....)
I've noticed similar readings, but slightly different behavior. I rarely hold onto the sensing bars for very long, but when I do get readings, my heart rate starts in the upper 70s or low 80s, then heads up into the 140s and stays there. This usually takes about 10 minutes. If I let go for a while, then get another reading, it tends to be in the 140s. If I slow down and take it easy for a bit, perhaps choosing a lower workout setting, my heart rate drifts downward. I assume this is because my speeds up when I work out, so I start in the 60s, my usual resting heartbeat, and moves into the 140s. When I work less, my heart slows a bit.
I assume the bar sensors work using conductivity. It can't be a pressure sensor because the pressure variations more reflect your grip as you rebalance your upper body. The little wear-on-your-finger sensors use a bright infrared LED and a light detecting resistor to monitor slight color changes from blood flow in the capillaries.
Also, take the various advisory rates with a grain of salt, and probably a good drink of water. There is no absolute optimal heart rate while exercising. Different people are different. Athletic coaches consider most of the numbers garbage, save for day by day comparisons.