Thursday, March 28, 2013

Wake up nRF51, wake up! You have Math to do!


Ah ha! I found it! How to have the nRF51422 wake up on sensing the ADS1247 is ready to be read. Unlike the ADS8321 I previously used which converts as it reads out, the ADS1247 takes a little while to do a conversion (depending on the rate it is set to), and as such the nRF51422 can take a nap most of the time. Otherwise it’s just burning through electrons pointlessly.

In the included libraries it defines the pins generically… but without interrupt, however in the powermeter example it defines the buttons manually in another library… with interrupts.

Below is an excerpt for button press with interrupt:


Below is an excerpt for a generic GPIO without interrupt:


Some additional coding and configuration should allow me to sense the gpio pin that the DRDY line from the ADS1247 is connected to. When the line goes low the data is ready, and the nRF51 can wake up do a read, store the data, and sent it back to me via UART on the SEGGER J-Link. Later it’ll store the data for averaging later. This is the last major breakthrough I needed to figure out how to keep the nRF51422 in sleepy-time mode (Without using the above pictured Tea).


Onto gyro evaluation next. I just got confirmation my order shipped. My order from Adafruit on the thermocouple and thermocouple IC shipped. I haven’t heard about my solidstate relay though.


(Needed some other supplies too!)

Wednesday, March 27, 2013

Beta Testers Wanted –(KW/Waterloo/Cambridge/Toronto, Ontario)


I have to thank Ray from for his post. I think it paints a pretty good picture of things. His posting did highlight something. My initial reluctance to BTLE. This stems from a personal experience choice, but mainly cost. However, if down the road I can get some form of backing and some help with coding I will be dropping in the nRF51922 microcontroller (ANT+/BTLE simultaneously) when released for dual support of both protocols.

One point he made was about getting a product to 95%. I think it’s being misunderstood that the accuracy of my meter is +/-5%. This is NOT the case. My torque testing is easily measuring in the 2% described by other’s products. I believe he means in terms of finishing. That’s a big hurdle. Redesign – Packaging – Waterproofing – Validation – FCC / CE approvals - ANT+/BTLE approvals. That’s the last 5% of developing a product and it’s a big 5%.

I’ve been having good progress with the nRF51422 (ANT+) microcontroller and I’m about 99.9% settled on the ADS1247/8. The ADS1247 is a 2 differential (4 single sided) ADC while the 1248 is 4 differential (8 single sided). Why I might chose the ADS1248 is so that I can have a secondary force sensing arrangement. That means I could do the fancy directional force output that Pioneer has shown off. It’s information overload during riding, but it might be useful. I think I’m going to try and design the board to accept both. Future proofing I’ll call it.

I’m glad a couple of people commented on the gyro situation. 4ma doesn’t sound like a lot, neither does 2ma, but when your coin cell’s life curve shows a maxim total draw for 2ma then that is a problem. I have a gyro I like being put on a breakout board by Protoadvantage now. I’m hoping to have it next week. I like coin cells, but the gyro could kill that… or sticking with coin cells could kill the gyro. If you have an opinion, post in the comments or drop me a line.

Now the other thing which this post is titled. Beta Testers. If you are in any of the above listed area’s, an avid cyclist, and interested in access to some beta prototypes drop me a line at or I’m looking for local first so I can drive over and debug / check / upload new firmware / get your feedback.

I’m looking at two months to get the new design in order and a prototype built. After that I suspect it’d be another month or two before I’ll put a meter in anyone's hands. However, if you are further away and interested drop me a line too. I’ve had several people ask. There is a list being compiled. When goes live there will be a sign up section. This will be a closed Beta, more like an Alpha test really. Generally that means I’ll own the device, you have a loan of it and I will eventually take it back.

Thanks for following! And Thanks to Ray again for supporting the industry.

Monday, March 25, 2013

SPI, Buttons, Toasters, and More

