DESIGN OF AW IRELESS KEYBOARD, AUDIO, VIDEO & MOUSE SWITCH by 8Ti9QMoo

VIEWS: 0 PAGES: 30

									Language Detecting Keyboard with LCD Touch Screen Interface


                            By



                       Joon Sang Ryu
                        Si Hyung Lee
                      Sung Hwan Kim




            ECE 445, SENIOR DESIGN PROJECT

                        FALL 2008




                       TA: Ben Graf


                     09 December 2008


                       Project No. 16
                                               ABSTRACT


We designed and built a language detecting keyboard with LCD touch screen interface. This keyboard
automatically detects the language mode the user is in and changes the display of the keyboard to the
corresponding language on a LCD screen. Users frequently alternates between two or more languages
will find this keyboard very appealing and useful.

Once the programmed code detects the language mode from the system, the obtained language code is
infinitely sent to the FPGA board for graphic display of the LCD screen through RS232 cable.
Whenever the language mode of the system is changed, the display of the LCD screen also changes
correspondingly.

The touch screen acts as a keyboard and to find the spot of the keys of the touch screen, A/D converter,
bilateral switch, and coordinate controller was used. The A/D converter receives the analog signal from
the bilateral switch and converts it to digital signal to send it to the coordinate controller. The coordinate
controller receives a 10 bit digital signal from the A/D converter and matches the spot of the touch
screen to the LCD keyboard display.

Most of our project worked, except for displaying the typed characters to the monitor. We were able to
distinguish each key from each other but couldn’t figure out the transmission via PS/2. Some more
improvements could have been made to reduce the delay which will be further discussed later.

The cost of the project was around what we expected, but the actual components used were modified
from our initial plan. There are also some ways we can and should reduce the cost, which will also be
mentioned in conclusion.




                                                      ii
                                                         TABLE OF CONTENTS

1.   INTRODUCTION ....................................................................................................................1
     1.1 Purpose ...............................................................................................................................1
     1.2 Specifications ......................................................................................................................1
     1.3 Subprojects .........................................................................................................................3
         1.3.1 Language Detector Module .......................................................................................3
         1.3.2 RS232 Transmitter Module .......................................................................................3
         1.3.3 RS232 Receiver Module (UART) .............................................................................3
         1.3.4 VGA Controller Module ...........................................................................................3
         1.3.5 Color Mapper Module ...............................................................................................3
         1.3.6 Bilateral Switch Module ............................................................................................3
         1.3.7 Analog to Digital Conversion Module .................. Error! Bookmark not defined.3
         1.3.8 Coordinate Control Module.......................................................................................4

2.   DESIGN PROCEDURE ...........................................................................................................5
     2.1 Language Detector Design .................................................................................................5
     2.2 RS232 Transmitter Design .................................................................................................5
     2.3 RS232 Receiver Design (UART) ................................... Error! Bookmark not defined.5
     2.4 VGA Controller Module .....................................................................................................7
     2.5 Color Mapper Module.........................................................................................................7
     2.6 Bilateral Switch Design ......................................................................................................7
     2.7 Analog to Digital Conversion Design .................................................................................8
     2.8 Coordinate Control Design .................................................................................................8

3.   DESIGN DETAILS ................................................................................................................10
     3.1.1 Language Detector Module ...........................................................................................10
     3.1.2 RS232 Transmitter Module ...........................................................................................10
     3.2 RS232 & Graphic Controller ............................................................................................11
     3.2.1 “Async Receiver”: RS232 Receiver Module (UART) ..................................................12
     3.2.2 VGA Controller Module ................................................................................................13
     3.2.3 Color Mapper Module ...................................................................................................13
     3.4 Bilateral Switch Module ...................................................................................................14
     3.5 Analog to Digital Conversion Module .............................................................................14
     3.6 Coordinate Control Module ..............................................................................................15

4.   DESIGN VERIFICATION .....................................................................................................17
     4.1 Testing ..............................................................................................................................17
         4.1.1 Language Detector Module .....................................................................................17
         4.1.2 RS232 Transmitter Module .....................................................................................17
         4.1.3 RS232 Receiver Module (UART) ...........................................................................17
         4.1.4 VGA Controller & Color Mapper Module ..............................................................17
         4.1.5 Bilateral Switch Module ..........................................................................................18
         4.1.6 Analog to Digital Conversion Module ....................................................................18
         4.1.7 Coordinate Control Module.....................................................................................18

5.   COST ......................................................................................................................................22
     5.1 Parts ..................................................................................................................................22
     5.2 Labor .................................................................................................................................22
     5.3 Total ..................................................................................................................................22

                                                                            iii
6.   CONCLUSIONS ....................................................................................................................23

     REFERENCES .......................................................................................................................24

     APPENDIX A – Programmed Codes .....................................................................................25




                                                                       iv
                                         1. INTRODUCTION

