Friday, July 21, 2017

pcDuino and the Adafruit 5" LCD HDMI Display




After my inability to get the 7" LVDS display to work with the pcDuino I thought I would have a go with the 5" Adafruit display that I use with my Raspberry Pi. While not plug and play, it is significantly easier than the LVDS.

The Adafruit 5" 800x480 HDMI Backpack




This backpack features the TFP401 for decoding video, and for the touch version, an AR1100 USB resistive touch screen driver. Connecting the pcDuino to the screen is easy, just plug a HDMI cable into both.

You can power the display from a USB port on your pcDuino/Raspberry Pi but it is probably better to have a separate supply. Particularly for the pcDuino since it only has one USB port which you probably want to use for the keyboard and mouse.

With the default 5" 800x480 display and 50mA backlight current, the current draw is 500mA total. You can reduce that down to 370mA by running the backlight at half-brightness (25mA).

The gotcha with this display is that the TFP401 decoder chip does not contain a video scaler, it will not resize/shrink video! This means that you must feed it a resolution of 800x480 @ 60Hz or you wont see anything!

Forcing the resolution of LightDM


LightDM is the display manager running in Ubuntu. fortunately it is fairly straight forward to set the resolution used by LightDM. To find out the name of your display you can type xrandr into terminal. This indicated that my display was called LCD. Note you can't do this via SSH, you need to be on the pcDuino with the screen attached.

Next you need to find out the parameters for your screen so that we can add a new display mode. Type the following into a terminal screen.

$cvt 800 480
Then copy what comes after modeline. It should look something like: "800x480_60.00"   29.50  800 824 896 992  480 483 493 500 -hsync +vsync. To create and add a new display mode you then type:

$xrandr --newmode "800x480_60.00"   29.50  800 824 896 992  480 483 493 500 -hsync +vsync
xrandr --addmode LCD 800x480_60.00
You can then make sure that the new mode works:

$xrandr --output LCD --mode 800x480_60.00

With a bit of luck LightDM will now fill your LCD screen.

To ensure that this is done every time the pcDuino boots, you can add it to the profile bash script we attempted to use to load the touch driver in the last post.

ubuntu@ubuntu:~$ sudo nano /etc/profile
Add the following lines to the end of the file, save, exit and reboot.

# Set resolution for the Adafruit 5" Screen
xrandr --newmode "800x480_60.00"   29.50  800 824 896 992  480 483 493 500 -hsync +vsync
xrandr --addmode LCD 800x480_60.00
xrandr --output LCD --mode 800x480_60.00



Saturday, July 15, 2017

pcDuino and the 7" LVDS LCD Touch Screen

Diyode Magazine




A new electronics magazine recently launched in Australia called Diyode (a mashup of DIY and diode???). For a number of years the only local mag has been Silicon Chip so I welcome another entrant. Based on issue 1 it looks like Diyode is pitched at people who don't have quite as much experience as Silicon Chip readers and has more of a bias towards microprocessor based projects. With a sample size of one it is dangerous drawing too many conclusions, you can draw any line through a single point. Anyway the more the merrier and vive la difference, I say!

It will be interesting to see if the Australian market can sustain two electronics magazines. It has in the past, the peak was I think in the 1980's when there was Electronics Today International, Australian Electronics Monthly, Talking Electronics, Electronics Australia, and Silicon Chip. However by the late '80's Silicon Chip was the last mag standing. It is a tough time to be a traditional magazine publisher.

The reason for the history lesson is that as part of the launch, Diyode ran a competition for people to promote the mag on social media and I was one of the lucky winners. The prize was provided by Jaycar and was a pcDuino and its associated 7" LVDS LCD Touch Screen.  Thank you Diyode Magazine and Jaycar.