Just a small update today on what I’ve been working on.
  • nRF51422 – Talking to the ADS1247 on the SPI bus, figuring out the reference code, and reading and writing pins.
  • Looking into Gyro’s. They have very very high current consumption. 4.2 – 6.4ma. This is much to high. I can’t find any stats on start up time. Sleep mode doesn’t reduce current below 2ma. Still too high.
  • Strain Gauges – Not much new, but I’m hoping I can find 1000 ohm gauges instead of 350 ohm. This will save power
  • Toaster Oven – I’ve decided to make a reflow oven. This should speed testing new circuit boards. I have an SSR on order, and a thermocouple and sensor chip on order from Adafruit. Let’s see if I get dinged with Tarrifs.
  • I’m interested in going to the ANT+ Symposium in Sept, but looks like I’ll have to upgrade to Alliance Membership. $1500 dollars a year is a little hard to swallow right now. If I’m in the market for beta testers by June I’ll sign up then and just suck it up.
  • Beta Testers – If you’re a cyclist in Ontario or know someone who might be interested in testing my next prototypes have them drop me a line at either or Oh no, I gave away my new company name! Website coming in a month.
  • I’m thinking about making the board, or a variation of it, available to the hacker community. The plan would be to have space that other sensors (Accelerometer, Gyro, Magnetometer, General Purpose Analog Input with Gain [ADS1247/8]). Idea for now. ANT+ for all I say (but become an Adopter to get the ANT+ Key of course at )
  • Below is some testing. I’m sure all are becoming familiar with my laptop layout.
  • While I might pick up a BTLE sensor Tag from TI, I have no ambition to pursue BTLE at this time. Cost mainly. ANT+ will require FCC + $1500 membership + $750 device registration / testing. BTLE requires $22500. I am not joking. I became a BTLE adopter and I can barely understand the documentation and only have the vaguest ideas how it works compared with ANT+. Right now that’s a learning curve I am not willing to accept. If Accuity gets off the ground, has people test some prototypes, then I’ll reconsider.

Wednesday, March 20, 2013

Calibration–On the bike–Shows Powertap the Door


I just attempted to recalibrate the meter but this time with it installed in the bike. It confirms my original calibration, the one that is less than that of the Powertap G3 with calibrations around 26.5/170.1 compared to the original of 26.3/171.3 and the Powertap Corrected of 23.4/154.3.



N-M R Bits/N-m L Bits/N-M
7.410253 -25.2131 171.9632
14.90343 -26.9906 168.91
22.87888 26.49627 -170.11

What is going on?

Once on the bike the left measurements bending moment issue goes away – Completely! 100% no more issue. Apparently having it resting in a BB on a table doesn’t count because the cups are not rigidly held. Once on the bike in a relatively stiff frame the bearings are held more rigidly and the bearings remove the bending moment like I theorized.


However that still leaves the mismatch to the Powertap G3.

If my meter is accurately reproducing the torque on the crank pedals then how does the Powertap G3 read higher with drivetrain losses.

Two answers, I’m calculating cadence wrong or the Powertap G3 is out of wack.

Since my data lines up perfectly with the speed cadence sensor and my math looks correct, that only leaves the Powertap G3 is incorrectly calibrated.

I’ll rent the Powertap again in a few weeks potentially to check. Apparently the Powertap will update the torque value without spinning and can be used to check calibration.

Tuesday, March 19, 2013

Powertap Versus Prototype

Update: New Calibration information, issues presented at bottom is an anomaly of calibrating off the bike, see here.

In response to questions on accuracy of my V3 Prototype that was shown here and featured on Hackaday I’ve been doing some testing. The most recent testing is based on comparison to the Powertap G3. This is going to be broken up into a few steps
  1. The Software
  2. ANT+ Communications
  3. Test 1
  4. Correction
  5. Test 2
  6. Calibration
  7. Lessons Learned