Our group designed and created a keyboard that detects the language change in Microsoft Windows. The
keyboard consists of LCD screen and touch screen pad which shows the corresponding language key
configuration on the screen. The general components consist of FPGA, which controls the image shown
on the LCD, and touch screen controller which deals with the touch screen used as a touch pad. The
software will need to be installed into the user’s computer to detect the language and send the signal to
the FPGA. The basic computer to device connections will consist of PS/2 cable, for usage of device as
keyboard, and RS232 cable, for sending out the language detection to FPGA.

1.1 Purpose

The purpose of this project was to use all the knowledge that we learned from college (and more) to
build a device that could be useful to the public. We wanted to help any bilingual population who are
beginning computer users who need to type more than one language on the computer. Even though
solutions to this problem currently exist in many ways, they seem to be not so desirable in many ways.
The first solution that people end up with is using keyboard sticker, which tend to be not so visually
appealing. Another option would be buying programmable keyboard with led keys. However, they tend
to cost above $1,000 and average of $1500. So, we wanted to design something that can become visually
appealing and cheap at the same time. Another consideration we took when designing this keyboard was
making the whole process simple to the target audience. So, we decided to make keyboard that
automatically detects language, instead of users having to programming it.


1.2 Specifications

The project mainly consisted of three parts, computer interface, display controller, and touch screen
sensor controller.




                                                    1
Computer Interface                                                               Touch Screen Sensor Controller




Display Controller




       Figure 1. Overall block diagram for the project

       Computer, language detection, and LangID Tx via RS232 were for computer interface. Keyboard
       configuration decision and touch-screen display were for display controller. User input, A/D converter
       and PIC were for touch screen sensor controller. The communication between the computer interface
       and the display controller was done by RS-232 signals, and the communication between the display
       controller and the touch screen sensor controller were designed to be done by PS/2 signals.

       Our final product worked as we expected for the computer interface and the display controller parts. The
       computer interface could successfully retrieve the current language settings spontaneously. Whenever
       the region code was changed in the control panel, the detecting system responded and sent out the
       corresponding code immediately. The display controller could receive the RS-232 signal successfully
       and show the correct language key configurations on the display with no delays.

       The touch screen sensor controller was capable of sensing user’s touching on the screen, converting
       analog signals from the touch screen panel to digital signals in PIC, and assigning PS/2 signal codes for
       each key press. Although these involved some delays, they functioned as we aimed from the beginning
       of the project. However, the only part that did not work was actually sending out the PS/2 keyboard
       signals from the touch screen sensor controller.




                                                           2
1.3 Subprojects

The project was divided further from the big three divisions of the project (LangID Detection, RS232
Transfer to LCD Display, and Touch Screen Controller). The subprojects are the following.

1.3.1. Language Detector Module

The language detector is to detect which language mode the current user of the system is in and return
the corresponding language identifier value. Each language has a unique identifier value that distinct
from all other languages.

1.3.2. RS232 Transmitter Module

The RS232 transmitter module is to receive the language identifier value from the language detector and
transmit it out to through RS232 cable to the FPGA board. The transmitter uses the baudrate of 115200
bps.

1.3.3. RS232 Receiver Module (UART)

RS2332 receiver module is to properly receive the asynchronous RS-232 incoming signals. It converts
the serial incoming data into parallel data bits after filtering out the start bit and the stop bit. UART
involves clock reducer for the FPGA board, synchronizer for the board’s clock and the rate of incoming
RS-232 signals, and an 8-bit register to hold received data bits and to send out the proper decision signal
out to color mapper telling if the computer is currently in English settings or in Korean settings.

1.3.4. VGA Controller Module

VGA controller module manipulates which pixels on the LCD screen (touch screen keyboard) to be
considered and determined what to show. It involves horizontal signals, vertical signals, VGA clock,
blank, and sync signals. Every time the controller moves from one pixel to another, it sends out DrawX
and DrawY pixel coordinate signals to Color Mapper asking what color to fill into those pixels.

1.3.5. Color Mapper Module

Color mapper module receives DrawX and DrawY pixel coordinate signals from VGA controller
module, and it displays the correct combination of Red, Green, and Blue color signals on the screen
(touch screen keyboard) based on the decision signal sent from the receiver module.


1.3.6. Bilateral Switch Module

The Bilateral Switch were to switch each end of touch screen pad (Y+, Y-, X+, X-) according to control
signal coming from the control module, which will be mentioned later. When Y coordinate needs to be
read, X ends are to become open while Y+ becomes 5V and Y- become ground. For X coordinate
reading, Y ends connects to open while X+ becomes 5V and Y- become ground.

1.3.7. Analog to Digital Conversion Module

The Analog to Digital Conversion Module is supposed to read analog signal coming out of bilateral
switches that originate from the Y+ and X+. They will be ranging from 0 to 5Volts. The module sends
out 10bit binary digital signal for coordinate comparison and calculation.
                                                     3
1.3.8. Coordinate Control Module

