Docsity

Anywhere Microprocessor Laboratory - Computer Engineering Design | ECE 482, Study Guides, Projects, Research of Electrical and Electronics Engineering

Partial preview of the text

Download Anywhere Microprocessor Laboratory - Computer Engineering Design | ECE 482 and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!

ECE Senior Design Mid-Year Report

For

“Anywhere” Microprocessor Laboratory

December 15, 2003

Sponsor: Dr. Richard W. Wall

Student Design Team

_____________________________ _____________________________

Andrew Huska Lee Newbill [email protected] [email protected]

Instructor: Dr. Richard W. Wall

Advisors: Dr. Richard W. Wall, Dr. Greg Donohoe, Dr. Jim Frenzel, Dr. Brian Johnson

Mid-Year Report Table of Contents

I) Abstract II) Main Section a. Project Description i. Problem Statement ii. Solution Method b. Status (Block Diagram) i. What is designed and working ii. What is designed but not working iii. What is designed but not tested c. Method of Solution i. Technical description ii. Theoretical basis and fundamental relationships d. Validation Plan i. Test Plan e. Results i. Operating procedures ii. Validation results iii. Cost analysis III) Appendix A a. Specifications (Physical and Electrical) b. Bill of Materials c. Test Data IV) Appendix B a. Pin assigments V) Appendix C a. Test Code

II. Main Section

a. Problem Description i. Problem Statement: The ECE340 microcontroller course teaches critical skills for computer and electrical engineers. Student evaluations over the past 12 years show that students find the laboratory projects time consuming but invaluable to mastering the skills needed for designing embedded computer systems. The current ECE340 course is required for computer engineering majors alone though some electrical engineering students also enroll. Annual enrollment ranges from 30 to

The faculty adopted a curriculum where both electrical and computer engineering undergraduates are now required to take a course in microcontrollers engineering design. Under the new curriculum, the laboratory will now need to accommodate approximately 60 to 70 students per year. In addition to the on- campus students, the ECE department has students in Idaho Falls, and Coeur d’Alene. The microprocessor that our course is centered on is no longer in production, which means our microcontroller laboratory can no longer be supported. The laboratory, which has been operating near capacity, will be inadequate next semester. Outdated processors and facilities (development tools and instrumentation), in addition to the demand on instructor time, are all factors contributing to the need for an updated microcontroller laboratory. Offering the course each semester has temporarily solved the space issue, but this short-term solution is at the expense of instructor time. Due to the complexity of the suite of development tools, TA’s offer only limited laboratory assistance unless they have taken the existing microcontrollers course.

ii. Solution Method: In order to accommodate the number of students in ECE340 with the limited lab space we are designing a system that is self contained and inexpensive enough to allow students to purchase their own for use at home. To replace the current microcontroller that is no longer supported, our customer recommended the Rabbit Semiconductor 3000 series microcontroller. The Rabbit microcontroller family is inexpensive, well supported, has widespread market acceptance, and should be around for some time. The use of the Rabbit in embedded design is very well documented, and the development tools are easy to use and modern. This solves the problem of TA and instructor workload because students can access online information about the Rabbit, or a tutorial CD can be made and distributed to students in the class. To further modernize the laboratory system we will be adding more functionality. This will include the use of modern communication protocols, SPI and I2C. Also included will be a graphical LCD display, the ability to communicate with a slave processor, and other various features. All of these features are in addition to the current functionality of the laboratory system.

b. Status We have developed complete schematic diagrams for the entire microcontroller system. After optimizing and verifying the accuracy of these schematics, we created a printed circuit board (PCB) layout for the entire system. These two tasks are not trivial and took the majority of our time between 9/30/03 and 11/18/03. After we finished the PCB layout, we sent it to a prototyping facility and received the board on 12/4/03.

