Friday, 25 April 2014

BlueFlyVario_TTL integration with the Kobo

Since I released the BlueFlyVario_TTL a few weeks ago many people have purchased one to integrate with the Kobo for use with XCSoar. The purpose of this post is to provide a few tips. It is by no means a complete tutorial for beginners. Integration with the Kobo requires careful soldering and software manipulation shills.

Step 1 - Get your Kobo

The Kobo mini is currently being sold for around $50. I understand they are no longer being produced and most stockists are getting rid of them at cost. Other devices such as the Kobo Touch can be used in a similar manner. At some stage these devices will be hard to find.

Step 2 - Make sure it works as a standard eReader

After purchasing the Kobo you should configure it like a normal eReader as per the instructions that came with it. This is important to do prior to installing XCSoar.

Step 3 - Back up the SD Card

The device has an SD card inside which includes the operating system and applications. Open up the Kobo and put the SD card into a reader. Create an image of it with win32DiskImager or your favourite sd card imaging software. Save the backup image somewhere where you will not loose it. Make sure to turn off the kobo prior to the next step.

Step 4 - Solder wires to the internal serial port

Take off the back covers and identify the serial port in the bottom left of the circuit board. The images below shows a good location for the wires and holes if you want your BlueFlyVario_TTL mounted on the front of the device. I have used a 4 port 2.54mm pitch dupont housing to plug the BlueFlyVario_TTL into. I drilled the holes from the rear and matched each size hole with the diameter of the wires. Note that the Rx from the Kobo needs to match to the Tx from the BlueFlyVario_TTL, and the Tx from the Kobo needs to match to the Rx from the BlueFlyVario TTL.


The holes were drilled from the rear. The solder residue on the serial port is from a previous installation.


The holes look pretty small from the front.

Push the wires through from the front prior to soldering.


Soldering the wires is a little tricky. I started with a dab of solder on each solder hole, tinned the trimmed wire with solder, then angled each one into the hole after reheating it with the iron. Note that the ground is much more difficult to solder as the heat is rapidly drawn away by the larger copper pour on the Kobo PCB.

Step 5 - Install XCSoar

The Kobo XCSoar image and instructions can be found here: http://www.xcsoar.org/download/.  I will not cover how to do this in great detail; there is heaps of information on the XCSoar forums and other internet resources to help you out.

Step 6 - Test the BlueFlyVario_TTL is working

After you have XCSoar working, and the Kobo is on, plug in the TTL to the front of the device. You should here it's startup beep. Next:

  • Double tap on the screen to bring up the Menu.
  • Go Config|Config 1/3|Devices
  • Ensure device A is selected and tap Edit
  • Change the following settings:
    • Port: ttymxc0
    • Baud rate: 57600
    • Driver: BlueFly Vario
    • Ignore checksum: On
  • Click ok, then Monitor to see the incoming data stream. 
Step 7 - Attach a GPS to the BlueFlyVario_TTL U1 port

Incoming GPS data (NMEA sentences) will be streamed via U1 on the BlueFlyVario_TTL and multiplexed with the BlueFlyVario output stream. XCSoar can read the combined stream from the single port. The image below shows a cheap NEO-6M module connected directly to the BlueFlyVario_TTL. The BlueFlyVario expects a 96008N1 serial input from the GPS. Read the section of the BlueFlyVario Hardware Settings Manual for more information about the second serial port. 



Step 8 - Configure the BlueFlyVario_TTL Hardware Settings

This bit was pretty tricky to work out. Thanks to Steve Nagle for his help. In fact, it was pretty much all worked out by him.

