David, Here is a small project I sent out a few weeks ago that might be at least part of what you are looking for. This simple servo cycler uses a 12C508/9 and a single pushbutton. When the button is pushed it cycles the servo to one side, waits 3 seconds, cycles the servo to the other extreme, waits 3 seconds, then returns the servo to the center. Instead of the pushbutton switch you could easily add a rheostat (there is a Microchip App Note and several web sites that tell how to read a rheostat), measure the rheostat and convert that to your pulse width to send to the servo. I use this simple circuit to help install servos in R/C airplanes and it should be easily modifiable for what you need. Adam On Thu, 20 May 1999 20:53:06 -0400 David Olson writes: > I'm wondering of someone can point me in a PWM direction. SNIP > servos. This idea is much more simple - 1 servo driven from 1 > rheostat. SNIP > -DO > +5v--+------------------------------------------+---------------To Servo + | | | > | < 10K | +-------+ > +--|vdd | | | GP0|-------------------------------+ | | | | | 0 | | | |-- N.O pushbutton swi tch | GP1|---To Servo signal line 0 | +--|vss | | | +-------+ | | | Gnd--+------------------------------------------+---------------To Servo - ;******************************************************************** ; SERV_SET.ASM ; Servo setup device utilizing a 12C508/9. ; ; This file will implement a servo setup device utilizing a 12C509. ; To reduce parts count, the internal oscillator will be used. ; ; Operation: ; A single button will be included for user interaction with ; this device. A press of the button will cycle the servo all the ; way to the low end, hold for two seconds, cycle the servo all the ; way to the high end, hold for two seconds, then return the servo ; to the center. ;******************************************************************** ; Include register equates and what-not list p=12C509 include p12c509.inc ;==== LOCAL DEFINES ============================= #define INPUT GPIO,0 #define OUTPUT_ON BSF GPIO,1 #define OUTPUT_OFF BCF GPIO,1 ;==== LOCAL MACROS ============================== PULSE_ON MACRO OP1 OUTPUT_ON MOVLW OP1 MOVWF width CALL Output ENDM PULSE_OFF MACRO OP1 OUTPUT_OFF MOVLW OP1 MOVWF width CALL Output ENDM CBLOCK 0x07 counter flag width dcount ENDC ORG 0 MOVWF OSCCAL ; write preset factory calibration value. Init MOVLW b'01001000' OPTION MOVLW b'11000001' ;should make bits 1 output, 0 input TRIS GPIO CLRF flag CLRF GPIO Main PULSE_ON .15 PULSE_OFF .185 MOVF flag,F ; test if flag is zero SKPNZ GOTO Main Key_pressed MOVLW .150 ; output 1ms pulse width for 3 seconds. 3 seconds will MOVWF counter ; give it time to cycle to the endpoint and hold for at least 2 seconds. Out_1ms PULSE_ON .10 PULSE_OFF .190 DECFSZ counter,F GOTO Out_1ms MOVLW .150 ; output 2ms pulse width for 3 seconds MOVWF counter Out_2ms PULSE_ON .20 PULSE_OFF .180 DECFSZ counter,F GOTO Out_2ms CLRF flag ; reset the flag register. Doing it here will provide a crude form of ; debouncing. GOTO Main ; Output routine. ; This routine is basically a 100us delay loop with a test for a button press. ; If the button is pressed, the flag register will be set and tested for elsewhere. ; This routine is repeated "width" times Output Test_key ;this routine implements a 100us timing loop ;Delay calculation is as follows: ; .000090 - 5 cycle loop 18 times. ; .000004 - last time through delay loop ; .000006 - delay for this loops setup ; .000100 - total MOVLW .19 MOVWF dcount NOP BTFSS INPUT BSF flag,0 DECFSZ dcount,F GOTO $ - 3 ; Go back to button press test DECFSZ width,F GOTO Test_key ; Do until width = 0 RETURN END Adam Bryant (age 0x23) abryant@peaktech.com (work) adamdb@juno.com (home) Parker, CO, USA Robotics, RC Airplanes, anything using a PIC ___________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com/getjuno.html or call Juno at (800) 654-JUNO [654-5866]