The Software
The above software looks ultimately dull, and I’ll admit it is. However it’s functional (though can crash if I do something stupid I suspect) and does something out there no software does. It records all data fields transmitted by a power meter (except crank frequency, but nothing uses that data page that I know of) and it does it every 0.250 second or 4hz. I’ll get to why that is important in the ANT+ communications bit, but suffice to say that the data from 2 powermeters is recorded and synchronized. I rented the G3 on a Tuesday – I didn’t get the software written until Friday, so 2 days of missed testing.
ANT+ Communications
From top to bottom you’ll see B Watt, C Watt, W watt, C N/M, C RPM, W N/M and W RPM. This will become clear soon but suffice to say B, C, W are for Basic, Crank, and Wheel.
In the power profile for ANT+ it defines pages. There is an 8 byte message to every payload that happens every 0.25 seconds, and the first byte defines the page. Sadly this is a bit of a waste of data but necessary. A basic powermeter transmits only the basic page. This is the bare minimum for compatibility and if your receiver supports the basic profile it can communicate with ALL powermeters. That’s correct. You might be wondering then what about the crank and wheel profiles? Every 4 messages these powermeters have to send a basic page!
So a crank will go:
If you bother to read all that you’ll see an ‘M’. That M is the manufacturers information containing serial numbers, manufacturer ID etc. These come sporadically working out to every few seconds.You’ll notice then that a head unit has two means of displaying power. In practice I’ve found that the Garmin Edge 500 I have is pretty clever in what is going on in the background. If you start it up and the powermeter starts sending basic pages it’ll start extracting power data from that, but if you switch to crank or wheel it ignores these pages. However if the computer starts up and sees crank or wheel data it’ll calculate the power from the torque and rotational velocities presented, but if you switch to only basic power transmission then it doesn’t show power – you have to reboot it or research for the powermeter. If your head unit is only seeing basic profile for a crank or wheel unit then your 1hz recording is now oversampling because you only get a basic page every 1.25 seconds.
What I’ve presented, changing profile types, would not be approved by the ANT+ committed, but it’s worth noting that these devices expect consistency and what page they get their data from can change how fast you get your data.
I noticed the Powertap updates it’s wheel page only when the basic page is updated. GASP! That means you are only ever getting data at 0.8 hz from a Powertap G3!
However, let us assume that a wheel based meter or crank based meter updated every rotation, and at high speeds at around 200+ rpm that means almost every page it sends is different. You get 4 times the data you get with the basic profile potentially. If the basic page comes around it syncs well with the wheel page but it isn’t averaged for the last 4 pages you’d notice error. So if you’re wheel is spinning 240 rpm or about 30.2km/hr, your data could have error – with itself! Using the ANT+ Sensor Simulator and my software I can show you this error below. Notice how the blue basic page lags the more accurate red crank page.
Below is some real Powertap G3 Data. No real error, however this means that the G3 could actually have greater accuracy potentially and may actually answer why it sometimes doesn’t line up perfectly with the crank based meters. Honestly, I think that Cycleops should have the Powertap updating every revolution, but I’m more engineer than Coach – to a coach, it doesn’t likely matter.
Test 1
Utilizing both the Powertap G3 and my V3 Prototype produced the graph below. Both meters follow similar trends very closely. Initially I had to restart my prototype to re-zero it a couple of times. Once that is complete and the V3 is responding well it follows much better, though offset lower.
Below is a blow up of my meter versus the Powertap G3 to highlight the differences. One of the things you’ll notice is the higher response of my meter versus the G3. This again goes back to how the processing happens. In theory the wheel is spinning faster so should update twice as often as the crank but it does not.
The difference between both meters hovers around zero, however there is some offset on average. There is some larger errors coming up during the intervals.
Mapping my meter against the G3 shows good linearity, but showing a slightly greater slope. When I calculate out the average torque and gear down during intervals it appears there needs to be an 11% torque correction. The bits/torque is therefore decreased 11%.
Increasing the torque by 11% from the first test yielded the results below. The data now lines up very well.
Again, plotting my meter versus the G3 shows a better relationship, though potentially overcorrected. This is correct as we’ll see in the next test.
Test 2
Using the data from the Powertap and the V3 Prototype with the correction factors yielded the following test. Once corrected they give good alignment with the G3. The blue indicates my powermeter while the red indicates the Powertap G3. One thing to note that was mentioned earlier – the Powertap G3 is updating the Wheel page ONLY after it updates the basic page whereas I am only using the basic page. The Wheel is usually spinning much faster than the crank, say approximately 2:1. But the G3 only updates once every 1.25 seconds, so I’m really achieving 2:1 more data approximately with my prototype as was shown previously. Near the end of the last interval I wanted to push it and you can see the response of my powermeter leads that of the Powertap clearly showing the advantage of more updates.
Once I implement a 1 second smoothing algorithm (that would likely be used in most cycle computers) this becomes the graph below. As you can see, it’s lining up even better.
Similar to the graphs shown before, the comparison of each meter by graphing the power of the V3 Prototype against that of the Powertap we get the following. There is certainly scatter as the Powertap can be delayed in time up to a second causing offset forward or backward. The regression now indicates that the new calibrations are over estimating power compared to that of the Powertap. This is more in line with what should be expected as there is a certain amount of drive train loses to be compensated for. It is very close to what was expected based on the 11% change in terms of linear regression.
The average offset works out to be about 7 watts. I can again drive this back down. The minor slope indicates good correlation and little drift resulting from the room warming up. There is still a little. The new ADS1247 has a thermal sensor built in, and the nRF51422 also has a thermal sensor built in. I can therefore use these to do any thermal compensation needed.
Above is a picture of a $32.99 dollar strain gauge based weight scale that measures up to 5kg in 1g increments. I tested 15kg worth of weight and recalibrated. What I found was that my right crank arm calibration was somewhere between the original and the Powertap G3 Adjusted and my Left one ranged. Wait, what? How can that be.
Apparently my alignment of the strain gauge in the axel is not perfect and as a result the hard the effort on the left leg the greater the bending moment combined with the twisting moment and causes a nonlinear calibration. It’s not bad, but it’s certainly an issue. There was a bare hint of this on the right side, but not much.
Lessons Learned
Strain gauge alignment. This is more critical than expected. At work I’ve made alignment gauges, here I assumed that the self compensating nature would take care of most of it, and to an extent it does, however 2 degrees of angle better and it might never have been an issue. The right measurement using the double bending bridge arrangement is good but the left will need serious attention to alignment and installation.
Also, notice I put in the price of a strain gauge scale. If there was an easy way to combine this with a 50 dollar Garmin speed / cadence sensor you would have a powermeter essentially. I mean the scale has a microcontroller in it already and a display and fancy stainless steel flat. Powermeters aren’t complicated in terms of engineering, but they have their issues to build.

