Flyport WiFi

 The retailer boxtec (www.boxtec.ch) has provided me with a openPicus flyport WiFi board for testing. As the module itself cannot work without a supporting board that provides USB and power connectivity, a so called "nest" is needed. boxtec provided me a flyport to arduino shield which not only provides USB and power but a arduino UNO compatible shield socket. On this adapter shield, there is no arduino. (First release 0.9, 26.03.2012


Table of Contents
Test Protocol
Technical Inspection
Software Installation
First Light ...
First Project
Inserting the Arduino Shield
Preparing the KeyPad
Verifying the Pin Asignment
Programming openPICUS
Writing to the Nokia 5110
Changing the AJAX/CGI scripts
Summary
Download
Funny Idea

 Test Protocol

 Technical Inspection

Flyport to Arduino Shield

In Contrast to the picture in the boxtec shop, I received the latest version with a new board print in white and the change, that the right-most connector J6 is not staffed with a pin connector.

 

 

 

 

 

 

 

 

The picture shows the board with J6 unfilled. The optical inspection shows a professional board that reminds me the boards that you receive from fritzing. The USB connector is of type B with metal case. I recommend to immediately insulate this housing with scotch tape to avoid short circuits with arduino shield reaching over the USB port.

As test shield, I decided to use the Nokia 5110 LCD with keypad shield.

Flyport WiFi Module

This module is absolutely new to me. The documentation is limited and I will see where I get. The first surprise of the module is the size: it is really small (35*48 mm)!

The board is minimalistic and has a PIC processor, the WiFi module with MAC address printed on it and a voltage stabilization:

Name FlyPort WiFi Antenna
Hardware revision 1.0.2
Firmware BTS 1.0.0
Serial Number 1396
MAC 001E C006 AAC4
Processor PIC 24FJ256 GA 106

This 16-bit processor has 256kB memory, 16kB SRAM and runs on 32 MHz. The full data sheet I found at the open hardware resource picus page

When inserting the module on the Flyport to arduino shield, use some of the shipping foam to support the module as it hangs freely in the air only supported by the connector.

 Software Installation

The next step is to install the software on the PC. The hosting OS I use is Windows7, 64bit. On this platform you need

  • .net framework 4.0
  • C30 Microchip Compiler (3.24 lite version)
  • OpenPICUS IDE 2.1

C30 Compiler installation

The installation package is a compressed exe with 44 MB size. After the installation, which runs straight forward without issues, the compiler consumes 270 MB disk space. During the installation, the system PATH variable is changed to include the compiler. There is no entry in the windows start menu and no desktop icon after the installation. This is no surprise, as the IDE will take care of calling the compiler.

OpenPICUS IDE installation

The ~5MB installation files installs without problems into ~9MB on disk. The image shows the first start with a basic project created.

 

 First light ...

as astronomers say, when they power up their telescope the first time.

Windows device driver

The FT232R USB UART is not recognized by the OS, the device driver installation fails. However, the serial port (in my case COM7) is initialized. A check with the device manager shows the COM port to be working correctly.

The power light on the Flyport module is green and the power light on the arduino shield is red.

OpenPICUS IDE - RTFM

As I will not write a new guide to openPICUS, I now check the manual and the following documentation will refer to the manual of IDE 2.1

 First Project

I start creating a new project using the WiFi 2.1 - Webserver example as start. Compiling the example gives no errors:

-------- OpenPicusIDE: Start Project Compilation --------
Compiling C:\Opt\OpenPicus FlyPort IDE\Microchip\WF_Utils.c
Compiling C:\Opt\OpenPicus FlyPort IDE\Microchip\TCPIP Stack\HTTP2.c
Compiling C:\Users\Mathias\Documents\openPICus\test webserver full\HTTPApp.c
Compiling C:\Users\Mathias\Documents\openPICus\test webserver full\HWInit.c
Compiling C:\Users\Mathias\Documents\openPICus\test webserver full\Main.c
Compiling C:\Users\Mathias\Documents\openPICus\test webserver full\taskFlyport.c
Compiling C:\Users\Mathias\Documents\openPICus\test webserver full\WF_Events.c
Compiling C:\Users\Mathias\Documents\openPICus\test webserver full\MPFSImg2.s
*                     Total program memory used (bytes):        0x247b9  (149433) 57%
*                        Total data memory used (bytes):         0x20ec  (8428) 51%
----------------------------- End Project Compilation ------------------------------------
---------- Started at 18.03.2012 16:37:58
---------- Completed at 18.03.2012 16:38:06
---------- Duration (hh.mm.ss) 00.00.08
------------------------------------------------------------------------------------------

Downloading works ok, you just have to accept, that they call the load of your program downloading firmware (which made me hesitate a bit). After the download, the LED OUT5 goes on on the Flyport module and my laptop shows a new ad-hoc network called FlyportNet. By default, the settings of that example are to provide DHCP and the assigned IP address for my laptop is 192.168.1.2, subnet mask 255.255.255.0 and gateway 192.168.1.115, the IP address of the Flyport. Connecting to the flyport IP gives the following homepage of the flyport:

 Inserting the arduino shield

When inserting the arduino keypad shield with the Nokia 5110 inserted, the Nokia 5110 flashes once and the LCD backlight goes off. As the shield wiring is connecting the LCD backlight permanently to VCC, the LCD should be on. I disconnected the LCD and the shield and tested with an arduino that there was no damage and the Nokia 5110 is ok. Verifying the voltage on the pins returned 0V on the power lines for the LCD. When I reinserted the shield after I checked the shield on the arduino, the power to the LCD was at the expected 3.3 V (the keypad shield converts the 5V from the board to 3.3V for the LCD). It looks like there was a connector problem (dirt?). From now on, the LCD shield is on as expected.

 Preparing the keypad

I selected the keypad as it can be read in a simple way. To scan the key pressed in a row, the column pin of the row is set to high and the row pins are read. The pin mapping of the shield and the new pins are shown in the following table:

Keypad function Arduino Pin Flyport Pin
col 0 7 9
col 1 6 5
col 2 5 14
col 3 4 12
row 0 A5 21
row 1 A4 19
row 2 2 10
row 3 3 12

The picture shows the keys as they are assigned with the same numbering as on the Iteadstudio.

The Nokia LCD is inserted in socked 3

 Verifying the pin assignment

Using a code similar to the blink example from the arduino IDE, I verified the assignment of the pin numbers of the Flyport compared with the pins on the shield. While firing A4 (19) and A5 (21), I realized that the led OUT4 and OUT5 on the Flyport were flashing in sync with the pin state. However, this did not interfere with the operation of the Flyport as a webserver.

More difficult was the fact, that the arduino pins 0 and 1 (D0 and D1) are used for the serial communication. They are both HIGH by default and pin D1 must be remapped using IOinit(1,SCI_OUT). However, if this pin is used, the serial communication will no longer work. Even worse, the IDE got hung up on the communication and the serial monitor was no longer working. The only way to get this back to work was to reinstall the openPICUS IDE. For all shields that use the arduino pin 1 (D1), the pin must be remapped and serial communication is not possible. This is the case for the ITDB02 Color LCD shields.

Here now the complete pin map:

Arduino Flyport Comment Arduino Flyport Comment
13 8 ok A0 23 ok
12 2 IN5 A1 25 ok
11 17 OUT3 A2 18 ok
10 6 OUT2 A3 20 ok
9 4 OUT1 A4 19 OUT4
8 7 IN2 A5 21 OUT5
7 11 IN4      
6 9 IN3      
5 5 IN1      
4 14 ok      
3 12 ok      
2 10 ok      
1 15 UART1TX      
0 13 UART1RX      

The predefied ports of the Flyport and their link to the arduino shield pins are shown in this picture:

Flyport - Arduino pins

 

 

 

 

 

 

 

 

 

 

Now the next step is to create the readout routine based on the arduino library to read the keypad.

 Programing openPICUS

If you come from the arduino IDE, sit back and relax - the openPICUS uses a ANSI-C compiler! At least it is not Fortran77 but it means NONE of the arduino libraries will work as they use C++. But first things first:

The empty example consist of two files to edit, one called taskFlyport.c and it looks a bit like the default arduino sketch:

#include "taskFlyport.h"

void FlyportTask()
{
    WFConnect(WF_DEFAULT);
    while (WFStatus != CONNECTED);
    UARTWrite(1,"Flyport connected... hello world!\r\n");
    while(1)
    {
// your loop code here
    }
}

The first lines are the setup() part and the while(1) works as the loop(). However, this example will not run correctly and produce garbage at the serial monitor. You have to initialize the serial port first. So the arduino blink example looks like this (D13 is mapped to pin 8)

#include "taskFlyport.h"

void FlyportTask()     UARTInit(1,9600);    UARTOn(1);    WFConnect(WF_DEFAULT);    while (WFStatus != CONNECTED);    UARTWrite(1,"Flyport connected... hello world!\r\n");    IOInit(8,out);    while(1)    {        IOPut(8,on);        DelayMs(1000);        IOPut(8,off);        DelayMs(1000);    } }

