Saturday, December 29, 2012

V3–Maybe it will work

image

Okay, so if you look at the Arduino code in the image you’ll see a commented out delay(3); I had put this in the wrong location. Because I’m not properly reading the RTS line I put in the delay, and it cleared up ANT+ communications. However it’s in the wrong location and now it’s a delay after every read! Stupid I know!

More after the break. Also I’m starting to use breaks on the blog so the amount of posting will be short. Just click the read more if you visit the main page.

Bluetooth (2.0) to ANT+ Bridge

So a little while ago I mentioned that it should be a very simple affair to connect the AP2 module to a Bluetooth SPP (Serial Port Protocol) transceiver. With everything working on 2.4Ghz this might be a wireless mess, but there should be lots of wireless space in the 2.4Ghz spectrum, suffice to say as long as several people are not using ANT+ and Bluetooth in the same area.

Why bridge things?

Well, it’s simple. Most phones don’t have ANT+ and it’s the #1 question I’m asked about the power meter combined with BTLE on Android, the dominate phone OS, does not have BTLE sorted out in the slightest. I don’t claim to know much about BTLE and it’s problems on Android but the group on Linkedin makes it clear that it’s not prime time ready.

So I just ordered up a HC-06 Module for about 10 Dollars CAD and I’m going to try and wire it into my Sparkfun ANT+ stick. The stick is set to 9600 Baud already and is very simple to wire up so I figure I’ll give it a try. I’ll test it with the AP2 module after.

I don’t believe the HC-06 is FCC certified so it’s not like I could sell this. An FCC certified board is a bit more expensive at around $30 – 40 dollars. That means this translator would be near $100 minimum once packaged with a regulator and a battery.

13

So what could you do? Well, using the basic SPP protocol an Android, iPhone, tablet, Windows, etc device could talk directly to the ANT+ protocol. Meaning that someone could easily get fitness apps talking to the holy grail… I mean the power meter! Android’s been out in the cold for a while now in the ANT+ arena, so it needs a little help.

The second letter in the name of my power meter is C, so that’s a-c-X-X-X-X-X.

Happy holidays.

Saturday, December 22, 2012

Some more notes on ADC’s

I haven’t had much luck getting the SAR’s to work as I’d like. Honestly, it’d work better in Rotor’s or Garmin’s arrangement, that is, if you are essentially running two independent power meters and one just transmits its findings to the master. That way it would effectively double my sampling rate. However, as it stands, I can’t process the data on the Arduino fast enough to average out the signals to reduce the noise enough. I’ve thought about bumping to 16 Mhz. Several people have done this, and so long as you maintain good voltage it should be fine, however it is officially below the minimum requirement of the Atmega328 or Atmega32u4 chips requirements for 16Mhz.

Monday, December 17, 2012

TSSOP 20 Breakout? Help?

I’ve been reading up on the SAR (successive approximation, eg the ADS8321) versus Delta-Sigma (eg the ADS 1247). From what I can find out the Delta-Sigma’s are slower BUT they have much better noise rejection. I’m using an averaging technique with the SAR where the Delta-Sigma may not need an averaging technique or very little.

So if anyone knows of a TSSOP 20 breakout to DIP or DIL that’s available in Canada without a fortune in shipping let me know.

This could also reduce cost. The ADS1247 is approximately $13.50 CAD which eliminates two ADS8321 and AD623 and high precision resistors. I believe that is about $45 dollars. Major electronics could be < 40 dollars. Obviously, a power meter won’t be that – labour + other parts + casing + testing + overhead and equipment.

Still looking for an appropriate gyro on breakout board. I think I’ll eventually have to pick up a hot air rework station since I’m not ready to commit to a reflow oven – Gyros are only available in LGA style. If anyone in the Kitchener-Waterloo-Cambridge or Guelph area in Ontario that has one and willing to help out, let me know!

Saturday, December 15, 2012

How Many Bits is enough