i. What is designed and working: We have populated the board with all of the power supply components, decoupling capacitors, and the pin headers and LEDs to help with diagnostics. After testing these, we connected the microcontroller to the board and tested a few of its functions using the Dynamic C software and programming cable. We have also installed and tested a few other functions of the prototype board, including the stepper motor, DC motor, and character LCD. Each IC was placed in a socket so that it can be removed without needing to remove any solder.

ii. What is designed but not working: The holes for the character LCD’s single-row connector pins were not drilled wide enough. To circumvent this problem, we had to solder on separate wires and run them to an external connector for the character LCD. The pads and holes for this LCD connector need to be made larger in the board’s next revision.

iii. What is designed but not tested: The remainder of our board has been designed, though the components have not been soldered onto the board nor tested. These functions yet to be installed include the SPI and I2C protocol functions, serial ports and connectors, graphical LCD, slave components, interrupts, and state switches.

c. Method of Solution i. Technical description We are using the Rabbit RCM3000 module with TCP/IP and the RCM3100 module without TCP/IP. These modules are pin compatible and allow users to choose a less expensive module if the TCP/IP functionality is not needed. To maximize efficiency we elected to not use the standard Rabbit prototyping board, but to design our own. This will allow us to include only the features that are needed and to make the user’s interface to the system logical. We have included as much diagnostic capability as possible to make debugging easier.

ii. Theoretical basis and fundamental relationships We chose to use this solution because it fulfills all the requirements from our specifications and can be implemented easily. The Rabbit microcontroller family is popular and well supported; it will not be obsolete in the near future. This system is inexpensive to produce so students will be able to purchase and customize a system for their personal use. With students working at home there is less load on the University’s laboratory resources. Since the Rabbit is popular there are many sources of reference to be found. Our prototyping board will also

Initial tests on our board showed the board was manufactured correctly as there was no continuity between the power and ground planes. For all currently installed components, we tested to make sure the correct power was available and it was. We installed all of the power supply components and they worked properly. The rectifier allows DC power to be hooked up backwards and also allows for AC power to be used as well. The 5V switching regulator provides a steady +5V and the 3.3V linear regulator also provides the correct voltage. We installed the DC motor control components, which also worked correctly. With the board powered up, the Rabbit reset, and the motor plugged in, the motor spun freely at full speed. This is desired since the motor control must be activated to turn the motor power off. When we activated the motor control, it stopped spinning as was expected. The stepper motor components were then installed and tested. The stepper motor did not twitch or move when plugged into the board. When the motor’s control lines were toggled in the proper order, it turned smoothly. The implemented circuit is for a unipolar stepper motor but also allows bipolar stepper motors to work as well. We tested the circuit using a bipolar motor and it worked. It also worked with the center taps disconnected, which is a feature of this circuit. The final component installed was the character LCD. When plugged into the board the LCD lit up as it should. We controlled the interface lines using a standard LCD initialization algorithm, which cleared the LCD, positioned the cursor at the first position, and made the cursor blink. When we controlled the lines with an LCD writing algorithm the expected data was shown on the display.

iii. Cost analysis Our solution costs $149.27 for a fully equipped board with 1 RCM3000, or 203.67 for a dual RCM3000 board with all the features. It only costs $124. for a RCM3100 with the required stuff for ECE340. Well under the specified requirement of $150 per board for the ECE340 class.

Table II.1: Expenditures Update Item Amount ($US) PCB Production (2 board + setup fee) 270 Rabbit RCM3000 and RCM3100 modules 250 Various components 30 Documentation 15 Shipping and Handling 40 TOTAL $

Table II.2: Funds Update Item Amount ($US) External grant 2200 ECE Department Account 250 TOTAL $

III. Appendix A

a. Specifications (Physical and Electrical) We designed the new lab system to be as compact as possible while still allowing the board layout to be simple. The previous lab prototyping board was approximately 7”x8” but required an additional board of equivalent size for the microcontroller and its supporting hardware. Physical specifications of the new system are shown in Table III.1.