I converted my Nokia5110KeyPad library into this C dialect and imported it as external library (the .cpp file has to be renamed .c). To my surprise, the keypad read routine worked and returned the number of the key pressed:

#include "taskFlyport.h"

void FlyportTask()
{
    int keyNum, lastKey;
    char outstr[] = "key pressed    ";
    KeyPadInit();
    vTaskDelay(200);
    UARTInit(1,9600);
    UARTOn(1);
    WFConnect(WF_DEFAULT);
    while (WFStatus != CONNECTED);
    UARTWrite(1,"Flyport connected... hello world!\r\n");

    while(1)
    {
        keyNum = KreadKey();
        DelayMs(20);
        if (keyNum != lastKey)
        {
            sprintf(outstr,"key pressed:%d", keyNum);
            if (keyNum>0)
            {
                UARTWrite(1,outstr);
                UARTWrite(1,"\r\n");
            }
        }
        lastKey=keyNum;
    }
}

The next step is to initialize the Nokia 5110 ...

 Writing to the Nokia 5110

The Nokia 5110 is a simple serial LCD and the 4x4 keypad shield maps the LCD pins to the arduino pins as follows:

Nokia 5110FunctionArduinoFlyport
1 power VCC VCC
2 ground GND GND
3 SCE 12 2
4 RST 11 17
5 D/C 10 6
6 DN(MOSI) 9 4
7 SCLK 8 7
8 LED VCC VCC

