OK i got it to work, timing is a bit off but it shouldnt work with servo positions used. I added a 3rd servo on a pot just to see what numbers i had to send to activate the servos... weird thing is it rotates from 15 - 50, a pic programming manual says to use 130 - 170, and Ive seen articles on here that use 100 - 200. on a older program i wrote just for testing servos with a 12f675 I used 100 - 200 and it worked fine. I am now using a 18f4550. not sure why its having issues. I would like to get it back to the 100-200 range for servo resolution. heres the code working right now. I did speed it up changing the adc math, 500 will go back to 121.
Code:TRISA = 255 ' PORTA is all input TRISD = 0 ' PORTD is output TRISB = 0 ' PORTB is output LCDOUT $FE, 1 ' Clear LCD PAUSE 250 ' Wait 0.5sec for LCD to initialize Time Var WORD : time = 0 ' Time Between Engaging HomePos VAR byte : homepos = 20 ' Servo Starting Position 15 Servo VAR byte : Servo = 25 ' Servo Position Set when Engaged 50 NumServos VAR byte : numservos = 2 ' # of Servos, Max 8 Counter VAr WORD : Counter = 0 ' Time Counter X var word : x = 0 ' OnTime Y VAR WORD : y = 0 ' Servo Select Initialize: PORTB.2 = 1 ' Set All Servos to Home Position For Y = 1 to NumServos ' Select Servo (Each in use for 5s) for X = 1 to 25 ' 20ms X 250 = 5 Seconds PULSOUT PORTB.0[y], homepos ' Send the Home Position Pulse PAUSE 20 ' Wait 20 ms next X Next Y PORTB.2 = 0 Mainloop: ADCIN 0, time ' Read Channel 0 data time = (time / 512) + 5 ' 60-600 Seconds Counter = counter + 1 LCDOUT $FE, 2 LCDOUT $FE, $80 LCDOUT "Set Minutes = ", DEC3 time LCDOUT $FE, $C0 LCDOUT "Servo OFF = " , DEC3 counter if counter > time then counter = 0 For Y = 1 to NumServos ' Select Servo (Each in use for 15s) LCDOUT $FE, 2 LCDOUT $FE, $80 LCDOUT "Set Minutes = ", DEC3 time LCDOUT $FE, $C0 LCDOUT "Servo On = " , DEC3 counter ' Update Display (Servo Selection) PORTB.2 = 1 ' Set All Servos to Home Position for X = 1 to 25 ' 20ms X 250 = 5 Seconds PULSOUT PORTB.0[y], servo ' Send the Home Position Pulse PAUSE 20 ' Wait 20 ms next X Next Y PORTB.2 = 0 pause 100 PORTB.2 = 1 ' Set All Servos to Home Position For Y = 1 to NumServos ' Select Servo (Each in use for 5s) for X = 1 to 25 ' 20ms X 250 = 5 Seconds PULSOUT PORTB.0[y], homepos ' Send the Home Position Pulse PAUSE 20 ' Wait 20 ms next X Next Y PORTB.2 = 0 ENDIF 'For X = 1 to 100 Pause Time 'next x x = 0 GOTO mainloop ' Repeat END




Bookmarks