EE454 Sample TEST 1 1. Design a stepper motor driver that will interface to an 89c51. The stepper motor is a 24 volt six wire (two separate windings each center tapped) bifilar wound motor. The stepper windings have a resistance of 30 ohms (from the center tap to either end of each winding). Use only resistors and the active components specified below. Your design should not cause any winding currents to flow when the processor is reset. Include a sketch showing your circuit and the connected port pins. You need to show only one typical drive for one winding. Also you must include calculations for the resistor values. Transistor Type PNP NPN Current gain, 10 100 Type Description Sn7406 Open Collector Inverter Vce(sat) .1 v .2 v VOL @ IOL = 40 ma. and Vcc = 5 v .4 v Vbe(on) .6 v .6 v Ic(max) 1 AMP 200 ma. VOH Max voltage at output 30 v 2. Write a c-51 module that will step the stepper motor in problem 1 above n steps clockwise if direction = 1 and n steps counter clockwise if direction = 0. You must delay between steps. You may use a “for loop” for the delay with an integer value as the incremented time variable. Include the port pin assignments and variable declarations. The procedure prototype is shown: extern void stepper(unsigned char, bit); 3. A controller board with a Philips 89c51RD2 installed is running with a 20 MHz crystal. It is desired to operate the uart in serial mode 1 at a baud of 9600. Timer 2 is to be the baud clock. List the contents of the required special function registers and calculate the % error to determine if the system can function at 9600 baud. 4. Assume a 20MHz crystal is running on an 89c51RD2. Write the c-51 code that will run module 3 in pwm mode with a 25% duty cycle (high time divided by the period) and a frequency as high as possible. Write comments beside your special function register (sfr) statements to indicate what is being assigned. What are the period and the high time of the outputted signal in microseconds? 5. A sensor puts out a pulse each time a mark on a large flywheel passes by. The high time of the pulse is used for an rpm calculation. The signal is connected to P1.3 of an 89c51rd2, functioning with a 12 MHz crystal. Assume the maximum high time of the pulse will range as follows: 10ms high time 50 ms. a) What is the best choice for the clock source of the PCA? b) What is the maximum high time of the pulse that can be detected using your answer above? c) How many PCA modules should be used and what should their modes be? d) What should be the values of CAPPn and CAPNn for the modules used? 6. Given the initialize code below, answer the following: a) How many interrupts are enabled and what are they? b) Name the timers/counters that are being used and the mode they are in. void Initialize() { TMOD = TMOD & 0xf0; TMOD = TMOD | 0x01; TH0 = -(20000 >> 8); TL0 = -(20000); IE = IE | 0x82; TR0 = 1; CMOD = 0X02; CCAPM2 = 0X42; CCON = 0X40; IE = IE | 0x90; } 7. It is desired to input a 0 or a 1 into an 89c51rd2. Sketch how you would connect a simple normally open momentary push button switch to bit 0 of port 1. Write a module that will return the single bit value of the state of the switch. The procedure should return a 1 if the switch is pushed (closed) and a 0 if the switch is not pushed (open). Call the procedure SwitchState(). Declare all variables used. An example of the possible use of SwitchState() is shown below: if (SwitchState()) then led = on;