what's wrong with my servo control code?

Status
Not open for further replies.

Sorry I mixed up the modified config value my bad...the delay subroutine values should be working fine...the delay after the BSF is to send pulse while the delay after the BCF is to make sure total delay will be 20mS before sending another pulse...during the delay no input should be expected...I think that's how it should work...
 
hey mvs sarma
So u think that is the problem? The TURN90 won't come out of the loop...
ok i put in DECFSZ to get it out from the loop and I tested it...but the result still the same...It stuck at 90 instead of go to 180 then back to 90 Do you think is other problem (power problem)? Or still got programming error?

Before this I already tested the code to move servo only to 90 and another code to move servo only to 180...Both codes are a success...
 
Last edited:
Not a power problem to best of my beleif-- only software.

however nothing wrong in isolating the supply of motor using a driver.
 
Hi KCY

please change last instruction of TURN90 routine as
TRUN180
instead of
TURN90

Try to run and see

anxious to see the result
 
I tested your original code on a 16F876 and looked at the output on a scope. It is exactly as it is supposed to be. It outputs a 2mS pulse every 20mS for 4S and then switches to a 1.5mS pulse every 20mS. There is nothing wrong with your code. Can you get access to a scope?

Mike.
 
@mvs sarma I changed to TURN180 and run it but it's still the same problem :< the servo stuck at position 90 degree...

@Pommie unfortunately I don't have a scope and neither does my school :<
 
Last edited:
Hi all

As pommie has also certified that code is checked and OK, the only way is to see electrical part of it

btw, request pommie to help me learn how and the TURN90 loop is overcome?

Please, i am aslo a new commer to programming--
 
Hey guys I think I have successfully got the servo to move properly, sort of; I set the TURN90 routine to change every 4 sec same as the TURN180 routine then I loop it back to the start to repeat everything...The servo changes its position every 4 secs just like what I wrote but the only thing is the position to which the servo moves to seem out of sync i.e. not 180 and 90 as I had wrote...How should I fix this?
 
Hi,
--CONGRATS AT THE OUTSET--

what else, Fine tune your delays to acieve 180 and 90 degreees.
However try to post your latest patch let us also see and enjoy

All the best
 
mvs sarma said:
Hi all

btw, request pommie to help me learn how and the TURN90 loop is overcome?

Please, i am aslo a new commer to programming--


You are right in your interpretation of the code. However, it shouldn't matter as the servo will see a 2mS pulse for 4 seconds and then will get stuck in the turn90 loop by which time it has completed the task.

Mike.
 

Most modern servos will turn 270 degrees and so the difference between 1.5 and 2mS is 135 degrees. Try 1.66 to 2.0 for 90 degrees.

Anyway, congratulation on finally getting it working.

Mike.
 
Mike and mvs sarma, thanks alot for your help...I appreciate it

One thing I still don't understand...When I write the code to give the servo a 2mS pulse only, it moved to 180 degree position as written...but in the TURN180 code it won't turn to 180 just like the previous code...? The difference between the angles formed with the TURN180 code is 90 degrees but the position is not 180 degree and 90 degree as it should be...
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…