Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Servo library
01-10-2013, 05:09 PM, (This post was last modified: 01-10-2013, 06:19 PM by jesus_sphinx.)
#11
RE: Servo library
Hello guys,

I'd written that library originally. I was also some time ago working on expanding the pulse range to 500 microseconds and 2500 microseconds. I have finally got a good code working for me in the three p8 boards. I have tested it on 18F2550, 18F4450 and PICUNO_EQUO. I have also calibrated the pulses with an oscilloscope, in order to obtain pulses as much precise as possible. So, I hope you find the library useful now for those pulse ranges you mention.

In order you can change the min pulse accetable by the servo you should use the function:
ServoMinimumPulse(<servo pin>,<min pulse in microseconds>)
and for the maximum:
ServoMaximumPulse(<servo pin>,<max pulse in microseconds>)

As you can see you can specify a range for every particular servo. So, for instance, you could have a servo connected on pin 0 with a minimum pulse of 500 us (so, 0 degrees), and a maximum pulse of 2500 us (so, 180 degrees), and another servo connected to pin 1 with a minimum pulse of 1000 us (so, 0 degres for this one), and a maximum pulse of 2000 us (so, 180 degrees for this one).

if you don't specify min nor max with this funtions in the setup code part, it will be asumed for your declared servo that will work on a min of 1000 us and a maximum of 2000 us.

Let me put a code example for you :
Code:
// Servo library test with Pinguino
// Connect servo control lines to pinguino pins.
// Feed servos with +5 V:
//
//   +-----+
//   |servo|--------- PWM Servo control ---> to pinguino pin.
//   |     |--------- +5V
//   |  o  |--------- GND
//   |     |
//   +-----+


#define PIC18F4550

u8 position,user_servo=0;


void setup(void)
{
  servo.attach(user_servo);
  servo.setMinimumPulse(user_servo,700);
  servo.setMaximumPulse(user_servo,2300);
}  

void loop(void)
{
for (position=1 ;position<180 ;position++){

    servo.write(user_servo,position);
    delay(200);
     }

}

Another thing: I've done all my test on x.3 IDE. Let me know if you are working with this same version of IDE, please. Or if any of you are working with x4 version. Thanks in advance.

Any question, please ask.

PLease, find attached the servos.c file I was commeting here. thanks.

Sphinx.


Attached Files
.c   servos.c (Size: 37.48 KB / Downloads: 10)
Reply
16-11-2013, 02:30 PM, (This post was last modified: 16-11-2013, 05:11 PM by regis.)
#12
RE: Servo library
Hello guys,

here again. And finally the servos library has been completed and delivered at x.4 release 940. So, it's ready for you. update your svn copies.
I've tested it on 18F2550 and 18F4550 boards, and Regis helped me to test it on PICUNO EQUO. Results were fine.
We hope you enjoy the lib and report us back any drawback you could detect.
Thanks in advance.
Jesús.
"If you think you can do a thing or think you can't do a thing, you're right." Henry Ford
My blog: http://linuxdroids.wordpress.com
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)