Wednesday 31 December 2014

BlueFlyVario_USB_v10 released

Almost a year ago I started planning for an audio only vario to complement the original BlueFlyVario. I got a little distracted keeping up with orders of the Bluetooth version and the TTL_GPS (because of Kobo vario revolution). I started planning an audio vario again about six months ago. After settling on features, testing and producing an initial batch I am now very happy to announce a limited release the BlueFlyVario_USB_v10.


Design Philosophy

When designing this new vario I wanted to achieve a few things:

  • Build on the work of the successful Bluetooth model by providing a simple device designed for audio output. The firmware is pretty much the same as the Bluetooth and TTL_GPS models. 
  • Make it smaller. I wanted it to be easily able to fit in a helmet. I think this is the smallest vario available for purchase - it is about the size of a AA battery. 
  • Power with a rechargeable battery. Replacing batteries is a pain, but recharging is something we are really used to with our phone. The vario has a micro-USB connector which is the same as most phones. 
  • Provide a simple interface to alter the hardware settings. I considered having a separate USB-to-TTLSerial converter, but settled on incorporating a FTDI FT230X chip to provide an onboard emulated serial port. This only costs a few extra dollars, and does not take up too much board space (especially since I have now moved to using 4 layer PCB's). 
  • Expose the spare UART and audio interface for hacking. 
Because of all of this it ended up being more than just another audio only vario. The USB interface to change hardware settings and hack-able features makes it much more useful. 


Key Specifications

The BlueFlyVario_USB_v10 key features are:

  • Sensitive MS5611 pressure sensor with 10 cm resolution. 
  • Pleasant sounding audio tones, similar to fully featured varios. 
  • Onboard electromagnetic micro speaker (loudness 95dB). 
  • 250mAh rechargeable LiPo battery with 1.25mm Molex connector. Lasts about 10 to 20 hours depending on audio settings. Fully charge in about an hour. 
  • Onboard FTDI FT230X USB Serial chip. The device appears as a serial port with default drivers on most operating systems.  
  • Mass of about 9g. 
What is in the bag?

You need to do the final assembly yourself. You get the following bits in the bag:
  • The main module. This is 50mm x 12mm. 
  • A small piece of neoprene. This is really important. It must be placed over the pressure sensor if the sensor is exposed to any light. The neoprene allows the air pressure through, but stops the light. Light makes the pressure sensor go crazy.
  • A small 250 mAh battery. This is a single cell LiPo with a 1.25mm Molex connector. 
  • A small piece of blue PVC heatshrink. The simplest of cases is all you need. 


    Assembly

    Assembly should only take about five minutes:
    • Step 1 - Attach the battery. Remove the cover of the double sided tape and stick it to the bottom of the circuit board. See the placement in the image below.
    Battery placement
    • Step 2 - Do a quick test. At this point press the button to turn it on. You should hear a few beeps. The number of lower pitch beeps between the high pitch 2 second beep and short 0.5s beep indicate the battery voltage (6 = full, 1 = almost empty). Press and hold the button for 3s to turn it off.
    • Step 3 - Cover. Place the small piece of neoprene over the pressure sensor then encase the whole device in heatshirk. You will need to open up the heatshink to fit it over the button. Make sure the neoprene is covering every part of the sensor. 
    Neoprene placement
    Heatshrink placement
    • Step 4 - Shrink. Use a hairdryer on hot or a heat gun on very low to shrink the heat shrink. The switch might turn on. After shrinking, carefully slice the heatshink from the top of the switch, then shrink a little again. Test again to make sure the switch is working. 
    After shrinking
    Slice heatshink from top of switch
    A neat little circle
    After shinking again around the switch
    • Step 5 - Charge the battery. Plug in to a phone charger to charge the battery. The red LED will come on, then turn off when fully charged. [Note that as soon as you apply power to the micro-usb port that the device will turn on. This is because of stray current from the FTDI chip into the uart on the micro. Every ten minutes when on charge it will power down (based on the auto off feature), then power back on. The auto-on with recharge was an 'unintended feature' of this design. I might change it in the future with a couple of extra resistors in the design.
    • Step 6 - Alter the hardware settings. Most people will probably want to change the sink alarm from the default -0.2 m/s to something like -2.0 m/s (this stops the annoying sink alarm and reduces power consumption). Visit the support page of the website to download the BFV desktop app and the hardware settings manual to understand how to do it. 
    Advanced Use

    There should be a whole bunch of other things that this vario will do for advanced users. The pressure stream coming from the vario means that if you want to use it with an external application like XCSoar then it should be possible, provided the FTDI device enumerates properly on the device. This is only possible on Android/Kobo with some software hacking which I have not done yet. I have not tested this yet on anything other than the desktop version of XCSoar

    At some point I will update the BlueFlyVario Android app to allow the device to be used with a USB OTG connector.

    Design

    Like always; I share the design. Intrepid hackers might attach a GPS to the exposed U1 UART port or an external speaker. SJ1 and SJ2 provide for different power options. See the images below. 



    Friday 12 December 2014

    Firmware

    From version 10 the BlueFlyVario models include a bootloader so you can upgrade the firmware. The firmware is the chunk of code on the microprocessor which makes the Bluefly wield its magic. Current firmware versions use about 60% of the code space on the microprocessor, so there is some flexibility to add a few features within the limits of the hardware. Normally you need a special microcontroller programmer to update the firmware, however with the bootloader you can do it over a serial connection without the special programmer. In this post I will describe how the the bootloader works and how to update the firmware.

    The ds30loader bootloader

    The bootloader is a small section of code which runs before the main Bluefly code. For a whole range of reasons I selected the ds30loader that Michael worked on a few years ago as an open source project (it is GNU licensed, it is used in other devices, I could make it work... etc. ). This same bootloader is used in the bus pirate and other open products. Since Michael did the open source project the bootloader is also available in a commercial version, but I used the GNU licensed one as I wanted to customise it.

    You can download the modified source code for the bootloader from my github. You do not need the source, but some people might find it interesting. The source for the bootloader is in assembly and is set up as an XC16 MPLABX project. The bootloader is modified from Michael's original version with the following features:
    • The various settings (configuration bits, timeouts, processor, etc) recommended to be adjusted have been made to match the Bluefly hardware.
    • The bootloader mode will only be entered if RA0 is positive. This corresponds to programming pad #5 on the Bluefly hardware (PGEC). As programming pad #2 is positive then the bootloader mode will be entered if pins #2 and #5 are shorted.
    • When in bootloader mode the green LED is lit but there are no normal startup beeps. This provides some feedback so you know you are in bootloader mode.
    To use the bootloader you will need the ds30loader gui PC application. You can download it directly from here.

    Firmware Versions

    The firmware is contained in a .hex file. From version 10 I started a new numbering system for firmware. I will put all version 10 firmware versions on the support page of the website. The numbering scheme works like this:
    • BlueFlyVario_{DEVICE_TYPE}_v{MODEL_NO}.{TYPE_NO}{SUB_VERSION_NO}.hex where:
      • {DEVICE_TYPE} = Bluetooth, TTL_GPS or USB
      • {MODEL_NO} is associated with a particular series of hardware. (i.e. version 10 for the version 10 models).
      • {TYPE_NO} is associated with the DEVICE_TYPE (Bluetooth = 1, TTL_GPS = 2 and USB = 3).
      • {SUB_VERSION_NO} is the version of the firmware.

    For example BlueFlyVario_Bluetooth_v10.102.hex is the second release of firmware for model 10 Bluetooth hardware.

    Step 1 - Get the software

    Get the ds30loader gui application using the link above and make sure it runs on your pc. Download the right version of the firmware you will need.

    Step 2 - Prepare the hardware

    You will need access to the programming pads on the pcb so you can short pads #2 and #5. You might need to disassemble the Bluefly so you can access the pads. A small hole in the heatshrink might be sufficient. See the image below for an indication of which pads I am talking about.



    You will also need to establish a serial connection. You can test your serial connection using the BFV Desktop application or a terminal emulator like Realterm:
    • Bluetooth version: you should add the vario as a device to the PC (you might need to use code 1234 to pair it via the Devices and Setting menu, it depends on your Bluetooth adapter). You will need to work out what serial port it was assigned by looking at its properties.
    • TTL_GPS version: you will need a TTL to serial adapter. Depending on how you installed the TTL_GPS you might need to solder things. Again you need to work out what serial port the TTL to serial adapter has been assigned.
    • USB version: the serial port is assigned when the device is first connected to your PC.
    Step 3 - Open the ds30laoder application

    Open up the ds30loader application. Adjust the settings to match the following:
    • Hex file: Browse to the location of the firmware hex file you downloaded (make sure to unzip it)
    • Device: PIC24F
    • Model: 32KA301
    • Baud: 57600
    • Port: What ever serial port you plan to use based on the one you determined in Step 2.
    • Write flash: Checked
    • Flow control: None


    Step 4 - Start up the Bluefly in bootloader mode

    You will need to short programming pads #2 and #5 then power on the Bluefly module as described in the image above. You should just be able to use a paperclip bent appropriately.
    • For the Bluetooth version, press the power on button while the pads are shorted. As soon as the green led lights up solid you can remove the short. 
    • For the TTL_GPS you will need to power the module using something like a TTL to Serial adapter. Press power then when the green LED lights you can remove the short. 
    • For the USB version it will power on as soon as you attach it to the USB port of your PC, so make sure the pads are shorted when you attach it (you might need three hands).

    If the green led lights up and stays lit you are in bootloader mode. You should not hear any of the normal beeps associated with startup.

    After entering bootloader mode you have 60 seconds to complete the next step. If you do not program within 60 seconds the device will exit the bootloader mode.

    Step 5 - Program the device

    Press the Write button in the ds30loader application. The application should connect to the Bluefly and start programming. It takes about 20 seconds.

    When programming is complete the Bluefly will start like normal with the new firmware. You can connect it to the BFV Desktop application to confirm the new version is uploaded.