The aim is to alter the BlueFlyVario hardware settings directly from the Kobo (linux) command line without having to plug the vario into a windows PC. This is how you do it:
  • Restart the Kobo with XCSoar on it.
  • Press "Network" at bottom of screen. 
  • At top of screen press the button where it says "Wifi ON" (this turns the Wifi on - button then confusingly shows text "Wifi OFF" meaning that pressing it again will have that effect)
  • Press the button "Wifi" to select a Wifi network, connect to your network (The Kobo will display 'connected' next to network name on Wifi page).
  • Once connected press Close button on the wifi page
  • Use a pc and browser to log into your router to find out what network ip address it has allocated to your Kobo (my router is accessed by typing 192.168.1.1 into the browser address box - Google your router brand to find out what it's default internal ip address (and username / password is)
  • On the Kobo press the "Telnet server" button to start telnet on kobo
  • On your PC Telnet to the ip address you found with root as username, no password. In linux use the telnet command at the command prompt, or in windows download a program called Putty and use that. 
  • You should now have a command prompt on your PC. Your PC is now the screen and keyboard for your Kobo, which runs linux. (Type ls and hit return - you should get a directory listing).

Now communicate with the BlueFly over the serial port using commands as follows:
  • stty ospeed 57600 ispeed 57600 -F /dev/ttymxc0  'changes baud settings to match BlueFlyVario.
  • stty -F /dev/ttymxc0 raw  'makes sure the terminal program in linux sends off characters as they arrive.
If you want to see the BlueFly output do this (or skip it if you like)
  • cat /dev/ttymxc0  'test to display the output from BlueFlyVario
(here is a sample of output)
$GPGGA,025704.101,,,,,0,0,,,M,,M,,*4C
PRS 18681
PRS 18680
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
PRS 18680
PRS 18681
PRS 18680

Now press ctrl C to stop that. 

Now we will adjust some settings. These are just examples. See Annex A to the the Hardware Settings Manual for a detailed technical description of the settings. 

Type the following:
  • echo '$BVL 50*'>/dev/ttymxc0  'Sets the volume on the BlueFlyVario to 50.
  • echo '$BOF 10*'>/dev/ttymxc0 'This command changes the output rate to five sentences a second (from the normal 50 (i.e. 50/10)). I think this lessens the CPU workload on the Kobo to handle so many characters over the UART. 
  • echo '$BOM 2*'>/dev/ttymxc0 'This command changes the output format to the LX protocol. Again this lessens the workload on the Kobo as vario value (rather than raw pressure value) is read from the incoming stream. You need to also change the XCSoar driver from 'BlueFly Vario' to 'LX / Colibri' if you change this setting.
  • cat /dev/ttymxc0  'Again to test the display. 
Now press ctrl C to stop that. Type exit to quit. Turn Wifi off and reboot the Kobo. 

More Pictures

Below are some more pictures from Steve's install.






Next Steps

Installing the BlueFlyVario_TTL on the Kobo with XCSoar has proven pretty popular. I am working on another version of the BlueFlyVario_TTL which includes a GPS onboard so there is no need to do that step. I am thinking the PA6H will be a good fit. The board could end up looking like this:


Note the switch so you can continue to use it as a eReader without draining power. Before I get this working I need to add a new setting in the firmware which allows configuration of the GPS when it is attached. More work to do...


Saturday, 5 April 2014

BlueFlyVario_TTL version 8 released

I have spent many months working on the BlueFlyVario_TTL. This post announces a limited release. Anyone can purchase one, but it is ‘limited’ because you will need some electronics skill to make it work the way you want. I will release another version of this in the next few months with extra components, but I am still not sure what is the best configuration.

I made a deliberate decision to produce a simpler version of the BlueFlyVario, rather than pursue the standard approach taken by many developers to make something more complex. This is a lot harder than it sounds.

I initially decided to pursue something like the TTL in an effort to produce an audio only vario module with the same awesome audio which the standard BlueFlyVario provides. Wide interest in modifying the Kobo eReader pushed me towards exposing a TTL serial interface, but with only one port available on the simple eReaders I had to multiplex GPS information using the second serial port on the micro controller. Development of this lead to the change in the BlueFlyVario version 8 which I released in the previous blog post.

Description

Compared to the standard BlueFlyVario with Bluetooth, the baseline BlueFlyVario_TTL is simply just a populated PCB which is programmed with the BlueFlyVario firmware. There is no Bluetooth module, battery or case. The key specifications are summarized in the image below:

  • 1: Second serial interface. A serial port of the PIC microcontroller (UART1) is exposed with V+, Rx, Tx and GND (3.3v). By default it is configured at 9600 Baud to accept NMEA sentences from widely available GPS modules. Sentences starting with $ and ending with /n (carriage return character) are stored then immediately multiplexed with the information being sent out the primary TTL Interface. XCSoar is smart enough to interpret the multiplexed stream via a single device.
  • 2: Pressure sensor. The MS5611 pressure sensor is a super accurate little temperature compensated module with a digital interface. The surrounding components filter the power supply. When shipped this component is covered with neoprene to avoid light sensitivity (but do not press on it when active to avoid touch sensitivity). 
  • 3: Microcontroller. The PIC24F16KA301 is running at 8MHz. This is fast enough to provide advanced Kalman filtering of the pressure measurements (which is reads from the pressure sensor at 50 times a second). At this speed the micro controller can also handle reading and sending data over the two serial ports. 
  • 4: Speaker interface. Super keen experimental users might want to integrate the audio signal into a headset. 
  • 5: Solder jumper. If you want to disable the integrated transducer clear this solder jumper.
  • 6: Status LED. This lights up with every beep. 
  • 7: TTL Interface. The primary interface (which is actually UART 2 on the microcontroller) is used to provide power to the device and send and receive data via Tx and Rx (at 57600 kps). See the hardware settings manual for detailed information about the interface.
  • 8: Programming Pads. I program the firmware using a PICKIT 3 and this pads. Short pads 2 and 4 when turning on to reset the hardware settings (see the Hardware Settings Manual). 
  • 9: Voltage Regulator.  A Microchip TC1015 LDO voltage regulator outputs 3.0V to run the micro controller and pressure sensor. It works with input power between 3.3V and 6V. Below about 3.2 V it fails to provide a stable voltage to the pressure sensor. Standard 3.3V in from other low voltage TTL devices (such as the Kobo) work well. 
  • 10: Audio. An integrated small electromagnetic transducer provides the kind of pleasant sounding vario that is normally reserved for bigger devices. 

Use

To make the TTL work you will need to do the following:

  • Provide power. I have deliberately not included a battery and switch. There are so many options and everyone has a slightly different need. You might choose to power it with a 1S LiPo, 3 x AAA alkaline batteries, power from USB, or power it from a Kobo. Whatever you choose you need to do ensure you meet the following specs.
    • Voltage: The TTL needs between 3.3V and 6V at the V+ pin on the main TTL interface end (do not provide power to the other end).
    • Current: The device consumes 10mA when not making noise, and around 50-60mA when sounding. Assuming a duty cycle of silence:noise of about 4:1 the average current consumption is about 20mA.
  • Provide a programming interface. A USB to Serial connector provides the ideal programming interface. This is used to configure the hardware settings if you want to change the defaults. You can get cheap USB to TTL serial converters on ebay, at hobby king or electronics shops like Sparkfun. I am considering including one in future releases of the TTL. 
  • Provide a data interface for external applications. If you want the vario data to be sent to an external application you can use the aforementioned USB to Serial convertor (for devices that support such a converter). Other devices (such as the Kobo) can be wired directly to the Tx and Rx pins. 


I envisage that the TTL can be used in many ways once it has been configured via the programming interface. Some examples:

  • Audio only mode. In this mode you only need to provide power and it will work. Something like a 3 x AAA case with integrated switch should meet the needs of most people. I am considering including one of these in future releases with the baseline configuration.
  • Integrated Helmet vario. The board is small enough to be integrated into a helmet. In this configuration a small RC 1s LiPo of around 600mA provides heaps of juice. A switch in series allows it to be turned on and off in flight. 
  • Integration via USB to a Linux device. Some users in sailplanes might want to integrate the vario directly into a Linux device via a USB to serial interface. I understand a few people are going to try to encase the vario and connect it to the TE probe. I am keen to get feedback. 
  • Integration with a Kobo. The picture below shows how I have integrated it with the Kobo on my workbench. In this configuration the Kobo is providing power to both the BlueFlyVario_TTL and the attached GPS module. This type of GPS module, based on the NEO-6M chip, is widely available and the default settings should work for most users. 



Schematics

The images below show the schematic and PCB layout for the BlueFlyVario_TTL version 8 prototype.