Created Thu, 16 Jun 2011 09:47:56 +0000 by pburgess
Thu, 16 Jun 2011 09:47:56 +0000
There have been several threads in several places bemoaning the lack of a working Servo library. Had a need myself, so put something together today. This isn't compatible with the standard Servo lib (isn't even a library for that matter, just a sketch you can adapt to your own needs) and the units are somewhat ambiguous CPU 'tick' measurements. On the plus side, handles up to 8 servos with ludicrous resolution and is not terribly processor-intensive. Hope it's of some use to folks...and don't be frightened by the size, it's mostly comments!
// Example chipKIT sketch for precise control of up to
// eight servos with low instruction overhead. Exploits
// the fact that servo PWM uses a relatively small duty
// cycle range for a full range of movement: servo pulses
// are offset (rather than synchronized) so that each has
// the full resolution of a PWM timer for 1/8 of the time:
// _ _
// _| |_____________| |___ Servo 0
// _ _
// ___| |_____________| |_ Servo 1
// _ _
// _____| |_____________| Servo 2
// _
// _______| |_____________ Servo 3
// _
// _________| |___________ Servo 4
// _
// ___________| |_________ Servo 5
// _
// _____________| |_______ Servo 6
// _ _
// |_____________| |_____ Servo 7
//
// This is a compromise between fully hardware-based
// servo PWM (zero instruction overhead or timing
// jitter, but limited to 5 outputs on PIC32) and
// "tick counting" approaches, which permit any number
// of outputs but may have limited resolution and/or
// higher instruction overhead.
// Uses one or two timers, output compare and interrupts
// to achieve better than 14-bit resolution with 8 servos
// (or better than 16-bit if EXTRA_RES is #defined
// ...though even the lower figure is already pretty
// absurd and more than typical servos can resolve).
// This uses the "communication" row on the Max32
// simply because my servo adapter doodad fit there,
// not for any important reason. These can be changed
// to most anything EXCEPT pin 3, and they do not need
// to be consecutive pins nor in-order.
byte servoPin[8] = { 14, 15, 16, 17, 18, 19, 20, 21 };
// This code assumes servo timings with the canonical
// 50 Hz (20 millisecond) frequency with a 1.0 to 2.0
// millisecond pulse for position. Some servos are
// capable of operating beyond this range, but the
// timings here are set up for the conservative case.
// The longest pulse this can handle is 2.5 mS due to
// the 8-way split of the 20 mS interval.
#ifdef EXTRA_RES
#define SERVO_MIN (F_CPU / 1000) // 1.0 mS
typedef int servo_t;
#else
#define SERVO_MIN (F_CPU / 4 / 1000) // 1.0 mS
typedef unsigned short servo_t;
#endif
#define SERVO_MAX (SERVO_MIN * 2) // 2.0 mS
#define SERVO_CENTER ((SERVO_MIN + SERVO_MAX) / 2) // 1.5 mS
// With lots of clever shenanigans, this idea could be
// expanded to upwards of 20 servos, but this would start
// to invoke limitations and assumptions that may not
// apply to all servo setups; the broadest "sure thing"
// case is implemented here.
// Just load position data into this array; interrupts will
// take care of the rest, no need for any function calls.
servo_t servoPos[8];
void setup()
{
// Enable output pins for servos, set inital states to 'off'
for(int i = 0; i < 8; i++) {
pinMode(servoPin[i], OUTPUT);
digitalWrite(servoPin[i], LOW);
servoPos[i] = 0;
}
// Initialize timer to 400 Hz (50 Hz * 8 servos)
#ifdef EXTRA_RES
// Extra positional accuracy requires joining Timers 2 and 3.
// Interrupt function is attached to Timer 3 -- this issues
// the 'up' tick for each servo.
ConfigIntTimer23(T23_INT_ON | T23_INT_PRIOR_3);
OpenTimer23(T23_ON | T23_PS_1_1 | T23_32BIT_MODE_ON, F_CPU / 50 / 8);
// Output Compare 1 w/interrupt handles the 'down' tick.
// OC1 is the reason pin 3 can't be used; its output state
// will be the combined PWM for all servos together.
ConfigIntOC1(OC_INT_ON | OC_INT_PRIOR_3);
OpenOC1(OC_ON | OC_IDLE_CON | OC_TIMER_MODE32 | OC_CONTINUE_PULSE, 0, 0);
#else
// Standard resolution uses Timer 3 with 1:4 prescaler.
// Same interrupts and output compare situation.
ConfigIntTimer3(T3_INT_ON | T3_INT_PRIOR_3);
OpenTimer3(T3_ON | T3_PS_1_4, F_CPU / 4 / 50 / 8);
ConfigIntOC1(OC_INT_ON | OC_INT_PRIOR_3);
OpenOC1(OC_ON | OC_IDLE_CON | OC_TIMER3_SRC | OC_CONTINUE_PULSE, 0, 0);
#endif
}
// Motion example generates a nice millipede-like sine wave
// across a row of eight servos.
float x = 0.0; // Used only for motion demo below; not servo driver
void loop()
{
float y = x;
for(int i = 0; i < 8;i ++) {
servoPos[i] = SERVO_CENTER +
(int)((float)(SERVO_MAX - SERVO_CENTER) * sin(y));
y += M_PI / 5.0;
}
x += M_PI / 100.0;
delay(20); // No point updating faster than servo pulses
}
extern "C"
{
static volatile byte servoNum = 0; // Cycles through servos
// This is the timer interrupt, invoked at a uniform 400 Hz.
// Generates the 'up' tick for each of 8 servos (unless
// position is set to 0) and sets the OC1 PWM duration
// for the subsequent 'down' tick.
// These two functions would obviously benefit from some
// direct PORT love (instead of digitalWrite())...just done
// this way for quick and easy implementation.
void __ISR(_TIMER_3_VECTOR,ipl3) pwmOn(void)
{
mT3ClearIntFlag(); // Clear interrupt flag
if(servoPos[servoNum] > 0) {
digitalWrite(servoPin[servoNum], HIGH);
SetDCOC1PWM(servoPos[servoNum]);
}
}
// This is the output compare interrupt, also invoked 400
// times per second, but the spacing is not uniform; this
// establishes the position of each servo. 'Down' tick
// occurs here, then servo number is advanced by 1.
void __ISR(_OUTPUT_COMPARE_1_VECTOR,ipl3) pwmOff(void)
{
mOC1ClearIntFlag();
digitalWrite(servoPin[servoNum], LOW);
if(++servoNum > 7) servoNum = 0; // Back to start
}
} // end extern "C"
Thu, 16 Jun 2011 18:16:06 +0000
Wow!
You beat me to it! And probably better then I could have done it.
Lots of nice clues how to do interrupts, and how to access the hardware registers directly. A little different then the 18F PICs, so that really helps!
Thanks!
Alan KM6VV
Thu, 16 Jun 2011 23:48:24 +0000
That is some nice example code, very readable. I look forward to any other contributions you might make!
Any chance you'll be looking into input capture? (measuring pulsewidth of external signal using a timer). Well, I may have to bite the bullet and figure it out myself...
By the way, for the beginner at this, where do I find descriptions of SetDCOC1PWM() and similar things?
Fri, 17 Jun 2011 00:40:54 +0000
Yes, thank you for the well-documented example code.
Fri, 17 Jun 2011 04:47:38 +0000
Regarding SetDOC1PWM(), etc: there's a Microchip document (PDF) called "PIC32 Peripheral Libraries for MPLAB C32 Compiler" that covers most of these functions. It's now deprecated, they prefer folks use the .chm version that's included when you install MPLAB (info is more current, but not covered as thoroughly). If you Google around you can still find the older PDF.
Afraid I haven't messed with input capture, and not anticipating a need among any upcoming projects yet, sorry about that. Thanks for the feedback though, and I'm glad the code comes across as legible.
Sat, 18 Jun 2011 15:47:05 +0000
Hello , I remember a very old project i have write for servos. Your code have a limitation to max 10 servos due to the method you use (one servo at time) The method i have made was set the servos ports from the UC to 1 and sequentially put 0 for the servo who reach it's pulse length in µS. For doing this i have set one interrupt who run that servos routine every 20mS. That the code work you have to made a servos array variable and sort all servo from less µS to most µS (positioning). I don't know now how to do it with my brand new chipkit max32 board but for those who want try here are how i made it.
1 : variables declaration ( array of servos and how much servos)
int16 Servo[16][2]; // the servos array
int16 NbServo = 15 ; // How much servos you are going to use
// We start with servo number 0
// They are 16 servos in this example
2 : Assign servos to UC Pins
void SetupServosPin(void)
{
servo[0][0] =PIN_D0; // servo[nn][0] = pin to use
servo[1][0] =PIN_D1;
servo[2][0] =PIN_D2;
servo[3][0] =PIN_D3;
servo[4][0] =PIN_D4;
servo[5][0] =PIN_D5;
servo[6][0] =PIN_D6;
servo[7][0] =PIN_D7;
servo[8][0] =PIN_B0;
servo[9][0] =PIN_B1;
servo[10][0]=PIN_B2;
servo[11][0]=PIN_B3;
servo[12][0]=PIN_B4;
servo[13][0]=PIN_B5;
servo[14][0]=PIN_B6;
servo[15][0]=PIN_B7;
3 : We give initial values for each servo (set to 0° = 1000µS = 1mS)
void GiveInitialValue(void)
{
int16 a;
// Give initial values to all servos before we start
for(a=0;a<=NbServo;a++)
{
Servo[a][1]=1000; // Servo[nn][1] = pulse lenght in µS
}
}
4 : The most important routine is to sort the servos pulse length that we can stop them sequentially one after the other.
void SortServos(void)
{
int8 a,b;
int16 temp[1][2];
// Sorting Algorythm
for(a=0;a<=NbServo-1;a++)
{
for(b=a+1;b<=NbServo;b++)
{
if(Servo[a][1] > Servo[b][1])
{
temp[0][0]=servo[a][0];temp[0][1]=servo[a][1];
servo[a][0]=servo[b][0];servo[a][1]=servo[b][1];
servo[b][0]=temp[0][0];servo[b][1]=temp[0][1];
}
}
}
}
5 : Now with this routine we pilot all servos.
void CommandServos(void)
{
int8 a;
// All servos pins are set to 1
output_d(255);
output_b(255);
set_timer1(0);
for(a=0;a<=NbServo;a++)
{
while(get_timer1()<servo[a][1])continue;
output_bit(servo[a][0],0);
}
}
6 : Now for test all servos we need to change the values for all servos I made this little test routine for that.
void ModifyServos(void)
{
int8 a;
for(a=0;a<=NbServo;a++)
{
servo[a][1]+=10;
if(servo[a][1]>2000) servo[a][1]=1000; // if the pulse is more than 2mS set it to 1mS (0°)
}
}
7 : Now the main program can be like that
void main()
{
set_tris_b(0x00); // set port B and D as output
set_tris_d(0x00);
output_b (0); // set port B and D to 0
output_d (0);
SetupServosPin();
GiveInitialValue();
// main loop
While(TRUE)
{
SortServos();
CommandServos();
// Do something for 18mS
// .....
// in this time you can get servos position from
// Serial , SPI , etc .. or just continue
// with the ModifyServos() test routine
ModifyServos();
}
}
I have do this servo tricks long time ago on a PIC18F4680 and the soft was made with CCS C Compiler. Just don't forget that the servo routine need 2mS for set all servos in requested position , then you have to do something for 18mS or use one timer interrupt every 20mS. You are not limited in number of servos you can use , just in number of digital output you can use on your CPU :? That's it , i hope it will help you to made the next super servos board :lol:
And sorry for my French English !
Darth.
Tue, 28 Jun 2011 12:14:45 +0000
There have been several threads in several places bemoaning the lack of a working Servo library. Had a need myself, so put something together today.
Thanks very much for this, I tried it on my new Uno32 and it works great.
I made a quick-and-dirty version of the Arduino Servo library that uses your code. It works like the original with the provisos that you can only use 8 servos and can't use pin 3. Is it OK with you if I post this? Cheers.
Tue, 28 Jun 2011 18:00:05 +0000
Sounds good to me! I'd just suggest making it abundantly clear that it's a stopgap measure and not an "official" port of the Servo lib, even if the syntax is the same. My choice of timers and stuff may be different than what's eventually delivered, and I wouldn't want folks moving in and getting too comfortable, y'know?
Tue, 28 Jun 2011 18:16:51 +0000
You've got it together in a compatible servo library?
Yes, I'd sure be glad to see that!
That, and a MsTimer LIB would allow me to compile my "Table Top Challenge" 'bot code.
Thanks!
Alan KM6VV
Thanks very much for this, I tried it on my new Uno32 and it works great. I made a quick-and-dirty version of the Arduino Servo library that uses your code. It works like the original with the provisos that you can only use 8 servos and can't use pin 3. Is it OK with you if I post this? Cheers.
Tue, 28 Jun 2011 22:47:58 +0000
OK, try this. I've named it "MakeshiftServo" so it won't be mistaken for an "official" version.
Tue, 28 Jun 2011 23:30:18 +0000
Thanks! I will!
Alan KM6VV
Sat, 09 Jul 2011 02:36:49 +0000
I note there is no "keywords.txt" file in your MakeshiftServo.zip package (along with the MakeshiftServo.cpp and MakeShiftservo.h files). To make a complete library folder, should I simply copy the keywords.txt from the existing "Servo" folder into the new "MakeshiftServo" folder?
Sat, 09 Jul 2011 06:36:52 +0000
To make a complete library folder, should I simply copy the keywords.txt from the existing "Servo" folder into the new "MakeshiftServo" folder?
Yes, if you like. It is only for syntax highlighting in the IDE.
Fri, 05 Aug 2011 21:24:01 +0000
OK, try this. I've named it "MakeshiftServo" so it won't be mistaken for an "official" version.
This works for very well me... I need only 8 servos. Any chance of adding a timer driven speed variable?
I can use a for loop with delays to do this, but it is too much overhead, I (the UNO32) need to do other things while the commanded servo is moving..1-3 seconds is what I am looking for. I used a library named varSpeedServo with the UNO that worked great.
David Garrison :D
Sat, 06 Aug 2011 00:33:28 +0000
I used a library named varSpeedServo with the UNO that worked great. David Garrison :D
Thanks, that's a really useful library so I've added timed move code from it to MakeshiftServo (attached), with a new sample program that demonstrates it.
Sun, 07 Aug 2011 14:53:52 +0000
Thanks, that's a really useful library so I've added timed move code from it to MakeshiftServo (attached), with a new sample program that demonstrates it.
I downloaded your code and tried it out ; it works very well indeed.
My problem is with the MakeshiftServo library restriction on pin 3 use, as a connection of the color LCD, I am using, is wired to pin 3. There is no way to change this as the graphics library uses RD0-7 directly..pin 3 is either OC1 or RD0....bummer.
Do you think that this pin 3 restriction will also apply to the ChipKit porting of the Arduino servo Library?????
Thanks for work!
Best Regards
David Garrison :(
Tue, 09 Aug 2011 03:05:35 +0000
Do you think that this pin 3 restriction will also apply to the ChipKit porting of the Arduino servo Library?????
No, the new servo code is in git now (Servo.cpp) and it only uses timers so no need for the OC pin. Haven't tried it yet but it looks good.
I was a bit surprised to see:
#define usToTicks(_us) (1.25* _us)
#define ticksToUs(_ticks) ( (unsigned)_ticks/1.25)
Won't this do a float calculation?
Tue, 09 Aug 2011 13:52:47 +0000
No, the new servo code is in git now (Servo.cpp) and it only uses timers so no need for the OC pin. Haven't tried it yet but it looks good.
Good news indeed!
Do you plan to work your magic again and produce a VarSpeedServo version of this library ? I surely hope so, as I need it for my application..
David Garrison :D
Tue, 09 Aug 2011 18:54:27 +0000
is the new servo.cpp only for the MAX?
Alan KM6VV
Tue, 09 Aug 2011 22:45:30 +0000
is the new servo.cpp only for the MAX?
No, it works on the UNO32 as well.
Tue, 09 Aug 2011 23:30:16 +0000
Do you plan to work your magic again and produce a VarSpeedServo version of this library ? I surely hope so, as I need it for my application..
Yes I will have a go, maybe next weekend though.
It's interesting that the interrupt handler for the PIC32 version of Servo is almost identical to the AVR version, I didn't know you could use the PR register in the same way as the output compare on the AVRs. That will make porting timer code a lot easier.
Wed, 10 Aug 2011 00:34:03 +0000
Yes I will have a go, maybe next weekend though.
Huge thanks in advance
David Garrison
Sun, 28 Aug 2011 12:25:32 +0000
I haven't totally forgotten about this, but my attempts so far haven't worked very well. Just pasting the VarSpeedServo code into the PIC32 Servo code works for one or two servos but gets glitchy with any more at some speeds, so there is a complex timing problem in there somewhere. Anyway attached is what I have so far, see if it works for you.
Wed, 31 Aug 2011 01:10:50 +0000
I haven't totally forgotten about this, but my attempts so far haven't worked very well. Just pasting the VarSpeedServo code into the PIC32 Servo code works for one or two servos but gets glitchy with any more at some speeds, so there is a complex timing problem in there somewhere. Anyway attached is what I have so far, see if it works for you.
I just got around to testing your work..I have only two servos that I can use on my bench and it works just dandy! I will free a few more up tomorrow and wire up a kludge to power them and get them connected and I will report my findings.
BTW, my servos --least expensive Hitec's --don't like going 180 degrees!
David G 8-)
Thu, 01 Sep 2011 23:48:57 +0000
"BTW, my servos --least expensive Hitec's --don't like going 180 degrees! "
Sorry to report that you are correct , there is bad jitter. What I thought was a servo fault was indeed the software. It was driving them past the stops on one end. bummer!
I wrote a sketch to drive just one servo and commanded it to 90 degrees, the resultant pulse width was 3000 us! at 0 degrees it was 2100us... not good.
Just to make sure that my Open Bench Logic analyzer was telling me the truth . I wrote a sketch using the Normal servo library and it worked fine ..90 degrees was just about 1500 us.
David G. :(
Fri, 02 Sep 2011 00:32:44 +0000
:o
BOY DO I HAVE EGG ON MY FACE!!
I noticed that even though I was commanding only one servo to move in my last test..the next two also moved....What was that about??? time to get the ohmmeter out, and wring out the prototyping board I built to house the servo connectors and servo power leads......yup all the signal wires are connected together??????
Wait....what are those white marks between the pads I have the servo connectors mounted to?.. UGH Dummy! those indicate that they are connected by tracks...No problem for the ground and the +5V but not good for the servo signals..all were connected together...who knows what that was doing to the poor ole micro...$%^$#@
Find the exacto , cut the tracks, reload the VarSpeedServo example...upload to the Uno32....wait......wait....wait...and yipee, the five servos I have connect, all danced together with no jitter in sight.....!!!!
I just emailed my eye doctor for an appointment.
David G. now---- :lol:
Fri, 02 Sep 2011 00:41:48 +0000
all the signal wires are connected together??????
Yep I can see how that could cause problems. :)
Can you try running the slowmovetest example included with the library please? You don't have to have 8 servos connected, just one or two, but leave the TEST_SERVOS number at 8. On mine it glitches towards one end of the servo range at some speeds. Maybe I should check my wiring. :)
Fri, 02 Sep 2011 15:03:21 +0000
Yep I can see how that could cause problems. :) Can you try running the slowmovetest example included with the library please? You don't have to have 8 servos connected, just one or two, but leave the TEST_SERVOS number at 8. On mine it glitches towards one end of the servo range at some speeds. Maybe I should check my wiring. :)
Tried your test. Only one servo glitched at the lowest speed and it is servo dependent , move it to another channel and it acts the same..So I gather it is a problem with with individual servo.
All in all, I am please with your work..I think it's a keeper!!!!
Thanks Again.
David Garrison
Sun, 18 Sep 2011 16:44:49 +0000
I have my application finished (two weeks ago) and up and running using the VarSpeedServo library. I have 7 servos connected and they are working without any glitches. I control them with touch input from a 340 x 240 color LCD with a touch screen.
MANY thanks to davec for his work on the VarSpeedServo Library and to Henning Carlson for his graphics/touch LCD library.
For VarSpeedServo download link:[url] http://chipkit.org/forum/viewtopic.php?f=15&t=150&start=20#p1854 [/url] David G. :)
Mon, 19 Sep 2011 14:10:02 +0000
I control them with touch input from a 340 x 240 color LCD with a touch screen.
Which LCD touch 320x240 screen are you using?
Mine comes from :arrow: 4D Systems and I'm also using it to control a stepper motor.
As controller, I'm using the I2C :arrow: AMIS30624.
Mon, 19 Sep 2011 15:08:03 +0000
I am using the ITDB02 from ITead which is a 3.2" display and Henning Karlson's library:
See: [url]http://chipkit.org/forum/viewtopic.php?f=7&t=37&start=10#p1131[/url]
Best Regards
David G.
Tue, 06 Dec 2011 13:42:20 +0000
As you have already experienced, there is no data-sheet available for above servo motors. Below posted is a simple code that you can use for getting an idea about the pulse width of the servo.
Code:
Thu, 25 Oct 2012 16:41:30 +0000
Hi guys,
In reference to library VarSpeedServoPIC32 posted by davec in this thread, I have been beating my head on this for last 2 days and can't a simple code to work, though the following works just fine on the Arduino. I have even tried to change all references of "BYTE" to "uint8_t" in VarSpeedServo.cpp
I am running mpide-0023-windows-20120903 so a lot of the library issues noted back in 2011 seem to be already fixed in this version of the IDE.
Could someone please help before I go nuts or resort to the inferior Arduino which I vowed to stay away from.
#include <VarSpeedServo.h>
const int NBR_SERVOS = 4; // the number of servos
VarSpeedServo Servos[NBR_SERVOS]; // servo objects
int servoPins[NBR_SERVOS] = {8, 9, 10, 11}; // servo pins
int servoSpeeds[NBR_SERVOS] = {1, 10, 100, 255}; // sweep speed, 1 is slowest, 255 fastest)
int servoMinPosition[NBR_SERVOS] = {10, 20, 30, 40}; // the minumum servo angle
int servoMaxPosition[NBR_SERVOS] = {120, 130, 140, 150}; // the maximum servo angle
void setup()
{
for(int i=0; i < NBR_SERVOS; i++)
{
Servos[i].attach(servoPins[i]);
Servos[i].slowmove(servoMinPosition[i],servoSpeeds[i]) ; // start sweeping from min position
}
}
void loop()
{
// sweep the servos
for(int i=0; i < NBR_SERVOS; i++)
{
if( Servos[i].read() == servoMinPosition[i])
Servos[i].slowmove(servoMaxPosition[i],servoSpeeds[i]) ;
else if( Servos[i].read() == servoMaxPosition[i])
Servos[i].slowmove(servoMinPosition[i],servoSpeeds[i]) ;
}
}
Error:
In file included from c:\mpide-0023-windows-20120903\hardware\pic32\compiler\pic32-tools\bin\../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/peripheral/i2c.h:50:0,
from c:\mpide-0023-windows-20120903\hardware\pic32\compiler\pic32-tools\bin\../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/plib.h:54,
from C:\mpide-0023-windows-20120903\.\hardware\pic32\libraries\VarSpeedServoPIC32\utility/int.h:39,
from C:\mpide-0023-windows-20120903\.\hardware\pic32\libraries\VarSpeedServoPIC32\VarSpeedServo.cpp:62:
c:\mpide-0023-windows-20120903\hardware\pic32\compiler\pic32-tools\bin\../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/GenericTypeDefs.h:342:33: error: expected unqualified-id before numeric constant
c:\mpide-0023-windows-20120903\hardware\pic32\compiler\pic32-tools\bin\../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/GenericTypeDefs.h:360:5: error: expected unqualified-id before numeric constant
Thu, 25 Oct 2012 17:57:38 +0000
Just a guess, but do you know if there is any AVR specific stuff in VarSpeedServo? This is not a standard (i.e. included) library with Arduino or MPIDE. There may be some things that need to get changed a little bit so it will work with the chipKIT boards.
*Brian
Thu, 25 Oct 2012 19:06:08 +0000
Just a guess, but do you know if there is any AVR specific stuff in VarSpeedServo? This is not a standard (i.e. included) library with Arduino or MPIDE. There may be some things that need to get changed a little bit so it will work with the chipKIT boards.
Could be. But I assume this was already worked out by poster "davec" who posted VarSpeedServoPIC32 library further up in this thread. :
http://www.chipkit.org/forum/viewtopic.php?f=15&t=150&start=20
Thu, 25 Oct 2012 23:51:09 +0000
Yes they reshuffled the include files slightly. The attached version compiles OK , I haven't tested it though.
Edit: I re-attached this file as it was corrupted in the forum storage.
Fri, 26 Oct 2012 14:16:07 +0000
Not sure if any one is interested, but I also hacked up the Servo Library (like I did on the Arduino) and created a new private library (servoEx), which has code on the interrupt handlers to update the positions per pulse, such that you can have timed moves, or a group of servos with a timed move... At some point soon, I will try it out on one of my Hex robots and see if I can get the servo library to work with 18 servos without any jitters...
I do have a test in my test app, that shows that it is at least working for one servo at a time... Where I have it sweeping the servo back and forth from 60 to 120 degrees, with code that looks like:
for(;;) {
if (!g_servo.moving()) {
fServoDir = !fServoDir;
g_servo.move(fServoDir ? 120 : 60, 500);
}
}
This code tells it to move to 60 or 120 degrees and take 500ms to get there and I have a test (moving) as part of the library that says has the servo made it to it's destination or not... Note: in my actual code I have more than the actual for(;;;) loop
Kurt
Fri, 26 Oct 2012 15:18:01 +0000
Yes they reshuffled the include files slightly. The attached version compiles OK , I haven't tested it though.
Hi Davec That worked !!! yay !! I should have just pinged you before instead of beating my head on this for a whole day and a half. YOU DA MAN !!!
dragonbot (Bruce)
Wed, 24 Dec 2014 14:32:56 +0000
Hello,
I uploaded the VarSpeedServo_mpide file but I have problem to unzip the file no matter how I try to (with 7-ZIP and Winzip and on 2 differents computers).
Is there something special to do to make the file usable?
Thanks
Sat, 11 Apr 2015 21:17:14 +0000
Hi bcrepet, I re-attached the file to the original message, you should be able to download it now.