Design Project - Purdue University



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. 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. 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. 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].

Configuration Completion Status: Not Started

The “Configuration” module is a generic module that contains the necessary modules that configure the peripherals, OLED screen, and the uMiRF. The purpose of the configuration module is to properly configure and initialize the uMiRF and the microcontroller to perform in the desired operation.

Configure peripherals Completion Status: Not Started

Configure OLED Completion Status: Successfully ported and tested

This module properly configures the OLED screen on the lower board so that data can be sent to it to display on the screen.

Upper Rotating Microcontroller – Figure B-2 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 oversees the shifting out of the data to the LED Drivers and the transmitting and receiving of data from the transceiver.

Configuration Completion Status: Not Started

The “Configuration” module is a generic module that contains the necessary modules that configure the uMiRF transceiver, the ports, pins, and registers. The purpose of the configuration module is to properly configure and initialize the uMiRF and the microcontroller to perform in the desired operation.

Configure uMiRF Completion Status: Outlined in Pseudo-Code

Same format as the ARM. See above.

Initialize ports, pins, and registers Completion Status: Not Started

This module initializes the ports, pins, and registers for the desired operation. It initializes the appropriate ports and pins for communication with the transceiver, IR LED, and the LED drivers.

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

Same format as the ARM. See above.

Shift Data to LEDs Completion Status: Not Started

The “Shift Data to LEDs” module uses the SPI to shift the pixel map data to the LED drivers. Since each column has 32 RGB LEDs, 96 bits of data are shifted out to the LED drivers for each column. Since there are 96 columns, this module is used 96 times per revolution.

Speed/Angle Offset Calculation Completion Status: Not Started

This module calculates the angle offset as well as the time for each column in terms of clock cycles. The purpose of the module is to calculate how many clock cycles the center of the project image should be offset from the reference point in order to project the image toward the RF beacon. The basic calculation for determining the number of clock cycles from the reference point to the center of the image is:

# clock cycles = (cycles/revolution)* (angle offset)/360

The angle offset variable is calculated from the lower board and sent to the upper rotating board via the transceiver.

4. Summary

The project uses a rotating column of LEDs turned on and off at precise times to exploit the phenomenon of persistence of vision and create the effect of a complete image being displayed and obscuring the fact that there is only a single column of LEDs. This is made possible by using two separate microcontrollers—a stationary ARM Cortex M3 running software that functions like a state machine to control the user interface and mode selection, and a rotating PIC24F with an interrupt based software architecture to control the LED drivers. The two microcontrollers are communicating over a 2.4 GHz wireless link. One of the features of this POV machine is the ability to track the angle of a 1.2 GHz RF beacon and display an image in that direction. This beacon angle is monitored by the stationary ARM microcontroller and the data is wirelessly transmitted to the rotating PIC24F. The mode selection and pixel map generation are performed on the ARM while the PIC controls the LED drivers and their timing.

5. List of References

1] Persistence of Vision, ,

2] Microchip Technology, Inc, “PIC24FJ64GA004 Family Data Sheet,” PIC24FJ32GA002-I/SS. January 2008.

3] Luminary Micro, “LM3S8962 Microcontroller,” Datasheet. EKK- LM3S8962. July 2008.

4] Nordic Semiconductor, “Single Chip 2.4 GHz Transceiver nRF2401A,” µMiRF WRL-00152. December 2004.

Appendix A: Flowchart/Pseudo-code for Main Program

Appendix B: Hierarchical Block Diagram of Code Organization

[pic]

[pic]

-----------------------

Figure A-1 Main program flowchart for the stationary ARM Cortex M3 microcontroller

no

yes

yes

no

On any button press

Figure A-2 Main program flowchart for the stationary PIC24F microcontroller

no

Data Function for handling new pixel map

no

yes

yes

Figure B-1 Hierarchical Block Diagram of ARM Cortex M3 microcontroller

Figure B-2 Hierarchical Block Diagram of PIC24F microcontroller

Interrupts

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download