Silicon ChipMicromite, Pt.3: Build An ASCII Video Display Terminal - July 2014 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Argo drones gathering deep sea data
  4. Feature: Argo: Drones Of The Deep Oceans by Dr. David Maddison
  5. Review: AmScope Stereo Microscope by Andrew Levido
  6. Project: Threshold Voltage Switch by John Clarke
  7. Feature: Eye-Fi Mobi SD Wireless Camera Cards by Ross Tester
  8. Subscriptions
  9. Product Showcase
  10. Salvage It! Wrecking The Computer Itself by Bruce Pierson
  11. Project: Micromite, Pt.3: Build An ASCII Video Display Terminal by Geoff Graham
  12. Project: Touch-Screen Digital Audio Recorder, Pt.2 by Andrew Levido
  13. Project: L-o-o-o-n-g Gating Times For The 12-Digit Counter by Jim Rowe
  14. Order Form
  15. Vintage Radio: The upmarket 1950 HMV R53A radiogram by Rodney Champness
  16. Market Centre
  17. Notes & Errata
  18. Advertising Index
  19. Outer Back Cover

This is only a preview of the July 2014 issue of Silicon Chip.

You can view 38 of the 104 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "Threshold Voltage Switch":
  • Threshold Voltage Switch PCB [99106141] (AUD $10.00)
  • Threshold Voltage Switch PCB pattern (PDF download) [99106141] (Free)
Items relevant to "Micromite, Pt.3: Build An ASCII Video Display Terminal":
  • PIC32MX170F256B-50I/SP programmed for the Micromite Mk2 plus capacitor (Programmed Microcontroller, AUD $15.00)
  • PIC32MX170F256D-50I/PT programmed for the Micromite Mk2 (44-pin) (Programmed Microcontroller, AUD $15.00)
  • CP2102-based USB/TTL serial converter with 5-pin header and 30cm jumper cable (Component, AUD $5.00)
  • Firmware (HEX) file and user manual for the Micromite (Software, Free)
  • Firmware (HEX) file and user manual for the 44-pin Micromite (Software, Free)
  • 44-pin Micromite PCB pattern (PDF download) [24108141] (Free)
  • 44-pin Micromite PCB [24108141] (AUD $5.00)
  • ASCII Video Terminal PCB [24107141] (AUD $5.00)
  • PIC32MX270F256B-I/SP programmed for the ASCII Video Terminal [2410714A.HEX] (Programmed Microcontroller, AUD $15.00)
  • MCP1700 3.3V LDO (TO-92) (Component, AUD $2.00)
  • Firmware (HEX) file for the ASCII Video Terminal [2410714B] (Software, Free)
  • ASCII Video Terminal PCB pattern (PDF download) [24107141] (Free)
Articles in this series:
  • The Micromite: An Easily Programmed Microcontroller, Pt.1 (May 2014)
  • The Micromite: An Easily Programmed Microcontroller, Pt.2 (June 2014)
  • Micromite, Pt.3: Build An ASCII Video Display Terminal (July 2014)
  • The 44-pin Micromite Module (August 2014)
Items relevant to "Touch-Screen Digital Audio Recorder, Pt.2":
  • Touch-screen Audio Recorder PCB [01105141] (AUD $12.50)
  • PIC32MX695F512H-80I/PT programmed for the Touchscreen Digital Audio Recorder (Programmed Microcontroller, AUD $30.00)
  • Firmware for the Touchscreen Audio Recorder [0110514B.HEX] (Software, Free)
  • Touch-screen Audio Recorder PCB pattern (PDF download) [01105141] (Free)
  • Touch-screen Audio Recorder end panel artwork (PDF download) (Free)
Articles in this series:
  • Touch-Screen Digital Audio Recorder, Pt.1 (June 2014)
  • Touch-Screen Digital Audio Recorder, Pt.2 (July 2014)
Items relevant to "L-o-o-o-n-g Gating Times For The 12-Digit Counter":
  • 2.5GHz 12-Digit Frequency Counter Main PCB [04111121] (AUD $20.00)
  • 2.5GHz 12-Digit Frequency Counter Display PCB [04111122] (AUD $12.50)
  • 2.5GHz 12-Digit Frequency Counter Add-on PCB [04106141a/b] (AUD $12.50)
  • PIC16F877A-I/P programmed for the 2.5GHz 12-Digit Frequency Counter [0411112C.HEX] (Programmed Microcontroller, AUD $20.00)
  • VK2828U7G5LF TTL GPS/GLONASS/GALILEO module with antenna and cable (Component, AUD $25.00)
  • 2.5GHz 12-Digit Frequency Counter front panel [04111123] (PCB, AUD $25.00)
  • Firmware for the 2.5GHz 12-Digit Frequency Counter project [0411112C.HEX] (Software, Free)
  • 2.5GHz 12-Digit Frequency Counter Main PCB pattern (PDF download) [04111121] (Free)
  • 2.5GHz 12-Digit Frequency Counter Display PCB pattern (PDF download) [04111122] (Free)
  • Long Gating Time Add-on Module for the 2.5GHz 12-Digit Frequency Counter PCB pattern (PDF download) [04106141a/b] (Free)
  • 2.5GHz 12-Digit Frequency Counter front and rear panel artwork (PDF download) [04111123] (Free)
