Introduction
When you use microcontrollers in your designs, sometime you face a problem how to show user required data. Several LEDs, 7 segment display or LCD module can be solution. But if you must show a lot of information simultaneously, it can be difficulty. Large LCD modules are expensive and graphic modules require complicated control. You can solve it with a help of PC. Just send data via serial line to the computer and display everything on computer's display. But another user usually occupies computer or you need it for another job ... :-)I have had to solve the same problem some time ago. I have chosen normal small TV set for that. A lot of families change TV in this time because of digital broadcasting or modern flat and slim LCD and plasma displays. So they put older TV set away and it is dormant somewhere. Or you can buy older TV very cheap.
Aim of construction
The display unit must be maximum easy. For data displaying is text mode with semigraphic mode sufficient. Just only 1 integrated circuit - microcontroller - must guarantee every function of the unit. A keyboard will be useful for data input."Button by button" assembling of keyboard is complicated and mechanical design is a weak point in hobby construction. Special keyboards are usually inaccessible or expensive. That's why I have chosen standard IBM PC keyboard. PC keyboard solves as design as character variability - there are all characters on keyboard. Economic view is very advantageous and accessibility is almost unbeatable. The size is disadvantage of PC keyboard but beside TV set it doesn't matter.
I have developed 2 versions of TV terminal. "Built-in" version is designed for utilization in device. The second version is standalone device with external power source.
The described TV terminal accomplishes these results:
Display mode: | black and white |
Text mode: | 40 characters x 25 lines |
Semigraphic mode: | 80 x 75 "points" |
Printable characters: | ASCII 32 - 127 |
Keyboard: | IBM PC AT compatible |
Control characters: | 11 |
Serial line speeds: | 1200 Bd to 115.2 kBd |
Power supply: | 9 - 12 V or 5 V (built-in version) |
Current consumption: | cca 30 mA + keyboard consumption |
Wiring diagram
TV terminal utilization is very easy. Connect video output to video (AV) input on TV set. Set communication speed on J1 jumpers. You can connect PC keyboard but it isn't necessary. Turn terminal ON and display will show current parameters. The terminal is in full operation 3 seconds later.Wiring diagram for standalone version (Please click on schematic to view it large)
Wiring diagram for built-in version
The U1 microcontroller has to maintain 3 independent processes:
- Video signal generation.
- Character reception from the keyboard, decoding and dispatch to serial line.
- Receiving characters from serial line and storing it in the memory.
Independency for every of these 3 processes was the most complicated task. Video signal must be generated utterly on the dot. Program was created in assembler and compiled code is here.
Microcontroller clock is on maximum frequency - 20 MHz. Frequency 22 MHz would be better, but for reproducibility I accepted 20 MHz. This backtracking brings slight differences in the horizontal width of pixels. Forgive me - it is only hobby design (or maybe you will notice this never :-).
The power supply voltage regulator and logic level converter are included in the standalone version. To keep circuit easy I selected (inspired by biprog) simple converter with 2 transistors. There is no problem with short serial line. But if you connect long wires with bigger capacity then communication can produce errors in higher speeds. Be careful with used keyboard. Consumption most of them is reasonable low, but there are types with consumption above 100 mA. High current causes overheating of U2 voltage regulator. Use voltage regulator 7805 in the TO220 case or reduce power supply voltage in this event.
Setting in operation
It is very easy to make both versions of TV terminal. Mount and solder every component to PC board. Check up complete device. The last operation is downloading program into microcontroller. Set fuses: RESET=ON, BROWN-OUT LEVEL 4.0V, OSCILLATOR=EXT. CRYSTAL HIGH FREQ.Component bill is here...
PCB for standalone version
PCB for built-in (SMD) version
For standalone version
For built-in (SMD) version
Properly programmed microcontroller with running oscillator will produce video signal. Change slightly value of R7 when TV doesn't synchronize.
Connect built-in version directly to other microcontroller. Logic levels respond standard convention (log. "1" = 5 V). I suggest connecting serial line input and output for the first test. Type text on keyboard and check TV screen.
PCB for standalone version is designed to suit in KG22M plastic box (see programmer biprog). Make 3 rectangle and 1 round holes in box (style "attach, see and then use file or drill").
Application of TV terminal
TV terminal responds to 3 character types:- Control characters (11 selected characters)
- Printable ASCII characters 32 - 127
- Semigraphic characters 128 - 191
Active control characters are in the table. To tell the truth, I have modified function for control characters SOH, STX, DC1,... DC4. Emulation e.g. VT100 terminal is to no effect for such easy device. Terminal control is easier and quicker with this reduction. Default "new line" is achieved by CR+LF.
Character | Decimal value | Hexadecimal | Description |
SOH | 1 | 0x01 | Set mode "CR or LF for new line" (Unix, Apple like) |
STX | 2 | 0x02 | Set mode "CR and LF for new line" (Microsoft like) |
BS | 8 | 0x08 | Backspace |
TAB | 9 | 0x09 | Horizontal TAB - move cursor to position modulo 8 |
LF | 10 | 0x0A | Line feed (see SOH and STX as well) |
FF | 12 | 0x0C | Form feed (clear screen) |
CR | 13 | 0x0D | Carriage return (see SOH and STX as well) |
DC1 | 17 | 0x11 | Cursor ON |
DC2 | 18 | 0x12 | Cursor OFF |
DC3 | 19 | 0x13 | Next byte will specify X position of cursor |
DC4 | 20 | 0x14 | Next byte will specify Y position of cursor |
Semigraphic characters are split into 6 squares. Semigraphic code is explained in the picture.
You can type printable characters directly. Special characters (e.g. control characters or characters above 127) can be placed as well. Left ALT must be pressed at first and then 2 hexadecimal characters follow. E.g.: for LF character press successively keys "left ALT" + "0" + "A". This way you can place all characters 0 to 255.
Special keyboard mode is remnant from the development time. When you press F12 key then keyboard is switched into "SCAN mode". Pressing of key will produce text string with base SCAN code of the key. E.g. press keys "A" and "B" - terminal will send text string "1C 32 ". Key F12 stops this mode as well.
There must be the same speed on the both devices for the proper communication. Serial line speed is conditioned through JUMPERs J1-0, J1-1 and J1-2 (see table). Communication is 8 bit always. Communication parameters are displayed for about 3 seconds on the screen after the start.
Speed | |||
115200 Bd | |||
57600 Bd | |||
38400 Bd | |||
19200 Bd | |||
9600 Bd | |||
4800 Bd | |||
2400 Bd | |||
1200 Bd |
Conclusion
This TV terminal is very easy device. Even a beginner should assemble it without problems. TV terminal is practical for your microcontroller-controlled device. Most of modern microcontrollers have built-in universal serial unit. So you can design user interface very easy with TV terminal and few line code in your microcontroller.TV terminal is advantageous for:
- device with a lot of displayed information,
- debugging phase of design (I work on the PC and TV terminal is interface for debugged microcontroller),
- to make keyboard and display for occasionally gadget is waste of time.
No comments:
Post a Comment