ECE 471 LAB 8 FALL 2008 PURPOSE: Learn about driving a stepper motor, interrupts on the PIC, writing code in C. EXERCISE: This program will control a stepper motor using interrupts. The speed of the motor will be controlled by two inputs ("buttons"). Each time one button is pressed, then the motor will increase it's speed by 10 RPM. When the other button is pressed, the speed will decrease by 10 RPM. If the speed becomes zero, then the motor will stop (disable the interrupt). If the motor speed becomes negative, then the motor will reverse direction. Your code will be written in C. Motor stepping must use interrupts on TIMER1. Your program will have three main parts: initialze the interrupt, main code which checks the buttons and updates the RPM, and the interrupt service routine which steps the motor in the proper direction. Notes: Remember to debounce when checking the buttons (disregard time spent in the interrupt routine when computing the delay). When the main program determines the new RPM, it must compute the new delay between motor steps and store it in memory. This can either be done in a lookup table, or do the division using the routine given in Microchip Application Note #544. Your ISR will simply step the motor in the proper direction. The motor turns at 15 degrees per step. Include delay calculations in your notebook. MOTOR STEPPING TABLE: Bit 3 Bit 2 Bit 1 Bit 0 1 1 1 0 1 1 0 1 Read down for patterns to cause CW rotation 1 0 1 1 Read up for patterns to cause CCW rotation 0 1 1 1 You can initialize the motor pattern with 0xEE and then do an 8-bit rotate to get the next pattern. Initialize the motor output port with the pattern before making it an output. If you make it an output first and then initialize the pattern, you can momentairly have all pins being one, drawing too much current. In wiring the motor, the 4 control lines must use a wire to jumper each of the four outputs to the PIC. Power and ground can attach to the HC11 board (if you are using that for power). On the stepper motor board GND is next to the four stepper motor inputs, and VCC is on the end (the end nearest the center of the board). Please check with the instructor if you are not sure. Unused Bit 3 Bit 2 Bit 1 Bit 0 GND VCC Board Center --->> For a 90 grade do just this. For more points use features not yet covered. Turn in the usual and anything else that is appropriate, including lab sheet, flowchart, schematics, timing calculations, and code.