

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The fifth lab exercise in the electrical and computer engineering 341 course, focusing on implementing a process control system to manage the speed, direction, and step mode of a stepper motor using full preemptive real-time control with prioritized interrupts. Students will learn about interrupt service routines, converting rpm to time delays, and implementing external interrupts.
Typology: Lab Reports
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Revised (9/24/2009)
The purpose of this lab is to incorporate the concepts investigated in the past four laboratory exercises to implement a process control system to control the speed of rotation, direction and step mode of a stepper motor using full preemptive real-time control with prioritized interrupts.
Embedded systems best coding practices usually mandate that interrupt service routines be kept as short as possible. For this exercise, all processes will be initiated from within one of the two interrupt service routines. After initialization, the main loop will consist of the statement, “while(1);”. The specifications are present in revolutions per minute (RPM). However, this must be translated into steps per second that then can be implemented by executing a delay between steps. What is needed is an equation that converts the specified RPM to a time delay. Fortunately (for you) I have selected rotational speeds the convert in even multiples of milliseconds. A step frequency in steps/sec is easily computed using the appropriate conversion factors. The inverse of this frequency is the delay period. Include the equation that you used to complete Table II in your report.
You will be mapping the two inputs on BUTT2 and BUTT3 to stepper motor mode, direction, and speed control described in Table I. Implement a 1ms delay based on Timer A2 interrupts for stepper motor speed control. Implement an external interrupt where Button 2 and 3 will generate external interrupts on bits 5 and 6 of the returned data when the PCF8574_IOX_Rd(IOX_PORT0) function is called. The example external interrupt code discussed in class and provided at http://www.ece.uidaho.edu/ee/classes/ECE341/lab5/IOX_Interrupt.c should be used to serve as an aid in developing the external interrupt ISR. The student are expected thoroughly understand the functions provided as examples before attempting to use them in a program for lab exercises. The following list of requirements must be implemented in your code: Implement a fully nested interrupt scheme with timer A2 interrupts set for level 2 priority and the push button interrupts set for level 1 priority. Tasks executed in the “main” function o Board initialize to setup IO ports G and F o Initializes the RCM 3000 system for external interrupts See Part 2 of Chapter 5 of the ECE 340 course notes http://ee.uidaho.edu/ ee/classes/ECE340/notes/notes.htm see http://www.ece.uidaho.edu/ee/classes/ECE341/lab5/IOX_Interrupt.c
Initialize the PCF8574 I2C serial-parallel expansion IC o Sets up Timer A1 and A2 for one millisecond interrupts See Part 1 of Chapter 5 of the ECE 340 course notes http://ee.uidaho.edu/ ee/classes/ECE340/notes/notes.htm o Continuously executes the statement “while(1);” Tasks executed while servicing the button interrupt o Set PG5 high at the start and reset it low at the end of the button ISR o Implement a 1 ms software delay that does not use the virtual timer, MS_TIMER, inside the button ISR. o Decodes the button states by executing the “PCF8574_IOX_Rd(IOX_PORT0);” library function found in i2c_devices_ui.lib o Write the stepper motor control variables (direction = CW or CCW and mode = FS or HS) and the stepper motor step rate (in Hz) that will be measured on the Port G bit 6 pin to the STDIO window. Tasks executed while servicing the time A2 interrupt o Toggle PG7 each timer interrupt at the 1ms rate. o Toggle PG6 each time the stepper motor steps o Call the stepper motor step state control Changing PG0 through PG3 to control the stepper motor as specified by Table I. Changes to PG0 through PG3 do not affect PG4 through PG Capture a trace on the oscilloscope using PG5 and PG7 that verifies that the nested interrupt scheme functions correctly. All code must be demonstrated to the instructor or lab TA. Table I. Inputs Outputs D7/BUTT3 D6/BUTT2 DIRECTION MODE SPEED Off Off CW HS 15 Off On CW FS 15 On Off CCW HS 10 On On CCW FS 25