Back when I was doing my Engineering Masters degree I had to build an active suspension setup, simulate it in software, and then test it in real life. That was a difficult proposition and my 300+ page thesis took 4 months to review instead of the 3 weeks costing me about a thousand dollars in tuition. However, I was using about 6 MCP3201’s tied to a Spartan FPGA that was running at about 50000 samples per second and then averaged down to 512 sample/second with an artificial 16 bits created by summing and averaging the 12 bits. Suffice to say, this did actually help when it came to differentiating the positions for velocities, but it was honestly a mess.
I’ve done some experimenting in order to determine why I can’t get stable numbers with it sitting on a table while I simulate high RPM (120 RPM +/- 40). 60 – 90 RPM seem acceptably stable at 0 watts, but at 200 RPM it could erroneously read high, up to 26 watts I’ve seen. 26 watts error is flat out unacceptable!
So I’m back to basics. Read out the samples as fast as the fake serial port can allow and I come up with a few graphs. So what I am doing is summing up so many samples and then dividing them by the count, so averaging out over so many samples. This will be referred to as Samples/Report.
image
At 2000 samples/report things look very good! Less than 1 bit of appreciable noise getting though this crude filtering technique. But things quickly go bleak.
image
At 200 samples/report we have about 3 LSB of noise almost. My 16bit ADC is now barely a 13 bit ADC.
image
At 20 samples / report things just get very very very bad. We are at 4 – 5 LSB of noise! This means I’m down to MCP3201 territory with 11-12 bit.
This wouldn’t be so bad, but with so much time spent doing floating point math, at 160 RPM the code is struggling to make 200 samples before it has to update the calculations. This is skewed because I’m slowing it down a lot by sending data over USB. However it’s much slower than I can actually read out. Keep in mind that this is reading two sets of data.
So what is the problem? It’s now ratiometric so it should be more tolerant of voltage fluctuations. I’ve tested to see if I am causing any spikes in voltage due to magnets passing over it, that’s proven to not be a problem. I think it’s one of two things, the voltage regulator isn’t great causing some additional noise, or a higher quality ADC with more bits is needed.
Let’s look at one of the other problems mentioned, time calculating versus time reading. I’ve had the serial output tell me the running time before the zeroL and before and after zeroR. This is seen below.
Speed Time (Absolute)
Start Zero L Zero R
4mhz 8017 8914 9699
2mhz 8019 9037 9943
1mhz 8017 9277 10424
Well this seems peculiar, as the time only seems marginally affected by the SPI bus speed… also, the ADS8321 should not be run at higher than 2 Mhz, but seemed to function at 4 Mhz. I won’t do it again in case of damage, but it survived and I haven’t seen any anomalies.
Speed Time (relative) Time Reading  Time Calculating
Zero L Zero R Zero L Zero R
4mhz 897 785 121 776 664
2mhz 1018 906 242 776 664
1mhz 1260 1147 484 776 663
Interesting!!!
At 2 Mhz I’m spending 3 times as long to calculate as I am to read! So what is my code! Below is the zero command. I am summing to a “Long” from a short and then after 20000 reads it averages it out.
short zeroadcL()
{
   long adcl = 0;  //initialize a long variable
   for (int i=0; i < 20000; i++){adcl += long(readadcL());}
//     Serial.print(adcl);
//     Serial.print(",");
//     Serial.println(i);} //Read 1000 times
   return (short((adcl/20000))); //Output the average
}


I think this is a limitation of two things 8 bit and 8 Mhz microcontrollers. However, it puts me back on another issue; I need the microcontroller to spend more time sleeping. If I have to bump to 16Mhz on an 8 bit AVR type chip then I might as well hold off until I can move to the nRF51 which is 32bit and shouldn’t require so many commands to sum.


A lot to think about.

Saturday, December 8, 2012

Sorry for the Lack of Updates

I’d like to apologize for the lack of updates lately. I’ve been exceedingly busy at my day job. Long days testing has slowed the development of V3.

So where is it? The short is that V3 contains some bugs. I last had some zeroing issues which I believe is sorted by replacing the LM4140 with a voltage divider but it becomes hard to test this in conjunction with the magnetic pickup code. This is the major slowdown.

As a result I very much dislike the magnetic pickup. The code will need to be edited and trimmed I suspect. My research into gyro’s indicate they consume about 400 microamps. This isn’t much compared to the current consumption, but still adds to the target.

I’m actively exploring the nRF51422 and sorting out getting either an evaluation kit or development kit into Canada. After some back and forth NuHorizons seems that they thought they originally collected Canadian tax… however they do not. This means that a 99 dollar development kit costs 99 + 25 dollars shipping + either 19.45 or more likely 29.00 to process the customs and 13 dollars taxes totalling 166 dollars, or pay the 66 dollars for express shipping totalling 179 dollars as customs brokerage is included.

Symmetry Electronics seem a little more reasonable as the Fedex Express options are only 44 dollars and include brokerage processing, but it still totals 157 dollars for a 100 dollar dev kit.

While I had earlier mistaken that Digikey carries Nordic things they do carry Dynastream modules using the nRF24AP2. The difference is Digikey is express shipping for 8 dollars, or free ver 200 dollars and no brokerage! That would mean if they did sell Nordic products then it’s total cost would be 121 dollars shipped next day.

In terms of development costs 166 vs 157 vs 179 vs 121 shouldn’t be significant, however considering all the costs up until this point I’m about 2000 – 3000 dollars into development costs depending on if you include certain elements that I use (FR60 watch kit, Garmin Edge 500, programmers, tariff processing, etc). Keep that in mind if you think this is the cheap way out to getting a working power meter. (I could have bought 2 Quarqs or an SRM) That being said I’ve been pushing my budget for this project and there are huge limitations to the way it’s built right now.

The nRF51 would allow me to drive down the board / electronics costs. The AP2 Module is very expensive (25 dollars in low volume) compared with the cheap nRF51 ($2.63) and the AP2 module still requires a micro controller. Thought a finalized arduino style board is expensive, using an atmel atmega 32u4 is about $6.50. So even if I was to drop the pre-made board, the nRF51 still comes in cheaper by a significant margin.

Oh, and one more think nRF51422 (ANT+) is interchangeable with nRF51822 which means BTLE is possible without a significant change over in board design – in fact no change over! It’ll require different code (if BTLE ever pulls together a power meter profile).

To do:

Get V3 working well enough to make some videos of it working and post the board + code

Get nRF51 development equipment.