Table III.1: Physical specifications Dimension Value (units in inches unless otherwise specified) Board length 11. Board width 8 Overall height 2, approximately (includes base and components) Pin headers 0.1 pitch (unless otherwise specified) RCM pin headers 2mm pitch Battery diameter 20mm Power plug O.D. 5.1mm Power plug I.D. 2.1mm

This system was designed to operate in a laboratory environment and to be inexpensive. It is not intended to be used in power critical areas such as mobile or space applications. Therefore, the electrical requirements for the system were primarily determined by the components to be included on it. Electrical specifications of the new system are show in Table III.2. Voltage reference is ground.

Table III.2: Electrical specifications Value Input power AC or DC Maximum input current, DC or ACrms 1.5A Maximum input voltage, DC or ACrms 20V Maximum 5V current draw 1A Maximum 3.3V current draw 0.5A Board top plane voltage 5V Board bottom plane voltage 0V (GND) Microcontroller current draw, RCM3000, each 0.15A Maximum I/O pin current in 6.8mA (unless otherwise specified) Maximum I/O pin voltage in 5.5V (unless otherwise specified) Maximum voltage on ADC pins 5.5V Maximum current on ADC pins 400uA Maximum voltage on I2C pins 5.5V Maximum current on I2C pins 3mA Maximum voltage on SPI pins 5.5V Maximum current on SPI pins 75mA Maximum Rabbit I/O pin output voltage 3.6V (VDD) Maximum Rabbit I/O pin output current 6.8mA

c. Test Data Code used to test the functionality of the system can be found in Appendix C.

Table III.4: Power Supply Test Test Input Expected Result Actual Result +15.5V DC before rectifier ~+14.8V DC after rectifier +14.7V DC -15.5V DC before rectifier ~+14.8V DC after rectifier +14.7V DC 4.5V ACrms before rectifier ~+3.1V DC after rectifier +2.65V DC +18V DC into 5V reg +5.0V DC output +4.99V DC +5V DC into 3.3V reg +3.3V DC output +3.29V DC

Table III.5: DC Motor Test Test Input Expected Result Actual Result Plug DC motor into board Motor should spin at full speed

Motor spins at full speed

Turn on power MOSFET by outputting 1 on PF.

Motor should stop Motor stops

Adjust duty cycle of PWM3 Motor should vary speed Motor varies in speed Adjust duty cycle of PWM3 Motor V DC should vary Voltage vary proportionally

Table III.6: Stepper Motor Test Test Input Expected Result Actual Result Plug motor into board Motor should be stationary No movement or twitching Toggle motor control lines in order: 1, 3, 2, 4 (PF0-3)

Motor should move in full step mode

Motor turns in full step mode

Table III.7: Character LCD Test Test Input Expected Result Actual Result Plug LCD into board LCD should light up LCD lights up Adjust R7 Contrast should change Contrast level changes Send standard LCD initialization to interface

LCD should clear, return home, and blink

LCD is cleared, at the first location, and blinking. Send standard LCD write code with a byte of data

LCD should display the character corresponding to the data and move the cursor to the next position

LCD displays the correct data and moves to the next character position

IV. Appendix B

a. – Pin Assignments, RCM3000, RCM

Table IV.1: RabbitCore pin numbers and pin names Pin Pin Names ECE340 Usage ECE404/504 Usage 26 /SCS, I7, PE7 I7 (Slave chip select) 27 I6, PE6 INT1B (from Slave) INT1B (from Slave) 28 INT1B, I5, PE5 INT0B (I2C parallel expander int.)

INT0B (I2C parallel expander int.)

29 INT0B I4, PE4 INT0B (push button) INT0B (TT chip alarm, push button 1) 30 I3, PE3 PE3 (CAN Controller RESET) 34 INT1A, I1, PE1 I1 (Slave SMODE1) 35 INT0A, I0, PE0 I0 (Slave SMODE0) 36 APWM1, RXE, PG7 PG7 (Char LCD Data, SPI CS1)

