Hi all,
I have a project which should be very basic. I need to move a servo from the rightmost extreme to the leftmost extreme. Pic is @ 4MHz. I have written a program in mikroPascal which will do this :
program ServoControl;
Procedure Pulseout(time : word);
begin
SetBit(GPIO, 2);
delay_cyc(time); // delays time * 10 cycles
ClearBit(GPIO, 2);
end;
var
b : byte;
begin
TRISIO := %0000000;
CMCON := $07;
// Pulseout(25); // set servo to right
// delay_ms(5000); // wait for servo to react
repeat
//pulseout(225); // leftmost position
//pulseout(25); // rightmost position
for b := 25 to 225 do
begin
Pulseout(b);
delay_ms(90);
end;
SetBit(GPIO, 0);
for b := 225 downto 25 do
begin
Pulseout(b);
delay_ms(90);
end;
ClearBit(GPIO, 0);
until true = false;
end.
This works, but... I need more servo resolution than the 200 steps that are available. I am thinking of using asm instead of pascal but, I know nothing about it
What I need is for the servo to start out on the right and go to the left in the smallest possible steps. And, it needs to take approx 3 mins to go all the way. The 3 minutes is fine in the above pgm but, the resolution is such that the servo looks like a second hand ticking on a clock. If I were to use asm, would I be able to get better resolution out of a hitec hs-81?
btw, this is going to be used in a play as an old time elevator floor pointer. I guess the premiss is that the elevator goes up as the kids dance to some song (3 mins or whatever).
no. but, there are free versions. They (mikroElectronika) make mikroBasic, mikroC, & mikroPascal. They are nice and you can check them out at http://www.mikroe.com - I like their EasyPic dev boards!
would people PLEASE PLEASE use the code option to post source code. That assembler code is frickin unreadable when it's posted that way. I generally don't bother to read it if the poster hasn't taken the 2 extra seconds to make iit readable.