Monday, March 18, 2013

Powertap G3 Comparison Update–Few more days

It’s just taking a little longer as I’m adding information related to strain gauge misalignment.

The primary things I’ve found out from V3 now include that the torque tube gauge alignment is critical. The BB bearings does not completely prevent  bending moments from transmitting through the axle. As a result, misalignment can show up as torque. This misalignment is causing calibration issues.

There may be some twisting interaction with the double bending arrangement but I believe that this can be reduced with more accurate locating of the gauges.

Sunday, March 17, 2013

Step 2 - Break prototype

Step 1) Calculate calibration adjustment based on Powertap and upload to microcontroller
Step 2) Break off the USB connector promptly after uploading
Step 3) More testing - To be posted soon
Step 4) Leave the house, get coffee with plans on attempting to solder it back on sometime in the evening

pb = V3 prototype, pw2power = Powertap G3

Not major, but annoying. I've got the calibration close but now my version is over predicting power. This might technically be okay because of drivetrain losses but I have no basis for the calibration now. The whole point was to bring it in line with the powertap. To subjectively look at the graphs I'd say they are similar, but breaking it down there is about a 7 watt offset with now.

Around the 286 samples mark you'll notice something. I stopped pedalling  My prototype doesn't detect a stopped condition yet. It therefore does not update the transmission. This goes to how the chipsets work. When I tell an ANT+ chipset to transmit data it does it continuously until I update it again. Really this is a few lines of code, but it'd be quite annoying to anyone familiar with power meters. It'd artificially increase or decrease average power. You can see it doesn't make much of a difference anywhere else except around 7981 samples. otherwise it's pretty similar. More to come.