This module receives least significant 8 bit signal from analog to digital conversion module. The most
significant 2 bits of digital signal is ignored because they either do not change or 8 least significant bits
do not have overlap of range. When the touch is detected, this module first sends out signal to bilateral
switches to measure y-coordinate. Once the y-coordinate is acquired, it sends out another set of control
signal to bilateral switch to acquire x-coordinate. Once the y and x coordinates are determined, it sends
out PS/2 signal to be used as a keyboard.




                                                      4
                                       2. DESIGN PROCEDURE


2.1. Language Detector Design

Among many programming language such as Visual C++, MatLab, VHDL, Visual Basic, and so on, we
decided to use Visual C++ to design the language detector. Since our project was based on Windows XP
operating system, we thought it would be more efficient in terms of time consumption and easier to
program with a Microsoft product. Our initial assumption was correct and we were able to find an
embedded function in Windows XP from MSDN Library that directly returns the value we attempted to
obtain. In addition, Visual C++ was a relatively cheap programming language compared to MatLab and
other languages that are in market for commercial use.

2.2. RS232 Transmitter Design

RS232 required software programming and the first step was to decide which programming language to
use. From our previous experience when designing a language detector, our initial educated guess was to
use Visual C++ again. If programming the RS232 transmitter with Visual C++ was done successfully,
we would have readily been able to interconnect it with our Language Detector Design.

However, unidentifiable errors were continuously found and we couldn’t obtain the expected results.
Therefore we moved on to our contingency plan to use MatLab R2008a. We have tried the most to avoid
using MatLab because it costs much more than other programming languages, but it had become the
only solution to the problem we faced. The first thing I had to keep in mind when designing the RS232
transmitter was to discuss and decide the baudrate. Since the transmitter from the computer and receiver
from the FPGA board was a separate task, we had to come up with the best matching baudrate of the
two.

The most challenging part of the design was constructing a bridge between the RS232 transmitter and
the Language Detector. Since they were programmed in different languages, we couldn’t just combine
the codes to get the result. This role was done by creating a text file from Visual C++ and retrieving that
text file from MatLab.

2.3. RS232 Receiver Design (UART)

RS232 receiver module was implemented by VHDL language in Quartus II, then the code was
downloaded to Altera DE2 FPGA board. We once dealt with PS/2 signals before in ECE385 using
Quartus II with the same FPGA board. Therefore, we were already comfortable with VHDL coding, and
chose it for our project. We believed that using Quartus II would let us control the RS-232 signals with
minimal errors and time because of our previous experience. However, although PS/2 signals and RS-
232 signals were both using serial bit transmissions, they had a big difference since PS/2 was
synchronous but RS-232 was asynchronous.

This means that PS/2 cable includes its own PS/2 clock in the cable, but RS-232 does not. In PS/2 case,
we could have used clock reducer for the board clock and D-flip flops to synchronize the reduced board
clock and the embedded PS/2 clock from the cable. We used 9-pin RS-232 cable and it involves data
carrier detect, received data, transmitted data, data terminal ready, signal ground, data set ready, request
to send, clear to send, and ring indicator.




                                                     5
