typical servos respond to pulse width control, e.g. you vary the pulse width to affect the position of the servo.
typically most take pulses from 1msec wide to 2msec wide
these pulses are generally updated at 45 hertz by typical hobbyist radio control systems (such as the challenger 250 for example).
the specs vary, some claiming a range of 50hz to 100hz even though typical hobbyist devices sometimes fall a bit under this range (e.g. 45hz).
we will be driving the servo at 100hz (10msec per period).
this gives us a duty cycle that ranges from 10 percent to 20 percent.
note that you can often "get away with" running the servo beyond both the 1msec lower limit and the 2msec upper limit.
however, they vary from manufacturer to manufacturer in how far you can go past these limits.
generally the range from 1msec wide to 2msec wide pulses takes you over a 90 degree swing, while it is possible often to get nearly 180 degree swing from some makes and models.
the important thing is to have fun and learn something!
our particular computers happen to have a clock with period 0.12us (approx. 8.3333333... MHz), as determined by connecting an oscilloscope probe to "CLK".
this is true for the "wearcomps" that you use in the lab, as well as for the filling stations (the slightly fatter "wearcomps" that have a pci slot).
however, this may not be true for your home computer (if you have your own computer that is different from the "wearcomps" it may have a slightly different clock speed, so you may need to experiment with the numbers or verify the clock speed).
we desire an approx. 1MHz clock to run the 82c54 timer chip, so we use the clock speed, 8.333333...MHz and divide by 8 using 3 toggle type flip flops (actually 3 jk flip flops with j and k tied high).
8.333333...MHz/8 is approx. 1.04166666...MHz.
for our clock speed, you need to write the number 10417 into mode 2 to set the timer for 10ms (100Hz).
calculate this yourself to see that you get 99.99679946241720264951...Hz when you write 10417 into the timer set to mode 2 (presuming you've read the 82c54 documentation prior to coming to lab this will all make sense).
the 82c54 chip has 3 timers in it.
the first one is used in mode 2 (free running oscillator) and the other two are used in mode 1.
if you follow our diagram, you will end up putting the first timer at address 220, the second at addr. 221, and the third at addr 222.
we desire to write the 16 bits into the timer by writing low order and then high order 8 bits as separate bytes.
a fourth addr (in our case 223) is a control address.
the two most significant bits select timer (one of the three above), the next 2 bits are read write (set them to 11 to sel the 16bit mode we will be using).
the lsb is a bcd selection bit so set it to 0 because we won't be using bcd.
all of the above means you will be writing 0x34 into the control register to set timer 0 into mode 2.
timer 0 is the free running timer, timer 1 is the light (e.g. LED) and timer 2 is the servo.
can also control a big light
thus counter 1 is the light and 2 is the servo.
write 0x72 into control word to set timer 1 into mode 1
write 0xB2 into control word to set timer 2 into mode 1
dev driver only accepts bytes
there are actually in this example, two minor numbers for the device driver
pwm0 is the servo
pwm1 is the led
this lab should also give you a good intro to the proc file system
when you try to read an inode in /proc the kernel fills in the info, even though it all "seems" to the user that you're just reading a file.
phone with web browser, email, etc., built in.