Ok, that's good...at least you know stuff is working.
Now take the program and modify it to 'pull the endpoints' in a bit until you get to the actual endpoints.
When it 'stops for awhile', the program is probably trying to drive the servo past it's endpoints. The program goes to 0ms pulse width, but the servo can only actually drive to a 1ms pulse width, actually it'll probably drive farther than that, a lot farther, just not all the way to zero, or by the same token, won't drive all the way to 2.55 ms pulse width.
Decrease the 100 until it starts pausing at one end (meaning the PIC is trying to over-drive the servo) and increase the 200 until it starts pausing at the other end (again, meaning the PIC is trying to over-drive the servo in the other direction).Code:@ device HS_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF DEFINE OSC 4 temp var byte main: for temp = 100 to 200 pulsout portb.0, temp pause 17 'try lower numbers until it starts acting even stupider than it's acting now next temp for temp = 200 to 100 step -1 pulsout portb.0, temp pause 18 'try lower numbers until it starts acting even stupider than it's acting now next temp goto main END
Hi, Glenn
This one Should run
and do not forget : courtesy SKI !!!Code:@ device HS_OSC,MCLR_OFF,LVP_OFF,WDT_ON,PROTECT_OFF DEFINE OSC 4 CMCON = 7 ' Disable comparators PORTA = %00000011 PORTB = 0 TRISA = %00000011 TRISB = 0 'Use b1 to hold pulse width variable for servo 1 b1 var byte 'initialize variables b1 = 150 low portb.0 ' put the servoport low. main: low portb.0 pulsout portb.0, b1 'send current servo 1 position out if porta.0 = 0 then left1 'check for pressed switch 0 if porta.1 = 0 then right1 'check for pressed switch 1 bugtrap: if b1 > 150 then b1 = b1 - 1 else if b1 < 150 then b1 = b1 + 1 endif pause 18 : goto main left1: IF porta.1 = 0 Then bugtrap b1 = b1 + 1 if b1 > 199 then max1 Pause 8 : goto main right1: IF Porta.0 = 0 Then bugtrap b1 = b1 - 1 if b1 < 100 then min1 Pause 8 : goto main max1: b1 = 100 : goto main ; jump to other side min1: b1 = 200 : goto main ; jump to other side END
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Looks it should be in the 1500µs position ...
should reach slowly one end, then RUN to the other end, then slowly to the other end , Then RUN ...but it moves in very strange ways, I'll try to adjust the values a bit and see if it changes anything.
WHILE pushing a button
and going back to center if buttonS realeased ... or both buttons pushed.
But it sure looks like the comparators was the problem, great!
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Well, as you said before the values depends on which servo I use, I settled for the servo that I'm going to use (the brand new china-made) and with that 75 and 255 seem to be the correct values, however, when its 255, its still not at the endpioint, its a few mm more left. ..However this doesnt matter.
Hi, SKI
The maximum I ever reached is 250 µs to 2600 µs ... with a Futaba S3001 or a Robbe RS100 ...
not linear at all between 250 and 600µs !!!
regards
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hi, Glenn
I Think I've found what looks "strange" to you ...
This is not the "perfect movement" ... but the maximum to get from this coding style.Code:@ device HS_OSC,MCLR_OFF,LVP_OFF,WDT_ON,PROTECT_OFF DEFINE OSC 4 CMCON = 7 ' Disable comparators PORTA = %00000011 PORTB = 0 TRISA = %00000011 TRISB = 0 'Use b1 to hold pulse width variable for servo 1 b1 var WORD 'initialize variables b1 = 150 << 4 low portb.0 ' put the servoport low. main: low portb.0 pulsout portb.0, ( b1 >> 4 ) 'send current servo 1 position out if porta.0 = 0 then left1 'check for pressed switch 0 if porta.1 = 0 then right1 'check for pressed switch 1 bugtrap: if b1 > ( 150 << 4 ) then b1 = b1 - 1 else if b1 < ( 150 << 4 ) then b1 = b1 + 1 endif pause 18 : goto main left1: IF porta.1 = 0 Then bugtrap b1 = b1 + 1 if b1 > ( 3199 ) then max1 Pause 8 : goto main right1: IF Porta.0 = 0 Then bugtrap b1 = b1 - 1 if b1 < ( 1601 ) then min1 Pause 8 : goto main max1: b1 = ( 100 << 4 ) : goto main ; jump to other side min1: b1 = ( 200 << 4 ) : goto main ; jump to other side END
Alain
PS : Question : Why multiply b1 per 16 ( << 4 ) and divide it per 16 ( >> 4 ) when outputting the pulse.
The answer to last trouble is here !!!
Last edited by Acetronics2; - 23rd September 2008 at 09:39.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks