I'm using a 16F627A
and yes, I've tried changing those numbers and I've tried using the numbers that Bruce posted, but I still get the same result regardless. I've also tried using a different servo (another parallax one)
I'm using a 16F627A
and yes, I've tried changing those numbers and I've tried using the numbers that Bruce posted, but I still get the same result regardless. I've also tried using a different servo (another parallax one)
So, you're running at 4Mhz (INTOSC). The PBP manual tells us that at 4Mhz, pulsout has a granularity of 10us. Your loop runs from 200 to 1200, meaning 2000us (2ms) to 1200 (12ms). A bit out of the range of a normal servo ya think? Unless you've got one of the oddball ones...
Also, try turning off the WDT and Brown-Out reset for grins... You might be killing the battery voltage when the servo tries to move and causing a reset.
Use GOSUB VS GOTO if the routine you're going to uses RETURN to get back.
Disable onboard comparators with CMCON=7 before trying to use a pin that
has the comparator feature.
Give this a shot;
This should cycle your servo from one side to the other. Tested with aCode:@ __config _INTOSC_OSC_NOCLKOUT &_WDT_ON &_PWRTE_ON &_MCLRE_OFF &_BODEN_ON &_CP_OFF &_DATA_CP_OFF &_MCLRE_OFF servo1 var Porta.0 x var byte CMCON=7 ' <-- disable analog comparators low servo1 HIGH PORTB.3 loop: pause 500 low portb.3 pause 500 high portb.3 GOSUB move ' <-- use GOSUB VS GOTO pause 2000 low portb.3 GOTO loop move: for x = 200 to 100 STEP -1 ' 2mS to 1mS pulse pulsout servo1,x pause 18 next x pause 2000 for x = 100 to 200 ' 1mS to 2mS pulse pulsout servo1,x pause 18 next x pause 2000 return END
Parallax servo.
Bookmarks