Saturday, September 24, 2016

My Orange Pi SBCs

A few Orange Pis
I have been playing with Orange Pi single board computers (SBCs) some lately. This is a few of them in order of performance, counter clockwise from lower left:
  Orange Pi One, Orange Pi PC, Orange Pi PC Plus and Orange Pi PC 2E.

The OPi One is running OpenELEC with dedicated Kodi media center is used as Trinda's movie machine. The OPi PC is just for fun and testing. The OPi PC+ is the new built-in navigation system running OpenCPN chart-plotter. And the OPi 2E is the big compilation server for software development for the smaller ones.

All but the media center are running Armbian Jessie, a Debian based Linux for arm computers. It is a rapidly developing OS. I started just a few months ago with 5.05 and now just loaded 5.20.

Thursday, April 14, 2016

OpenCPN on Orange Pi an Allwinner H3 Arm SBC

I ordered a new Orange Pi PC and a Orange Pi One for $15.99 and $9.99 plus shipping. It has an Allwinner H3 CPU with a Mail-400 GPU. They are supposed to perform a little better than the Raspberry Pi 2. So I thought I'd give it a try. The OPi One is a little short on memory for compiling, so I started with the OPi PC.

The details: (as of Apr 15, 2016. Check you revisions.)
There are several choices for an operating system, I chose armbian.com 's Debian Jessie. This OS is also available for several other H3, A10 and A20 CPUs by Allwinner such as the Banana Pi, CubieBoard, etc. These instructions may be adapted for them. They recommend a real class 10 SD card, not a fake. I this card seems a little slow but it is what is on hand.

Orange Pi PC w/ Samsung 8GB SD class 10, but only 4.2MB/s write speed when copying the image with this:

myrealpc$ sudo dd bs=4M of=/dev/mmcblk0 if=Armbian_5.05_Orangepih3_Debian_jessie_3.4.110_d  esktop.raw

Next boot the OPi PC from the SD card and setup the system. At armbian 5.05 there are several things to setup that will likely be changed in the next release (any day now). Other distributions will have different configurations. In addition to creating users and setting passwords, you should at least do:

orangepipc$ sudo apt-get update
orangepipc$ sudo apt-get upgrade


This was a 79 MB download this time, last week only 48MB.
Next install the necessary commands and libraries for compiling:

orangepipc$ sudo apt-get install build-essential cmake gettext git-core gpsd  
gpsd-clients libgps-dev wx-common libwxgtk3.0-dev libglu1-mesa-dev  
libgtk2.0-dev wx3.0-headers libbz2-dev libtinyxml-dev libportaudio2  
portaudio19-dev libcurl4-openssl-dev libexpat1-dev libcairo2-dev


Get a copy of the current opencpn source code. Change to the directory where you want to store the code, my home dir.And create a build directory.

orangepipc$ cd 
orangepipc$ git clone git://github.com/OpenCPN/OpenCPN.git
orangepipc$ cd OpenCPN
orangepipc$ mkdir build
orangepipc$ cd build


Make these changes to the CMakeLists.txt  in order for the Mali-400 drivers to be included:

orangepipc$ nano ../CMakeLists.txt

#  find_path(OPENGLESv1_INCLUDE_DIR GLES/gl.h )
  SET(OPENGLESv1_INCLUDE_DIR "/usr/include/GLES" )

The default swap size for this distribution is 128MB, not nearly enough for opencpn to compile. Therefore I plugged in a USB stick with a linux on it which had a swap partition on partition 5. To temporarily add swap space I did:

orangepipc$ sudo mkswap -f /dev/sda5
orangepipc$ sudo swapon /dev/sda5


The Mali-400 graphics accelerator driver is not found in the directory opencpn is looking for it. So I made a symbolic link to the expected directory. The error was:

 ERROR: /usr/bin/ld: cannot find -lEGL 
 
orangepipc$ sudo ln -s /usr/lib/mali/libEGL.so /usr/lib/


The OS should be ready to compile at this point. Use cmake to create the Makefiles for the compile. There are a few options available as per the OpenCPN site:
Default install dir is /usr/local, you can change this by providing the appropriate option to cmake: $ cmake -DCMAKE_INSTALL_PREFIX=/usr ../ If you're not into debugging, change to this to generate a smaller and marginally faster binary: $ cmake -DCFLAGS="-O2 -march=native" ../
It took about 2 hours for the compile. The first time through, just to satisfy me it succeeded, I directly installed opencpn as below.

orangepipc$ cmake ../
orangepipc$ make clean; make -j1
     # go drink some coffee, we're talking about a $15 computer compiling
orangepipc$ make install


It WORKS!! mostly.
I decided to try the optomized compile next so I:

