Your SlideShare is downloading. ×
Portable Bitmap Reader
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Portable Bitmap Reader

650
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
650
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. American University of Dubai Portable Bitmap Reader Final Report Senior Design Project – Spring 2009 Dr. Alaa Ashmawy Nesma Aldash 6/25/2009 1
  • 2. Table of Contents List of Tables ................................................................................................................................................ iv List of Figures ................................................................................................................................................ v 1. Introduction .......................................................................................................................................... 1 1.1. Purpose ......................................................................................................................................... 1 1.2. Problem Statement ....................................................................................................................... 1 1.3. Objective ....................................................................................................................................... 2 1.4. Scope ............................................................................................................................................. 2 1.4.1. Research Tasks ...................................................................................................................... 2 1.4.2. Hardware Tasks ..................................................................................................................... 3 1.4.3. Software Tasks ...................................................................................................................... 3 1.5. Out of Scope.................................................................................................................................. 4 2. Solution Summary ................................................................................................................................. 5 2.1. Key Requirements ............................................................................................................................. 5 2.2. Components Included ....................................................................................................................... 5 3. Solution Overview ................................................................................................................................. 6 3.1. Brief Overall System Architecture................................................................................................. 6 3.2. General Description of the Device’s Operation ............................................................................ 7 4. A Description of the Different Communication Protocols ................................................................... 9 4.1. The Universal Asynchronous Receiver/Transmitter Communication (UART) Protocol ................ 9 4.2. The RS232 Communication Protocol .......................................................................................... 10 4.3. The Universal Serial Bus (USB) Communication Protocol ........................................................... 11 4.3.1. Introduction to USB ............................................................................................................ 11 4.3.2. How a USB device and Host Communicate......................................................................... 12 4.4. UART/RS232 Communication Interface ...................................................................................... 14 4.4.1. Hardware Implementation ................................................................................................. 14 4.4.2. Software Implementation ................................................................................................... 15 4.4.3. Testing UART0 and UART2 .................................................................................................. 15 5. Descriptions of the File Systems ......................................................................................................... 17 5.1. Flash Memory Stick File System .................................................................................................. 17 ii
  • 3. Portable Bitmap Reader 2009 5.2. Bitmap File System ...................................................................................................................... 18 6. Description of the Hardware .............................................................................................................. 21 6.1. Microcontroller ........................................................................................................................... 21 6.2. The Keypad.................................................................................................................................. 22 6.2.1. General Information ........................................................................................................... 22 6.2.2. Identifying the Rows and Columns of the protruding pins ................................................. 22 6.2.3. Connecting the Keypad to the Microcontroller .................................................................. 23 6.2.4. Detecting a Pressed Key and Identifying its Value .............................................................. 24 6.2.5. The Keypad Functionality .................................................................................................... 26 6.2.6. Keypad De-bouncing ........................................................................................................... 26 6.3. Software Implementation ........................................................................................................... 27 7. The USB Interface ............................................................................................................................... 29 7.1. The Vinculum VDIP2.................................................................................................................... 29 7.2. Communicating with the VDIP2 .................................................................................................. 31 7.3. Using the VDIP2 in the project design ........................................................................................ 36 7.3.1. The Commands Used to Interact with the VDIP2 ............................................................... 36 8. The Video Graphics Array Signal ......................................................................................................... 42 8.1. A General Overview of How a TV System works......................................................................... 42 8.2. The Scan Lines ............................................................................................................................. 43 8.3. Implementation of the Signal ..................................................................................................... 45 8.4. Implementing the Font ............................................................................................................... 47 8.5. Direct Memory Access Controller (DMA).................................................................................... 51 8.6. Fault with this Solution ............................................................................................................... 53 9. The microVGA ..................................................................................................................................... 54 9.1. The microVGA – a brief description ............................................................................................ 54 9.2. Using the microVGA in the Project Design ................................................................................. 54 10. Share of Responsibilities ................................................................................................................. 58 11. Project Budget................................................................................................................................. 59 12. Conclusion ....................................................................................................................................... 61 13. Resources ........................................................................................................................................ 62 iii
  • 4. Portable Bitmap Reader 2009 List of Tables Table 1: Implemented Keypad functions .................................................................................................... 26 Table 2: LED Behavior ................................................................................................................................. 31 Table 3: Commands and their Description [17] .......................................................................................... 31 Table 4: VDIP connection to MCU............................................................................................................... 31 Table 5: Voltage Levels of the Video Signal ................................................................................................ 42 Table 6: Signal Generation Pin Assignment ................................................................................................ 46 Table 7: Hardware Connections between microVGA and MCU ................................................................. 54 Table 8: Portable Bitmap Reader Budget Plan............................................................................................ 59 iv
  • 5. Portable Bitmap Reader 2009 List of Figures Figure 1: Brief Overall System Architecture.................................................................................................. 6 Figure 2: General Device Description Flow Chart ......................................................................................... 8 Figure 3: RS232 connector pin numbering [6] ............................................................................................ 10 Figure 4: UART to RS232 Converter Circuit Schematic ............................................................................... 14 Figure 5: Testing UART0/2 - Polling Method .............................................................................................. 16 Figure 6: Testing UART0/2 - Interrupt Method........................................................................................... 16 Figure 7: Bitmap image used to clarify the file structure of Bitmap images [12] ....................................... 20 Figure 8: The result of passing the Bitmap image through a Hex Editor .................................................... 20 Figure 9: Renesas 16-Bit M16C microcontroller Starter Kit Plus [2] ........................................................... 21 Figure 10: The Keypad................................................................................................................................. 22 Figure 11: Keypad Internal Schematic [3] ................................................................................................... 22 Figure 12: Hardware connection of the Keypad to the microcontroller .................................................... 23 Figure 13: Flow Chart of the Keypad Algorithm.......................................................................................... 25 Figure 14: The VNC1L chip and Interface Circuit [15] ................................................................................. 29 Figure 15: The VDIP2 Module [16] .............................................................................................................. 30 Figure 16: Hardware Connection between VDIP2 and MCU ...................................................................... 32 Figure 17: Communication Interface between VDIP2 and Hyper-Terminal ............................................... 34 Figure 18: Detecting Flash Memory Stick ................................................................................................... 35 Figure 19: Running a Command .................................................................................................................. 35 Figure 20: Running the Second Command.................................................................................................. 36 Figure 21: An Example of a Video Signal [13] ............................................................................................. 43 Figure 22: Vertical Synchronization Patterns for Even and Odd Fields [12] ............................................... 45 Figure 23: The microVGA ............................................................................................................................ 54 v
  • 6. Portable Bitmap Reader 2009 Figure 24: Hardware Connection between MCU and microVGA................................................................ 55 Figure 25: Setup Pads.................................................................................................................................. 56 vi
  • 7. 1. Introduction 1.1. Purpose The purpose of this report is to detail the work that has been done to design and implement the Portable Bitmap Reader as it was described and approved in the final progress report. This report is the final report to be submitted for this course. Included is detailed technical description of the design and the implementations undertaken for the projects operation. 1.2. Problem Statement When thinking of a suitable project, the intent was to create a small, handheld device that allows people to use it for several applications both for personal and business uses. The Portable Bitmap Reader allows the home user to view slideshows in the form of bitmap images and allows the business user to easily and quickly show their presentations to clients. There is no specific problem this device addresses except trying to make people’s lives easier and more entertaining by providing them with a portable handheld device. This device can be improved in unimaginable ways. For one, it may be possible to view movies, connect a camera and view the photos taken, viewing Microsoft office files and so much more. Therefore, this project seeks to achieve this goal, which is to operate and view the contents of a USB flash memory stick through a microcontroller and display them onto a monitor. 1
  • 8. Portable Bitmap Reader 2009 1.3. Objective The Portable Bitmap Reader is a device whose intent is to allow people to view the bitmap images stored on a flash memory stick without the use of a computer; instead, one may merely connect this device to any monitor and view the required images. At first, the intent of this project was to allow the user to view JPEG images stored on the flash memory stick; viewing power point presentations, although a very important feature, requires the presence of an operating system because Power Point, Excel, Word and such programs are platform dependent. JPEG and Bitmap images on the other hand are platform independent. Reading JPEG images require decompression, a process that requires fierce mathematical calculations and prior understanding of the different process stages. Therefore, due to sever time constraints, the functionality of this device is limited to viewing bitmap images only due to the fact that the image is not compressed and can therefore be read easily (more details are given in latter chapters). Due to the time limitations it has been decided to not implement the file system of a USB flash memory stick and instead implement the video signal transmission. 1.4. Scope Since the final progress report, the tasks have been revised so as to reflect on the actual tasks implemented for the project. As before, the tasks were divided into three categories and listed as follows: 1.4.1. Research Tasks Task 1: Understand the operation of the VDIP2 circuit board. Task 2: Understand the file format of the Bitmap images. 2
  • 9. Portable Bitmap Reader 2009 Task 3: Understand the Universal Serial Bus protocol. Task 4: Understand the RS232 Serial communications protocol. Task 5: Understand how to connect the microcontroller to the VGA monitor. 1.4.2. Hardware Tasks Task 1: Order the hardware components. Task 2: Connect the keypad and USB port to the microcontroller. Task 3: Create the interface circuit between the RS232 and Universal Asynchronous Receiver/Transmitter communication protocols (UART). Task 4: Implement the interface circuit between the USB flash memory and the Renesas microcontroller Task 5: Implement the interface circuit between the Renesas microcontroller and the VGA monitor 1.4.3. Software Tasks Task 1: Write the code for the keypad implementation and functionality. Task 2: Write the code for the RS232/UART interface. Task 3: Write the code interfacing the VDIP2 chip to the Renesas microcontroller Task 4: Write the code responsible for reading the bitmap file from the flash memory. Task 5: Write the code responsible for handling the display. Task 6: Write the user menu code. 3
  • 10. Portable Bitmap Reader 2009 1.5. Out of Scope It was intended to allow the user to be able to copy files from a camera and store them onto the USB flash memory stick or view them directly. Furthermore, the implementation of a “scrolling through images feature” was planned for. Unfortunately, time did not allow for such implementations to be made. 4
  • 11. Portable Bitmap Reader 2009 2. Solution Summary This section describes the main requirements Group 1 intends to meet with regards to this project, The Portable Bitmap Reader. 2.1. Key Requirements The main requirements are as follows: 1. Detecting the flash memory device. 2. Be able to read the Bitmap file from the flash memory stick. 3. Display the Bitmap image through a VGA monitor. 2.2. Components Included The project requires the following hardware components:  Renesas M16C microcontroller  VDIP2 circuit board  RS232 cable (1x)  A VGA monitor  RS232 cable connector (1x)  Red LED (1x)  0.1µF capacitor (5x)  A flash memory - Any size (1x)  270Ω resistor (1x)  Keypad (1x)  MAX232 IC chip (1x)  Connecting wires  2 input AND gate (1x)  microVGA Later chapters in this report describe the purpose of the listed components. 5
  • 12. Portable Bitmap Reader 2009 3. Solution Overview 3.1. Brief Overall System Architecture Stage 2 Stage 4 Stage 3 Stage 1 Figure 1: Brief Overall System Architecture As seen from Figure 1, there are four main stages to this project. Stage 1 entails setting up communication between the VDIP2 circuit board and the Renesas microcontroller. The VDIP2 chip gives its user the option of choosing between three communication protocols, as will be seen in latter chapters. One of the communication protocols supported is the UART protocol; having said that, the communication between the VDIP2 and the microcontroller is UART to UART. Stage 2 entails the connection of the keypad to the microcontroller and implementing the keypad functions described in latter chapters. Stages 3 and 4 entail connecting the microcontroller to a VGA monitor. A detail of the implementation of each stage is described in latter chapters of this report. 6
  • 13. Portable Bitmap Reader 2009 3.2. General Description of the Device’s Operation As a general explanation, this is how the device is intended to work: 1. When a Flash memory stick is inserted in the USB connector, the LED2 of the VDIP2 device is turned on, which in turn sets a pin on the microcontroller to ‘1’. This pin is used to inform the microcontroller to start requesting the filenames contained on the flash memory stick. 2. After receiving the filenames, the microcontroller is to display them to the user on the monitor and wait for the user to choose the file to be viewed. 3. The microcontroller would then request the file data of the selected file. 4. Upon receiving the file data, the microcontroller is to interpret the data appropriately. 5. The microcontroller is to then use the interpreted data to display the image onto the monitor. 6. After viewing the file the user may choose to perform the following operations: a. Delete the file b. Close the file c. Go back to main menu (viewing the list of files) The following flow chart in Figure 2 describes the mentioned operation. 7
  • 14. Portable Bitmap Reader 2009 Figure 2: General Device Description Flow Chart 8
  • 15. Portable Bitmap Reader 2009 4. A Description of the Different Communication Protocols 4.1. The Universal Asynchronous Receiver/Transmitter Communication (UART) Protocol Serial communication is regularly used with modems, computers and other “non- networked” communication. Asynchronous transmission enables data to be transferred without the transmitter having to send a clock signal to the receiver. Due to that fact, “the sender and receiver must agree on timing parameters in advance”, and a special bit or character must be specified to indicate the end of a transmission. When a word is transmitted through the UART a bit called the “Start Bit” is introduced to the beginning of the word; this bit is used to inform the receiver that data is about to be sent in order for the receiver to synchronize its clock with that of the sender’s. If the two clocks are not in sync data may be lost. Therefore, the frequency used by the sender and the receiver should not exceed a 10% difference from one another [5]. Following the “Start Bit” the bits of the word being sent are transmitted with the least significant bit (LSB) sent first. After the word has been sent a “Parity Bit” may be added at the end to allow the receiver to perform a simple error check to ensure the data sent is complete; the “Stop Bit” follows which indicates the end of the word; there may be more than one stop bit in the transmission. The two devices must agree on the transmission format, meaning that they should agree on the presence of the “Parity Bit” and the number of “Stop Bits”. The “Start Bit” of the following word is sent as soon as the “Stop Bit” of the previous word has been transmitted. If there is not data to be sent the transmission line becomes idle [5]. 9
  • 16. Portable Bitmap Reader 2009 For this project UART0 will be used to communicate with the VDIP2, and the Baud Rate will be 9600. While UART2 will be used to communicate with the display unit (microVGA), and the baud rate will be 19,200. 4.2. The RS232 Communication Protocol “One of the familiar asynchronous network-based I/O schemes in use today has evolved from the RS-232 (now the EIA-232) standard model” [6]. The RS-232 model was developed by the Electronic Industries Association (EIA) in the early 1960s. Their intension was to create a standard interface between “a piece of computing equipment and a piece of data communications equipment” [6]. As seen from Figure 3, the RS-232 Figure 3: RS232 connector consists of 9 pins. The functionality of each pin is as follows [6]: connector pin numbering [6]  Pin 1: Carrier Detect, CD – this pin is used to indicate that a connection has been set up and an answer tone has been received from the remote device.  Pin 2: Transmitted Data, TXD – Data transmission line from the Data Terminal Equipment (DTE) to the Data Communications Equipment (DCE).  Pin 3: Received Data, RXD – Data transmission line from the Data Communications Equipment (DCE) to Data Terminal Equipment (DTE).  Pin 4: Data Terminal Ready, DTR – This line notifies the DCE that the data terminal has fulfilled the required initializations and that it is ready to open a communication channel and exchange messages .  Pin 5: Signal Ground, SG – A signal ground. 10
  • 17. Portable Bitmap Reader 2009  Pin 6: Data Set Ready, DSR – This line informs the DTE that the data set has a valid connection and has fulfilled the required initializations and is ready to exchange messages.  Pin 7: Request to Send, RTS – This line notifies the DCE that the DTE needs to send data.  Pin 8: Clear to Send, CTS – This line notifies the DTE that the DCE can receive the data to be sent.  Pin 9: Ring Indicator, RI – This line is used by the DCE to notify the DTE that the “phone is ringing”. (Used by modems) The RS232 uses a serial transmission method by which one data byte is transmitted at a time through a single wire; the data being transmitted is labeled TX, while the data being received is labeled RX. Since the RS-232 protocol is asynchronous it doesn’t have a clock signal, hence, the two systems communicating using this protocol must have the same Baud Rate [7]. 4.3. The Universal Serial Bus (USB) Communication Protocol “Anything new usually has to remain compatible with whatever came before it” [8] 4.3.1. Introduction to USB One of the main purposes of a USB is to enable users to connect several peripherals to the same connector. The USB has an asynchronous serial format and supports three bus speeds:  High speed of 480Megabits/sec – this became an option with the release of the second version of the USB specifications.  Full speed of 12 Megabits/sec – may serve as a replacement to serial and parallel ports. 11
  • 18. Portable Bitmap Reader 2009  Low speed of 1.5 Megabits/sec – used for devices that require flexible and low speed cables. Such devices include mice and keyboards. Another appealing reason to work with the USB is that its hardware specifications of the driver, receiver and cable eliminate noise that would cause errors in data transmission. Furthermore, the USB protocol makes it possible to detect errors and notify the sender to allow retransmission. According to Axelson, “the detecting, notifying, and retransmitting are typically done in hardware and don’t require any programming or user intervention” [8]. 4.3.2. How a USB device and Host Communicate When a system is powered up the host, in this case the microcontroller, is made aware of all the attached USB devices by the hubs attached. The host then assigns addresses to the devices and requests additional information from each device; this process is called Enumeration. From then on, whenever a device is added or removed the host is notified and it enumerates the newly attached devices. During enumeration the device will request the bandwidth needed for transmission. If the bandwidth requested is not available the host denies the request and the device must send another with a smaller bandwidth request [8]. In the case of this project, one need not worry about dividing the total transfer time of data into segments because only one device will be connected at any given time. When the host wishes to communicate with a device, the device address is sent to the connected USB devices. Each device then compares the sent address to their own, if it matches, communication with the host is commenced and the device stores 12
  • 19. Portable Bitmap Reader 2009 the data in it’s receive buffer and an interrupt is generated to inform the host that the data has been received. This process is built into the hardware of the devices and is therefore automatic [8]. To summarize, the responsibilities of the host (microcontroller) are [9]:  Detect Devices – The USB hub alerts the host of the devices attached upon power up  Provide Power  Manage traffic on the bus – not applicable for this project since only one device will be connected to the microcontroller.  Handle Error Checking – When the host transmits data to the USB device it adds error-checking bits; when receiving data the error-checking bits are used to detect errors.  Exchange Data with the USB Devices While the responsibilities of the USB device are:  Detect the Bus voltage – once the voltage is detected a pull-up resistor is switch to let the host know there is a device present.  Manage Power – the USB device connected must limit its consumption of the bus’s current.  Respond to Standard Requests – a device must respond to the host’s requests during and after enumeration.  Handle Error Checking 13
  • 20. Portable Bitmap Reader 2009  Exchange Data with the Host – a device connected to the host has an address that allows the host to communicate with the devices. An interrupt is generated to notify the host that a communication has been established.  Implement the Device Functions 4.4. UART/RS232 Communication Interface 4.4.1. Hardware Implementation The MAX-232 used in the circuit board is an industry standard chip used to convert between CMOS logic levels and RS-232 logic levels. The MAX-232 contains two full duplex communication links each with two pairs of pins. An LED is present in the circuit in order to certify that the circuit is working. The following figure, Figure 4, represents the circuit that implements the communication interface. V CC C3 5V V CC 0.1µF 5V Vcc M A X232 GND C1 P1 P16 J1 0.1µF P2 P15 UART TX P3 P14 UART RX P4 P13 P5 P12 C2 P6 P11 0.1µF P7 P10 P8 P9 R S 232 J3 J2 C4 0.1µF V CC Pin C5 5V R1 0.1µF 270Ω LE D 1 Figure 4: UART to RS232 Converter Circuit Schematic Assignment for the MAX232 chip: Pin 1: C1+ Pin 9: R2OUT Pin 2: V+ Pin 10: T2IN Pin 3: C1- Pin 11: T1IN 14
  • 21. Portable Bitmap Reader 2009 Pin 4: C2+ Pin 12: R1OUT Pin 5: C2- Pin 13: R1IN Pin 6: V- Pin 14: T1OUT Pin 7: T2OUT Pin 15: GND Pin 8: R2IN Pin 16: VCC 4.4.2. Software Implementation The microcontroller being used in this project has three serial ports that can be used for serial communication; these serial ports are: UART0, UART1 and UART2. For this project UART0 will be used. There are two different ways to implement the serial communication, either through a process called “Polling” or through interrupts. Polling entails the microcontroller waiting on an even to happen, while the interrupt method allows the microcontroller to perform other tasks till an interrupt is generated by the device. For efficiency reasons, interrupts will be used. The software implementation of the serial communication involves using transfer and receive queues. When the device needs to send data to the microcontroller an interrupt is generated and the data sent is stored in the receive queue. Once the transfer is complete, the microcontroller may then start to de-queue the data. Therefore, when the flash memory needs to send the Bitmap image information an interrupt is generated and the data is stored in the receive queue. When the microcontroller needs to send the data to the final output device, the data will be stored in the transfer queue and is then sent. 4.4.3. Testing UART0 and UART2 In order to insure that any communication errors and problems are not due to the microcontroller being faulty, hyper-terminal was used to communicate with the microcontroller. The interface used was the RS232/UART interface described in the 15
  • 22. Portable Bitmap Reader 2009 previous section. Furthermore, in order to insure full and undoubted functionality, the code used was that of Dr. Ali who provided the code during the Embedded Systems course. The tests made provided the following results: 1. Polling method (Figure 5) Figure 5: Testing UART0/2 - Polling Method 2. Interrupt method (Figure 6) Figure 6: Testing UART0/2 - Interrupt Method 16
  • 23. Portable Bitmap Reader 2009 5. Descriptions of the File Systems 5.1. Flash Memory Stick File System A flash memory card stores data in flash memory chips; the memory is non-volatile. It also contains a controller that handles the reading and writing to the memory. According to Axelson in his book “USB Mass Storage”, in order to create an embedded system that hosts USB devices one must have the following [9]:  A microcontroller (or other intelligent hardware) to manage the embedded system’s operations  A USB host controller. This controller can be either embedded in the microcontroller’s circuitry or on a separate chip.  A flash drive connected to the host’s USB port. Axelson also explains that USB devices support Logical Block Addressing (LBA). This method entails numbering the blocks capable of storing data sequentially and beginning at zero. The blocks of a flash memory all have the same size, usually 512 bytes. “The flash drive’s controller translates each LBA to a block, page, and column in the memory array” in order to be able to access the different memory locations [9]. There are two types of flash memory technologies [9]:  NOR flash – this form of flash memory has a fast read time but a slow write/erase time. Hence, it is better suited for storing program code because of its fast file access and limited write-backs. The NOR flash memory has a low density which therefore requires more storage chips to accommodate large memory needs. 17
  • 24. Portable Bitmap Reader 2009  NAND flash – this form of flash memory has a fast write/erase time, low power consumption and is cheaper than the NOR flash. It has a high density, which means that it can accommodate large memory needs in fewer chips. There are three “varieties” to the NAND flash:  Old Single-level Cell (SLC)  New Single-level Cell (New SLC)  Multi-level Cell (MLC) – this form of NAND flash allows multiple bits to be stored in each cell. The MLC is very popular due to its cheap manufacturing. The MLC has a slower write/erase time as compared to the SLC. 5.2. Bitmap File System Because the Bitmap file structure was initially created by Microsoft and IBM, the file structure is “bound to the architecture of the main hardware platform” supported by both companies; which means that the Bitmap file format follow the Intel format/Little Endian format [10]. The Bitmap file structure is divided into three main parts [11]:  A header – The header contains information about the type, size and layout of the bitmap file. The first two bytes of the file starts with a “BM” to indicate that the file is a bitmap file. The next four bytes contain the file size with the least significant bit first. The four bits following the file size are set to zero because they are unused, and the final four bits represent “the start of the image pixel data from the header” and is measured in bytes. 18
  • 25. Portable Bitmap Reader 2009  A bitmap information header – This section of the bitmap file structure specifies the dimensions, compression type and color format of the bitmap image. The first four bytes represent the size of the header after which the height and width of the image in pixels is given. The following two bytes represent the number of planes in the bitmap image, and the next two bytes contain the number of bits used to signify the “color intensities of a pixel”; the number of bits can be either:  1 – monochrome bitmap  4 – 16 color bitmap  8 – 256 color bitmap  16 – 16bit bitmap (high color)  24 – 24bit bitmap (true color)  32 – 32bit bitmap (true color) The next four bytes hold the compression followed by the image size. The compression has a value of 0 for a 24bit RGB, and if the image is not compressed then the image size would be zero. The next eight bytes hold the resolution in pixels per meter, and the final entry of this section holds the number of “color map entries and the number of significant colors”.  A color table – This table is not present in a 24bit bitmap image because each pixel is represented by the RGB values.  An array of bytes that define the image – This section contains byte values that represent the rows, also known as scan lines, of the bitmap image. The order of the scan is from bottom to top and from left to right, which means that the start 19
  • 26. Portable Bitmap Reader 2009 of the scan is on the bottom left corner of the image. “A scan line must be zero- padded to end on a 32-bit boundary or rounded up to a multiple of four bytes”. To help illustrate the different sections of a bitmap file, a bitmap image ( Figure 7) was passed through a hex editor (Figure 8). The results are as follows: Figure 7: Bitmap image used to clarify the file structure of Bitmap images [12] Figure 8: The result of passing the Bitmap image through a Hex Editor 20
  • 27. Portable Bitmap Reader 2009 6. Description of the Hardware 6.1. Microcontroller For the purpose of this project, the Portable Bitmap Reader, the Renesas 16-Bit M16C microcontroller was used (Figure 9). Furthermore, this microcontroller was used before in a previous course (Embedded Systems) thereby making it familiar. Figure 9: Renesas 16-Bit M16C microcontroller Starter Kit Plus [2] The microcontroller is the heart of the device. It is the one connecting all the different components together and synchronizing their operation. The starter kit used comes with: a. The M16c 62P Renesas microcontroller b. An installation CD that provides the user with a complier, linker, assembler and debugger. Sample projects demonstrating the microcontroller’s capabilities are also provided on the CD. c. A debug Emulator known as FoUSB is provided. The C programming language is used write the software. This microcontroller has 32kB of internal RAM as well as 382kB of flash ROM; it also has a clock speed of 24MHz. The availability of Timers, communication ports and Direct Memory Access (DMA) make this microcontroller ideal for the projects implementation needs. 21
  • 28. Portable Bitmap Reader 2009 6.2. The Keypad 6.2.1. General Information The keypad (Figure 10) is composed of 16 buttons that include the numbers 0 to 9, the letters A to D and the symbols ‘*’ and ‘#’. There are 8 pins protruding from the keypad, four representing the columns and four representing the rows. The Figure 10: The Keypad schematic of the keypad is shown in Figure 11; the switches represent the key. When a switch is pressed, for example SW1, the respective row and column are connected, in the case of the example, row 1 and column 1 and connected. The connection made produces an electrical signal that is then passed through to the protruding pins of the keypad. The method of identifying the key pressed uses the property described. Figure 11: Keypad Internal Schematic [3] 6.2.2. Identifying the Rows and Columns of the protruding pins In order to check which four pins are the rows and which are the columns, a voltmeter was used. The voltmeters available in the lab have an option where they sound off a ‘beep’ like sound when the two probes are short circuited. Using that 22
  • 29. Portable Bitmap Reader 2009 option, a button was pressed and the presumed row and column were connected using the voltmeter probes. To clarify the idea, pressing button ‘2’ is taken as an example. From the schematic shown in Figure # we can see that pressing key ‘2’ connects Row 1 and Column 2. Knowing that, one probe was connected to the first pin on the left (assumed to be Row 1) and the second probe was connected to the third pin from the right (assumed to be Column 2). Since, the voltmeter did not sound the ‘beep’ it was concluded that the assumption made was incorrect and the probes were switched; the second pin from the left and the forth pin from the right were connected using the probes. The voltmeter sounded off the ‘beep’ which means that the four left-most pins represent the columns and the four right-most pins. 6.2.3. Connecting the Keypad to the Microcontroller The connection between the keypad and the microcontroller must be done is such a way so as to enable the detection and identification of the pressed key. In order to do so, a 2-input AND gate was introduced. The hardware connection of the keypad to the microcontroller is shown in Figure 12. The microcontroller pins used for the keypad connections are the Port 0 pins, where pins P0_0 to P0_3 were used for the keypad columns and P0_4 to P0_7 were used for the keypad rows. Figure 12: Hardware connection of the Keypad to the microcontroller 23
  • 30. Portable Bitmap Reader 2009 6.2.4. Detecting a Pressed Key and Identifying its Value There are two ways to detect the pressed key. One way is to have the microcontroller continuously check if a key was pressed; this process is done through polling. Polling entails that the microcontroller does nothing else but waiting on a key to be pressed. This method is not efficient for the project’s design and is therefore not used. The second method with which the microcontroller can detect a pressed key is by using interrupts. This method allows the microcontroller to perform other functions until an interrupt is generated by the pressing of a key. Due to that advantage, interrupts were used for the detection method. There are two ways to implementing an interrupt, one through software and the other through hardware. The software interrupt is generated by a code through instructions such as INT. A hardware interrupt on the other hand is asynchronous and can therefore be generated at any given time and whenever the “event” occurs. Because the user can press a key at any given time the hardware interrupt method has been chosen so as to not be tied done by the code running. For this design, interrupt zero (INT0) on pin P8_2 was used for the detection of the pressed key. A flow chart representing the process is shown in Figure 13. 24
  • 31. Portable Bitmap Reader 2009 Figure 13: Flow Chart of the Keypad Algorithm 25
  • 32. Portable Bitmap Reader 2009 6.2.5. The Keypad Functionality The function of each key on the keypad is given in the table below (Table 1): Table 1: Implemented Keypad functions Key Function Key Function 1 - 9 - 2 Up Arrow A Get list of files 3 - B Read file 4 Left Arrow C Close file 5 Down Arrow D Delete file 6 Right Arrow * - 7 - # - 8 - 6.2.6. Keypad De-bouncing As with many mechanical devices, when a button is pressed bouncing occurs. Bouncing is the “tendency of any two metal contacts in an electronic device to generate multiple signals as the contacts close or open” [4]. There are two ways to tackle this problem, one through software and the other through hardware. However, since this is an embedded application we are trying to minimize the total cost of materials which is why we chose to perform software de-bouncing. Software de-bouncing entails setting a timer once an interrupt is generated, and that timer is decremented until it reaches ZERO. Once that happens the value at the output of the AND gate is taken. In order to find out what value we should put for the timer we connect our system to an oscilloscope to see the bouncing effect. The probes are to be directly connected to the microcontroller. We then press a button and halt the oscilloscope, we note down the bounce time and repeat the process several times in order to take in the greater time (worst case scenario); that time will be the value of the one-shot timer. 26
  • 33. Portable Bitmap Reader 2009 6.3. Software Implementation The software implementation of the keypad and acquiring the key pressed is as follows: //===================================================================== // Get the row and column for the keypad // --------------------------------------- //When a button is pressed this function gets the rows. Then re- //initializes //the keypad, setting the rows to zero and connecting the columns to the //pull-up registers. //===================================================================== void getRowColumn(void) { // store the value of the rows & columns (p0) in a variable. unsigned int k = p0; int i; for (i=0;i<500;i++); // A delay... this allows us to accurately get the value of the row row = k; // finding the row number if (row == 0x70) { row = 3; } else if (row == 0xb0) { row = 2; } else if (row == 0xd0) { row = 1; } else if (row == 0xe0) { row = 0; } /**************************************** // Keypad Re-Initializations // // Making the Columns Input & Rows Output ****************************************/ // Set the direction of the Output port // Input->0, Output->1, rows are bits 7->4, columns are bits 3->0 // 1111 0000, Columns are input and rows are output pd0 = 0xf0; // In order to find out which column, set the rows to ZERO p0 = 0; // Pull-up Resistors pu01 = 0x0; // disable pull-up resistors for rows pu00 = 0x1; // enable pull-up resistors for columns // Negate the value of p1 and AND it with f0 // (0000 0111 -> 1111 1000 & 0000 1111 -> 0000 1000) for (i=0;i<500;i++); // A delay... this allows us to accurately get the value of the column k = p0; 27
  • 34. Portable Bitmap Reader 2009 column = (~k)& 15; // finding the column number if (column == 0x8) { column = 3; } else if (column == 0x4) { column = 2; } else if (column == 0x2) { column = 1; } else if (column == 0x1) { column = 0; } // Store the value of the pressed key into char key key = keypad[row][column]; // The rows and columns can only go from 1->4 // if the row or column is greater than 4 then set the key to NULL // Helps with debugging if (row>4||column>4) { key = NULL; } for (i=0;i<5000;i++); // A delay fileNumber = key; /**************************************** // Keypad Re-Initializations // Making the Rows Input & Columns Output ****************************************/ pd0 = 0x0f; p0 = 0; pu01 = 0x1; pu00 = 0x0; for (i=0;i<10000;i++); // A delay keypressed = 0; } 28
  • 35. Portable Bitmap Reader 2009 7. The USB Interface 7.1. The Vinculum VDIP2 In order to be able to communicate with the Flash memory stick, an interface between the microcontroller’s UART communication protocol and the Flash memory’s USB communication protocol must exist. There are several commercial interface chips on the market that will perform this operation with grace. Through the course of the Group’s research a USB to UART interface chip called VN1CL-1A (Figure 14) was found. According to Dart in his article “Interfacing a USB Flash drive to a PIC microcontroller”, the controller used in the implementation of the interface is “based around a custom processor core with twin direct memory access (DMA) engines” which enables fast data transfer as well as a “32-bit numeric co-processor to optimize the calculations for the file system”. The chip also contains a 64KB embedded flash program memory and a 4KB internal data SRAM. Dart explains that one of the appealing features of this chip the code length of the implementation. “Reducing the code overhead of the core allows much more functionality to be squeezed into the on-chip e-Flash memory” [15]. Figure 14: The VNC1L chip and Interface Circuit [15] 29
  • 36. Portable Bitmap Reader 2009 The schematic shown in Figure 14 demonstrates the Vinculum chip connected to the PIC microcontroller and a USB connector ‘A’ which in turn is used to connect the flash memory stick. The microcontroller takes in information from the sensors or “other sources via its general-purpose I/O pins (RC0, RC1, RA2 on pins 9,10,11)” and converts the data format before writing the data in a “stream to a file on the Flash drive”. The chip handles the FAT12, FAT 16 and FAT32 “file creation and data storage on the USB Flash Drive” and communicates with the device using the USB2DM and USB2DP (pins 28 and 29). The data being read from the Flash drive uses the same pins and is sent from the Vinculum chip’s TXD (pin 31) to the microcontroller’s RXD (pin 5) [15]. The VDIP2 (Figure 15) unit is a microcontroller that utilizes the USB protocol to create an interface that allows its user to communicate between a USB operated device and an embedded system. Its controller is the VNC1L chip, also developed by Vinculum. When bought, the VDIP2 unit comes equipped on a 40 pin printed circuit board. Through jumpers, the user can select one of three communication protocols: UART, FIFO and SPI The FIFO and SPI communication protocols will Figure 15: The VDIP2 Module [16] 30
  • 37. Portable Bitmap Reader 2009 not be discussed in this report. The VDIP2 module gives the user the ability to mount 2 USB devices and communicate with them. There are also two LEDs that tell the user a number of things depending on the lighting combination: Table 2: LED Behavior Description LED1 LED2 Power ON Flash Flash USB Initialization ON OFF USB Ready OFF ON USB Removed OFF OFF The commands used to interact with the USB flash memory stick are: Table 3: Commands and their Description [17] Command Description DIR Get the list files present in the current directory E Echo back “E” (used for debugging purposes) RD filename Read a file DLF filename Delete a file CLF filename Close a file QP2 Query USB port 2 All commands are followed by a carriage return to indicate the end of the command. 7.2. Communicating with the VDIP2 Communicating with the VDIP2 is rather simple. The connections made are as follows: Table 4: VDIP connection to MCU VDIP2 Pin M16C microcontroller Pin AD0 – pin 14 (TXD) P6_2 (RXD) AD1 – pin 16 (RXD) P6_3 (TXD) AD2 – pin 17 (CTS) Not Connected AD3 – pin 18 (RTS) Ground This can also be seen in Figure 16. 31
  • 38. Portable Bitmap Reader 2009 Figure 16: Hardware Connection between VDIP2 and MCU In order to communicate with the VDIP2, serial communication UART0 is used. A function was implemented to send the commands to the VDIP2. Listed below is the sequence of events that occur once the system is started: 1. Query Port 2. This is done through polling, since the microcontroller will be doing nothing until a USB flash memory stick is inserted. 2. Once the USB flash memory is inserted, two bytes are transmitted to the MCU. The first byte is the device classification and the second byte is always zero. For the implementation of this project the first byte will be 7. 32
  • 39. Portable Bitmap Reader 2009 3. The directory command is then sent to the VDIP2. Upon receiving the command, the VDIP2 starts sending the filenames available in the directory. Each filename is followed by a carriage return. That property is used to distinguish between the filenames received. The filenames are stored in a string array. 4. The filenames are then sent to the display stage of the project. (discussed in latter chapters) 5. The system will wait for the user to enter the number of the file to be opened. Once selected the number will be used to scroll through the string array for that specific location. Once there, the filename stored will be used to apply the read file command. 6. The user then has the option to either close the file or delete it. The settings of the UART0 were made as follows: void init_UART0() { // UART 0 bit rate generator – Baud rate set to 9600 u0brg =155; // UART 0 transmit/receive mode register smd2_u0mr = 1; // eight data bits smd1_u0mr = 0; smd0_u0mr = 1; ckdir_u0mr = 0; // internal clock stps_u0mr = 0; // 1 stop bit pry_u0mr = 0; // Odd parity prye_u0mr = 0; // parity disabled // uart0 t/r control register 0 clk1_u0c0 = 0; // f/1 clock selected clk0_u0c0 = 0; nch_u0c0 = 0; // CMOS push-pull output ckpol_u0c0 = 0; // transmite data at falling edge uform_u0c0 = 0; // LSB first crs_u0c0 = 0; // CTS function selected crd_u0c0 = 0; // CTS/RTS enabled // uart0 t/r control register 1 te_u0c1 = 1; // enable transmitter re_u0c1 = 1; // enable receiver // uart t/r control register 2 u0irs = 0; // select interrupt source u1rrm = 0; // select interrupt source 33
  • 40. Portable Bitmap Reader 2009 clkmd0 = 0; // n/a clkmd1 = 0; // clock output is only clock 1. // Setting the priority levels s0ric = 5; s0tic = 4; } When using that communication protocol it is necessary to have an End Bit defined that is agreed upon by both communication parties. In the case of this project, the End Bit is the carriage return. Because some difficulties were faced when operating the VDIP2 a method was devised to help identify the problem. The VDIP2 was connected to a computer through the RS232 interface and Hyper-terminal was used to communicate with the VDIP2. However, the RS232 cable uses a 5V. In order not to damage the chip a simple circuit was implemented that brings down that voltage to the TTL voltage level of approximately 3V. The circuit is shown in Figure 17. Figure 17: Communication Interface between VDIP2 and Hyper-Terminal 34
  • 41. Portable Bitmap Reader 2009 Once communication is established it is known that the VDIP2 would send the following information: the version of the firmware, whether a device is detected and if the device holds any updated firmware, as seen from Figure 18. Figure 18: Detecting Flash Memory Stick An instruction was then sent to the VDIP2 through Hyper-terminal, the response is shown in Figure 19. A very bizarre problem was then encountered; the VDIP2 would only accept the first command entered. Any other command sent would result in the message seen in Figure 20. What’s so puzzling is that the first command was accepted and run; therefore it does not make sense that the second command is not being accepted. Seeing as to how entering a command on HyperTerminal takes more than enough time for the VDIP2 to settle after running the previous command, I see no reason as to why the second command is not being accepted. I have tried contacting the developers of the VDIP2, but they were anything but helpful. Furthermore, people from all over the world were contacted in an attempt to find out the problem. These people have used the VDIP2 before, but not one person faced my problem and I’m afraid that Figure 19: Running a Command they were not able to help. 35
  • 42. Portable Bitmap Reader 2009 Figure 20: Running the Second Command 7.3. Using the VDIP2 in the project design Because the information sent from the VDIP2 to the microcontroller (firmware version and so on) is not of interest, and because the LED2 lights up upon the detection of a device, the LED2 pin was connected to an interrupt port in the microcontroller. This way, only when a device is inserted will the microcontroller start to send the required information/commands to the VDIP2. 7.3.1. The Commands Used to Interact with the VDIP2 The following are a list of the commands used, their description and implementation. 1. Directory Command (DIR) – This command is used to instruct the VDIP2 to send the names of the files stored in the flash memory stick. Each filename is separated by a carriage return. Once all the filenames are sent 36
  • 43. Portable Bitmap Reader 2009 over the communication line, a “D:” is sent. The end of the transmission is identified when the “:” is recognized. That particular character is used to identify the end of the file name list because it is not a valid filename character. void keyOperations(void) { if (key == 'A') { char f; int x = 0; DisplayString(LCD_LINE1," Main "); DisplayString(LCD_LINE2," Menu "); // Request VDIP2 to send the file list sendCommand('D'); sendCommand('I'); sendCommand('R'); sendCommand(0x0D); // recieve the filenames while (x<100) { f = Q_Dequeue(&rx_q); if (f == ':') { // no more filenames. Therefore, break! break; } filenameBuffer[x] = f; x++; } fileBufferSize = x - 1; // To remove the D of the D:> ListFiles(filenameBuffer); } 37
  • 44. Portable Bitmap Reader 2009 2. Reading a File (RD filename) – When this command is executed, the respective file is requested to be read. The VDIP2 sends the file data in the form of ASCII hex. The data is then stored in buffers. These buffers are to be later used in the display process. if (key == 'B') { int data; int x = 0; long int y = 0; DisplayString(LCD_LINE1,"View prv"); DisplayString(LCD_LINE2," file "); sendCommand('R'); sendCommand('D'); sendCommand(' '); sendCommand(fileList[fileNumber - 1]); sendCommand(0x0D); // recieve the data // getting the file type (2 bytes) fileType = Q_Dequeue(&rx_q); data = Q_Dequeue(&rx_q); strncat(fileType,data); // getting the size of file (4 bytes) sizeOfFile = Q_Dequeue(&rx_q); while (x <= 2) { data = Q_Dequeue(&rx_q); strncat (sizeOfFile, data); x++; } x = 0; // getting the Unused (4 bytes) Unused = Q_Dequeue(&rx_q); while (x <= 2) { data = Q_Dequeue(&rx_q); strncat (Unused, data); x++; } x = 0; // getting the Offset of the start of the image(4 bytes) OffsetStart = Q_Dequeue(&rx_q); while (x <= 2) { data = Q_Dequeue(&rx_q); strncat (OffsetStart, data); x++; } x = 0; 38
  • 45. Portable Bitmap Reader 2009 // getting the Header Size(4 bytes) HeaderSize = Q_Dequeue(&rx_q); while (x <= 2) { data = Q_Dequeue(&rx_q); strncat (HeaderSize, data); x++; } x = 0; // getting the Width of the image(4 bytes) ImageWidth = Q_Dequeue(&rx_q); while (x <= 2) { data = Q_Dequeue(&rx_q); strncat (ImageWidth, data); x++; } x = 0; // getting the Height of the image(4 bytes) ImageHeight = Q_Dequeue(&rx_q); while (x <= 2) { data = Q_Dequeue(&rx_q); strncat (ImageHeight, data); x++; } x = 0; // getting the number of planes(2 bytes) NoOfPlanes = Q_Dequeue(&rx_q); data = Q_Dequeue(&rx_q); strncat(NoOfPlanes,data); // getting the color intensity (2 bytes) ColorIntensity = Q_Dequeue(&rx_q); data = Q_Dequeue(&rx_q); strncat(ColorIntensity,data); // getting the compression (4 bytes) - 0 for BM compression = Q_Dequeue(&rx_q); while (x <= 2) { data = Q_Dequeue(&rx_q); strncat (compression, data); x++; } x = 0; // getting the Image Size (4 bytes) ImageSize = Q_Dequeue(&rx_q); while (x <= 2) { data = Q_Dequeue(&rx_q); strncat (ImageSize, data); x++; } x = 0; // getting the X and Y resolution (4 bytes) XYresolution = Q_Dequeue(&rx_q); while (x <= 2) { 39
  • 46. Portable Bitmap Reader 2009 data = Q_Dequeue(&rx_q); strncat (XYresolution, data); x++; } x = 0; // getting the number of color indexes used in the color table (4 bytes) NoOfColorIndexs = Q_Dequeue(&rx_q); while (x <= 2) { data = Q_Dequeue(&rx_q); strncat (NoOfColorIndexs, data); x++; } x = 0; // getting the number of important colors (4 bytes) IMPcolors = Q_Dequeue(&rx_q); while (x <= 2) { data = Q_Dequeue(&rx_q); strncat (IMPcolors, data); x++; } x = 0; // getting the color table (4 bytes) ColorTable = Q_Dequeue(&rx_q); while (x <= 2) { data = Q_Dequeue(&rx_q); strncat (ColorTable, data); x++; } x = 0; // getting the Image scan line data (each scan line is 32bits-4bytes) while (y < ImageSize) { ImageData[y] = Q_Dequeue(&rx_q); while (x <= 2) { data = Q_Dequeue(&rx_q); strncat (ImageData[y], data); x++; } y++; } } 40
  • 47. Portable Bitmap Reader 2009 3. Deleting a File (DLF filename) – When this command is executed the respective file is deleted from the flash memory stick. Upon receiving the command, the VDIP2 handles the deletion process. if (key == '#') { DisplayString(LCD_LINE1,"Deleting"); DisplayString(LCD_LINE2," file "); sendCommand('D'); sendCommand('L'); sendCommand('F'); sendCommand(' '); sendCommand(fileList[fileNumber]); sendCommand(0x0D); } 4. Closing a File (CLF filename) – This command simply closes the file and returns the user to the main menu. Upon receiving the command, the VDIP2 handles the file closing operation. if (key == '*') { DisplayString(LCD_LINE1,"Closing "); DisplayString(LCD_LINE2," file "); DisplayString(LCD_LINE1,"Reading "); DisplayString(LCD_LINE2," file "); sendCommand('C'); sendCommand('L'); sendCommand('F'); sendCommand(' '); sendCommand(fileList[fileNumber]); sendCommand(0x0D); } 41
  • 48. Portable Bitmap Reader 2009 8. The Video Graphics Array Signal 8.1. A General Overview of How a TV System works The standard TV-set has a built in vacuum tube with an electron canon shooting at a phosphor screen. When the electrons from the canon hit the screen light is generated due to the phosphor. The electron beam can be bent with the use of magnets; this method is used to allow the canon to shoot electrons on different parts of the screen. An image is drawn on the screen through controlling the direction of the beam and its intensity. Ideally, the screen is redrawn 25 times per second on a Phase Alternating Lines (PAL) system. The PAL system uses a method known as interlacing to reduce flickering effects. Interlacing involves drawing the odd horizontal lines first followed by the even horizontal lines. This allows the image to be “partially updated” 50 times per second instead of 25 times per second [13]. The video signal sent to the electron canon has to include key information. This key information includes where the electron beam is to be located and its intensity. In order to control the location of the electron beam a synchronization pulse is sent at the start of each scan line to tell the system that the current scan line is finished and to move on to the next line. In order to inform the TV system that new image data is arriving, a special synchronization pattern is provided. Furthermore, to inform the system of whether the information sent corresponds to even or odd lines, a vertical synchronization pattern is sent. The intensity of the beam is controlled through the voltage levels of the video signal [13]. The voltage levels can be divided into three levels as seen in the table below (Table 5): Table 5: Voltage Levels of the Video Signal Level Voltage Description Level 1 0V Synchronization Pulses Level 2 0.3V Black 42
  • 49. Portable Bitmap Reader 2009 Level 3 1V White Voltages between 0.3V and 1V are characterized as Grey Scale. In order to generate more colors from the black/white/grey signal we “superimpose” a 3.58MHz signal for NTSC television systems or a 4.43MHz for a PAL television system [14]. By doing so, the amplitude and phase of the added signal leads to the generation of more colors. 8.2. The Scan Lines As discussed earlier in earlier sections, every image is divided into scan lines. Typically, a scan line is 64 long [13]. That time is divided as follows: 1. 4 for sending the synchronization pulse. This is done by setting the voltage level to 0V, as seen from Table 5. This is to inform the system that a new scan line is starting. The synchronization pulse here is the Horizontal Synchronization Pulse. 2. 8 delay to allow everything to settle into place. 3. 52 to transmit the image data. The image data is drawn from left to right. As mentioned earlier, the intensities are obtained from the voltage levels of the video signal during that time. Figure 21 shows an example of a video signal with its various stages. The faster the voltages are updated during an image scan line, the better the horizontal resolution [14] Figure 21: An Example of a Video Signal [13] There are two main types to a video signal: 1. Composite Baseband Video Signal (CVBS) 43
  • 50. Portable Bitmap Reader 2009 2. Red-Green-Blue Video Signal (RGB) The CVBS signal is impossible to create using the M16C microcontroller because the generation of its information requires the microcontroller to generate the 3.58MHz or the 4.43MHz signal. The RGB signal on the other hand can be easily created using the microcontroller. For an RGB signal the color information is broken down across four wires: 1. One wire for the synchronization pulses 2. One wire for the Red color component 3. One wire for the Green color component 4. One wire for the Blue color component Because the color information was divided as described, the 3.58MHz or the 4.48MH signals are no longer needed. For a high resolution and high quality television image the voltage must be updated ten million times per second [14]. However, the M16C microcontroller used for the implementation of the display can by no means provide such speed. Fortunately, the 24MHz provided by the microcontroller are sufficient enough for this project design. To insure the stability of the displayed image two key pieces of information must be known: 1. The start of the image line 2. The start of the field (information that states whether the image data is for an even or odd line) As seen from the previous section, the horizontal synchronization pulse is embedded in the video signal. The vertical synchronization pulse on the other hand, is not. The vertical synchronization pulse tells the television system whether the image data being sent is for an even or odd line. The pulse patterns for the odd and even lines are different and can be seen in Figure 22. 44
  • 51. Portable Bitmap Reader 2009 Figure 22: Vertical Synchronization Patterns for Even and Odd Fields [12] According to Geraets, “The number of lines in each field restricts the vertical resolution. A PAL image contains about 560 visible lines. An NTSC image contains about 470 visible lines,” *14+. 8.3. Implementation of the Signal The microcontroller used in this design has the ability to provide a 5V digital output. However, in order to generate the RGB signal a maximum of 0.7V can be used. In order to do so, the simple concept of voltage division is applied. As seen from Figure 23, for the Red signal resistors R1 and R3 are used for the voltage divider circuit. Resistor R2 is used to provide a DC offset. The transistor T1 is connected as an emitter follower and resistor R4 is used to provide the signal with the 75Ω output impedance required [14]. The same implementation was done for the green blue signals and synchronization signals. 45 Figure 23: Display Circuit for Solution 1
  • 52. Portable Bitmap Reader 2009 The microcontroller pins used were: Table 6: Signal Generation Pin Assignment MCU pin number Signal generated P4_0 Red Signal P4_1 Green Signal P4_2 Blue Signal P4_3 Sync Signal As previously mentioned, the microcontroller provides the RGB and synchronization signal through its I/O pins, thereby making it possible to change the video signal levels easily and quickly. Because only 52µs of the signal is visible on the screen and because some television systems clip the ends of the signal, it was assumed that the visible portion of the video signal is only 45µs. According to Geraets, “To be able to show a reasonable amount of text on the screen, you need at least 120 pixels (20 characters) from left to right” *14+. For this design, it was taken that the microcontroller assigns 3MHz for the pixel frequency, thereby giving the microcontroller eight clock cycles to output a pixel; having said that, the final horizontal resolution is taken to be 135pixels. This value was calculated: Horizontal Resolution = pixel frequency × time period ∴ Horizontal Resolution = 3MHz × 45µs = 135 pixels As previously mentioned, the number of lines is each field for a PAL image is 560 lines. Therefore, each field consists of 280 lines. According to Geraets, “It doesn’t make sense to use a higher resolution in the vertical direction than in the horizontal direction,” *14+. Therefore, by using two video lines for each pixel, the number of lines in a field becomes 140 lines, which is approximately the same as the horizontal resolution. The code implementation of the vertical synchronization pulse is: 46
  • 53. Portable Bitmap Reader 2009 /*************************** Vertical Sync Pulse decleration ***************************/ /* Because S2 is defined in skp_bsp.h in order to use it, it must be undefined and then redefined to the design’s specification. */ #ifdef S2 #undef S2 #endif /* sync level for time in usec */ #define S2 SYNC_P, SYNC_P, SYNC_P, SYNC_P, SYNC_P, SYNC_P // 2usec #define S4 S2, S2 // 4usec #define S28 S4, S4, S4, S4, S4, S4, S4 // 28usec /* black level for time in usec */ #define B2 BLACK_P, BLACK_P, BLACK_P, BLACK_P, BLACK_P, BLACK_P // 2usec #define B4 B2, B2 // 4usec #define B28 B4, B4, B4, B4, B4, B4, B4 // 28usec #define B30 B28, B2 // 30usec #define B32 B30, B2 // 32usec // odd and even sync const uint8_t V_SYNC1[8 * 64 * PIXELFREQUENCY] = {S4, B28, S2, B30, S2, B30, S2, B30, S2, B30, S2, B30, S28, B4, S28, B4, S28, B4, S28, B4, S28, B4, S2, B30, S2, B30, S2, B30, S2, B30, S2, B30}; const uint8_t V_SYNC2[8 * 64 * PIXELFREQUENCY] = {S2, B30, S2, B30, S2, B30, S2, B30, S2, B30, S28, B4, S28, B4, S28, B4, S28, B4, S28, B4, S2, B30, S2, B30, S2, B30, S2, B30, S2, B30, B32}; const uint8_t BlackLine[ 64 * PIXELFREQUENCY] = {S4, B28, B32}; 8.4. Implementing the Font The font for the displayed text was implemented by first defining each row of pixels of the character to be displayed. For example, taking the character ‘A’: ‘A’ – ASCII code 41: 00100000 - 0x20 01010000 - 0x50 10001000 - 0x88 10001000 - 0x88 11111000 - 0xF8 10001000 - 0x88 10001000 - 0x88 00000000 - 0x00 Therefore, in the code ‘A’ would be represented as follows: A = F04, F10, F17, F17, F31, F17, F17, F00 Where, 47
  • 54. Portable Bitmap Reader 2009 /* This section makes the bit patterns line up with the corresponding output ports used in the RGB and S signals.*/ #define F00 (uint8_t)(0x00) #define F01 (uint8_t)(0x08) #define F02 (uint8_t)(0x10) #define F03 (uint8_t)(0x18) #define F04 (uint8_t)(0x20) #define F05 (uint8_t)(0x28) #define F06 (uint8_t)(0x30) #define F07 (uint8_t)(0x38) #define F08 (uint8_t)(0x40) #define F09 (uint8_t)(0x48) #define F10 (uint8_t)(0x50) #define F11 (uint8_t)(0x58) #define F12 (uint8_t)(0x60) #define F13 (uint8_t)(0x68) #define F14 (uint8_t)(0x70) #define F15 (uint8_t)(0x78) #define F16 (uint8_t)(0x80) #define F17 (uint8_t)(0x88) #define F18 (uint8_t)(0x90) #define F19 (uint8_t)(0x98) #define F20 (uint8_t)(0xA0) #define F21 (uint8_t)(0xA8) #define F22 (uint8_t)(0xB0) #define F23 (uint8_t)(0xB8) #define F24 (uint8_t)(0xC0) #define F25 (uint8_t)(0xC8) #define F26 (uint8_t)(0xD0) #define F27 (uint8_t)(0xD8) #define F28 (uint8_t)(0xE0) #define F29 (uint8_t)(0xE8) #define F30 (uint8_t)(0xF0) #define F31 (uint8_t)(0xF8) Using the defined font mentioned above all the ASCII characters are defined as follows: const uint8_t font[128][8] = { /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, 48
  • 55. Portable Bitmap Reader 2009 /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* */ {F00, F00, F00, F00, F00, F00, F00, F00}, /* ! */ {F04, F04, F04, F04, F00, F00, F04, F00}, /* */ {F10, F10, F10, F00, F00, F00, F00, F00}, /* # */ {F10, F10, F31, F10, F31, F10, F10, F00}, /* $ */ {F04, F15, F20, F14, F05, F30, F04, F00}, /* % */ {F24, F25, F02, F04, F08, F19, F03, F00}, /* */ {F08, F20, F08, F21, F18, F19, F12, F00}, /* ' */ {F02, F04, F08, F00, F00, F00, F00, F00}, /* ( */ {F02, F04, F08, F08, F08, F04, F02, F00}, /* ) */ {F08, F04, F02, F02, F02, F04, F08, F00}, /* * */ {F04, F21, F14, F04, F14, F21, F04, F00}, /* + */ {F00, F04, F04, F31, F04, F04, F00, F00}, /* , */ {F00, F00, F00, F00, F00, F04, F04, F08}, /* - */ {F00, F00, F00, F15, F00, F00, F00, F00}, /* . */ {F00, F00, F00, F00, F00, F12, F12, F00}, /* / */ {F00, F00, F01, F02, F04, F08, F16, F00}, /* 0 */ {F14, F17, F19, F21, F25, F17, F14, F00}, /* 1 */ {F04, F12, F20, F04, F04, F04, F31, F00}, /* 2 */ {F14, F17, F01, F02, F12, F16, F31, F00}, /* 3 */ {F14, F17, F01, F06, F01, F17, F14, F00}, /* 4 */ {F02, F06, F10, F18, F31, F02, F02, F00}, /* 5 */ {F31, F16, F28, F02, F01, F02, F28, F00}, /* 6 */ {F06, F08, F16, F30, F17, F17, F14, F00}, /* 7 */ {F31, F17, F02, F04, F04, F04, F04, F00}, /* 8 */ {F14, F17, F17, F14, F17, F17, F14, F00}, /* 9 */ {F14, F17, F17, F15, F01, F02, F12, F00}, /* : */ {F00, F00, F04, F00, F00, F04, F00, F00}, /* ; */ {F00, F00, F04, F00, F00, F04, F04, F08}, /* */ {F03, F06, F12, F24, F12, F06, F03, F00}, /* = */ {F00, F00, F31, F00, F31, F00, F00, F00}, /* */ {F24, F12, F06, F03, F06, F12, F24, F00}, /* ? */ {F14, F17, F01, F02, F04, F00, F04, F00}, /* @ */ {F14, F17, F01, F13, F21, F21, F14, F00}, /* A */ {F04, F10, F17, F17, F31, F17, F17, F00}, /* B */ {F30, F09, F09, F14, F09, F09, F30, F00}, /* C */ {F06, F09, F16, F16, F16, F09, F06, F00}, /* D */ {F28, F10, F09, F09, F09, F10, F28, F00}, /* E */ {F31, F16, F16, F30, F16, F16, F31, F00}, /* F */ {F31, F16, F16, F30, F16, F16, F16, F00}, /* G */ {F14, F17, F16, F23, F17, F17, F14, F00}, /* H */ {F17, F17, F17, F31, F17, F17, F17, F00}, 49
  • 56. Portable Bitmap Reader 2009 /* I */ {F14, F04, F04, F04, F04, F04, F14, F00}, /* J */ {F07, F02, F02, F02, F02, F18, F12, F00}, /* K */ {F17, F18, F20, F24, F20, F18, F17, F00}, /* L */ {F16, F16, F16, F16, F16, F16, F31, F00}, /* M */ {F17, F27, F21, F21, F17, F17, F17, F00}, /* N */ {F17, F25, F25, F21, F19, F19, F17, F00}, /* O */ {F14, F17, F17, F17, F17, F17, F14, F00}, /* P */ {F30, F17, F17, F30, F16, F16, F16, F00}, /* Q */ {F14, F17, F17, F17, F21, F18, F13, F00}, /* R */ {F30, F17, F17, F30, F20, F18, F17, F00}, /* S */ {F14, F17, F16, F14, F01, F17, F14, F00}, /* T */ {F31, F04, F04, F04, F04, F04, F04, F00}, /* U */ {F17, F17, F17, F17, F17, F17, F14, F00}, /* V */ {F17, F17, F17, F17, F10, F10, F04, F00}, /* W */ {F17, F17, F17, F21, F21, F27, F17, F00}, /* X */ {F17, F17, F10, F04, F10, F17, F17, F00}, /* Y */ {F17, F17, F17, F14, F04, F04, F04, F00}, /* Z */ {F31, F01, F02, F04, F08, F16, F31, F00}, /* [ */ {F14, F08, F08, F08, F08, F08, F14, F00}, /* */ {F00, F00, F16, F08, F04, F02, F01, F00}, /* ] */ {F14, F02, F02, F02, F02, F02, F14, F00}, /* ^ */ {F04, F10, F17, F00, F00, F00, F00, F00}, /* _ */ {F00, F00, F00, F00, F00, F00, F31, F00}, /* ` */ {F08, F04, F02, F00, F00, F00, F00, F00}, /* a */ {F00, F00, F14, F01, F15, F17, F15, F00}, /* b */ {F16, F16, F22, F25, F17, F25, F22, F00}, /* c */ {F00, F00, F14, F17, F16, F17, F14, F00}, /* d */ {F01, F01, F13, F19, F17, F19, F13, F00}, /* e */ {F00, F00, F14, F17, F31, F16, F14, F00}, /* f */ {F02, F05, F04, F31, F04, F04, F04, F00}, /* g */ {F00, F00, F13, F19, F19, F13, F01, F14}, /* h */ {F16, F16, F30, F17, F17, F17, F17, F00}, /* i */ {F04, F00, F12, F04, F04, F04, F14, F00}, /* j */ {F02, F00, F06, F02, F02, F02, F18, F12}, /* k */ {F08, F08, F09, F10, F12, F10, F09, F00}, /* l */ {F12, F04, F04, F04, F04, F04, F14, F00}, /* m */ {F00, F00, F26, F21, F21, F21, F21, F00}, /* n */ {F00, F00, F22, F25, F17, F17, F17, F00}, /* o */ {F00, F00, F14, F17, F17, F17, F14, F00}, /* p */ {F00, F00, F22, F25, F25, F22, F16, F16}, /* q */ {F00, F00, F13, F19, F19, F13, F01, F01}, /* r */ {F00, F00, F22, F25, F16, F16, F16, F00}, /* s */ {F00, F00, F15, F16, F30, F01, F30, F00}, /* t */ {F08, F08, F30, F08, F08, F09, F06, F00}, /* u */ {F00, F00, F18, F18, F18, F18, F13, F00}, /* v */ {F00, F00, F17, F17, F17, F10, F04, F00}, /* w */ {F00, F00, F17, F21, F21, F21, F10, F00}, /* x */ {F00, F00, F17, F10, F04, F10, F17, F00}, /* y */ {F00, F00, F17, F17, F19, F13, F01, F14}, /* z */ {F00, F00, F31, F02, F04, F08, F31, F00}, /* { */ {F03, F04, F04, F08, F04, F04, F03, F00}, /* | */ {F04, F04, F04, F04, F04, F04, F04, F00}, /* } */ {F24, F04, F04, F02, F04, F04, F24, F00}, /* ~ */ {F08, F21, F02, F00, F00, F00, F00, F00}, /* ¦ */ {F04, F04, F04, F04, F04, F04, F04, F00} }; 50
  • 57. Portable Bitmap Reader 2009 The first 32 characters of the ASCII table were defined as zeros because they are special characters that will not be used in the design of this project. 8.5. Direct Memory Access Controller (DMA) According to the Renesas M16c/62p microcontroller datasheet, the DMA controller “allows data to be transferred without the CPU intervention…the DMAC transfers one (8 pr 16-bit) data from the source address to the destination address” *18+. This property of the DMA controller is very helpful in this design because it will allow for continuous transfer of data from the microcontroller to the display unit. This would entail creating a large buffer that would hold the necessary data, setting the source pointer to the beginning of that buffer and setting the destination pointer to memory mapped I/O ports used for the video output signals (red, green, blue and sync). Because the DMA controller is separate from the actual processor, the processor is free to perform other operations. The trigger for the DMA was set to be a timer interrupt. The DMA settings used in this design are as follows: /* DMA0 Request Cause Select Register: ------------------------------- DSEL0,DSEL1,DSEL2 DSEL3 : 0010 - Timer A0 selected b5-b4: 00 DMS: 0 - basic factor of request DSR: 0 - Software DMA requested. */ dm0sl = 0b00000010; sar0 = (uint32_t)BlackLine; // source address dar0 = (uint32_t)p1; // destination address tcr0 = sizeof(BlackLine) - 1; // Transfer counter /* DMA control register settings: ------------------------------- DMBIT: 1 - Transfer Unit bit - 8bits 51
  • 58. Portable Bitmap Reader 2009 DMASL: 1 - Repeat transfer DMAS: 0 - DMA not requested DMAE: 0 - DMA is disabled DSD: 1 - Source address direction is forward DAD: 0 - Destination address direction is fixed b6-b7 - reserved (00) */ dm0con = 0b00010011; /* Time A0 mode register settings: ------------------------------- TM0D0 TM0D1: 00 - Timer Mode is selected MR0: 0 - Pulse is not Output (No pulse Output) MR1 MR2: 00 - Gate Function is not selected MR3: 0 - Set to 0 when Timer Mode is Selected TCK0 TCK1: f1 is selected */ ta0mr = 0b00000000; ta0 = (uint16_t)((f1_CLK_SPEED / (PIXELFREQUENCY * 1000000)) - ); dm0ic = 7; // DMA priority level - Highest priority dmae_dm0con = 1; // enable DMA ta0s = 1; //start timer 52
  • 59. Portable Bitmap Reader 2009 8.6. Fault with this Solution Sadly enough, due to the lack of the appropriate Television monitor compatible with the built system, this design was not used in the implementation of this design stage. Using this design a proper picture is not expected if a VGA monitor was used. The system is specific to televisions that display PAL or NTSC television signals. A modern computer cannot possibly display the signals provided by the design because it expects the RGB signal at a different voltage level and it also expects the pixels at a much higher frequency than the one being provided. However, going through this process has been very helpful as it helped make me aware of how the system works to a somewhat detailed level. 53
  • 60. Portable Bitmap Reader 2009 9. The microVGA 9.1. The microVGA – a brief description As mentioned in the previous section, due to the unavailability of a suitable television monitor for the previously mentioned display solution, another method had to be devised. A device called microVGA Figure 24: The microVGA (Figure 24) was found that allows the user to display data on any monitor with a 15 dub connector or an S-Video output. This device greatly improves the scope of the project since the final device will be compatible with a wide variety of monitors. Furthermore, the microVGA utilizes the “conio.h” library in the implementation of its functions. 9.2. Using the microVGA in the Project Design Connecting this device to the microcontroller used is fairly simple. UART2 was used to communicate with the microVGA, since UART0 was used to communicate with the VDIP2. The connections between the microVGA and the MCU are as follows: Table 7: Hardware Connections between microVGA and MCU microVGA Signal Description MCU pin Description Pin 1 Ground Ground Ground 2 +5V 5V input VCC 3 +3.3V 3.3V regulated output - 4 CS# Reset Signal Ground 5 RxD UART receive TxD P7_0 6 TxD UART transmit RxD P7_1 7 RTS# Request to send Not connected 8 CTS# Clear to send Not connected Not 9 - 20 - - connected 54
  • 61. Portable Bitmap Reader 2009 An image of the connections mage is shown in Figure 25. Figure 25: Hardware Connection between MCU and microVGA In order to operate the microVGA three functions were in need of implementation: 1. putchar() – writes a character to the console 2. getchar() – reads a character from the console 3. kbhit() – detects if keyboard key was pressed However, due to the simplicity of this design stage only the putchar() function was implemented since the design has no need for acquiring characters from the console or detecting keyboard keys. The putchar() function implementation is as follows: void putchar(char c) { // put the character in the transfer queue Q_Enqueue(tx_q, *s) // if transmitter not busy, get it started if (ti_u0c1) { u0tbl = Q_Dequeue(tx_q); } } 55
  • 62. Portable Bitmap Reader 2009 The next step was to change the baud rate of the microVGA since the default baud rate is 1,000,000 which is not supported by the microcontroller used. This change is done by accessing the system setup of the microVGA by short circuiting the setup pads on the microVGA (Figure 26). Through the setup menu the input type to the microVGA was set. For this project and ASCII hex input was set since the data stored in the image data buffers is in ASCII hex. Figure 26: Setup Pads However, after doing implementing all the mentioned steps the microVGA is yet to work. The following debug methods were performed in order to identify the problem: 1. Verified that the connections made were correct. This was done by: a. Using a volt meter to make sure that the connections made were not reversed (there are no pin numbers on the board). It was known that pin 3 provides a regulated output voltage of 3.3V. The voltmeter was connected to the third pin from the left and then to the third pin from the right. As expected, the voltmeter showed the 3.3V when connected to the third pin from the left, thereby proving that the connections where not incorrect. b. Informed the support team of the hardware connections made. They verified that they were made correctly. 56
  • 63. Portable Bitmap Reader 2009 2. Connected an oscilloscope to the TxD pin of the microcontroller and verified that the character is being sent. 3. Using the RS232/UART interface circuit described in previous sections, the microVGA was connected to the computer. Hyper-terminal was used to attempt and communicate with the device. However, this too did not work. Different baud rates were used, starting with the slowest, 9600 baud. 4. Replaced the device for another in hopes that the device itself was faulty. Unfortunately that did not solve the problem, and the probability of both devices being faulty was very unlikely. 5. As a last resort, the support team offered to investigate the problem. It was anticipated that the problem was that of compatibility. The microcontroller used for this project design was sent to the support team. After some work on the developers part they replied stating that the display had worked one time and stopped working afterwards. They thought that the problem was that the microcontroller was damaged. However, after suggesting they test the microcontroller with demo code provided with the starter kit, it became apparent that the microcontroller sent was not damaged. Their latest claim as of May 24, 2009 is that the device works. However, they have failed to provide me with proof of its operation. They did state the procedures they took to operate the device, and after following their procedure to the letter, the display still does not work. 57
  • 64. Portable Bitmap Reader 2009 10. Share of Responsibilities A. Nesma Aldash i. Biography Nesma is a senior Computer Engineering student. She has previously worked on an embedded systems course project that involved serial communication (UART/RS232 interface). ii. Key Responsibility Designing and implementing the entire project. 58
  • 65. Portable Bitmap Reader 2009 11. Project Budget Table 8: Portable Bitmap Reader Budget Plan Item Description Quantity Price Per Shipping Total Unit Cost Cost Renesas M16C The processor 1 0 AED 0 AED 0 AED Provided by microcontroller the University Monitor/Projector The final output device 1 0 AED 0 AED 0 AED Available Connecting Wires To connect different X 0 AED 0 AED 0 AED Provided by hardware components the University RS232 to UART interface Hardware RS232 cable 2 0 AED 0 AED 0 AED Provided by the University RS232 cable 2 6 AED 0 AED 12 AED - connector 0.1µF capacitor 10 0 AED 0 AED 0 AED Provided by the University 270Ω Resistor 2 0 AED 0 AED 0 AED Provided by the University MAX232 IC chip 2 0 AED 0 AED 0 AED Provided by the University Keypad Hardware 2 input AND gate 1 0 AED 0 AED 0 AED Provided by the University Keypad 1 0 AED 0 AED 0 AED Provided by the University USB hardware Flash memory Stick Any memory size 1 0 AED 0 AED 0 AED Available Vinculum VDIP2 The USB interface circuit 1 89.28 AED* 190.54 279.82 - AED* AED Vinculum VNC1L Bought in case the chip 1 82.97 82.97 - chip on the VDIP2 gets AED** AED damaged VGA Display VGA monitor For display purposes 1 656 AED 0 AED 656 AED - SCART Cable 1 78 AED 0 AED 78 AED - BC547b Transistor 4 1 AED 0 AED 10 AED - Resistors Resistor values are 75Ω, 10 ea 0.10 AED 0 AED 7 AED - 2.2kΩ, 4.7kΩ, 2kΩ, 8.2kΩ, 15kΩ, 6.8kΩ microVGA Display Solution microVGA Display solution 2 2 109.83 45.84 265.5 AED* AED* AED Power Supply LM7805 Voltage Regulator. Used 1 3 AED 0 AED 3 AED - 59
  • 66. Portable Bitmap Reader 2009 to get 5V from a 9V battery 0.1µF capacitor 1 0.33µF capacitor 1 Experimental Equipment ATmega16 Microprocessor used for 1 84.15 AED 84.34 168.491 - the display design AED AED Resistors 15Dsub to RS232 1 7.334 AED 7.41 AED 14.74 - wire AED Total Cost of Project Materials 1577.52 AED * US dollars to AED rate was taken to be 3.667AED per $1 * Price includes shipping ** British Pound to AED was taken to be 5.444AED per pound 60
  • 67. Portable Bitmap Reader 2009 12. Conclusion This project has been extremely educational. It allowed me to explore material I never thought I would be interested in. The fact that I was able to study and implement a display interface fills me with great pride, even if it did not work in the end. There were, several complications that occurred throughout this project, one of which was the arrival of the ordered hardware. Another problem faced was with the VDIP2 module. The module is provided with such poor and contradicting manuals that it made it very difficult to understand the communication interface. The main problem faced that could have possibly ruined the entire project is the with the display interface. The microVGA was expected to fulfill the projects goals with great ease; however the complications faced were unexpected. Even with all the problems faced throughout the course of this project, the improvements that could be made are endless. For one, allowing the user to connect a keyboard to Port 1 of the VDIP2 and enabling the user to directly interact with the files on the storage device would prove to be very useful. Being able to read more file formats would be a great advantage to the system. Providing better display or “eye candy” would also make the system more user friendly and better welcomed by consumers. I have no regrets as to what I have done on this project. I exhausted all resources to find solutions to the problems faced and most important of all I did my best to accomplish the project goals. 61
  • 68. Portable Bitmap Reader 2009 13. Resources [1] University of San Francisco, ITS Desktop Laptop Backup. [Online] Available: www.usfca.edu. [Accessed: May 6, 2009] [2] Innovation Creativity, “The Renesas M16C Design Contest 2005”. Circuit Cellar. [Online] Available: http://www.circuitcellar.com/renesas2005m16c. [Accessed: February 2009]. [3] Rickey, “Matrix Keypad Interfacing with Microcontrollers: Introduction”.*Online+ Available: www.8051projects.net/keypad-interfacing/introduction.php. [Accessed: April 24, 2009]. [4] Debouncing, Tech Target, 2008. [Online] Available: www.whatis.techtarget.com. [Accessed: February 2009]. [5] F. Durda, Frank, Serial and UART Tutorial. 13 Jan 1996. [Online] Available: www.freebsd.org/doc/en/articles/serial-uart/index.html. [Accessed: April 4,2009] [6] J.K. Peckol. Embedded Systems: A contemporary design tool. New Jersey, 2008. Pg 694-696. [7] How RS232 works. Best Microcontroller Projects.[Online] Available: www.best-microcontroller- projects.com/how-rs232-works.html. [Accessed: April 5, 2009] [8] J. AXELSON. USB COMPLETE: EVERYTHING YOU NEED TO DEVELOP CUSTOM USB PERIPHERALS, 3RD EDITION. LAKEVIEW RESEARCH LLC, 2005. [E-BOOK] AVAILABLE: GOOGLE BOOKS. [9] J. AXELSON. USB MASS STORAGE: DESIGNING AND PROGRAMMING DEVICES AND EMBEDDED HOSTS. LAKEVIEW RESEARCH LLC, 2006. [E-BOOK] AVAILABLE: GOOGLE BOOKS. [10] D. Kirkby, “BMP Format”. *Online+ Availabel: www.atlc.sourceforge.net/bmp.html. [Accessed: April 4, 2009]. [11] R. WHITROW. OPENGL GRAPHICS THROUGH APPLICATIONS. SPRINGER, 2008. [E-BOOK] AVAILABLE: GOOGLE BOOKS [12] CAROLINE. AUSTARNET. [ONLINE] AVAILABLE: www.home.austarnet.com.au/caroline/Slideshows/Butterfly_Bitmap_Download/butterfly_ bitmap_download.html . [ACCESSED: APRIL 5, 2009]. [13+ Rickard, “How to generate video signals in Software PIC,” *Online+ Available: www.rickard.gunee.com/projects/video/pic/howto.php. [Accessed: April 24, 2009] [14] R. GERAETS, “GENERATE VIDEO FROM SOFTWARE,” CIRCUIT CELLAR, VOL. 195, PG 24, OCTOBER 2006. [ONLINE]. AVAILABLE: WWW.CIRCUITCELLAR.COM. [ACCESSED: MAY 1, 2009] 62
  • 69. Portable Bitmap Reader 2009 [15] F. Dart, Interfacing a USB Flash drive to a PIC microcontroller, DATAWEEK, 19 September 2007. [Online] Available: www.dataweek.co.za. [Accessed: April 5, 2009] *16+ Future Technology Devices International Ltd., “VDIP2: Vinculum VNC1L Prototyping Module”.VDIP2 datasheet, 2007. [17] Future Technology Devices International Ltd., “Vinculum Firmware User Manual”.VDAP datasheet, 2008. *18+ Renesas, “M16C/62P Group (M16C/62P, M16C/62PT) Hardware Manual”, Sep 1,2004. *19+ SECONS, “MicroVGA-TEXT Datasheet”, 2008. 63