I have long been tempted to give the pcDuino a try but the cost has been a barrier given you can get similar functionality with a Raspberry Pi and Arduino. I have a project in mind for the pcDuino which I will cover in due course, but first I need to get the LCD screen working. This is a lot harder than it should be, using a HDMI screen is certainly the easier path. If Jaycar are selling the pcDuino and LCD as a package they should flash the pcDuino with the correct drivers so that it works out of the box. I thought I would document my attempts to get the LCD screen working to save people some trouble if they purchase the same kit.

pcDuino vs Raspberry Pi 3




How does the pcDuino stack up against the Raspberry Pi 3 and Arduino? You can see the specifications in the table below. Generally the Pi 3 is better spec'ed than the pcDuino except for Analogue & PWM inputs.

As usual the answer to which is better will depend on what you are trying to do. The big selling point of the pcDuino is the built in "Arduino", however note that there is no Atmega microcontroller on board, so the Arduino functionality is emulated and I suspect this will cause issue with some (if not most) of the available libraries. I haven't tested this yet but I don't expect to be able to just drop in my exisiting Arduino code and have it work.


pcDuino v3B Raspberry Pi 3
CPU:  1 GHz ARM Cortex A7 Dual Core  1.2 GHz Quad-core 64-bit ARM Cortex A53
SoC:  All Winner A20 SoC  Broadcom BCM2837
GPU:   Mali 400 Dual Core Broadcom VideoCore IV @ 400 MHz
RAM:  1GB  1 GB LPDDR2-900 SDRAM
Storage:  4GB on board flash  microSD
Storage Expansion:  microSD slot, SATA port.  USB
Ethernet:  10/100/1000  10/100 MBPS Ethernet
Wi-Fi / Bluetooth:  802.11b/g/n  802.11n Wireless LAN, Bluetooth 4.0
GPIO pins:   14  40
ADC pins:   6  0
PWM pins:    2  1
Communication:  SPI, I2C, UART  SPI, I2C, UART 
USB:  1 x Host + 1 x OTG  4 x USB
Video Output:  HDMI, LVDS HDMI, Display Serial Interface (DSI), Composite
Analog Audio:  3.5mm stereo audio socket  3.5mm stereo audio socket 
Digital Audio:  Yes, via I2C  I2S
Default OS:  Ubuntu Linux  Raspbian
Power Supply:  5VDC 2000mA (via Micro USB) 5VDC 2500mA (via Micro USB)
Dimensions:  121(L) x 65(W) x15(H)mm 85.6 x 56.5 x 17 mm


The LVDS LCD 1024 x 600 Touchscreen



This is a custom made 7" LVDS colour LCD with capacitive touch for pcDuino3 (XC-4350). It has a resolution of 1024 x 600, and comes with an LVDS screen with driver board, a ribbon cable and 10 pieces of male to female jumper wires.

Low-voltage differential signalling, or LVDS, also known as TIA/EIA-644, is a technical standard that specifies electrical characteristics of a differential, serial communications protocol. LVDS operates at low power and can run at very high speeds using inexpensive twisted-pair copper cables.

• Resolution: 1024 x 600
• 5V powered via pcDuino board
• Overall dimensions: 167(L) x 107(W) x 10(D)mm

Connecting the pcDuino and the LVDS LCD Screen




Unfortunately this isn't as simple as you might hope. The first trick is connecting the ribbon cable to the LVDS connection on the pcDuino. Note that you have to pull out the dark grey part of the connector before you can insert the cable, you then push it back in to hold it in place. This isn't mentioned in the instructions and took me a while to figure out.

You can then connect the 10 jumper wires as instructed. These control the touch portion and supplies power.

• Pin 1 of the LCD driver breakout board —> 5v of pcDuino
• Pin 2 of the LCD driver breakout board —> GND of pcDuino
• Pin 3 of the LCD driver breakout board –> D2 of pcDuino
• Pin 4 of the LCD driver breakout board –> D3 of pcDuino
• Pin 5 of the LCD driver breakout board –> D4 of pcDuino
• Pin 6 of the LCD driver breakout board –> GND of pcDuino
• Pin 7 of the LCD driver breakout board –> D9 of pcDuino
• Pin 8 of the LCD driver breakout board –> SCL of pcDuino
• Pin 9 of the LCD driver breakout board –> SDA of pcDuino
• Pin 10 of the LCD driver breakout board –> D8 of pcDuino