orangepipc$ make clean
orangepipc$ cmake -DCFLAGS="-O2 -march=native" ../ 
orangepipc$ make -j1

orangepipc$ make package


You can then install the package with:

orangepipc$ sudo dpkg -i opencpn_4.2.0-1_armhf.deb 


Installing this way did not include the default world map or tcdata and I haven't heard the ships bells yet.

The map and tcdata can be included by following the instructions here. Or simply copy them in from another copy of opencpn (my Ubuntu15.04 laptop with opencpn 4.2 installed for instance) while you are copying in some charts to view.


There were a number of steps to cleanup the armbian 5.05 for automount the USBsticks etc. that I intend to document on my blog. At the rate the Armbian team is progressing, the OS cleanup will not be necessary for long.

Saturday, March 12, 2016

ESP8266 Design Contest Entry NMEA Bridge for OpenCPN

 !! Update edited Fritzing schematic Apr 28,2016 !!

 
Everything ESP8266  had a Design Contest In March 2016. The following was my entry, viewable at http://www.esp8266.com/viewtopic.php?f=152&t=8738



An ESP8266-01 WiFi module to read NMEA marine serial data and UDP broadcast it to multiple openCPN instances as a Bridge.

On my boat and several others, we are running OpenCPN for navigation software. Most of us run it on a laptop. The common inputs are GPS, AIS and some have all their instruments connected as well; depth, wind, speed & distance log, etc.

There are two problems that I am trying to solve. First, too many cables to the laptop providing the instrument data. And second, a way to share the instrument data with multiple devices. The release of opencpn for android tablets and smart phones makes it feasible to have multiple displays around the boat. Like in the captain's bunk to check on the boat and crew performance without getting out of bed.

So this friend that wants all of the instrument data over the network has a multiplexer that takes his SeaTalk and various NMEA 0183 signals and outputs a higher baud NMEA sentence data stream. And I have a combination AIS/GPS that has NMEA 0183 at 38400 baud. My laptop is getting old and if you touch the USB cable from the RS-232-to-USB it disconnects and reconnects using a different port configuration.

And besides it would be nice to have no cables, especially to a phone or tablet.

Along comes the ESP8266 Serial WiFi module with a modest price around $2.50 USD and other board configurations for a few dollars more.

So the plan is to create new firmware for the module, connect the rs-232 based NMEA 0183 signals to it and broadcast the sentences over the WiFi as UDP packets on the local subnet. So this will require a WiFi Access-point (AP) on the boat. (ED. It may be possible for the ESP to be the router too.) Another recent development is the availability of cheap pocket routers such as the TP-LINK WR702N. I picked mine up in Singapore for less than $8.00 USD last year, but the market is full of competitors.
I want to be able to run openCPN on both a laptop and a tablet at the same time. I would like the laptop down below deck, safe from the rain and salt water spray. I would like to have a mostly waterproof tablet in the cockpit to monitor progress. And I would like to be able to quickly check the ship's status from the captain's berth when off watch, maybe on a smart phone.

I decided to implement a device to read the serial data from all the boat instruments and send that data to openCPN over a WiFI link so there are no physical wires attached. It will broadcast the data with UDP so that multiple devices can read the data at the same time.

The ESP8266 ESP-01 was chosen because it was on hand and it has adequate I/O for this project.


NMEA 0183 is usually rs232 or rs484 at 4800 baud. The rs-232 input signal voltage should work with -12 to +12 volts. This project was tested with a Garmin 72H which outputs -5 to +5 and 4800 baud and an OceanPC AIS which outputs -3.0 to +3.0 at 38400 baud. Therefore, after a little search, I found a single transistor level shifter for the Rx input to make it conform to the 3.3v TTL levels of the ESP module.



Figure 1a. Strip-board implementation


Figure 1b. Strip-board bottom

The +5v power (from a 12v automobile USB charger module) comes in through the switch, upper left then a 3.3v regulator and then to the ESP module's socket. It is a little sensitive, so pull-up resistors are recommended on the 3 data lines, GPIO2 and Rx) and the chip select and reset pins. Tx and Rx are needed for programming (flashing) the firmware, and as a development board I chose to bring those to the top right pins with a ground for a future test of a 16x2 serial display.




Figure2. Schematic

The LEDs and pins at the bottom show the state of the 2 GPIO lines. The software configuration technique uses a short between these to go into config mode. The push button puts the module in flash mode.

First Usage