PG7 (Char LCD Data, SPI CS1, IO Exp CS1) 37 TXE, PG6 PG6 (Char LCD Data, SPI CS0)

PG6 (Char LCD Data, SPI CS0, IO Exp CS0) 38 ARXE, RCLKE, PG5 PG5 (Char LCD Data) PG5 (Char LCD Data, Graph LCD D/I) 39 ARCLKE, TCLKE, PG

PG4 (Char LCD Data) PG4 (Char LCD Data, Graph LCD Reset)

40 /IOWR I/O Expansion ctrl, Slave ctrl 41 /IORD I/O Expansion ctrl, Slave ctrl 44 SMODE 45 SMODE 51 VBAT 52 APWM3, ARXA, PD

PD7 (I2C SDA)

53 ATXA, PD6 PD6 (I2C SCL)

54 APWM2, ARXB,

PD

PD5 (Char LCD ctrl) PD5 (Char LCD R/W)

55 ATXB, PD4 PD4 (Char LCD ctrl) PD4 (Char LCD RS) 56 PD3 PD3 (Char LCD ctrl) PD3 (Char LCD E2) 57 PD2 PD2 (Char LCD ctrl) PD2 (Char LCD E1) 58 PD1 TCP/IP (RCM3000) TCP/IP (RCM3000) 59 PD0 TCP/IP (RCM3000) TCP/IP (RCM3000) 60 APWM0, RXF, PG3 PG3 (Char LCD Data bus) PG3 (Char LCD Data bus) 61 TXF, PG2 PG2 (Char LCD Data bus) PG2 (Char LCD Data bus) 62 ARXF, RCLKF, PG1 PG1 (Char LCD Data bus) PG1 (Char LCD Data bus) 63 ARCLKF, TCLKF, PG

PG0 (Char LCD Data bus) PG0 (Char LCD Data bus)

66 PC7, RXA RXA (Serial) RXA (Serial) 67 PC6, TXA TXA (Serial) TXA (Serial) 68 PC5, RXB RXB (SPI) RXB (SPI) 69 PC4, TXB TXB (SPI) TXB (SPI)

V. Appendix C

a. Test Code

Character LCD:

/* Andrew Huska [email protected] Lee Newbill [email protected] ECE482 Senior Design Fall 2003 Dr. Richard Wall [email protected] / / Character LCD control test function. Writes "482=easy" to LCD display */

#define lcd_cfg 0x #define lcd_entry 0x #define lcd_on 0x0F #define lcd_home 0x #define lcd_clr 0x

Delay_Ms(long ms); LCD_en(); void LCD_putc(char c); LCD_gohome(void); LCD_puts(char *s);

main() { int read; //PPG WrPortI(0x48, NULL, 0x00); //data reg WrPortI(0x4C, NULL, 0x00); WrPortI(0x4D, NULL, 0x00); WrPortI(0x4E, NULL, 0x00); WrPortI(0x4F, NULL, 0xFF);

//PPD WrPortI(0x60, NULL, 0x00); //data reg WrPortI(0x64, NULL, 0x00); WrPortI(0x65, NULL, 0x00); WrPortI(0x66, NULL, 0x00); WrPortI(0x67, NULL, 0xFF); WrPortI(0x6A, NULL, 0xFF); WrPortI(0x6B, NULL, 0xFF); WrPortI(0x6C, NULL, 0xFF); WrPortI(0x6D, NULL, 0xFF);

//INIT WrPortI(0x60, NULL, 0x00);

LCD_en(); WrPortI(0x48, NULL, lcd_cfg);

LCD_disen(); Delay_Ms(30);

//SETUP LCD_en(); WrPortI(0x48, NULL, lcd_entry); LCD_disen();

Delay_Ms(1);

LCD_en(); WrPortI(0x48, NULL, lcd_on); LCD_disen();

Delay_Ms(1);

LCD_en(); WrPortI(0x48, NULL, lcd_home); LCD_disen();

Delay_Ms(1);

LCD_en(); WrPortI(0x48, NULL, lcd_clr); LCD_disen();

Delay_Ms(1);

LCD_gohome();

//WRITING //LCD_putc('A'); LCD_puts("482=easy");

while(1) {

}

}

