Friday, 19 April 2013

Hardware Audio Integration

The last few weeks have been dominated by continuing recovery from my accident at the end of last year. While that has been going on I have sent out the last few version 5 prototypes, and have been tinkering with the initial version 6a prototypes to finalise the hardware and firmware design for version 6. The most important outcome of this is my new plan to add hardware audio from version 6. The good news is that the vario will beep when not connected via Bluetooth (providing you are going up). The less good news is that all of this will delay the release of version six to some time in May.

So, how will it work. Essentially, when you turn on the vario it will start in hardware audio mode. If you go up above the lift threshold it will start beeping, if you go down below the sink threshold it will sound the sink alarm. Like other advanced varios, the audio frequency changes dependent on the lift/sink rate. For example, for the lift settings, by default the audio frequency is 700 Hz at 0.0 m/s, then increases by 10 Hz for each 0.1 m/s. The cadence also decreases from 0.5s to about 0.25s as lift increases from 0.0 m/s to 3.0 m/s. When (if) the Bluetooth connection is made the hardware audio turns off and the connected device provides the audio. If no Bluetooth connection is made within about 5 minutes then the Bluetooth is turned off to save power.

Like most of what I do, I want the audio settings, and things like the Bluetooth scan period, to be configurable. I will do this by adding a few features to the Android app that sets features on the BlueFlyVario hardware audio mode.

I spent quite some time testing a range of buzzers. I started with piezo buzzers like everyone else. I 'drove' a few using the PWM (Output Compare) from the PIC. To do this I have had to alter my planned 6a layout to swap a few pins around. The main problem with piezo buzzers in my design is twofold. First, piezo buzzers are generally driven by a higher voltage than 3V in order for them to be loud. Adding a charge pump circuit is quite a big change that I am not going to make. Second, the resonant frequency is around 4000 Hz. They are not so loud at 700 Hz.

For those reasons I chose to consider electromagnetic buzzers. They have the advantage of being smaller, having good SMD options, having better frequency response in the range I am interested in, and able to be run at 3V effectively. The main disadvantage is the need for additional components including a switching transistor and a back EMF protection diode. Overall the additional component cost is less than $2. The buzzer I am probably going to use is listed here http://au.element14.com/jsp/search/productdetail.jsp?SKU=2135919. The one I have in the test bed at home appears as loud or louder than other audio only varios. See the picture below where I have hacked in a 8mm x 8 mm buzzer. I will need to tweak the PCB layout to make it all fit...



Power consumption changes a bit. I intend to ensure there is sufficient resistance in place for the buzzer so that power consumption is less than when connected via bluetooth, without negatively effecting the loudness. This should mean that battery life will still be well over 12 hours.

