I’ve been working in the background on things that most people will find dull – more coding. No major breakthroughs, but no breakthroughs are needed at this point. I’ve ported about 65% – 70% of the code and what is left to do is below. More after the break.
Friday, April 5, 2013
Monday, April 1, 2013
nRF51 Interrupts–Not what I expected
The interrupts are acting a little different than I expected based on my current limited experience. They seem to be active when the pin is in a certain mode rather then when it changes state. This means that when DRDY (DataReady) asserts low, it wakes up the microcontroller and keeps it awake. The nRF51 can’t go back to sleep until DRDY asserts high. I’m sure I could code around this or some other options exist but luckily I don’t have to – and here is why:
When in continuous read mode I need to send it “NOP”, or No OPeration, which is fancy for 0xFFh. Into the first NOP command the DRDY asserts back to high, and once the read operation is complete the nRF51 can go to sleep. DRDY will only assert low when a new conversion is ready.
For those who are interested in the how the ADS1247 operates when reading multiple inputs, instead of NOP you can send a change input command while in continuous read. The next conversion will be the other selected channel.
Here is something neat that you can do with this too. My strain gauge arrangements are full wheatstone bridge differential inputs, meaning that each sensing arrangement requires its own differential pair. However, if you want a half wheatstone bridge for generic strain inputs you can put a voltage divider to input of MUX0, and have 3 inputs to half-bridges. This would be a quick and easy solution for multiple thermally compensated sensing arrangements. I’m currently testing this way with a workpiece I made while in North Carolina at Vishay’s training course. It’s a differential bending beam so it is a half bridge configuration. I’m using two 10k resistors (Vishay 1 ppm, 0.01%) as a voltage divider on MUX0, and this differential beam input to MUX1. I have another full wheatstone bridge wired to MUX2 and MUX3, but sometimes I’ve just sent it to MUX0 and MUX2. That means an ADS1248 with 8 inputs could do 7 half bridge sensing arrangements!
The 2000sps max for this chip is spread over all channels then. So if you set the read rate to 2000sps and have it over 4 input setups then that is only 500sps for each channel. I am planning on testing to determine the ideal rate, but right now this chip is so low noise that I suspect I won’t need to pass 320/channel (640sps total) which will put me in line with most production powermeters. That would give 160 per revolution at 120rpm per leg.
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:
GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos
Below is an excerpt for a generic GPIO without interrupt:
GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos
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 www.dcrainmaker.com 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 kwakeham@gmail.com or kwakeham@accuity.ca. 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 www.accuity.ca 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 kwakeham@gmail.com or kwakeham@accuity.com. 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 www.thisisant.com )
- 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.
PERFECT.
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
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
- The Software
- ANT+ Communications
- Test 1
- Correction
- Test 2
- Calibration
- 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:
CCCCBCCCCBCCCCBCCCCBMCCCBCCCB
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%.
Correction
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.
Calibration
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.