View previous topic :: View next topic |
Author |
Message |
misato14
Joined: 29 Mar 2010 Posts: 3
|
SERVO MOTOR |
Posted: Mon Mar 29, 2010 7:40 am |
|
|
Hello I'm using a servo motor futaba S3003. I'm using this code:
Code: |
#include "18f4550.h"
#fuses HS,NOWDT
#use delay(clock = 4000000)
#define servo PIN_B1
void main(){
while(true)
{
OUTPUT_HIGH(servo);
delay_us(1500);
OUTPUT_LOW(servo);
delay_us(18500);
}
}
|
Whatever values I put on the delay, the servo rotates to same side, I cannot rotate to the other side, or center. Can you tell me why, or what I'm doing wong? |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
![](templates/subSilver/images/spacer.gif) |
mbge5amw
Joined: 13 Dec 2004 Posts: 15 Location: Yorkshire, UK
|
|
Posted: Mon Mar 29, 2010 8:11 am |
|
|
I don't know if you have any external pullup resistors on your device to make the pins go high.
You may need the line
Code: | port_b_pullups(TRUE); |
before your while loop.
I would also suggest you get a meter to double check that the output pin is/is not toggling as you expect, so you can identify if it is a SW or HW issue
Andy |
|
![](templates/subSilver/images/spacer.gif) |
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Mon Mar 29, 2010 8:31 am |
|
|
You don't really need pull-ups. Do you get a pulse on B1? Can you check this with an oscilloscope? If not, in your clock/fuse definition: Code: | #fuses HS,NOWDT
#use delay(clock = 4000000) | Use XT instead of HS.
Rohit |
|
![](templates/subSilver/images/spacer.gif) |
misato14
Joined: 29 Mar 2010 Posts: 3
|
|
Posted: Mon Mar 29, 2010 8:48 am |
|
|
We already used an oscilloscope, and it is 50 Hz wave and the duty cycle is correct. I already use fuse XT and HS... the result is the same.... |
|
![](templates/subSilver/images/spacer.gif) |
dezso
Joined: 04 Mar 2010 Posts: 102
|
|
![](templates/subSilver/images/spacer.gif) |
misato14
Joined: 29 Mar 2010 Posts: 3
|
|
Posted: Mon Mar 29, 2010 9:48 am |
|
|
I already seen that link, but problem remains, is that the servo rotate to one side whatever value I put in the duty cycle. I cannot find the problem and I already buy a new servo motor. I'm using pic 18f4550. |
|
![](templates/subSilver/images/spacer.gif) |
|