Tuesday, December 22, 2015

Colour Coding - Part IV

The new FT812 VGA Shield  - with PS/2 Keyboard and Mouse Inputs

A couple of weeks ago, I completed the pcb layout for the universal VGA shield - a small 50mm x 50 mm pcb that fits a range of popular 3.3V microcontroller development boards. Any dev board that supports the basic Arduino style headers can use this board - and that opens it out to a very wide range of boards.

The board provides
  • A powerful 800 x 600 graphics co-processor   - the FT812 from FTDI
  • PS/2 Keyboard connector
  • PS/2 Mouse connector
  • Additional UART via FTDI cable
The freshly minted pcbs arrived in today's post - just in time for some development work over the Christmas holiday period.

The boards may be fitted to several popular microcontroller and FPGA dvelopment boards  - including

  • STM32F  Nucleo boards
The VGA shield fits neatly on any STM32F Nucleo Board
  • STM32F7 Discovery Board
Fitted to the underside of a STM32F746 Discovery board
  • Gadget Factory  Papilio Duo FPGA Board with Xilinx Spartan 6 FPGA

Fitted to a Papilio Duo FPGA board
  • Any board that supports Arduino headers with 3V3 signalling!
My 3V3 ATmega328 "WiNode" pcb - which also has a SDcard
The FTDI FT812 is a complete graphics co-processor - intended for driving colour LCDs. With a little bit of tinkering, we can make it produce a VGA signal - suitable for displaying on any flatscreen monitor.  The PS/2 keyboard and mouse interfaces offer the extra connectivity to bring a full user interface to your latest microcontroller project.

The FT812 embedded video engine removes the burden of producing a colour graphical interface from the microcontroller - and allows quite stunning GUIs to be produced from even a basic 8 bit microcontroller.

The FT812 is accessed over a SPI bus - and for convenience this has been brought out to the standard Arduino headers.  Provided that your dev-board works at 3V3 - then this board should be compatible.

Instead of using an 8-bit microcontroller, such as the ATmega328 - this board has been produced with much faster, 32-bit processors in mind.  These include the STM32Fxxx range of ARM Cortex M3, M4 and M7 processors from ST Microelectronics, and the Soft Core processors available from the Gadget Factory Papilio Duo FPGA board.

Some Hardware Details.

The FT812 is accessed via the SPI bus  - on the usual D11,D12,D13 Arduino pins. Additionally there is a Chip Select on D9 and an optional INT on A1, and a Power Down PD on A2.  PD acts as a reset an normally needs to be pulled high. 

The FT812 has 8-bit outputs for the Red, Green  and Blue components of the video signal. These digital outputs are recombined in a resistor network to produce an analogue component video signal of approximately 0.7V amplitude.

The value of the resistors are chosen to be as close as possible to increasing powers of two - starting at 499 ohms.  There is a useful blog post and a XL spreadsheet describing how the resistor values are chosen for a similar VGA project here.  It should be noted from the XL spreadsheet that the most significant resistor (499 ohms) appears to give a step discontinuity in the output - this may be minimised (on paper) by lowering this value to approximately 470 ohms. This has yet to be tried in practice.

The values finally chosen for the resistor network are:

R7      499R    (470R)
R6      1K
R5      2K
R4      4K02
R3      8K06
R2      16K
R1      31.6K
R0      63.4K

The shield also provides a PS/2 Keyboard and Mouse interface.

For full hardware details - please refer to Colour Coding Part III

As this shield is merely a prototype, it has not configured to allow the audio output of the FT812 IC. A second iteration of the PCB will include a 3.5mm jack socket for sound output and a microSD connector for local image storage.

Firmware Development

Fortunately FTDI have provided a comprehensive set of code examples for the FT81x. These include header files describing all the internal registers, and walk you through the process of configuring the main registers for various display setups.

I will use these as the basis of the initial C code so that I can bring the IC up - using known, tried and tested code.

To maximise the usefulness of the VGA board - and make development simpler and more accessible to all, I have decided to write the code using the mbed compiler, and use a STM32F103 Nucleo board - as the development platform. 

The reasons for this is that the mbed online toolchain is free to use and has good library support, the code will be portable across a range of different target platforms - including the STM32F7 Discovery board - and the Nucleo boards are really cheap.

This avoids the whole situation of having to deal with codesize limited Keil or IAR toolchains, and added complexity of the STM32xxx HAL shenanigans!  

It also make the code portable across a wide range of mbed supported platforms - from IC vendors including Freescale, NXP, Nordic, Renesas, Maxim, Wiznet and ST. In fact any vendors platform that supports the Arduino style headers - at 3V3! can be used.

Meanwhile, in sunny Northern California, James Bowman of GameDuino - has recreated the VGA board and is writing some drivers so that it can be run from his J1b Forth processor - a softcore cpu - hosted on the Gadget Factory Papilio Duo, - which is a Xilinx Spartan 6 FPGA board.  

This little VGA shield will also allow VGA graphics for any softcore processor - such as recreated 6502, Z80 etc.  The FT812 takes all the grunt of graphics generation away from the cpu - so even a little 8 bit processor - recreated in a FPGA from a 40 year old design can have graphical output that was never an option back then.

Other FPGA boards such as the Arty - a $99 Artix board from Xilinx can also be fitted with this VGA/Keyboard/Mouse  (VKM) shield - in fact anything that has the all important Arduino headers! 

There will be a full report in a later post as we get the firmware up running - both in mbed C and J1b Forth on this new unit.







No comments: