ECE 477 Digital Systems Senior Design Project Rev 8/09

Homework 9: Software Design Considerations

Team Code Name: __POV Machine______Group No. _7____

Team Member Completing This Homework: ___Shaun Greene______

E-mail Address of Team Member: _spgreene_ @ purdue.edu

Evaluation:

SCORE

/

DESCRIPTION

10 /

Excellent – among the best papers submitted for this assignment. Very few corrections needed for version submitted in Final Report.

9 /

Very good – all requirements aptly met. Minor additions/corrections needed for version submitted in Final Report.

8 /

Good – all requirements considered and addressed. Several noteworthy additions/corrections needed for version submitted in Final Report.

7 /

Average – all requirements basically met, but some revisions in content should be made for the version submitted in the Final Report.

6 /

Marginal – all requirements met at a nominal level. Significant revisions in content should be made for the version submitted in the Final Report.

* /

Below the passing threshold – major revisions required to meet report requirements at a nominal level. Revise and resubmit.

* Resubmissions are due within one week of the date of return, and will be awarded a score of “6” provided all report requirements have been met at a nominal level.

Comments:

Comments from the grader will be inserted here.

1.0  Introduction

The project is an electronic display device that uses a single column of rotating LEDs turned on and off at specific time intervals utilizing the phenomenon of persistence of vision (POV) to create the illusion of a stationary image floating in the air [1]. The display on this device can be used to display simple things such as clock or the temperature or complex things such as a picture. The LEDs are three color (red, green, and blue) so there are a total of 8 output colors – Red, Green, Blue, Cyan, Magenta, Yellow, White, and Black (all off). An added feature of this POV machine is the ability to track a 1.2 GHz radio frequency (RF) beacon angle relative to the machine and display the LED output in that direction. To implement this, two microcontrollers are necessary—one stationary microcontroller that will detect the RF beacon position and control the user interface and the second microcontroller mounted on the rotating disc to control the LEDs. These two microcontrollers communicate over a 2.4 GHz wireless data link using a µMiRF RF transceiver.

The software for the lower microcontroller has many functions, but is primarily responsible for controlling the user interface, measuring values for different modes of operation (RF position, temperature, etc.), generating the pixel map to send to the upper microcontroller, and controlling the RF Transceiver. The software for the upper microcontroller controls its RF transceiver, measures the precise rotational speed, sends the image data to the LED drivers, and controls the timing on the LED output.

2.0  Software Design Considerations

The software for the stationary ARM microcontroller [2] is structured in state-machine form as you can see from the block diagram in Figure A-1in Appendix A. The states correspond to the functions that the POV machine performs and state examples are: user menu, clock mode, temperature mode, user-input text mode, picture mode, or option mode. In menu mode, a list of options is displayed, with each option corresponding to a “mode.” When the user selects one of these options using the pushbuttons, the software jumps to that corresponding function and executes the function until the user presses any input button in which case the software jumps back to the menu function. All functions have the ability to use the RF position information, or allow the user to input a fixed offset angle for the display to be projected at (this change is user configurable from the “option” mode in the user menu). The time function allows the user to set the time and then the microcontroller generates the corresponding pixel maps to send to the OLED and to the transceiver. This image is updated once per second and the new pixel maps are sent when it does. The temperature function uses the ATD peripheral to read the temperature from the analog temperature sensor then display the value on the OLED and send the pixel map to the transceiver. The user-input text option has a menu for the user to input text. The LED display can be broken down into three rows of 16 characters with each character consisting of 5x10 pixels.

The beacon angle is detected by reading the two analog voltage outputs of the phase detectors, using the ATD module, and finding the corresponding angle from a look-up table. The interrupts in this software are used for scanning the push buttons and to update the time in clock mode. The OLED screen is connected to the SPI port which is multiplexed with the RF transceiver. The temperature sensor and the phase detectors are connected to the ATD port, and a piezo transducer is connected to the PWM output and can be used for making quiet chirps. The input buttons and IR sensor use GPIO digital inputs and the motor relay uses a GPIO output.

The program architecture for the ARM was selected based on desired program functionality. The micro does not have to multitask very often and generally runs a single function in a loop until it changes to run a new function, so this fits the description of a state machine. Any functions that need to be performed regardless of the “state” are put into interrupts such as button scanning and keeping time on the clock.

The PIC42F is the microcontroller [3] on the upper rotating disc and its software is structured as an interrupt based operation where processing intensive activities are done in a polling loop and functions in the loop are enabled and disabled by the interrupts. Examples of the polling loop functions are Speed/Angle Offset Calculation (See section 3.0 for detailed description of this function) as well as the Shift Data to LEDs function. The IR Sensor uses the external interrupt pin which fires an interrupt that reads the value from a running timer (TIM1/2) and writes that value to a variable in SRAM. This variable is then used to calculate the offset delay and the time of a column. This interrupt also sets the flag in SRAM for the polling loop to shift out the first column of data to the LED driver. The RF Transceiver is connected to SPI1 as well as 2 extra GPIO lines used for control and configuration. The LED drivers are connected to the SPI2 as well as 2 extra GPIO lines for control. TIM3 is the delay timer, and it is enabled by the EINT pulse. When TIM3 expires, it will pulse the latch on the LED driver (GPIO), enable TIM4, which is the column width timer, set the flag in SRAM to shift out the next column of data to the LED driver and disable TIM3. When TIM4 expires it pulses the latch on the LED driver and sets the flag for the next column to be shifted out. After the last column of the display is shifted out to the LED drivers TIM 4 is disabled. The other interrupt that the PIC24F has to service is the SPI1 interrupt that says data is ready to be received. The program will read the byte from the SPI1Rx register and store that to a linear buffer in SRAM that corresponds to the pixels on the pixel maps, or the angle offset of the delay. The data shifted out to the LED drivers is stored in a different linear buffer. This double buffering prevents a half-loaded image from being displayed. Once a complete pixel map has been received, the program will change the SPI2 output pointer to the new image and the SPI1 input pointer to the old image in SRAM. This software flow can be seen in Appendix A Figure A-2.

The software architecture for the PIC24F was chosen to be primarily interrupt driven because of the time critical nature of the operations it performs. Only a few functions discussed earlier were too time consuming to put into an interrupt. The PIC24F architecture has many options for interrupt sources and a vectored interrupt handler with masking of interrupts which makes the interrupt based programming a simple architecture to achieve the necessary functions and the required determinism of the top micro.

3.0  Software Design Narrative

Lower Stationary Microcontroller Figure B-1 Appendix B

Main Program Completion Status: Outlined in Pseudo-Code

The main program for the upper rotating microcontroller is outlined in Appendix A. Its purpose is to oversee and control the functions of the upper rotating microcontroller. The program allows the user to select different options for the POV machine such as displaying a preset image, displaying a user generated text image, or turning on or off the beacon-following feature.


ARM Menu Completion Status: Not started

The ARM Menu module will use the Draw Menu module to display a user menu on the screen. The options on the menu are displayed in white text with a black background and the selected option has a gray background. As the user scrolls through the options, the gray background moves to the active option and the module keeps track of what option is selected. The user then presses the select button and the ARM Menu option outputs the next state for the software, typically a specific function such as clock, temperature display.

Draw Menu Completion Status: Started coding

The Draw Menu function uses the Generate OLED Pixel Map function to generate images to be displayed to the user that represent a menu. The Draw Menu module will accept the menu labels and format them to fit correctly on the OLED screen. This will also generate the gray rectangle and its coordinates for the selected menu option. ARM Menu is the module that keeps track of what option is selected.

Generate OLED Pixel Map Completion Status: Successfully ported and tested

This module has two mode— string and picture input mode. String mode will accept a string as input and display that at the corresponding location on the screen. Picture mode will read a 4-bit grayscale picture from memory (flash, RAM, or heap) and display that image on the screen.

Get Buttons Completion Status: Not Started

The “Get Buttons” module receives the data from the pushbuttons on the user interface. These values are set and cleared during an interrupt.

Generate RGB Pixel Map Completion Status: Outlined in Pseudo-Code

Since the display area is 96 pixels wide by 32 pixels tall, the 5x10 pixel characters fit into three rows of characters with 16 characters in each row. This allows for a blank row and column of pixels to separate each character from the adjacent ones. A nested loop is used to loop through the 5 columns of each character and then through the 16 characters in each row. A pointer points to the pre-stored pixel data for each character and adds it to the pixel map column by column. This process repeats for each color (red, green, and blue) of each column of each character in the string.

Get Data Completion Status: Outlined in Pseudo-Code

The “Get Data” module is a generic module that contains the “Get Temp”, “Get Time”, “Get Beacon Arrival” code modules. Each of these modules receives necessary data from the digital thermometer, RF phase detectors, and the Ethernet port. The module relays the information to the functions that request the data.

Get Temp Completion Status: Outlined in Pseudo-Code

The “Get Temp” module reads the data from the digital thermometer. The thermometer chip outputs an analog voltage which is read by the analog-to-digital converter. The module will then translate the read value into a numerical temperature.

Get Time Completion Status: Outlined in Pseudo-Code

The “Get Time” module receives the current time from user input. The purpose of the module is to receive the current time of day from the user so that it can be updated and projected as an image on the POV Machine.

Get Beacon Arrival Completion Status: Outlined in Pseudo-Code

The “Get Beacon” module receives the data output from the RF phase detectors. Its purpose is to read the phase detector voltages so that it can be used to calculate the angle of arrival of the RF beacon. The phase detectors output analog voltage levels that will be read by the analog-to-digital converter.

Calc. Angle. Completion Status: Outlined in Pseudo-Code

The “Calc. Angle” module interprets the data received from the “Get Beacon” module by using it to calculate the angle of arrival of the RF beacon so that the image can be projected in the direction of the RF beacon. It calculates the angle by using a look-up table that is based on the analog input values.

Configure uMiRF Completion Status: Outlined in Pseudo-Code

The purpose of this initialization is to tell the nRF2401A transceiver chip the following information: size of data transmission packet, channel address, enable/disable checksum function, data transmission mode (compressed or direct transfer), data rate, crystal oscillator frequency, RF output power in Tx mode, channel number, and Rx versus Tx operation. Configuration for the upper transceiver is identical to the configuration for the lower transceiver except for the Tx/Rx configuration bit. After the nRF2401A transceiver chip powers up, the micro waits 3ms minimum before setting CS high to enter the configuration mode. It then shifts in the configuration bits (MSB first) using the CLK1 and DATA pins and finishes by setting CS low. The maximum SPI data rate between the micro and the transceiver is 1 Mbps [4].

Transmit/Receive uMiRF Completion Status: Outlined in Pseudo-Code

To transmit data, the lower micro sets the CE pin high, clocks in the channel address followed by the payload data, and then sets CE low to begin the wireless transmission. To receive the data, the upper micro sets the CE high and then waits for data to be received by the nRF2401A. When a full data packet has been received and the checksum is correct, the DR1 (data ready pin) goes high and the micro can set CE low and clock out the data when it is ready [4].