Saturday, March 16, 2013

Testing with a Powertap G3

As I mentioned in a previous blog post I’ve been testing my V3 Powermeter. There is going to be a major overhaul with the next iteration but I can still learn a huge amount from V3. Just like how I learned from V2. I’m mainly concerned with testing the consistency of the readings. I’ll be making a post Sunday or Monday with the actual results but suffice to say the results are very similar though my calibration is off, it’s reporting lower power than expected. What you are looking at in the above picture is what I was looking at during and interval session with my prototype along with a Powertap G3 rented from Cycles London. Above you are seeing a movie on one monitor with two custom pieces of software I wrote. One I mentioned previously as my trainer software that I use for indoor training, and one is a program that I pulled together in 3 days of spare time. It connects to heart rate monitor, speed cadence sensor, and two power meters and records them synchronized at 0.25 second intervals. That’s right, 4 times a second.
Here is the catch on why 4hz recording. Powermeters transmitting on ANT+ can do so in a few ways. It can transmit the basic power profile which is mainly power and balance, crank profile which transmits more accurate cadence and torque but no balance, and wheel which does the same as crank. It transmits at 4.06hz. More after the break.

Tuesday, March 12, 2013

nRF51422 EK / DK Arrival

After some mix up and delays by Fedex my EK and DK kit arrived. Some might be wondering why I ordered both the EK and the DK. I don’t actually have an nRF6700 (nRFgo starter kit).

The DK, or developer kit, “requires” a starter kit for Nordic development – the nRF6700, and if I truly need it I’ll get it. However, the nRF6700 is used for essentially power and nothing else. The DK has pin headers on the back of the two boards supplied so I can just run some wires out there. It comes with five sample chips and a standalone programmer which I’ll need for developing my own board. That’s the bigger motivating factor here.

The EK, or evaluation kit, has the reference design for the nRF51422 plus a trace antenna and an on-board Segger J-link programmer and debugger. What you really need for development. Nuhorizons has these for 88 dollars, a drop from 99 dollars but only has the DK in stock. I think they have 2 EK on order though. Anyway, Honestly I think the EK price is a little high if we are comparing it to the the TI series or even an Arduino with on caveat – This is meant for ANT+ and as such comes with some Nordic backing in terms of an SDK.

The SDK comes with reference code for power meter, speed/cadence sensor, heart rate monitor, stride-distance monitor and a generic ANT communications design. In 10 minutes I had all the software installed, the ANT+ network key installed, and was transmitting the basic power profile to ANT+ display simulator. It’s programmed in a much more efficient way than my previous prototype, but it’s a good deal more complicated.

Also just rented a G3 Powertap. Time for some comparisons of my meter and a production unit. Might have to code up a multiple power meter recorder software.

Monday, March 4, 2013

nRF51–Finally en route

It’s finally on order! The nRF51422 DK / EK kit that uses the new ANT+ transceiver with Arm Cortex M0 all in one chip.

So that means that development is switching to a slightly more closed platform. Depending on how the evaluation of this part goes will determine the potential for a commercial unit.
Yes, that’s right, I’m in the planning process of evaluating the possibility of going commercial. Generally response to the blog has been good, and testing with the recent updates has been very positive. I’ll be posting more data soon. I also found a local company that rents Powertap G3 wheels. I’m planning on renting one in the next two weeks and showing the error between data similar to that of when he does his power meter reviews.
A commercial version will contain the nRF51422 for the ANT+ version and likely the nRF51822 or nRF51922 for BTLE compatibility if it’s warranted in the future. As of right now there still isn’t a BTLE power meter profile as far as I can find.

Update: BTLE power profile at version 0.9 which means adopters can get access. Still waiting on confirmation as I had to re-register.