As part of this tinkering I have conducted a few tests of the latency associated with the transmission of data from the BlueFlyVario and time taken by Android to respond by beeping. My test setup, with a custom app and a test firmware on the vario, essentially beeped on the hardware, then sent a signal to the Android device saying beep as soon as you can. I recorded the output in Audacity to roughly measure the delay. It varied a little depending on the code order on both devices, but by far the biggest delay is the responsiveness of the audio subsystem on the Android device. I am using older Andriod code which adds over 100 ms of latency. Newer Andriod versions (4.1) and devices are targeting 10ms or less of latency. (http://createdigitalmusic.com/2012/07/android-high-performance-audio-in-4-1-and-what-it-means-plus-libpd-goodness-today/) But for the moment for most devices the total latency averages to 150ms, which is noticeable but probably not really significant for most pilots. However, it will be for some. This means that I think that some pilots will prefer the audio to be from the hardware rather than the Android device, even when connected via Bluetooth. More custom settings...

Oh, and finally, to support the hardware audio, I have implemented a Kalman filter on the PIC micro-controller  This is going to be in the Android app as well to replace the relatively clumsy linear regression + IIR filter. 

Thursday, 21 March 2013

Experimenters Version


I am toying with an experimenters version of the BlueFlyVario. I got a batch of circuit boards made, but have only populated one for my own use. The idea is to expose all of the spare micro-controller pins so daughter boards can be designed to provide additionally functionality. Additionally, the In Circuit Serial Programming (ICSP) pins have been exposed to allow easy reprogramming of the micro-controller using a PICKIT 2 or equivalent programmer. A picture of the board design is shown below. The pins are exposed in a 0.1" series of through holes to allow standard headers. It is possible to still put the board in the DP5031 case I used for prototype version 5 (and intend to use in version 6).



Up until now I have used software SPI (bit banging) for the interface between the PIC24F16KA101 and the MS5611 pressure sensor. In this experimenters version I have moved the interface to the hardware SPI pins on the micro-controller. This has meant a pretty significant change to the firmware. It also means that adding additional devices to the SPI bus becomes less of a hassle.

The exposed pins will allow additional (spare) PIC24F hardware features to be used; including an AD channel, UART, I2C, and general IO pins. I will be using the experimenters version to get the code right for prototype version 6 (which is just the same as version 5 to look at, but will be easier to make and is electronically much more similar to this experimenters version). I have lots of ideas for daughter boards and altered firmware. These are all independent ideas, I am not thinking of doing them all in the one device!:

  • Two additional pressure sensors configured in such a way that allows connection of pitot and static tubes.
  • An LCD screen display (I have pretty much got a Nokia 84 x 48 LCD screen working already on a breadboard)
  • A small ePaper display (something like this  http://www.seeedstudio.com/depot/eink-display-shield-p-1374.html?cPath=132_134; or without the arduino integration overhead http://www.aliexpress.com/store/product/E-ink-e-paper/600281_563811171.html)
  • Integrating two high resolution 1D accelerometers. These would be physically connected to each riser. The idea is to see if I can measure the 'feeling' of wing feedback we get to improve the flight instrument. 
  • Integrating an ISM RF transceiver to transmit the vario data over ranges up to a few km. 
  • Integrating a GPS receiver to get better data than what a phone spits out.
  • Integrating a speaker to develop the code for audio output.


I still expect that the standard version 6 hardware will be what most people will want. I am intending to get quite a few of them made. The experimenters version 6a will be available in much more limited quantities for those that fell they have the electronic design skills to make use of it. My aim is to release both by the end of April with firmware code and updated schematics.

Thursday, 28 February 2013

Prototype Version 0.5b

As I recover from my accident I have been doing a little work progressing the prototype hardware to the next version. This version incorporates a few user suggestions, improves the look, and is slightly easier for me to make.

A summary of key changes from version 0.4b:
  • A new case based on the Dangerous Prototypes Sick of Beige DP5031. This is slightly smaller than a tic-tac box in length and width, but it is a little thicker. The extra $1.50 compared to a box of tic-tacs is worth it, considering that final assembly is easier, it is noticeably smaller, and it looks way cooler. A few people have mentioned that they are concerned that the sides are exposed. I am not. If you are, just put the whole thing in a small ziploc bag or 40mm heatshrink. 
  • I have switched from mini USB to micro USB for the charging point. This is the same as pretty much every Android device and it should be easier for most people. The connector is a little more flimsy, but I have been generous with the amount of solder I use to keep it on. 
  • I have changed the battery type to a 35x30x6mm 600mAh LiPo. This smaller capacity is a compromise based on what was available (I could not get more of the old one) and what would fix in the new case. The battery life is now around 12 hours, which is still way more than is really needed. 
  • The new PCB layout is a little neater. All of the LED's are lined up on the side. The RN42 antenna does not hang over the edge of PCB. Apart from looking cooler, this results in the device being easier to make.
  • I have changed a few of the tantalum capacitors to ceramics. This has reduced the electrical noise by about 10%.
I have only made a small run of prototype version 0.5b. There are a few available through the order site. See the image below:



Prototype version 0.6b is in the works. It will be very similar to version 0.5b, but with a few more PCB layout tweaks to make it even easier to manufacture. I intend to release the complete design files for that version under some sort of permissive free licence (including PCB gerbers, schematic, and PIC24F code).



Saturday, 9 February 2013

XCSoar Integration

Great news! Thanks to the XCSoar dev team (particularly Tjeerd), the BlueFlyVario is now integrated with XCSoar. For the moment the integration is in the XCSoar testing app available on Google Play here https://play.google.com/store/apps/details?id=org.xcsoar.testing&hl=en. I understand that features in the testing app will migrate to the stable version over time. Because of my injury I have not flown with this yet so my comments are based on testing on the desktop.

The BlueFlyVario pressure data sent via bluetooth is used by XCSoar in a similar manner that would be used to process pressure data from an internal pressure sensor or a serially connected device. The current implementation uses a Kalman filter to smooth the data. (http://git.xcsoar.org/cgit/master/xcsoar.git/tree/src/Device/Driver/BlueFlyVario.cpp). It provides XCSoar with barometric altitude and vario data (see line 90 and 92 of the driver).

A few tips to getting it working:

  • Make sure you have paired the BlueFlyVario with your device prior to starting up XCSoar. You should only ever need to do this once (not every time you use it). 
  • Ensure that your device's bluetooth radio is turned on prior to starting XCSoar. 
  • Ensure that the BlueFlyVario is turned on prior to starting XCSoar. 
  • Click Menu|Config|Config 2/3|Devices (You can also do the same thing through Menu|Config|Config 2/3|System|Setup|Devices - this is what the screenshot below is from). Select a disabled device and click Edit (probably "B: Disabled" if the only other device you have connected is the internal GPS). Set the "Port" to the particular BlueFlyVario device (you will only see the BlueFlyVario device here if the bluetooth radio is turned on). Set the Driver to "BlueFly Vario". At this point you might need to close and restart, perhaps reboot the device, maybe use the reconnect feature. It was a bit fiddly for me the first time around. For me now, the BlueFlyVario connection to XCSoar seems pretty robust and happens automatically. 
  • You might like to switch a few of the info boxes around. The Vario Trace one is handy to get good feedback from testing. Don't forget that to get the Barometric Altitude working you need to set QNH.
  • You might like to turn on the Audio Vario gauge.
  • You might like to change the "Look" by setting the InfoBox geometry to one that includes the  word Vario in it. 

An example of what the setup should look like.
How you could configure the screen to included extra data from the BlueFlyVario.
A todo in the XCSoar code is to do something with the BlueFlyVario battery status that is sent every ten seconds. I am not sure if that will end up being used. 

This does not mean I am going to give up on developing my BlueFlyVario android app. There are many things I still want to do with my app that I could not do easily in XCSoar. Additionally, my understanding of C magic is quite poor. I will stick with developing my stuff for Android in Java.

Tuesday, 22 January 2013

Update

I have been out of action for a few weeks after a nasty towing accident that resulted in my broken neck and other relatively minor broken bones. A full recovery is expected but it will be a number of months. 

I have shipped all back orders, made enough extra prototypes to satisfy demand up to now, and there are still a few more left. With the clarity of thought from relaxing on my back for a while I have decided to continue making prototypes, albeit I will modify the design slightly to make them easier to manufacture at home. I investigated commercial manufacture but all options with quantities less than thousands would end up almost doubling the sale price. So, for now, expect some time in the next few months, a slightly updated prototype design and being able to order more prototypes. 

You can continue to order the current prototype on the website http://alistairdickie.com/blueflyvario

Sunday, 23 December 2012

Android app released under GPL

The android app has now been released under the GPL. You can find the source on GitHub. 

Website and ordering prototypes

I put together a simple website to summarize the important stuff. Also you can now purchase limited quantities of the prototypes.

http://alistairdickie.com/blueflyvario