As a first test I insert before the while(1):

Nokia5110Init();           // initialize the Nokia 5110 display (default=black)
NdrawRect(10,10,30,30, 2); // draw an empty rectangle with white borders)
Nupdate(); // show the changed display memory

And the display works as expected! Now I want to write text to the display. This requires a font to be loaded - which I succeeded. The Nokia 5110 display now shows the library demo I hve written for the shield to be used on the arduino.

 Changing the AJAX/CGI scripts

The goal should be to see the keys pressed on the web page of the server. For that I will see if I can tweak the existing code as I do not intend to dig into AJAX programming. I therefore only chaged the button line in the index.htm file to show a 4x4 button grid and modified the calling routine to query 16 instead of 5 buttons and updated the sttus.xml file accordingly. After that, I changed the HTTP routine to query the keybord nd return the button state. The way to update the web pages is a bit complicated: You hve to use the WebPages button of the IDE to re-generate (import) the files and then re-compile the code and download the hex file.

At the end, the whole thing worked and the picture shows the browser output with button 6 pressed. Simultaneously I write "key pressed: 6" to the Nokia LCD. I however recognized, that responing to the web request slowed down the Flyport remarkably.

 Summary

All in all, the Flyport web server as well as the arduino shield interface is a marvelouse piece of hardware and I really like it. The IDE is working well, only the compiler is not as good as expected, as it is an old ANSI-C compiler. Here I would expect to see this compiler to be replaced in the near future with either gcc or with the compiler used for arduino or the chipKIT compiler. This would allow to use the arduino libraries without porting it. The UTFT library of Henning Karlsen which I use for the ITDB02 color LCD will most likely not be simple to port.

Things to improve:

  • a mechanical support for the Flyport module would be a good idea
  • I wonder if it would be a good idea to pass the pins (excluding power) down to allow to plug the adapter into an arduino.
  • a shield for the arduino mega

I hope, this test has added some value.

 Download

I will now clean out the code to get rid of the warnings the compiler is still printing and post it here for download as soon as it is complete.

 Funny Idea

Stay tuned ...