Delay_Ms(long ms) { long time; if (!ms) { ; }

else { time = MS_TIMER + ms; while(time > MS_TIMER) { ; } } }

if(c==0) { return; }

WrPortI(0x60, NULL, 0x00);

while(BF) { //WrPortI(0x48, NULL, 0xFF); WrPortI(0x60, NULL, 0x20); LCD_en(); read = RdPortI(0x48); add = read & 0x7F; BF = read & 0x80; LCD_disen();

}

//WrPortI(0x48, NULL, 0xFF); WrPortI(0x60, NULL, 0x20); LCD_en(); read = RdPortI(0x48); add = read & 0x7F; BF = read & 0x80; LCD_disen();

Delay_Ms(1);

if(add==0x08) { WrPortI(0x60, NULL, 0x00); WrPortI(0x48, NULL, 0xA8); LCD_en(); Delay_Ms(1); LCD_disen(); }

WrPortI(0x60, NULL, 0x10); WrPortI(0x48, NULL, c);

LCD_en(); LCD_disen();

}

LCD_gohome(void) { LCD_putc('\n'); }

DC Motor:

/* Andrew Huska [email protected] Lee Newbill [email protected] ECE482 Senior Design Fall 2003 Dr. Richard Wall [email protected] / / DC motor control test function. In stdio window Z, X, C, V, B, N, M set duty cycle of PWM output which controls speed of DC motor. Z is 100%, M is 0% */ int semaphore; int pwm_freq; int accel; char c;

Delay_Ms(long ms); void pwm_update();

main() { int i;

//PPF WrPortI(0x3F, NULL, 0xFF); WrPortI(0x3E, NULL, 0x00); WrPortI(0x3D, NULL, 0xFF); WrPortI(0x3C, NULL, 0x00);

pwm_init(0x7F); pwm_set(0x03, 128, 0x00);

semaphore = 0; pwm_freq = 512; accel = 1;

while(1) {

costate { if ( !kbhit() ) abort; // check if key was pressed

c = getchar(); if(c == 'z') pwm_freq = 1024; if(c == 'x') pwm_freq = 768; if(c == 'c') pwm_freq = 512; if(c == 'v') pwm_freq = 256; if(c == 'b') pwm_freq = 128;

Stepper Motor:

/* Andrew Huska [email protected] Lee Newbill [email protected] ECE482 Senior Design Fall 2003 Dr. Richard Wall [email protected] / / Stepper motor control test function. In stdio window Z and X increase and decrease stepping rate of motor */

Delay_Ms(long ms); Step(); faster(); slower(); int step_delay; int i; char c;

main() {

WrPortI(0x3F, NULL, 0xFF); WrPortI(0x3E, NULL, 0x00); WrPortI(0x3D, NULL, 0xFF); WrPortI(0x3C, NULL, 0x00); step_delay = 50;

while(1) { costate { if ( !kbhit() ) abort; // check if key was pressed

c = getchar(); if(c == 'x') faster(); else if(c == 'z') slower(); } Step(); } }

Step() { Delay_Ms(step_delay); WrPortI(0x38, NULL, 0x01); printf("hi1\n");

Delay_Ms(step_delay); WrPortI(0x38, NULL, 0x04); printf("hi2\n");

Delay_Ms(step_delay); WrPortI(0x38, NULL, 0x02); printf("hi3\n");

Delay_Ms(step_delay); WrPortI(0x38, NULL, 0x08); printf("hi4\n");

}

faster() { if (step_delay < 100) step_delay += 5; }

slower() { if (step_delay > 5) step_delay -= 5; }

Delay_Ms(long ms) { long time; if (!ms) { ; }

else { time = MS_TIMER + ms; while(time > MS_TIMER) { ; } } }