Figure 2.0 Pin out for RS-232 cable.
(* retrieved from http://mail.pet.ac.il/~michaelk/Documents/RS232Tutorial_files/9_PIN_PIN_OUT.gif)

As seen from figure 2.0, there is no clock signal coming through the RS-232 cable. In addition, the only
pins we used for our project was pin2 and pin5, receiving data bits and signal ground. Since we were not
sending any signals from the FPGA board to the computer, we did not have to use pin3, transmitting
data. All the other remaining pins did not come up for any use in our project.

We could not use the same synchronizer and registers with different bit length as from ECE385.
Therefore, we researched how RS-232 signal transmission exactly works, and found that transmission
formats can judged by the user by varying data bit lengths, stop bit lengths, parity bit lengths, stop bit
lengths, and baud rates to send all of these trough the cable.

The start bit is fixed as 1-bit so we did not have any options. For data bit lengths, we had options of
4,5,6,7, or 8 bit long. We chose 8 bit following the most used format in general. For the parity bits, we
had options of 0 or 1 bit, but we did not use any parity bits. We wanted to minimize the complexity of
the signal flowing in the cable for easier manipulation of the receiver. Also, since the transmitting
module was sending all zeros or all ones depending on the language settings, the exact bit-to-bit content
of the data did not matter much. All we needed was either zero or one to recognize the language settings.
For the stop bit, we had options of 1, 1.5, or 2 bit long. We used 1 stop bit following the general format.
We had many options for the baud rate. 1200, 9600, 38400, 115200, and many others were available.
                                                       6
We chose 115200, which was the second fastest among the baud rates we have found, because we
wanted to minimize the delay in the signal transmissions, and also we did not want to risk any noise or
unexpected random variables getting involved from using too high baud rates at the same time. Thus, we
used 1-start bit, 8-data bit, no parity bit, 1-stop bit at 115200 baud rate.

Once we confirmed which format to use, remaining steps were to match with the format.

2.4. VGA Controller Module

Since we did not need any modifications to the pixel coordinate controls, we could reuse the code from
ECE385.

2.5. Color Mapper Module

We initially wanted to upload JPEG file of our two keyboard pictures for English and Korean to the
FPGA board’s memory. In this way, we could reduce the time for drawing the keyboard configurations,
and have ease of altering the configuration details whenever we want. However, we realized that our
model requires extra components to enable JPEG uploading. After consulting with the teaching
assistants, we learned that it is possible to upload JPEG on our board, but it will require so much coding
and works that the whole job can be considered as one independent senior design project.

Therefore, we had to choose laborious method of defining every single pixel’s colors upon conditions
and coordinate ranges.


2.6. Bilateral Switch Design

When designing Bilateral Switch Module, initial thought that came across my mind was Multiplexer.
However, multiplexers are used for digital signal and only sends high or low signal. For our purpose, it
was important to use a component that could pass analog signal and be able to retain its value. If that
was not possible, at least be able to transmit analog signal proportionately, so we can later amplify
signal if needed.

The bilateral switch, CD4016CN, was used because it functioned exactly the way we wanted. It was
able to transmit analog signal, and the data read from the other side was the same as the data read from
the input. The image of CD4016CN circuit is shown in the datasheet in figure 2.1.




                                                    7
Figure 2.1 datasheet schematic of bilateral switch

We first tested the circuit using the power supply, where we can adjust the voltage to measure the
voltage coming out of the other side. The test seemed successful and started designing this module.
Since the control signal that is supposed to come from the Coordinate Control Module is not present yet,
I tested the circuit by making coordinate control signal by connecting to Vcc or ground, and observing
the output. Further circuit detail such as pin connections are discussed in the Design Detail section.

2.7. Analog to Digital Conversion Design

The A/D Module was designed with PIC 16F877A. The alternative solution to using PIC 16F877A
could have been using any other A/D component available from the part shop or in the market.
However, PIC was readily available for the project and was used. Also, the initial thought of using A/D
converter with PIC made sense in the beginning because if the PIC had enough memory and space, we
would be able to put all the programming into 1 PIC.

However, the thought of putting the entire program was not possible due to limitation of PIC 16F877A.
Therefore, we used inbuilt A/D converter in separate PICs. The testing A/D converter was done with the
LEDs in series with some resistor. Initially, we thought of using multi-meter to measure each digital
output, but it was very confusing because the output was constantly changing due to sensitive change in
the input (this is totally understandable because hand pressing onto the touch screen is not totally stable).
Since we are using 10 bit digital signal as output of the converter, we connected each output with LED.
We found that we did not really need first 2 bit of the digital output because it either did not light up at
all coordinate within the keyboard, or bit 7 to 0 did not overlap for whole range of the keyboard.

When I programmed PIC with 2 analog input signals and 20 digital output signals, the PIC was not able
to read input and output the correct value of digital output all the time. Because of its unreliability, we
decided to use two PICs for x and y coordinate-conversions.

Once the A/D was confirm to work (decreasing binary number with pressing onto lower y or x
coordinate on Touch Screen), we moved onto designing coordinate control module.

2.8. Coordinate Control Design

The LEDs used for A/D proved useful for coordinate control designing (I started measuring and took
data only when the LEDs seemed to be relatively stable. Since this part consisted of tedious work of
finding out the x and y coordinate range of each key in the keyboard, it took long time to figure out each
range and write the code.

The condition “If” was used for most part of conditions on the coding. The alternative would have been
using interrupt for the coordinate detecting part of the designing for less delay in output. However, this
part does not seem to be too useful in shortening the time because most of the “if” statements are
actually after detecting touch. The comparison of y coordinates and x coordinates contributes much
more to the delay than touch detecting part. Also, another alternative of y and x coordinate control
would have been using case function. After researching online, we found that the improvement of
efficiency by using “case” instead of “if” was only minimal.

The actual digital numbers used for each key is listed in the design detail, and if this project was to be re
constructed with different graphic, this part will need major modification.


                                                      8
The other part of the coordinate control actually happens before the actual coordinate calculation. It is
the production of signal that goes to the bilateral switch, it needs to send signal to read y coordinate until
the touch screen is touched at all time. Then, once the screen is touched and y coordinate is read, the x
coordinate reading control bits are sent to the bilateral switch. After getting x coordinate change, it goes
back to touch detecting state.

The last part of the coordinate control design is the sending of PS/2 data. The PS/2 clock cannot be
produced with the PIC 16F877A because of the clock limitation. PS/2 clock needs to be created
externally at 10 kHz and connected to the PS/2 cable itself. For the PS/2 data sending, it is relatively
simple procedure. All we need to do is to turn the signal high or low with some delay, which could be
done in the coding. For each key, the separate PS/2 code needs to be written. The change that needs to
be made is the changing of PIC to better processor with bigger space because the all PS/2 code cannot fit
into PIC due to space and memory limitation.




                                                      9
3. DESIGN DETAILS

3.1. Language Detector Module

Designing a language detector was the first part of this project. To create a LCD language detecting
keyboard, it is evidently essential for the keyboard to be able to be aware of what language mode the
current system is on. We used a function called “GetUserDefaultLangID( )” found from MSDN Library
for C++ to achieve this task. The role of this function is to return the language identifier of the current
user locale. Therefore, it will return either 1033 or 1042 for English or Korean, respectively. For our
project, there were only two options, so instead of outputting the exact language identifier, we decided
to set English as 0 and Korean as 1, which will make the transmitting and receiving part much easier.

In this code, a text file called “langtemp.txt” was created and either 0 or 1 was written into the text file
depending on which language identifier was detected. “langtemp.txt” file acts as a terminal to MatLab
code, which handles the RS232 transmitter module.

This program was run by an infinite loop because the keyboard should be useable as long as the system
is on. Therefore, if the system was to be on for a very long time, this infinite loop might cause a system
overload and eventually degrade the performance of the system. In order to prevent this phenomenon,
we gave 100ms of interval between each loop by using “Sleep(100)” command.

Programmed code is in Appendix A.

3.2. RS232 Transmitter Module

First task to complete when designing a RS232 transmitter module was to create and set the serial ports.
These information had to fully match with that of RS232 receiver so after discussion, we decided to use
“COM1” for the port and 115200 bps for baudrate. Baudrate of a data communications system is the
number of bits per second transmitted. In our case, we decided to use 115200 bps to match with baudrate
of RS232 receiver and clock frequency of graphic controller as close as possible.

As mentioned in 3.2., the language detector module and RS232 transmitter module is connected through
“langtemp.txt”. Once language detector module successfully detects the language identifier and writes
either 0 or 1 into “langtemp.txt”, RS232 transmitter written in MatLab code now reads the component
written in “langtemp.txt”. If a value of 0 or 1 was written, the RS232 transmitter will transmit
“00000000” or “11111111”, respectively to FPGA board. Reason for transmitting eight 0’s and 1’s is
because of the structure of character frame of RS232 communication.

RS232 character frame is structured in four parts – start bit, data bits, parity bit, and stop bit. Parity bit
was optional and in order to keep the character frame as simple as possible, we excluded parity bit from
our structure. There are total of 10 bits, divided as following:

1 Start Bit
8 Data Bits
1 Stop Bit

The mechanism for RS232 communication is quite simple. From IDLE state, if RS232 detects a start bit,
the signal changes to non-IDLE state, which indicates a start of transmission. Following the start bit,
there are 8 data bits, which in our case will be “00000000” or “11111111”. After all data bits were sent,
the communication terminates with a stop bit, which changes the signal back to IDLE.

                                                      10
In overall, after the serial port is created and set in an appropriate mode, RS232 transmitter module reads
“langtemp.txt.” from language detector. Depending on whether 0 or 1 is written in “langtemp.txt”, it
sends “00000000” or “11111111”, respectively, through RS232 cable to FPGA board, following RS232
communication mechanism.

Programmed code is in Appendix A.

3.3. RS232 & Graphic Controller

This part of the project lies between the computer and the touch screen keyboard display. The figure
below shows the hardware port on the FPGA board used to connect the other two parts of the project.




           VGA port (board -> keyboard display)             RS-232 port (computer -> board)




Figure 3.0 FPGA board used and its VGA and RS232 ports

The overall schematic for the software circuit in the FPGA board is shown below.




                                                    11
Figure 3.1 RS232 and graphic controller

“Clk” port at the top-left corner of the schematic brings in default 50MHz FPGA board clock. “Reset”
port receives an asynchronous push button on the FPGA board to reset all the settings and data
memories of modules. ‘Reset’ is connected to an inverter since the push button acts active-low. Since
the board clock, 50MHz, was too much faster than the baud rate we used, 115200Hz, we reduced down
the clock to half in “clk reducer”. ‘UART_RXD’ port receives serial input through the RS232 cable.
Since it is serial, we used a single line not a bus. LED langid output port was added for debugging
purpose, since we did not have any analog indicator for proper operation of the module except the LCD
screen.

3.3.1. “Async Receiver”: RS232 Receiver Module (UART)

“Async Receiver” is supposed to synchronize the FPGA board clock and the incoming asynchronous
inputs. It should then send out 8-parallel data bits to 8-bit register with a signal of “data_ready”
indicating that the receiving process is done and the data are ready to be determined if the current
language of the computer is English or Korean.

RS232 UART consists of three parts, oversampling, state machine, and shift register. We first have to
oversample the incoming signals at higher rates than our known baud rate, 115200Hz. This is because
we have to find when the start bit is received, and with the known baud rate, we have very small margin
of error detecting the start of the signal correctly. Therefore, we oversampled the incoming data at eight
times the known baud rate. Once the start bit is detected, the sampling rate returns back to our known
baud rate, and starts the state machine.

The state machine consists of 11 states, Idle, start-bit, data-bit 0, 1, 2, 3, 4, 5, 6, 7, and stop bit. Every
time we see new data bits along the state machine flow, we shift them into the 8-bit shift register. When
the state reaches stop bit, it outputs “data_ready” signal, and all 8 data bits stored in the shift register get
transferred to “reg_8” 8-bit register.



                                                       12
Since we are sending all ones or all zeros depending on the language detection, the decision maker in
“reg_8” 8-bit register should detect only either one ‘1’ or ‘0’ not a specific full 8-bit of data length. We
took the middle bit “RxD_Data(4)” among the received 8-bit data to avoid any possible glitches or
noises that could be involved during the synchronization process. This middle bit is sent out through the
output port of “reg_8” called “Decision”. When we receive all zeros, the middle bit through “Decision”
outputs zero, and when we receive all ones, it outputs one. This “Decision” signal is sent to “Color
Mapper” module.

3.3.2. VGA Controller Module

This module controls the pixels of the screen where there are 640 horizontal lines and 480 vertical lines.
It goes through the pixels from left to right in each row and from top to bottom in one row after another.
The module uses a 10-bit pixel counter mod-800 for the horizontal sync pulse (HS). The counter
increments whenever 25MHz pixel clock reaches its positive edge. The horizontal pixel counts from 0
up to 639 for display, and remaining counts from 640 up to 799 is outside the available range for display.
Whenever the counter reaches the end at 799, it resets back to 0. Another 10-bit line counter of mod-525
is used for vertical sync pulse (VS). The vertical counter increments once whenever the horizontal
counter reaches 800th pixel. The vertical line counts from 0 up to 479 for display, and remaining counts
from 480 up to 524 is outside the available range for display. When the vertical counter reaches 524, the
module resets the vertical line counter.

3.3.3. Color Mapper Module

When the module receives ‘0’ or ‘1’ from “Decision”, it should map English or Korean key
configurations on the screen. The module consists of two big chunks of coding defining letters on the
display of two different languages. First, to use all the pixels in the monitor, we changed DrawX and
DrawY coordinates from “SIGNED” to “UNSIGNED.” When the VGA controller module sends in
DrawX and DrawY pixel coordinates, Color Mapper decides which color to use for that indicated pixel.
Color Mapper goes trough conditions such as “Decision,” “DrawX >= …,” “DrawX <= …,” DrawY >=
…,” or “DrawY <= ….” The module tests if the given coordinate signals fall in the ranges of our
keyboard display configurations. If it does, the module assigns the RGB color for the keyboard frame;
else it assigns the RGB colors corresponding to the background colors for the given coordinates.




Figure 3.2. A part of the coding for the color assignment ranges for English key configurations


                                                     13
Figure 3.3 The final result of English key configurations display




Figure 3.4 The final result of English key configurations display


3.4. Bilateral Switch Module
We had to design bilateral switch so that there are 2 type of control signal for both (e.g. control 1 for
both are same signal). When y-coordinate is to be measured, control 1 is high and control 2 is low.
When x-coordinate is to be measured, control 2 is high and control 1 is low. The design detail of the
bilateral switch is shown in the following figure 3.5.




Figure 3.5 Bilateral switch connections


                                                     14
3.5. Analog to Digital Conversion Module
For analog to digital conversion module, port AN0 was used as an analog input and port B (bit 7-0) was
used as digital output. When designing this some of the control bits were under consideration such as
ADCON1. However, we decided on using CCS C language, and it was critical to learn all the commands
regarding analog to digital conversion. This part had most problems when we did not fully understand
the analog to digital conversion. Since CCS C compiler manual was readily available in the course
website’s PIC section, we had to search for them to study when designing analog to digital conversion in
C. After getting all the components of analog to digital conversion module, no further debugging was
needed, especially since the delay was relatively short for our consideration.

3.6. Coordinate Control Module
No part in coordinate control module could be made separately even though it consisted of more than
one part. We needed to take care of control signal going to bilateral switch, so that readable signal would
come as an input to coordinate control module. This however could not be tested separately as
mentioned before, so we moved on to next part for designing.

The next part was manually finding coordinate of each key. In order to make the whole process more
consistent and efficient, we decided to divide up the keyboard in row and columns instead of randomly
pressing keys to figure out the ranges. An object relatively sharp compared to figure was used in
pressing on the touch screen because we wanted to measure the signal at each edge of the key. The range
of keyboard is divided into 5 rows and 15 columns. The division range is shown in table 3.1.

                                      Start                              End
 st
1 row                                                              159                                 140
2nd row                                                            139                                 120
3rd row                                                            119                                 100
4th row                                                             99                                  80
5th row                                                             79                                  60
1st column                                                         150                                 138
2nd column                                                         137                                 124
3rd column                                                         123                                 105
4th column                                                         104                                  91
5th column                                                          90                                  75
6th column                                                          74                                  59
7th column                                                          58                                  42
8th column                                                          41                                  29
9th column                                                          28                                  12
10th column                                                         11                                 254
11th column                                                        253                                 243
12th column                                                        242                                 222
13th column                                                        221                                 206
14th column                                                        205                                 185
15th column                                                        184                                 160
Table 3.1 keyboard division ranges

With the table above, I was able to create all the condition for all keys on the keyboard designed for the
project. Then, for each condition I had to create PS/2 output signal and each had 100us of delay because
we needed to match with 10 kHz clock signal for PS/2.


                                                    15
The PIC16F877A was not able to handle all the PS/2 code at once. It did not compile when more than 3
ranges had PS/2 output. With given equipments this was unavoidable, and we needed better
microprocessor. However, we had enough to demonstrate out circuit’s capability to send PS/2 signal at
the output.




                                                 16
                                     4. DESIGN VERIFICATION

The testing was done in order to locate the error if there is any in the final product. If we divide the
testing procedure and limit the size of circuit or program for each testing, we will be able to find the
fault more easily. The large scale testing was basically divided into two parts. First was to test if LangID
is detected and displays the corresponding language keyboard on LCD. The other part was to see
whether or not the correct PS/2 data was produced when the touch screen is pressed. The following list
of testings consists of each components testing before we divide it into two big parts.

4.1 Testing

As mentioned above, smaller scale testing allowed us to locate the error quicker and make the whole
process more efficient. The following are the tests that the group went through.

4.1.1. Language Detector Module

Testing to verify whether the correct language identifier value is received or not, the most direct way is
to physically display the acquired language identifier value on the screen. This can be done by adding a
following line to the code:

printf (“%i\n”, l);

The variable, “l”, contains a value of language identifier. Running the program with the above line
written, the language identifier value corresponding to the system will appear in a screen every 100ms.
And as soon as the language mode of the system is changed, without having the code running again,
changed language identifier value will appear on the screen.

4.1.2. RS232 Transmitter Module

The only way to test the RS232 transmitter was to have it connected to the FPGA board with a working
RS232 receiver module. Since the RS232 cable is opened on both ends, they have to be physically
connected to a certain instruments in order to observe any kinds of performances, one to computer and
other to FPGA board. Once the RS232 receiver module was completed, we assembled all parts together
and tested if the LCD screen display was changing. By observing that the LCD screen display was
changing correspondingly with the language mode selection from the computer, we could verify that the
RS232 transmitter was successfully implemented.

4.1.3. RS232 Receiver Module (UART)

Since all the implementation for this module was done in software, we did not have many hardware
options for testing. Thus, we added “LED_langid” port in the software design, which lights on when ‘1’
is sent through “Decision” port. In this way, although sometimes we had some problems on the display
which was hard to tell if it was showing English or Korean, we could still see from the LED.

4.1.4. VGA Controller & Color Mapper Module

We concentrated on observing delays in switching between English and Korean displays whenever the
language setting is changed in the computer. As shown in the video of our presentation and verified by
professor Swenson, teaching assistant Ben, and the reviewing team, the switching worked with almost
no delays. Whenever the language settings were changed on the computer, the display switched
instantaneously.
                                                   17
4.1.5. Bilateral Switch Module

The testing procedure for this module was briefly described in subproject section. The bilateral switch
was connected to variable voltage at input and output was measured with multi-meter. Then the control
signal was connected to either Vcc or ground to see if the circuit was to connect when control signal is 1
and disconnect when control signal is 0. This test passed. Then we moved onto making of actual circuit.
Once the circuit was designed in full except for the control from the Coordinate Control Module, the
control signal was connected to either Vcc or ground. The output was shown to deliver the correct result,
therefore, confirmed about this module’s function.

4.1.6. Analog to Digital Conversion Module
The analog to digital testing was done with LED as mentioned before to see if the LED corresponded to
decreasing binary number as I moved finger down from + to – for both x and y coordinates. The test
showed that the signal was unstable at least significant 2 bits due to slight movement of finger (which
was unavoidable). So the test seemed to be successful. Then the last part of the testing consisted of
measuring delay of this module. The analog input signal was connected to one input of oscilloscope. The
digital output was connected to second input of the oscilloscope. The measurement was done and we
found that the delay existed in the circuit (shown in figure 4.1).




Figure 4.1 Delay of the A/D Converter circuit shown to be 200ms

4.1.7. Coordinate Control Module
The testing of this module consisted of three parts. First testing was done by seeing if the circuit is able
to produce the desired output at the output port (either high or low). When this testing showed us that we
were able to produce certain desired signal at specific location of the keyboard, we wanted to see if the
coding would allow the output to send PS/2 signal at specific rate or delay. We were able to produce the
PS/2 signal result with the desired delay as shown in figure 4.2 to 4.4.
                                                     18
Figure 4.2 PS/2 output when “`” was pressed




Figure 4.3 PS/2 output when “h” was pressed


                                              19
Figure 4.4 PS/2 output when “bksp” was pressed

As you can see from the graph above, we were able to produce the correct value at the output.

The last part of the testing is done similar to A/D converter module. The delay was measure to show
how much time it took to send out PS/2 signal once the signal was received from the A/D converter. The
figure 4.5 shows the delay of input to output delay.




                                                  20
Figure 4.5 Delay of the Coordinate Control circuit shown to be 900ms




                                                 21
                                                5. COST

5.1. Parts

         Component                 Manufacturer/Seller       Quantity     Unit Price       Total Price
      17.1” LCD Screen                    Dell                  1          Provided         Provided
        PS/2 Keyboard                     Dell                  2          Provided         Provided
     Touch Screen 17.1”              TVI electronics            1            $135             $135
      Computer/Monitor                     --                              Provided         Provided
         PIC16F877A                        --                     3        Provided         Provided
 C0603C105J4RACTU (0.1uF                   --                     2        Provided         Provided
           capacitor)
             LED                            --                     8       Provided         Provided
           Resistors                        --                    13       Provided         Provided
      20MHz Oscillator                      --                     1       Provided         Provided
   Altera FPGA DE2 Board                  Altera                   1       Provided         Provided
          MATLAB                        MathWorks                  1        $1900            $1900
                                                                            Total            $2035

The cost for parts is

5.2. Labor

Our expected salary in the future was $65.00 / hour. Counting up the amount of time spent on designing,
researching, and building the project, we came up with approximately 70 hours per person. Therefore,
the total labor cost will be

$65.00 / hour 70 hours 2.5 people = $34,125

So the total labor cost of our project would add up to $34,125.

5.3. Total

Summing up the part and labor costs, the total cost adds up to

$2,035 + $34,125 = $36,160




                                                      22
6. CONCLUSIONS

We are generally satisfied with the final outcome of our product. However, our design contains several
margins for improvement. The keyboard has small disappointment in the fact that we could not get it to
work just like a keyboard (connecting with PS/2 cable to make it work just like any other PS/2
keyboard. However, we have confirmed that only one component was lacking from performing fully.
The missing component is the 10 kHz clock is used for PS/2 Cable. If the low frequency oscillator is
readily available, or crystal oscillator for 10 kHz is available, the final product can be complete.

The language detecting part of the project works perfectly for both English and Korean. After that, we
are able to successfully transmit data with RS 232 to FPGA board. One improvement that we can make
in future to make the product more marketable and available to public is the software part. We could use
C language instead of Matlab in transmitting RS232. This will reduce the cost of 1,900 dollars because
Matlab is relatively expensive software product. Other than this expense consideration, FPGA and
language detecting part can detect and display the correct keyboard configuration.

For the touch screen controller part, one major disappointment is in the delay that we have to deal with
when in actual use. The controller can only function with the delay of more than 1 second. Many
consideration and improvement for this problem was stated in the earlier part of the report. However, it
seems that better equipment and usage of interrupt can be added for better functioning of our keyboard.

Objectively speaking, the project is not 100 percent complete. It can be improved in features, efficiency
and cost. However, we reached the initial purpose of this project because we were able to use our
previous knowledge in electrical engineering to design and build our product.




                                                   23
                                          REFERENCES

[1]   TAL Tech, “Introduction to Serial Communications” [Online Document], 2008 [cited 9 Dec 2008],
      Available HTTP:
      <http://www.taltech.com/TALtech_web/resources/intro-sc.html>

[2]   Microsoft Developer Network, “International Features: GetUserDefaultLangID” [Online
      Document], 2008 [cited 9 Dec 2008], Available HTTP:
      <http://msdn.microsoft.com/en-us/library/ms776265(VS.85).aspx>

[3]   ARC Electronics, “RS232 Data Interface” [Online Document] [cited 9 Dec 2008], Available
      HTTP:
      <http://www.arcelect.com/rs232.htm>

[4]   TVI Electronics, “4 Wire Resistive Touch Screen Specification”, [Online Document], 2007 [cited
      9 Dec 2008], Available HTTP:
      http://shop-on-line.tvielectronics.com/download/4-Wire_Resistive_TouchScreen_Specs.pdf

[5]   Fairchild Semiconductor Corporation., “CD4016BC: Quad Bilateral Switch”, [Online Document],
      1999 [cited 9 Dec 2008], Available HTTP:
      http://www.datasheetcatalog.org/datasheets/105/108712_DS.pdf

[6]   Microchip Technology Inc., “PIC16F87XA Datasheet”, [Online Document], 2003 [cited 9 Dec
      2008], Available HTTP: http://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdf




                                                 24
Appendix A – Programmed Codes


Language Detector by Visual C++




                                  25
RS232 Transmitter by MatLab




                              26

								
To top