Software PWM ( Servo driver)

Status
Not open for further replies.

Hero.sl

New Member
Hey guyz need a little help..
Im writting a software PWM to drive a Turnigy micro servo using PIC16F628A.
Port b is connected to the Parallel port of my PC which I programmed to output 0 - 100. The code is written in CCS C and has no errors. Well the servo rotates according to the input, but there is a vibration once I stop changing the input(for a constant input).

Does any one know what is wrong with the code? I dont have much experience with PIC programming. So if you guyz have a better way to code a sw pwm, please let me know.
btw Im planning to use this program to drive an ESC (connected to a Towerpro BLDC) once im done testing. Will I be able to use it with ESC? are there any changes that I have to make?
Thanks in advance..

 
Are you using a digital or analog servo? Some digital servos are known to chatter when put into a set position. Swap in an analog servo and see if the "vibration" still happens. John
 
Are you using a digital or analog servo? Some digital servos are known to chatter when put into a set position. Swap in an analog servo and see if the "vibration" still happens. John

thanks for your reply John. Itz a digital servo. I think this problem has some thing to do with input_b() function or with the multiplication. I changed the code to increase the duty cycle and decrease it without using the input from PC, then it works fine. No vibration. Any idea?
 
I have no experience with using a PC to control a servo. My suggestion related to the digital servo was based on experience with cheap servo controllers. For example, the early versions based on the 555 chip worked fine with analog servos, but digital ones tended to chatter. When I have used a 12F5xx PIC as a servo controller, both analog and digital worked fine. Your experience using just the PIC is consistent with that observation.

Unfortunately, I can't help you on the PC interface. To confirm that is really the problem, get a general purpose analog servo. If it doesn't chatter, then at least you know where to look for the problem. Those general purpose ("standard") servos typically came packaged with transmitter/receiver sets. Hitec HS300, Futaba S148, and Airtronics 94102 are examples. They are inexpensive when new (<$15) and even cheaper when used. If you were near Cleveland, the only thing I would ask is "how many?" Most modelers would probably give you one, or your local hobby shop might let you borrow a display unit.

John
 
I think I just found out what is wrong here..
Itz the multiplication. When I disabled interrupts during the multiplication part,it is working fine.

void read_port_b()
{
while(true)
{
portVal = (int16) input_b();
disable_interrupts(INT_TIMER1);
high_time = ( portVal * 10L ) + 1000L;
enable_interrupts(INT_TIMER1);
}
}

But I think now the frequency is varying. Is there a way to correct it?

can pics queue interrupts?
 

Thanks John..
Have no much experience with Analog servos and Im just using a little ($3 ) servo just to check the app before I connect it to the ESC. Guess im ready to go..
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…