High Level Design

 

 

 

The Rational

The original idea was to draw to a 5” TV screen using a pen input touchpad.  We had originally ordered a Jam Studio tablet but unfortunately it was too complex and poorlydocumented.  We couldn’t retrieve any signals from the pad.  Thus, we decided to use a regular touchpad.  This makes our design robust due to the inaccuracy of using a fingertouch as opposed to a pen point.  However, the concept remains the same: to draw to a screen.  

 

The microcontroller acts as a translator between the touchpad and the oscilloscope.  Its job is to communicate with the touchpad using any of the 4 standard protocols: serial, ADB, PS/2, or USB and to send appropriate signals to represent the coordinates on the oscilloscope.  Our touchpad uses the ADB protocol which is MAC compatible. Also, since the oscilloscope requires analog input signals, DACs are needed to translate the digital output from the MCU to a form that can be recognized by the oscilloscope.

 

Diagram

The following is the overall layout of our design. 

 

Figure1 . High Level Design Layout

 

 

 

The Logic: How does a touchpad work?

ADB Protocol

The protocol requires a single ADB data signal line for the two-way communication between MCU and touchpad.  This protocol is time sensitive.  Essentially, the MCU needs to know precisely when to can send the commands and when to listen for responses. 

 

Upon power on, the touchpad requires 200ms for calibration and self testing.  After this, the MCU can begin sending its command packet and receive data packets. Most touch pads have 4 commands and 4 registers. (Appendix A)  Our specific touchpad, Alps Glidepoint, has only 2 active registers: register0 and register3. 

 

An ADB command is a 1-byte value that specifies the 4 bit ADB device address, the desired action the touchpad should perform and to what register.   By default, the device address is 3 and the handler ID is $01.  In order to ensure a two way communication, the “LISTEN” and “TALK” commands need to be implemented.   Figure 2.  shows the command format.

Figure2 .  ADB commands.

 

The TALK command requests to read the data stored in the specified register. Register 0 is used to hold motion packet data.  The MCU polls the touchpad by sending a Talk Register 0 command.  The device responds to a Talk Register 0 command only if it has new data to send.  (If more devices were used as inputs, the MCU would have to resolve device address conflicts, collisions and the device would need to issue a service request to signal it has new data to send.)

 

The LISTEN command instructs the touchpad to prepare to receive additional data. The device must overwrite the existing contents of the specified register with the new data. 

 

The send command packet protocol follows the following flowchart:

          (a)

(b)

Figure3 .  Send Command Logic.

Once the MCU sends the stop bit, it releases the data line to wait for the touchpad to begin sending its data.  If the time between the stop bit till the data start bit exceeds its maximum range, then the MCU resumes control and resends the TALK to Register0 command.  If not, the device sends the motion data stored in its Register0 which by default consists of 2 bytes,  and , in relative mode. (See figure 4)

 

Figure 4 ADB Register0.

 

Once, the motion packet is received by the MCU, is can store the data and send appropriate signals to the DAC to output the point onto the oscilloscope.

 

Initially, we had tried to overwrite register 2, in order to change the relative mode to absolute mode.  This could have been done with the LISTEN register 2 command.  Unfortunately, with this touchpad, Register 2 couldn’t even be read so a LISTEN command would have been pointless.  Due to lack of documentation, we have made several assumptions based on the Sypnaptic touchpad documentation, an Apple book, and an article we found online implementing a sample ADB manager.  Since, relative mode was the only output from this touchpad; we decided to use the oscilloscope as the display device as opposed to the TV since it relies on incremental values as its input. 

 

Subsequently we also succeeded in using the TV as the display device.  In order to use the TV with relative mode inputs, we store the current position for x and y (with a default starting point at the centre of the screen) and update x and y with thereceiveddeltas(up=-1,down=1,left=-1,right=1).  Finally, the point is drawn using the video_pt subroutine.  We are currently carrying out further tests to perfect the implementation. 

 

Math Calculations

Timing sequence

Timer 0 is used to generate time.  It is pre-scaled by 64 to generate a 4  clock tick with a 16 MHz crystal.  The timing ranges required by this program for ADB signals are shown in the table below.  Note that each time reading is acquired by resetting TCNT0 and polling it until it exceeds the maximum range.  The MCU sends each command bit for a specified duration with  error.  Note, that a logic 0 and logic 1 is determined by the pulse’s low time.  A logic 0 is given by a low time approximately equaling to 65

.

 

Table1.  ADB protocol timings.

Signals

Times

Times used

Logic ‘0’ low time

65us 5%

64us

Logic ‘1’ low time

35us 5%

36us

Bit Cell time

100us 3%

100us

Attention

800us 3%

800us

Sync

65us 3%

64us

Stop bit low time

70us 3%

72us

Stop to start time

200us 30%

200us

 

 

Storing and for the oscilloscope input

The two 7-bit deltas are mapped to a two bit incremental value and saved in two position arrays, bufferx and buffery.  This is done by taking into consideration bit 6 of the relative motion packet bytes which represent the sign bits.  For y, a set signed bit represents movement in the upward direction. Hence +1 is stored in buffery.  For x, a set signed bit represents movement towards the right Hence +1 is stored in bufferx.  The incremental values are represented as 2 bits in the following format:

                                   { ‘-1’ = 11 , ‘1’ =01, ‘0’= 00 }.

 This scheme allows us to store 2 points in one byte of memory.  Thus in a 2k RAM, the maximum number of points we can store is 4000.  

 

Figure 5. Oscilloscope Interpretration of  incremental values.

 

 

Plotting x and y

First, we start at the center of the screen, meaning that the MCU outputs 0x40 to PORTA and PORTB to represent the analog Vx and Vy.  Each 2 bits in the buffers (bufferX, bufferY) represent the change in coordinates. 

 

The screen is refreshed in the main loop.  Starting with the center point, the next point is calculated by retrieving the next 2 bits from each position buffer, interpreting with the appropriate incremental value and updating the X and Y register value containing the current coordinate.  Finally, this register is sent to the ports connected to the appropriate DACs.  Refresh( ) reads the buffers and displays the points onto scope. This is written is assembly code for speed optimization.