Go Down

Topic: VarSpeedServo - a modified Servo library with speed control (Read 137152 times) previous topic - next topic

Zilch

#45
Nov 28, 2013, 08:07 pm Last Edit: Nov 29, 2013, 03:50 pm by zilch Reason: 1
Hi there, first of all - thanks for this great lib.
it is working nicely in my project.

i controll 3 servos to adjust 3 pots of an amp with an arduino nano.
the only issue i am having (same as with the original servo lib) is that attaching a servo causes it to go to middle position with full speed.
i really cant have that ;) the servos have to stay in the position they where when switched off.
otherwise the movement is too fast for the pots and could do some damage.

so is there a way to prevent that middle position when attaching a servo or at least do it in slow speed ?
i am really new to all this... so,
any help appreciated.

cheers


-------> EDIT:
kinda solved it, when i figured only writeMicroseconds can override the middle position after attach,
slowmove cant and write probably cant too...
so i can store the position of the servos after each move to eeprom and write it back in void setup before attaching the servos.

Nicolas1980

Sketches with the library compile under Arduino UNO, but won't as Arduino DUE...

3dprinter


kinda solved it, when i figured only writeMicroseconds can override the middle position after attach,
slowmove cant and write probably cant too...
so i can store the position of the servos after each move to eeprom and write it back in void setup before attaching the servos.
That would have been my suggestion, too. Note that the eeprom is not infinitly rewritable ("The EEPROM has an endurance of at least 100,000 write/erase cycles" in the spec), so add in a some "filtering" so you only store when there has been a great enough move from previous stored value if you do this many times a second. (one million seconds is 11+ days)

aeddleston

hi trying to use this code to move a servo with a remote control, an i want the speed to be slower, can you see any problems please,



#include <Servo.h>

#include <IRremote.h>
#include <VarSpeedServo.h>


unsigned long Value2 = 0xFFE01F; // where XXXXXXXX is on our your remote's values. We will call this Value 1
unsigned long Value1 = 0xFF609F; // where XXXXXXXX is another button on your remote

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
 
 VarSpeedServo myServo;

// the setup routine runs once when you press reset:
void setup() {             

Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver

  // initialize the digital pin as an output.

myServo.attach (10, 1, 179); // attack servo to digital pin 10 min 1 max 180
}
// the loop routine runs over and over again forever:
void loop() {

if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }

if(results.value == Value1) {
myServo.slowmove (180, 30);  //pos 180 speed 30
}

if(results.value == Value2) {
myServo.slowmove (1, 40);
}

}


  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
Arduino: 1.0.6 (Windows 7), Board: "Arduino Uno"
In file included from servoIRmove.ino:4:
C:\Program Files\Arduino\libraries\VarSpeedServo/VarSpeedServo.h:96: error: conflicting declaration '_timer1'
C:\Program Files\Arduino\libraries\Servo/Servo.h:83: error: '_timer1' has a previous declaration as 'timer16_Sequence_t _timer1'
C:\Program Files\Arduino\libraries\VarSpeedServo/VarSpeedServo.h:96: error: conflicting declaration '_Nbr_16timers'
C:\Program Files\Arduino\libraries\Servo/Servo.h:83: error: '_Nbr_16timers' has a previous declaration as 'timer16_Sequence_t _Nbr_16timers'
C:\Program Files\Arduino\libraries\VarSpeedServo/VarSpeedServo.h:96: error: conflicting declaration 'typedef enum timer16_Sequence_t timer16_Sequence_t'
C:\Program Files\Arduino\libraries\Servo/Servo.h:83: error: 'timer16_Sequence_t' has a previous declaration as 'typedef enum timer16_Sequence_t timer16_Sequence_t'
C:\Program Files\Arduino\libraries\VarSpeedServo/VarSpeedServo.h:114: error: conflicting declaration 'typedef struct ServoPin_t ServoPin_t'
C:\Program Files\Arduino\libraries\Servo/Servo.h:101: error: 'ServoPin_t' has a previous declaration as 'typedef struct ServoPin_t ServoPin_t'
C:\Program Files\Arduino\libraries\VarSpeedServo/VarSpeedServo.h:121: error: conflicting declaration 'typedef struct servo_t servo_t'
C:\Program Files\Arduino\libraries\Servo/Servo.h:106: error: 'servo_t' has a previous declaration as 'typedef struct servo_t servo_t'