Connect power lines and input signal rs-232 line with ground. Press and hold config button, press reset, continue to hold config until the LED stays lit. Connect to the AP "NMEA WiFi Bridge" with a system/phone/etc. Connect your browser to 10.1.1.1 with password in code "nmeawifi".` Configure the form for your network and click the "configure" button. Verify the results page. Press reset or cycle power for the module to connect to your network.

To verify it is working, there is a status page on the address on the NMEA WiFi Bridge. Type this address into your browser.

The design of the code has three parts: setup configuration, normal execution and a status webpage.

First, setup configuration, short GPIO0 to GPIO2 (press the config button) and turn on the power. After a few seconds (5-6) the LED comes on indicting the module is ready to configure. This starts an AP at 10.1.1.1 that you can connect to with a WiFi capable device (laptop or phone or tablet using DHCP), then access the webpage at that IP. You get page_1.jpg.




figure 3. Setup


Enter the ssid and password for your boat network, the UDP port to connect and the baud rate to listen for the NMEA data.

When you click configure, it displays a confirmation of your data. If it is correct, turn off the power, connect it to you NMEA data, remove the short between the GPIO pins (do not press the button) and turn on the power.



Figure 4. Confirmation

The second part of the code, normal execution, now runs. It listens for NMEA sentences and when it has a complete sentence, broadcasts it to the broadcast address of the subnet you provided in config. All devices on that subnet can read these UDP packets.

Now go to your opencpn configuration settings, then connections. Add a new connection, selecting: network, UDP and the port number from above (default is 10110).
You should be getting data.



Figure 5. Status

The third part consists of a status page. You can look in a web browser at the IP address of the NMEAWiFiBridge and get a status page that updates the number of sentences broadcast every 10 seconds. It may severely impact the ability of the ESP to keep up with a busy data stream to monitor it, so it is only there to help with trouble shooting the connections. It should only impact performance while your browser is displaying the page.


  Figure 6. Rev 3 installed

Since the initial build I have made custom boards (3 trys to get them right) and have 2 installed and running aboard the Katie Lee.

See my github repository for code and schematics: https://github.com/svkatielee/NMEA_WiFi_Bridge  https://github.com/svkatielee/NMEA_WiFi_Bridge

The configuring software is based upon the work of Forward Computing and Control. My hardware is open-source, my software is GPL3.

Parts
1 - ESP8266-ESP-01
1 - LD1117-33 regulator (any 3.3v > 500ma will do)
1 - 1uF tantalum
6 - 4.7K ohm pull-up resisters
1 - 330 ohm current limit for Tx buffer
1 - 10K ohm for rs232 level convert 1 - 2n2222 for level convert
1 - 1N5819 program Rx input
1 - LED
3 - momentary pushbuttons

Links
Code and schematic on Github

Tuesday, February 2, 2016

Programming the ICOM M710 with DIY CI-V

Success and failure...USB-TTL to ICOM M710 programming cable

I need to reprogram my I-COM M710 Marine SSB/HAM HF rig. I have been using it aboard my sailboat since it was new in 2006 with an older Pactor IIe.

I would like to play with WinMOR and soundcard modem and some of the digital modes.

I searched the Internet and found most people were making (8 years ago) clones of the ICOM interface OPC-478.

So I first made clone cable like the CI-V cable  with  dual 2N2222s, a diode, some resisters and a DB9 connector. It needed to be plugged into my current laptop with a USB-serial adapter/emulator.  It failed. I must have put a transistor in backwards or something. Then I found the ICOM software. The software for cloning and configuring the M710 seems to be EX1726.exe for DOS. It does direct manipulation of the serial port register so a PC with an real DB9 serial port running DOS, not Windows, would be required. I do not have these.

I kept searching.

I next found web page that says the ICOM clone port is TTL open collector, just one wire. And also elsewhere found the clause, "NMEA 0183 sentences at 4800 baud".

And a note describing how to make a clone cable from a USB-TTL adapter, commonly used to program Arduinos, and a phone plug.


   connect tip of mono phone plug to Rx and Tx soldered together and ring to ground of a USB to TTL serial adapter. I used a PL2303 based 5 pin adapter.


Mine shows up in syslog as:

Feb 2 14:50:18 nav3 kernel: [27157.768171] usb 1-4.4: Manufacturer: Prolific Technology Inc.
Feb 2 14:50:18 nav3 kernel: [27157.768585] pl2303 1-4.4:1.0: pl2303 converter detected

The user  belizesailor at Cruiser Forum says the DosBox emulator for games emulates the serial port so well that the ICOM software will work.

OK! I quickly made the cable for the USB-TTL adapter in the photo. Then downloaded DosBox from www.dosbox.com, for debian to my ubuntu 15.10 system.

I actually used the synaptic package manager and checked the box to include dependent packages from the repository. It worked fine. All this after a failed attempt to download the source tar ball and compile it myself. And I had also tried to install the packages on WinXP, but I have no XP driver for the Prolific USB.

Then found EX1726.zip at http://ea4yx.jimdo.com/software-radioaficionados/control-equipos/software-icom/

After unzip'ing it, edit the config file ~/.dosbox/dosbox-0.74.conf
 to set the serial ports to emulate, these two lines:
 
serial1=directserial realport:ttyUSB0
serial2=directserial realport:ttyUSB1


So to program the M710 from Ubuntu-Gnome 15.10, select:
Menu> Games> DosBox

Then in DosBox:


Z:\> mount c ~/Data/Radio/EX1726

Z:\> C:

c:\>  ex1726 /expert       # see the README maybe called M710.DOC

ESC > Clone > Rs232 >port2    # ttyUSB1

ESC > C > T   # read from transceiver to PC

....





Thursday, January 14, 2016

A New Laptop

Another laptop bites the dust.

(Updated Jan 31)

A few months ago my oldest laptop died an unnatural death. It was an Acer Aspire One about 6 years old.

I finally got tired of the other one freezing and complaining, so I went to town(Cebu, PH) and found a replacement. I had had good luck with the cheap Aspire Ones, so I just picked the best one Acer had in the market here.

Acer V3 15inch i7 8Gb 1Tb 2.4Ghz  -  V3-547G-77P6

It came with Windows 10 64bit. The hardest part about that was the decision of which Linux distribution to dual-boot with it. The Internet here is terribly slow, so the choice was limited, one year old LinuxMint 17.1 64bit, Ubuntu 14.04 32bit or Ubuntu 15.10 64bit.

It seems Windows 10 insists on EUFI type BIOS for boot configuration and boot loader. After a couple weeks I had upgraded the "BIOS" to the latest rev on Acer's support site, learned to select the next boot device from in Windows 10 menus, almost worn out the install media, re-partitioned the disk several ways and had working 14.04 and 15.10 on separate partitions alongside Windows.

The Acer barely acknowledges the F2(BIOS) and F12(boot order) soft-keys during post. After finding the Windows command to go to boot menu things got a lot less frustrating. Click Power then hold shift and click reboot for the F2 BIOS menu during boot, or pick the file to boot on the next power up.

I tried installing with the BIOS set to ignore EUFI, but then Windows10 would not boot.

The final answer is to upgrade the BIOS(to v1.31) from the default(v1.25) so it can boot a linux. Then install with EUFI enabled to secure mode and grub in the EUFI partiton, then in the BIOS set the grub file to be trusted, and there also set the boot order of the EUFI systems. Setting the boot order in Linux (efibootmgr -o 4,1 ) or in Windows 10 does not work.

I spent the next couple weeks doing all that system admin I had nearly forgotten. I installed VMware and VirtualBox. Then WindowsXP, Andy's HAM Radio, LinuxMint17.1-64bit as virtual machines. I also attempted to visualize the old Acer Aspire Windows 7 and LinuxMint physical drives into VMware, but got sidetracked about the time I realized I needed to do it from VMware instance installed in a Windows host OS.


THEN THE ACER V3 DIED!!!!

I took it to the local Acer repair/warranty center in Cebu. Tomorrow I am to get it back and have the notes to correct the above procedures.

Monday, December 28, 2015

More NMEA Bridge modules

I finally got around to testing the last 2 WiFi Bridge boards. Neither worked at first. I wasn't sure of anything.

I chose one board and went through the entire regression. When I finally got the scope (Xprotolab) out and followed the NMEA signal in, I found a broken trace. The input to the first resistor. Arg! Then I discovered I put the transistor in backwards in both boards.

But now they are both installed and broadcasting. The first is connected to the builtin Garmin GPS and depth finder data, wire-or'd on the same terminal strip at 4800 baud. And the second is connected to the AIS at 38400 baud.

Then I etched two more boards, but haven't drilled or populated them yet.

Sunday, November 1, 2015

Two More NMEA WiFi Bridge Boards

If I could only learn to take good photos
I etched two more of the NMEA WiFi Bridge boards. After only a week of messing with the layout in Eagle, I finally decided I had a valid rev x.3. It seems I left a Vcc trace off the x.2 board.

Printing the inkjet transparency went well this time, marking solid and black in eagle print, although the color came out greenish. I exposed the pre-sensitized board 1 minute 15 seconds in the 1:30 afternoon equatorial sun then immediately developed them in caustic soda from last year for about 3 minutes. Then etched in new peroxide and muriatic acid for about the same 3 minutes. They looked really nice for a change.

I then exposed them to the sun again for 2 minutes and used the caustic to get the rest of the green photo-resist off the traces so I could solder.

I tried to coat all the copper with solder, but the very fine letters just pealed off the board. I had levf a +, -,  G and Rx in copper near those pins.

It took less than 3 hours to print, etch and populate the 2 boards. Of course that doesn't count the week fussing with the layout!

I decided to leave the voltage regulator off these because I have a number of $2 Chinese buck converters that have good regulation in the 3.3v range to pair them with.