| ??? 06/09/09 08:10 Read: times |
#165935 - code Responding to: ???'s previous message |
it's a futaba servo..i found some code for generating PWM for 8051 family of uC but it is not enough and i don't know what to do further..if anyone wants to help me make this work i will be more than grateful...
PWMPIN EQU P1.0 ;PWM output pin
SJMP PWM_SETUP
ORG 000Bh
LJMP TIMER0_INTERRUPT
PWM_SETUP:MOV TMOD,#00h ;Timer 0 in mode 0
MOV R7,#160 ;set pulse width control ;this is a random value
SETB EA ;enable interrupts
SETB ET0 ;enable timer 0 interrupt
SETB TR0 ;start timer 0
RET
TIMER0_INTERRUPT:JB F0,HIGH_DONE; if F0=1 then we just finished the
;high section of the cycle so jump to
;HIGH_DONE
LOW_DONE: SETB F0 ;make F0=1 to indicate start of high section
SETB PWMPIN ;make PWM output pin HIGH
MOV TH0,R7 ;load high byte of timer with R7
CLR TF0 ;clear timer 0 interrupt flag
RETI
HIGH_DONE: CLR F0 ;make F0=0 to indicate start of low section
CLR PWMPIN ;make PWM output pin LOW
MOV A, #0FFh ;load A with 255
CLR C ;clear Carry flag so it does not affect the subtraction
SUBB A,R7 ;A=255-R7
MOV TH0,A ;low high byte with the value of A
CLR TF0 ;clear timer 0 interrupt flag
RETI
END
from what i read here http://www.seattlerobotics.org/guide/servos.html to rotate the servo from 0 to 90 degrees i have to apply a pulse with the length of 1,5 ms to the control wire(this means that the duty cycle is 7,5%??) here are the specifications for the servo http://www.gpdealera.com/cgi-bin/wgainf100p.pgm?I=FUTM0031 |
| Topic | Author | Date |
| control of servo | 01/01/70 00:00 | |
| One way of doing it... | 01/01/70 00:00 | |
| Limit switch? | 01/01/70 00:00 | |
| Standard? | 01/01/70 00:00 | |
| code | 01/01/70 00:00 | |
| Hobby R/C Servos | 01/01/70 00:00 | |
| the code | 01/01/70 00:00 | |
| SERVO_0.1.ZIP | 01/01/70 00:00 | |
| servo_0.1 | 01/01/70 00:00 | |
You don't have to translate it | 01/01/70 00:00 |