Loading the LVDS Driver - Attempt 1


The instructions are wrong. They say to copy ft5x_ts.ko from the pcDuino GitHub repository onto the pcDuino and then run:

$insmod ft5x_tx.k
Obviously this doesn't work because the file doesn't exist. Unfortunately, even running:

$insmod ft5x_ts.ko
didn't work for me.

Loading the LVDS Driver - Attempt 2


Whipping out Dr Google will point you to a number of videos by Jingfeng Liu who I assume works for Link Sprite the manufacturer of the pcDuino. They include:
  1. Install touch driver for LVDS LCD on pcDuino3;
  2. 1024x600 LVDS LCD on pcDuino3;
  3. pcDuino3B with 1204x600 LVDS; and
  4. Flash pcDuino3 with LVDS image.
Three out of four of these solutions involve re-flashing the kernel and then reloading Ubuntu which sounded like a lot of work so I tried option 1 first (installing the touch driver). To do this you will need to attach your pcDuino to a HDMI screen, keyboard and a mouse. You can follow along with the video, but in summary the instructions are as follows:

a) Boot up your pcDuino connected to a HDMI display and open LXTerminal. Install nano (a text editor) by typing:

$sudo apt-get install nano
b) Then install git so that you can clone the files you need from the pcDuino git repository.

$sudo apt-get install git-core
c) Copy the files you need using:

$git clone git://github.com/pcduino/modules
d) This will download more files than you need but some of the other ones look interesting and I may use them in a later project. If you type "ls" you will see a new directory called modules. Have a look at the contents if you want, but for now we need to make the location of the touch driver file our current working directory. To do this type:

$cd modules/touch/ft5x
e) Type "ls" and you should see the file ft5x_ts.ko, yes the same file we downloaded in attempt 1! As for attempt 1, you are instructed to load the driver using:

$sudo insmod ft5x_ts.ko
Unfortunately this still doesn't work and generates the error:

$insmod: error inserting 'ft5x_ts.ko': -1 File exists
In the video you are instructed to check that the driver has loaded using:

$sudo dmesg | tail
Doing this confirms that the driver hasn't been loaded *sigh*. Based on the comments on this video and the LinkSprite forum, I am not the only one to have this issue.

The remainder of the video deals with placing the insmod command in the etc/profile bash file so that the touch driver gets loaded every time the pcDuino boots. I did all this as well and rebooted (just in case a miracle occurred) but it still didn't work.

Loading the LVDS Driver - Attempt 3




Back to the drawing board. I guess we are doing it the hard way. I used the kernel and Ubuntu distribution from the pcDuino 3b download area (since my pcDuino is a version 3b - there is a separate area for the pcDuino 3).  Most of the instructions assume that you are using a Windows machine to create the microSD card image. If you have a Mac, the process is as follows:
  1. Format the SD Card using the SDFormatter app.
  2. In Terminal, get the name of the SD Device using "diskutil list". Mine was /dev/disk2.
  3. Unmount (not eject) the SD Card using the Disk Utility App. Select the SD Device and then click on umount - see image above.
  4. Copy the kernel to the SD Card by typing in Terminal:
$sudo dd if=~/Desktop/pcduino3b_lvds_a20_kernel_livesuit_20150314.img of=/dev/disk2
I then followed the instructions from the "pcDuino3B with 1204x600 LVDS" video but couldn't get the pcDuino to flash the new kernel. The LED never did the expected slow flash to indicate the new kernel being loaded. I tried redoing the SD Card but this didn't fix it.

The problem may be that you need to use LiveSuite or PhoenixCard to burn the SD Card, so I gave that a crack but it is only available for Windows.

I have decided that it is all too hard and will just use my HDMI screen instead!