proto-pic

Engineering Support team for Proto-PIC.co.uk

Proto-Pic

frodo1986

Thank you for building this lib file.

When I compile the file, this massage occur:

D:\arduino-1.5.2\libraries\VarSpeedServoMaster\VarSpeedServo.cpp:71: fatal error: avr/interrupt.h: No such file or directory

But the interrupt.h is in the "D:\arduino-1.5.2\hardware\tools\avr\avr\include\avr" , is there any advise?
Thank you

Sauarabh_garg

Hello Korman ,

Nice job first off all :) !

Can you tell me what will happen if we use false as third parameter in write function, and then without much delay will overwrite something else on the same servo pin of arduino, will the first one will complete before start of second or will skip that and start second ??

Thanking you in anticipation
 


Isaac96

Do not PM me for help. I will delete immediately.
CONNECT THE GROUNDS!

After Tuesday, even the calendar goes W T F

XiLinX

Is there a way that I can use <virtualwire.h> and <varspeedservo.h> libraries simultaneously as both use timer1

Currently I use <servotimer2.h> library but it has no speed control

Is there any <varspeedservo.h> library which use timer2

Thanks

JimboZA

Just so I don't end up with an out-of-date version, is that one attached to the opening post, still current? Or did I miss a newer one attached somewhere in the 4 pages of posts? Or maybe there's an update on github or somewhere?
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

Drivervince

 Hi all,
New person to the Arduino and software here.

I noticed the command has a function to let the servo finish to the end, before continueing.
I cannot find what the feedback is to the 'Finished servo'.

will the function continue reading the remainder of the loop or will the next item interfere?

Having some trouble understanding the inner functional working.
annybody can shine a light on this?


as background, after one run, i need to wait a moment, before the next run.
so i need the servo feedback, as the speed of the servo may vary (and thus the time it takes).

regards,
Vincent
 :smiley-mr-green:

zoomkat

Quote
so i need the servo feedback,
What servo are you using that provides feedback?
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


alexandre_cootep

Hi, I'm trying to run this code with the VarSpeedServo.h:

Code: [Select]

#include <VarSpeedServo.h>

VarSpeedServo myservo;    // create servo object to control a servo

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  myservo.write(180, 30, true);        // move to 180 degrees, use a speed of 30, wait until move is complete
  myservo.write(0, 30, true);        // move to 0 degrees, use a speed of 30, wait until move is complete
}




===>but is giving the following error:

Arduino: 1.6.5 (Windows 7), Placa:"Arduino/Genuino Uno"

sketch_sep19g.ino: In function 'void loop()':
sketch_sep19g:10: error: no matching function for call to 'VarSpeedServo::write(int, int, bool)'
sketch_sep19g.ino:10:30: note: candidate is:
In file included from sketch_sep19g.ino:1:0:
C:\Users\usuario\Documents\Arduino\libraries\VarSpeedServo/VarSpeedServo.h:130:8: note: void VarSpeedServo::write(int)
   void write(int value);             // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds
        ^
C:\Users\usuario\Documents\Arduino\libraries\VarSpeedServo/VarSpeedServo.h:130:8: note:   candidate expects 1 argument, 3 provided
sketch_sep19g:11: error: no matching function for call to 'VarSpeedServo::write(int, int, bool)'
sketch_sep19g.ino:11:28: note: candidate is:
In file included from sketch_sep19g.ino:1:0:
C:\Users\usuario\Documents\Arduino\libraries\VarSpeedServo/VarSpeedServo.h:130:8: note: void VarSpeedServo::write(int)
   void write(int value);             // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds
        ^
C:\Users\usuario\Documents\Arduino\libraries\VarSpeedServo/VarSpeedServo.h:130:8: note:   candidate expects 1 argument, 3 provided
Multiple libraries were found for "VarSpeedServo.h"

 Used: C:\Users\usuario\Documents\Arduino\libraries\VarSpeedServo

 Not used: C:\Program Files (x86)\Arduino\libraries\VarSpeedServo

no matching function for call to 'VarSpeedServo::write(int, int, bool)'


====>someone could help me, please!

 

Go Up