Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

connecting a pwm servo(RKI 1210 aka HS311) to pic16f877a

Status
Not open for further replies.

robot510

New Member
Can someone help me to connect a pwm servo (model rki 1210) to the pic16f877a.
I connected it direct first it rotated 20 degrees when it was supposed to rotate a 180 according to the pulse given. i thought it was due to current drain and connected a 220 ohm resister, it rotated around 130 but didnt act according to how i expected.
some suggested using a current amplifier (ULN 2003) ... I havent tried that one out.

could you please help me out here,i've been at trying to make the motor turn for the last 3 weeks.

thanks
 
Have you checked the output using a scope?, there should be no problem feeding a servo input directly from a PIC, it's a VERY common application.

we tried doing it directly, the current supply wasnt sufficient so the motor hardly turned 10 degrees .thats when i searched again and found an article suggesting to add a 220 ohm resitor in between the control output and the the motor control input.

also i have a doubt about the power supply to the motor. its a hobby pwm servo. i gave 5V for a 4.8-6 v rated supply. is it better to give 6v or 5v?
 
we checked the output with a Digital multimeter, the current was very low since it was getting drained when it was coming through the PIC.
you think we should check with a digital oscilloscope and check the magnitude of the pulse?
 
How do you know the current output wasn't enough?, what is the current requirement?. Like I asked before, have you checked the output with a scope?.

the current rated in the specifications was 600 mA. ie a PWM with 5v magnitude for the on time in the square wave generated.
 
Hi, Robot

Could you provide your scheme and tried code ??? .

That surely would let the discussion be constructive.

Alain
 
we are using a RKI 1210 which the same as HS 311 pwm hobby servo.
the code we used was a simply on and off of the 3rd pin on port c.we used the 'vdelay_ms' function in mikro C, it got compiled and worked well in proteus properly the day before. once again when we tried the simulation gave problem once again. it keeps fluctuating but we're not able to figure out the reason for that. which is not a good sign since we need it to work properly so our robot arm can go to the desired location :

void main()
{
int x,y,a;
PORTC=0 ;
TRISC=0 ;
while(1)
{
x=0.6;
PORTC.F3=1;
vdelay_ms(x);
PORTC.F3=0;
vdelay_ms(20-x);


delay_ms(1000);

a=1.5;

PORTC.F3=1;
vdelay_ms(a);
PORTC.F3=0;
vdelay_ms(20-a);

delay_ms(1000);

y=2.4 ;

PORTC.F3=1;
vdelay_ms(y);
PORTC.F3=0;
vdelay_ms(20-y);


delay_ms(1000);
}
}

ANOTHER PROBLEM is that 0.6 ms and 2.4 ms is the values i got for a generel pwm servo, i have no idea how to find out the minimum pulse and maximum pulse( which will make the servo turn to 180 deg) for the motor which im using. diffferent sites say diff values. some say 0.9 to 2.1 ms. how am i suppose to find that out?
 
Ok,

Did you know the position signal has to be sent @ ~ 50 Hz repeating frequency ???

Your program does not ... it just sends position ONCE ...

so, you should have 3 loops , each during 1s - send 50 times the position - , for each 3 position, inside the main loop ...

Also do not mix floating point when you declare and use integers ... ( I do not like Vdelay_ms ( 18.5 ) ... compiler nor !!! )

That's for soft.

You also have a problem with hardware wiring ... but I need your scheme !!!

Alain
 
Last edited:
@Alain :
i just wanted to clear what you told about 50 times repeating the postion.. i just want to clarify if i got it right :
im supposed to send the "Pulse width signal" for say 0degrees position 50 times? and then the postion for 90 degrees fifty times? am i right?

hardware we connected direct to the control wire first but the current magnitude is not upto requirement. we used 220 ohm resistor - the angle improved didnt reach 180 deg tho. is ULN2003 required ? a friend of mine said it'll amplify the current. can i use it with servo motors?
 
if you meant the schematic i've just connected the PIC16F877A 's 18th pin (which is PORTC.F3) to the control wire of the servo and given supply to both. This ive done in proteus.
 
we checked the output with a Digital multimeter, the current was very low since it was getting drained when it was coming through the PIC.
you think we should check with a digital oscilloscope and check the magnitude of the pulse?

Yes, you can't check it with a multimeter, and you certainly shouldn't be checking it on a current range either. Check it with a scope, once with the servo not connected, once with it connected.
 
Proteus is a view of mind ...

it's not because " proteus" works that it works in real life ... those are only TOYS !!!

I NEVER use simulators , even I have two here ( Proteus + Multisim ) !!!

Alain
 
you have any suggestion as to how to check the working of the servo otherwise. should as i use 0.6 and 2.4 ms as my pWM for 0 and 180 deg resp or 0.9 and 2.1 ms? both arent working properly in simulation. you have any sugestion wat i should do?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top