Articles in this series:
  • A 2.5GHz 12-digit Frequency Counter, Pt.1 (December 2012)
  • A 2.5GHz 12-Digit Frequency Counter, Pt.2 (January 2013)
  • L-o-o-o-n-g Gating Times For The 12-Digit Counter (July 2014)

Purchase a printed copy of this issue for $10.00.

By GEOFF GRAHAM Micromite, Pt3: Build An ASCII Video Terminal Now you can build your own VT100-compatible ASCII Video Display Terminal. It uses just one chip and lets you add a video display, keyboard and USB to your next microcontroller project. It’s the perfect companion for microcontrollers with serial input/ output such as the Micromite and the PICAXE. M ANY OLDER readers will remember the days when an ASCII terminal was the standard method of interfacing to a computer. In those days, the DEC VT100 was the “gold standard” for such a terminal. It had a keyboard, a 24 x 80 character display and an RS232 interface to allow connection to a multi-user minicomputer. That all changed with the introduction of the PC with its integrated display and networking over Ethernet. In recent years though, there has been a resurgence of serial communications. A serial interface is easy to implement on a microcontroller and devices such as the Micromite and PICAXE use serial as their basis for communications, as do many others. You could use a PC or Mac to con60  Silicon Chip nect to these microcontrollers via a serial port but they are large and clumsy and not a long-term solution if your project needs a permanent display. That’s where this ASCII Video Terminal comes in. It uses a single chip to add video, a keyboard and USB to an external microcontroller via a serial interface. Other (more powerful) small computers also often rely on a serial interface. For example, the Raspberry Pi puts out a series of informative diagnostic messages on its serial interface as it boots up and this project will display them for you. Once the Raspberry Pi has booted, you can then log into it via this serial interface using the terminal’s keyboard. By the way, the term ASCII refers to the character encoding standard used by the VT100. Back in the days of the VT100, there were other competing standards such as EBCDIC (used by IBM) but these days all serial communications use ASCII. Main features An accompanying panel lists the main features of the ASCII Video Terminal but in summary you can use either a VGA monitor, a composite monitor or a TV (PAL or NTSC) to display the video output. As indicated, the input can either come from a standard PS/2 keyboard or from a PC via the USB interface. Any of these I/O facilities can be left out if you don’t need them. For example, if you simply wanted to add siliconchip.com.au REG1 MCP1700-3302E +5V GND 10 µF 16V +3.3V OUT IN 10 µF 16V CON3 EXT 5V A 100nF 100nF + K – ACTIVITY 13 Vdd 82Ω BOOTLOAD JP1 28 AVdd VUSB PGED3 PGEC3 CON4 6 5 4 17 4 RB3 RB8 RB4 4–PGD 5–PCC 7 6–NC 11 JP3 16 15 22 2 21 3 RB7 Vbus D– D+ RPA4 RB2 CON6 220Ω 12 150Ω 6 5 4 TxD GND JP3 BAUD RATE SETTINGS A B C 9 X1 8MHz RATE 115,200 57,600 38,400 19,200 27pF VGA OUT 6 1 7 2 8 3 9 4 10 5 11 12 13 14 15 470Ω 10k RxD BAUD RATE SELECT SELECT COLOUR 100k 3.3V C B IC1 PIC32MX250PIC3 2 MX25026 SCK2 F128B +3.3V TTL SERIAL 2 A 4.7k CON1 3–GND 3 4.7k 1 1– MCLR 3 1 2 CON2 1 2–Vcc PS2 KBD JP2 (NOT POPULATED) RPB5 4.7k USE USB POWER CON7 ICSP 23 MCLR 14 USB +3.3V 4.7k λ LED1 27pF 10 DE-15F RPB1 RB13 RPB0 RB14 OSC1 RB9 OSC2 AVss 27 9,600 Vcap Vss 8 Vss 19 24 25 18 20 CON5 COMPOSITE VIDEO OUT 10 µF 16V 4,800 2,400 1,200 (DEFAULT CONFIG.) IN SC 20 1 4 LED MC P1700 ASCII VIDEO TERMINAL OUT K GND A Fig.1: the circuit is based on a PIC32MX250-F128B microcontroller (IC1). The table at bottom left shows the range of baud rates that can be selected using jumper block JP3. A black dot indicates that a jumper should be placed at that position. The default (no jumpers) can be set using the Set-up menu to any speed between 40 and 1,000,000 bps, the default being 1200bps. a small video display to a PICAXE project, you could do this by using the terminal’s microcontroller and seven other passive components to drive a low-cost reversing camera monitor. The USB and keyboard parts can be left out if not required, resulting in a simple, low-cost display. You can use the same minimalist approach with the SILICON CHIP Micromite (see May & June 2014 issues). However, the full ASCII Video Terminal with a keyboard and display works particularly well with this device. Together, the two provide almost the same functionality as our popular siliconchip.com.au Maximite but in two low-cost 28-pin chips. This is the key to this project. You can build the full ASCII Video Terminal on a PCB as described here or you can just pick the parts that you need and incorporate them into your own project. Because this project is based on a single low-cost and easy to solder microcontroller, this is easy to do. Circuit details Refer now to Fig.1 for the complete circuit details of the ASCII Video Terminal. This shows just how simple the project really is. It’s based on a single, yet powerful, PIC32 microcontroller from Microchip. This 28-pin chip generates the video, handles the keyboard and also manages the serial and USB interfaces. The other components are mostly there to ensure correct signal levels. The PIC32MX250F128B microcon­ troller (IC1) used here is a close cousin to the recommended chip for the Micromite, the only difference being that this one supports USB. So if you have the facilities to program the chip used in the Micromite, you can also program this device. If you don’t want to do that, you can purchase a July 2014  61 Otherwise, it assumes that a composite monitor is attached and it configures itself to drive this type of monitor. Note that you should not connect both types of monitor simultaneously. VGA output The ASCII Video Terminal emulates the original Digital Equipment Corporation (DEC) VT100 video terminal shown here. This is an example of the cheap composite monitors that are available (this one cost $19). They are normally used with vehicle reversing cameras but they also work great as a graphics display for a microcontroller using the ASCII Video Terminal microcontroller as the video processor. pre-programmed chip from the SILICON CHIP On-line Store. As shown on Fig.1, IC1 produces separate output signals for VGA video and composite video. Since separate resistive divider networks set the video levels, this means that it can provide an optimal display, regardless 62  Silicon Chip of which output you are using. At power up, the firmware first checks if a VGA monitor is connected. That’s done by measuring the impedance of pin 12 of IC1 to ground – if it’s less than 2kΩ, there must be a VGA monitor connected and the firmware configures itself to drive this monitor. The video signal is generated using a similar approach to that used in the Maximite series of computers. First, the video is written as a bitmap to a bank of memory. Then, using DMA (Direct Memory Access) and an SPI interface, the series of bits (pixels) are streamed from the memory to the monitor. The output is monochrome (just like the original VT100). A full scan line from the VGA output is 480 pixels wide which displays perfectly on an old-fashioned CRT monitor. On an LCD monitor, the character formation is not as good due to the monitor having to map this output to its native resolution. The result is perfectly legible and usable but you do get the best image with a CRT monitor. The default display is 24 lines x 80 characters wide, which is the VT100 standard. Alternatively, by using the Set-Up menu (more on this later) or by sending the correct escape code, you can switch the display to 36 lines x 80 characters wide if you wish. For VGA, the horizontal and vertical sync outputs are directly connected to the monitor which accepts standard TTL signalling levels. The video signal is different and is limited to a maximum level of 0.7V. This is achieved by connecting a 220Ω resistor in series with the 75Ω input impedance of the monitor. You can select the colour of the text on the monitor by bridging one of three sets of solder pads (SELECT COLOUR) in series with the VGA socket on the PCB. These are marked GRN, BLU and RED, ie, for green, blue and red. We chose green, as many ASCII terminals from that era used a green phosphor and the colour is soothing to the eye. You can select more colours by bridging two sets of pads (eg, green and red will give yellow). However, this will have the effect of halving the input impedance of the VGA monitor (as seen by the ASCII Video Terminal) and so the 220Ω series resistor should be reduced to 165Ω to compensate (ie, use two 330Ω resistors in parallel). The limiting factor is the output drive capability of the microcontroller which must not exceed 15mA. With siliconchip.com.au one colour and a 220Ω resistor, the peak current is 10mA. With two colours and 165Ω, it is 14mA which is just within the chip’s specification. If you select two colours, the display will be not as bright as for a single colour and you will be pushing the chip close to its limit. For these reasons, we recommend sticking with one colour (eg, green). Composite video output The composite video output is generated in a similar manner to the VGA output but with different timings. Another difference is that the video and sync signals are summed via 150Ω and 470Ω resistors in conjunction with the 75Ω input impedance of the monitor to give the correct composite voltage levels. By default, the composite output uses PAL timing (ie, 625 lines) which gives a display of 18 lines x 50 characters wide. You can also select NTSC timing via the Set-Up menu and in this mode it displays 15 lines x 50 characters. In both cases, the output is monochrome (black and white). Composite mode is especially useful when used with cheap monitors intended for use with reversing cameras on trucks and cars. They come in a variety of sizes and prices but a small 4.3inch monitor can be bought cheaply on eBay (ours cost just US$19). This display can be mounted on the front of an instrument case and can show an amazing amount of information, including graphics – all driven by a Micromite or PICAXE. On such a small screen, the standard font can be hard to read so the ASCII Video Terminal has two extra fonts which can be selected by sending the appropriate escape codes. These give extra large letters that really stand out, even on a 4.3-inch screen. Serial interface Connector CON1 is the serial data interface for the ASCII Video Terminal, with pins 2 & 3 going to the RxD (receive data) and TxD (transmit data) lines respectively. As shown, the RxD line is fed to pin 5 of IC1 and is pulled high via a 100kΩ resistor to prevent it from floating if it is not connected to anything. The 10kΩ resistor in series with pin 5 provides protection when the input is connected to a circuit that uses signalling voltages above 3.3V. Pin 4 of IC1 is the TxD output and siliconchip.com.au Main Features   •  Single chip ASCII Video display terminal with VT100 and VT52 emulation. •  VGA or Composite Video (PAL or NTSC) output with automatic switch over. •  VGA can display 24 lines x 80 characters or an extended resolution of 36 lines x 80 characters. •  Composite video can display 18 lines x 50 characters (PAL) or 15 lines x 50 characters (NTSC). •  Standard PS/2 compatible keyboard input with support for standard US keyboard layout or French, German, Italian, Belgian, Russian or United Kingdom keyboard layouts. •  TTL or RS232 serial input/output. Baud rates from 40 to 1,000,000bps with odd, even or no parity and one or two stop bits. •  USB input with serial emulation – can be used as a USB to serial converter. •  Extended VT100 terminal emulation. Extensions include graphics codes for drawing lines, boxes and circles (which can be hollow or filled). •  Graphics resolution is 480 x 288 pixels in VGA 25 line mode, 480 x 432 pixels in VGA 36 line mode, 304 x 216 in PAL composite and 304 x 180 pixels in NTSC composite mode. •  Three inbuilt fonts (standard, large and jumbo) and four character attributes (normal, underline, reverse and invisible). •  Power requirement: 5V at 50mA plus any current drawn from the 3.3V pin on the serial connector. is directly connected to the external device via CON1. The serial connector also provides a +3.3V output and a ground connection. The 3.3V connection can be used for powering other circuitry such as an RS232 converter or a Micromite and can supply a maximum of 100mA. The voltage levels used in the serial interface are TTL which means that idle is voltage high, the start bit is voltage low, data uses a voltage high for logic 1 and the stop bit is voltage high. You can also use RS232 signalling but more on that later. Setting the baud rate The baud rate is set by sliding shorting plugs over pairs of pins on jumper block J3. The table in Fig.1 shows the various baud rates that are available. This method makes it easy to select standard baud rates from 1200 to 115,200 bits per second (bps). Note that the baud rate is set when the ASCII Video Terminal is powered up, so if you change a jumper you will have to cycle the power for it to be recognised. The baud rate selected when there are no shorting plugs installed is slightly different – by default it is 1200 bps but this can be changed in the SetUp menu to anything from 40 bps to 1,000,000 bps (yes, that is a baud rate of one million bits per second). You are not just restricted to the standard baud rates (1200, 2400, etc); instead, you can set any speed that you require. For example, you could set the speed to 2222 bps if you wished. This arrangement gives you the best of both worlds. You can either select a range of standard baud rates using jumpers or you can configure any other non-standard speed via the Set-Up menu. Using this menu, you can also select other options, including parity (odd, even or none), the number of data bits and the number of stop bits. The processing required to convert each character to a bitmap (ie, for the video display) limits the sustained speed that the terminal can handle to about 44,000 bps. To offset this, the firmware uses a substantial input buffer that can store incoming characters while the preceding characters are processed. Most systems only send a block of data at a time (ie, a screen full of characters) because the user would not have the time to read the data otherwise. The Micromite is the same; the editor only displays one screen of characters, then waits for further user input. With its large input buffer, the ASCII Video Terminal can handle very July 2014  63 100nF 13 Vdd +3.3V 28 AVdd 23 VUSB MCLR 10k* RxD TxD 5 4 TxD RxD (9600 baud) OFF-BOARD MICROMITE OR PICAXE RPB1 Vbus RPB0 PIC32MX250PIC3 2 MX250F128B CON1 D– D+ TTL SERIAL Vcap 9 8MHz 10 GND 27pF 27pF OSC1 PGEC3 OSC2 AVss 27 Vss 8 RB3 Vss 19 1 15 4.7k 22 2 21 3 20 3 CON2 USB 1 4 10 µF 16V 7 * REQUIRED ONLY IF THE MICRO USES +5V USB TO SERIAL BRIDGE Fig.2: if all you need is a USB-to-Serial bridge, you can strip the circuit shown in Fig.1 down to the configuration shown here. It can be built on the PCB used for the full ASCII Video Terminal or on a piece of scrap stripboard. 100nF 13 Vdd +3.3V 28 AVdd 23 VUSB MCLR RxD TxD OFF-BOARD MICROMITE OR PICAXE TxD 10k* 5 PIC32MX250PIC3 2 MX250F128B CON1 8MHz GND 27pF RB2 RB14 9 27pF 10 1 RPB1 (9600 baud) TTL SERIAL RB9 OSC1 Vcap OSC2 AVss 27 Vss 8 The ASCII Video Terminal can be used directly with most RS232 sources but if you want a fullycompliant RS232 interface you should purchase one of these. It’s an RS232 converter that can be powered from the terminal and will drive the serial signal over long lines. They’re available for just a few dollars on eBay. Vss 19 6 25 150Ω CON5 COMPOSITE VIDEO OUT 470Ω 18 20 10 µF 16V into the Set-Up menu to invert the signal polarity of the serial interface and then you can directly connect an RS232 device. This arrangement does violate the RS232 rules but it should work fine for short cables up to a metre or two. On the other hand, if your cable run is much longer, then you should use an RS232-to-TTL converter as that will provide a far better level of immunity from electrical noise. Keyboard interface COMPOSITE VIDEO INTERFACE * REQUIRED ONLY IF THE MICRO USES +5V Fig.3: this circuit can be used if all you need is a simple video display for a project. It could be used to drive a low-cost 4.3-inch composite monitor as used with vehicle reversing cameras high speed data transmissions without losing any characters. RS232 RS232 is a serial signalling standard that’s similar to the TTL signalling used here. The difference is that, for RS232, the polarity is inverted and the voltage levels swing from -12V to +12V. RS232 is used in PC serial ports, older modems, test equipment and the original VT100 terminal. The “correct” way to connect an RS232 device to the ASCII Video Terminal to is to use an RS232-to-TTL converter such as the one shown in the 64  Silicon Chip above photo. These don’t cost much and generally use a Maxim MAX232 or MAX3232 chip which generates the required signalling voltages internally. However, you can directly connect an RS232 device to the ASCII Video Terminal if you wish. That’s because the 10kΩ resistor in the RxD (receive data) line will protect the PIC32 from the high voltage swing. In addition, most RS232 devices have a threshold of about +1V when detecting if a signal is high or low and so data from the PIC32, with its output of 0-3.3V, will be detected as a valid signal. Basically, all you need to do is go The keyboard input is via a standard IBM PS/2 connector. Keyboards with this connector are becoming harder to find but they are still out there and generally very cheap. The keyboard input will also work with keyboards that are dual-standard USB or PS/2 (ie, those that come with a suitable adapter). By default, the ASCII Video Terminal is configured to work with the standard US keyboard layout, as used in Australia and NZ. However, using the Set-Up menu, you can also select French, German, Italian, Belgian, Russian or United Kingdom layouts. Note that this does not include generating the special characters required by some languages. All the standard keys on the keyboard will work, including the numeric keypad, Num Lock, Shift and Caps siliconchip.com.au Lock. And by sending the appropriate VT100 escape commands to the ASCII Video Terminal, a program can also independently turn the three LEDs (for Num Lock, Caps Lock & Scroll Lock) on the keyboard on and off. Any keystrokes on the keyboard will be sent out on the TxD (transmit) line of the serial interface. This means that if you don’t have the terminal connected to anything, then pressing keys will not show anything on the screen. This means that when testing the ASCII Video Terminal, the TxD and RxD lines on the serial interface should be bridged so that you can then see the results of your key presses on the screen. USB The USB interface emulates a serial COM connection over USB. This means that you can open a serial emulator on your computer and anything you type will be sent out of the ASCII Video Terminal’s serial interface, just as if it was typed on its own keyboard. Similarly, anything received from the serial interface will be sent via USB to the computer. You can easily add USB capability to a microcontroller with the ASCII Video Terminal or simply use it to act as a USB-to-Serial converter for a Micromite or PICAXE. To use the USB interface on your Windows computer, you need to install the SILICON CHIP USB Serial Port Driver (available from the SILICON CHIP website). This will work with all modern versions of Windows and full instructions are included with the driver. The USB interface uses the standard CDC protocol and drivers are also available on the internet for the Mac and Linux operating systems. Power supply The circuit is powered from an external 5V DC supply and this can be fed in via the USB connector (ie, USB power) or via an external connector (CON3). If you wish to use USB power, you must install a jumper on JP2. However, if you do this, make sure that you do not simultaneously apply power to the external power connector (CON3) as that could cause a conflict with the power supply from the USB host. The 5V supply is used by the keyboard and is also regulated to 3.3V by 3-terminal regulator REG1 which supplies the PIC32 microcontroller siliconchip.com.au Fig.4: the Set-Up Menu is accessed by pressing Shift-F12 on the PS/2 keyboard. All changes are saved in the microcontroller’s flash memory so they will be remembered even if the power is removed. Note that you must have a keyboard and a video display attached to access this menu. (IC1). The specified regulator is a low drop-out device that will continue to deliver a stable 3.3V output even when the USB voltage is at the lower limit allowed by the USB standard (which is 4.5V). The 10µF capacitor on pin 20 (Vcap) of the microcontroller deserves special comment. Its ESR must be less than 1Ω and that means that it must be a multilayer ceramic capacitor or a high-quality tantalum type. Some low-cost tantalums have an ESR higher than 1Ω so if you suspect that yours might fall into this category you should substitute a 47µF tantalum (which should be well within the limit). The only other circuit item of note is the activity LED (LED1). This is illuminated after IC1 has completed its initialisation and this indicates that all is well with the chip. LED1 will also momentarily blink off whenever a keyboard key is pressed or a character is received on the serial or USB interface, indicating that activity is taking place. Selecting functions The ASCII Video Terminal can be interfaced to many different devices but that doesn’t mean they all have to be used. You can leave off any function and the device will still perform the other functions. This includes the USB, the video output and the keyboard. None of these need to be connected if your particular application does not require them. For example, if you just need a simple USB-to-serial bridge in a project, you could use the circuit shown in Fig.2. It uses only nine components including the USB connector and could be either be built on the ASCII Video Terminal PCB or built on a scrap of stripboard. If you just need a simple display in a project, you could add a 4.3-inch graphic display using a low-cost composite monitor. The required circuit is shown in Fig.3 and uses just 10 components. Set-Up menu The Set-Up menu lets you specify a number of options which will be stored in non-volatile memory. This means that they are automatically recalled when power is applied. You must have both a keyboard and a VGA or PAL composite monitor connected to the ASCII Video Terminal to access this menu. It’s brought up by pressing Shift-F12 on the keyboard – see Fig.4. We have covered most of the options that are available on the menu before, so we won’t go over them again. The only new option is “Display startup message on/off”. By default, when the terminal starts up, it will display a message on the video output, showing the version number and copyright. If you don’t want this, you can disable the message (just like on the original VT100). VT100 emulation We have mentioned VT100 emulation several times before but just what July 2014  65 ASCII Video Terminal Escape Codes   Note: codes surrounded by angle brackets (< and >; for example, <v> or <h>) represent one or more decimal digits Auto-wrap mode off Auto-wrap mode on (default) ESC [?7l ESC [?7h Set 36 lines per screen Set 24 lines per screen (default) ESC [?9l ESC [?9h Set alternate keypad mode Set numeric keypad mode (default) ESC = ESC > Turn off all character attributes Turn off all character attributes Turn underline mode on Turn reverse video on Turn invisible text mode on Select font #2 (large characters) Select font #2 (jumbo characters) ESC [m ESC [0m ESC [4m ESC [7m ESC [8m ESC [3m ESC [6m Move cursor up n lines Move cursor down n lines Move cursor right n lines Move cursor left n lines Move cursor to upper left corner Move cursor to upper left corner Move cursor to screen location v,h Move cursor to upper left corner Move cursor to upper left corner Move cursor to screen location v,h Move/scroll window up one line Move/scroll window down one line Move to next line Save cursor position & attributes Restore cursor position & attributes ESC [<n>A ESC [<n>B ESC [<n>C ESC [<n>D ESC [H ESC [;H ESC [<v>;<h>H ESC [f ESC [;f ESC [<v>;<h>f ESC D ESC M ESC E ESC 7 ESC 8 Clear line from cursor right Clear line from cursor right Clear line from cursor left Clear entire line ESC [K ESC [0K ESC [1K ESC [2K Clear screen from cursor down Clear screen from cursor down Clear screen from cursor up Clear entire screen ESC [J ESC [0J ESC [1J ESC [2J Device status report ESC 5n (response is ESC 0n) Get cursor position Response: cursor is at v,h ESC 6n ESC <v>;<h>R Draw a line Draw a box Draw a filled box Draw a circle Draw a filled circle ESC [Z1;<x1>;<y1>;<x2>;<y2>Z ESC [Z2;<x1>;<y1>;<x2>;<y2>Z ESC [Z3;<x1>;<y1>;<x2>;<y2>Z ESC [Z4;<x1>;<y1>;<r>Z ESC [Z5;<x1>;<y1>;<r>Z VT52 Compatibility Mode Codes Enter/exit ANSI mode (VT52) Enter alternate keypad mode Exit alternate keypad mode ESC < ESC = ESC > Move cursor up one line Move cursor down one line Move cursor right one char Move cursor left one char Move cursor to upper left corner Move cursor to v,h location Generate a reverse line-feed ESC A ESC B ESC C ESC D ESC H ESC <v><h> ESC I Erase to end of current line Erase to end of screen ESC K ESC J Identify what the terminal is Response: ESC Z ESC /Z VT100 Special Key Codes These are sent from the terminal back to the computer when the particular key is pressed on the PS/2 keyboard. Note that the numeric keypad keys send different codes in alternate mode. See escape codes above to change the keypad mode. UP DOWN LEFT RIGHT HOME INSERT DEL END PUP PDOWN F1 F2 ESC [A ESC [B ESC [D ESC [C ESC [1~ ESC [2~ ESC [3~ ESC [4~ ESC [5~ ESC [6~ ESC [11~ ESC [12~ Reset terminal to initial state ESC c Identify what terminal type ESC [c Identify what terminal type (another) ESC [0c (response is ESC [?1;0c) UP DOWN LEFT RIGHT ESC [13~ ESC [14~ ESC [15~ ESC [17~ ESC [18~ ESC [19~ ESC [20~ ESC [21~ ESC [23~ ESC [24~ ESC [25~ VT52 Special Key Codes Turn off all three LEDs Turn on LED Num Lock Turn on LED Caps Lock Turn on LED Scroll F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F3+0x20 ESC [0q ESC [1q ESC [2q ESC [3q These codes are sent when the terminal is in VT52 mode. All other keys will generate the VT100 codes listed above. ESC A ESC B ESC D ESC C Fig.5: these are the codes that the terminal will respond to and will send when a special key is pressed. They emulate most of the functions on both the original DEC VT100 and VT52 terminals. Note that the symbol ESC means the escape code (decimal 27, hex 1B) and all codes start with this character. For a more detailed explanation of each code use Google to search for “VT100 User Guide”. 66  Silicon Chip siliconchip.com.au does it mean in practice? Basically, the original VT100 would accept many different codes to perform special functions such as clear the screen or position the cursor. The code would always start with the escape character which is ‘27’ in decimal or ‘1B’ in hex. It would then be followed by a number of ASCII characters which defined the function to be carried out. That is why they are called “escape codes”. You would be hard pressed to purchase a VT100 terminal these days (most are in museums) but its repertoire of escape codes has become a defacto standard and any serial terminal worth its salt will recognise VT100 codes. The ASCII Video Terminal implements most of these VT100 escape codes which means that it will work with any software that requires VT100 emulation. Fig.5 lists the codes recognised by the ASCII Video Terminal. These include useful functions such as positioning the cursor, selecting reverse video, clearing the display, etc. There are also some less useful codes (such as set invisible text mode) but we implemented all that we could in the interests of compatibility. For a more detailed explanation of each code use Google to search for “VT100 User Guide”. Note that all the escape codes start with the escape character which is shown in the table as “ESC” . To give you an example of how you would generate these codes, the following program fragment running on a Micromite will clear the screen: PRINT CHR$(27)+"[2J"; The following code will then position the cursor at the top left hand position on the screen: PRINT CHR$(27)+"[f"; In these examples, CHR$(27) generates the escape code and the “+” symbol joins it to the following characters. The semicolon at the end of the statement suppresses the carriage return and line feed characters which BASIC normally adds to the end of any print statement. In addition, the ASCII Video Terminal adds some extensions to the VT100 standard. These include codes to select 36 or 24 lines per screen for VGA and the ability to select from two extra large sized fonts (large and jumbo). It also siliconchip.com.au includes codes to draw lines, boxes and circles on the screen. In the latter case, the terms “X1” and “Y1” refer to the starting position on the screen and “X2” and “Y2” refer to the ending position. In the case of a circle, “R” is the radius of the circle. All these variables are in pixels, with the top lefthand corner of the screen being X=0 and Y=0. X is the horizontal position and Y is the vertical, with both getting greater as you move away from the top left corner. The overall resolution depends on the display mode and these are listed in the features box. The following example demonstrates how to draw a circle with a radius of 100 pixels at the centre of the screen (which is at pixel 240 by 144 when in VGA 24-line mode): PRINT CHR$(27)+" [Z4;240;144;100Z"; Fig.5 also lists the codes generated by the terminal when a special key is pressed on the keyboard. These keys include the arrow keys, function keys, Home and End. These codes are also preceded by an escape character and followed by 1-4 characters which indicate the actual key pressed. It is then up to the program running on the Micromite or PICAXE to interpret and act on these codes. VT52 emulation The VT52 terminal was the little brother to the VT100 terminal and recognised a more limited range of codes. These codes are also less complex than the VT100 codes and some software programs insist on using them, so we have also included support for these. If you want to use VT52 codes, you can put the ASCII Video Terminal into VT52 mode by sending the code “ESC <”. To exit this mode, you simply send the same code again. The arrow keys on the keyboard generate different escape codes when in VT52 mode. Fig.5 also lists these codes. Construction The complete ASCII Video Terminal is built on a single PCB coded 24107141 and measuring 90mm x 51mm. It uses standard through-hole components (ie, no surface-mount parts), so construction is easy. If you wish to mount it in a box, the dimensions and mounting holes are sized Parts List 1 double-sided PCB, 90mm x 51mm, code 24107141 1 USB Type B socket, PCB mount (Jaycar PS-0920, Altronics P1307, element14 1696537) (CON2) 1 DE-15 (or HD-15) high-density 15-pin female D-connector (AMP 1-1734530-1, MULTICOMP SPC15430, element14 1557991 or 1564252) (CON6) 1 RCA socket, PCB mount (Jaycar PS0279, Altronics P0146A) (CON5) 1 6-pin mini DIN female socket, PCB mount (CON4) 1 28-pin DIL IC Socket 1 8MHz crystal (X1) 1 4-way polarised header, PCB mount, 0.1 inch pitch (CON1) 1 2-way polarised header, PCB mount, 0.1 inch pitch (CON3) 1 10-way snappable pin header, 0.1 inch pitch (CON7,JP1,JP2) 1 2 x 3 male pin header (JP3) 5 shorting blocks, 0.1-inch pitch Semiconductors 1 PIC32MX250F128B-I/SP microcontroller programmed with 2410714A.hex (IC1) 1 Microchip MCP1700-3302E TO92 voltage regulator (REG1) 1 red LED, 3mm or 5mm (LED1) Capacitors 3 10µF 16V tantalum 2 100nF monolithic ceramic 2 27pF ceramic Resistors (0.25W 5%) 1 100kΩ 1 220Ω* 1 10kΩ 1 150Ω 4 4.7kΩ 1 82Ω 1 470Ω * Replace with two paralleled 330Ω resistors if using two VGA colours. to suit a standard ABS box measuring 120 x 60 x 30mm (Altronics H0216 or Jaycar HB6032). Fig.6 shows the parts layout on the PCB. The first step is to decide what colour the text on the VGA monitor should be. This is selected by bridging one of three sets of pads with solder. This is best done first, as the jumper pads can be difficult to access once parts have been mounted. July 2014  67 COMPOSITE VIDEO PS/2 KEYBOARD VGA OUTPUT CON6 X1 8MHz A B C 3.3V RxD TxD GND CON1 A USB PWR JP2 * +5V GND CON3 + + 4.7k 100nF 220Ω LED1 100k JP3 BAUD RATE 27pF 10k 27pF 4.7k JP1 BOOTLOAD 10 µF 10 µF 3 1 BLU GRN RED 14 1 470Ω IC1 PIC32MX250F128B 150Ω 15 82Ω 100nF 10 µF 2 28 + 1 CON4 CON7 ICSP 4 4.7k 4.7k CON5 REG1 CON2 USB * INSTALL JP2 FOR USB POWER ONLY. REMOVE JP2 FOR EXTERNAL POWER VIA CON3. Fig.6: follow this diagram and the photo at right to build the ASCII Video Terminal. All the parts are mounted on a single PCB which makes it easy to incorporate into another project. As previously stated, we recommend that you select the colour green, ie, by bridging the pads marked GRN. It’s then simply a matter of populating the board, starting with the low-profile components such as the resistors, the crystal and the capacitors. Leave the larger components such as the connectors until last. Note that the crystal should be mounted 1-2mm proud of the PCB so that there is no danger of its case shorting on the solder pads. However, this is not strictly necessary if you are using a SILICON CHIP PCB because this will have solder resist covering the top solder pads. Another point to note is that the footprint for the RCA socket will accommodate either a standard socket or a switched socket (the switching mechanism is not used). An IC socket should be used for the microcontroller as that will help with fault-finding and testing. If you have a blank PIC32 microcontroller, the appropriate firmware should be downloaded from the SILICON CHIP website and programmed into it using a programmer such as the PICkit 3. The PCB includes a footprint for the ICSP (In Circuit Serial Programmer) header, so that you can program the microcontroller in-circuit. Alternatively, you can purchase a microcontroller pre-programmed with the latest firmware from the SILICON CHIP Online Shop. In that case, the ICSP header can be left out. The PCB for this project is also available from the Online Shop. The baud rate selection is done by slipping shorting links over pairs of pins on 6-pin header JP3 (see Fig.1). Alternatively, you could mount a 3-way DIP switch in place of the headers if you want to make it more convenient to change the speed. Testing The completed unit can now be tested by following this step-by-step procedure: (1) Remove microcontroller IC1 from its socket. (2) Apply power to the unit from a Table 1: Resistor Colour Codes   o o o o o o o o No.   1   1   4   1   1   1   1 68  Silicon Chip Value 100kΩ 10kΩ 4.7kΩ 470Ω 220Ω 150Ω 82Ω 4-Band Code (1%) brown black yellow brown brown black orange brown yellow violet red brown yellow violet brown brown red red brown brown brown green brown brown grey red black brown 5V bench supply or USB supply and check that +3.3V is present on pins 13, 23 & 28 of the IC socket. (3) If the supply rail is correct, remove the power and install the microcontroller (make sure that it is orientated correctly). (4) Reapply power and check that LED1 is illuminated. If so, this means that the microcontroller is correctly running its firmware and everything is OK in that department. (5) Switch off, connect a keyboard and video monitor and then short the TxD & RxD pins on the serial interface connector (CON1). (6) Reapply power and test the keyboard, monitor and serial interface by typing characters on the keyboard. You should see them echoed on the monitor via the serial interface. (7) Leave the TxD to RxD short in place and connect the ASCII Video Terminal  Table 2: Capacitor Codes Value µF Value IEC Code EIA Code 100nF   0.1µF   100n   104 27pF   NA   27p   27 5-Band Code (1%) brown black black orange brown brown black black red brown yellow violet black brown brown yellow violet black black brown red red black black brown brown green black black brown grey red black gold brown siliconchip.com.au to a USB port on your PC using a suitable cable. (8) Check that anything typed into your terminal emulator is echoed on both the monitor and on your computer’s screen. Fault finding Fault finding is simple because the only significant component is microcontroller IC1. If the indicator LED illuminates, it means that the microcontroller has initialised and is working correctly. Conversely, if the LED doesn’t light, check the power supply. If this is correct but the LED is still out, the fault must either be in the microcontroller, its programming or the 10µF capacitor attached to pin 20. If the problem is associated with the keyboard or monitor, check the relevant parts carefully. For example, if the keyboard doesn’t work, check your soldering around the PS/2 socket and any other parts associated with the keyboard. Firmware update There is always the chance that the firmware may contain a bug or we may This view shows the main I/O connectors. From left, they are the highdensity 15 pin connector for VGA video, the RCA connector for the composite video output and finally the mini-DIN connector for a PS/2 keyboard. Note that only one video connector should be used at a time. later think of a feature that could be added. If so, we will make an updated version of the firmware available which you can load without a programmer. Updating the firmware is easy to do (full instructions will be included with the update). To start the process, remove power, short jumper JP1 (marked BOOTLOAD on the PCB) and then reapply power. The firmware will then switch into update mode and will wait for the new firmware to be transferred via the USB interface. On your Windows PC, you then run a program (supplied with the update) to transfer the new firmware to the microcontroller. The whole process is quite painless and will take less than a minute. For firmware updates and handy hints, check the author’s website at http://geoffg.net/terminal.html So, there you have it. Your very own VT100-compatible terminal, ready to SC connect to your next creation. Radio, Television & Hobbies: the COMPLETE archive on DVD YES! NA R O M E THA URY T N E QUARTER C NICS O OF ELECTR ! HISTORY This remarkable collection of PDFs covers every issue of R & H, as it was known from the beginning (April 1939 – price sixpence!) right through to the final edition of R, TV & H in March 1965, before it disappeared forever with the change of name to EA. For the first time ever, complete and in one handy DVD, every article and every issue is covered. If you’re an old timer (or even young timer!) into vintage radio, it doesn’t get much more vintage than this. If you’re a student of history, this archive gives an extraordinary insight into the amazing breakthroughs made in radio and electronics technology following the war years. And speaking of the war years, R & H had some of the best propaganda imaginable! Even if you’re just an electronics dabbler, there’s something here to interest you. • Every issue individually archived, by month and year • Complete with index for each year • A must-have for everyone interested in electronics Please note: this archive is in PDF format on DVD for PC. Your computer will need a DVD-ROM or DVD-recorder (not a CD!) and Acrobat Reader 6 or above (free download) to enable you to view this archive. This DVD is NOT playable through a standard A/V-type DVD player. Exclusive to SILICON CHIP ONLY 62 $ 00 +$10.00 P&P HERE’S HOW TO ORDER YOUR COPY: BY PHONE:* (02) 9939 3295 9-4 Mon-Fri BY FAX:# (02) 9939 2648 24 Hours 7 Days <at> BY EMAIL:# silchip<at>siliconchip.com.au 24 Hours 7 Days BY MAIL:# PO Box 139, Collaroy NSW 2097 * Please have your credit card handy! # Don’t forget to include your name, address, phone no and credit card details. siliconchip.com.au BY INTERNET:^ siliconchip.com.au 24 Hours 7 Days ^ You will be prompted for required information July 2014  69