You are on page 1of 1

Question #1

Write a program using timer1 interrupts that generates a servo pulse exactly every
20 ms with a given pulse width of exactly z (in microseconds). There are two
types of programs you should investigate.

A) Interrupts are disabled when making the 1-2 ms pulse width. What are the
advantages / disadvantages of this approach ?

B) Interrupts are used for both the rising edge and falling edge of the pulse. In this
case interrupts are not disabled when making the pulse. What are the advantages
/ disadvantages of this approach ?

Question #2

Verify the performance of the program from question #1 using a second Arduino
that uses a digital input and micros() to measure the pulse width (min, max,
average) using external interrupts. Compare the result to using:
https://www.arduino.cc/reference/en/language/functions/advanced-io/pulsein/
Also verify the performance of the servo library function. Try different servo pin
numbers to see if that affects the performance.

Question #3

Implement a PI controller for a system using a compare match interrupt with a


period of T = 1 ms. The sensor value is read from the ADC and the actuator is
written to a servo actuator. Note that you can consider this question to be like a
“take home” exam question.

You might also like