Go Down

Topic: Help with dual servos (Read 3 times) previous topic - next topic

zoomkat

One can make a 180 deg servo turn something 360 deg, the servo output just needs to be geared up by 2x. Gears or DIY pully type setups can be used.
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

GRNDPNDR

I did mention earlier that one of the motors was geared, the "wiper" servo, which is why I'm not certain of the angle because the guy who bought the gears went WAY over 2:1 I think so that servo is only going to have to move like 25*.

We originally went with steppers but because the device we have is made from a rapid prototyper it's heat sensitive and the steppers were getting hot enough to re-melt the plastic......so we had to move to servos.

and yes I do have the servos working with servo code.


zoomkat

I think heating of stepper motors may be reduced by starting movement with max current, then reducing the current to a holding current when the stepper isn't moving.
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

patduino

Ground Pounder,

Here is a draft of what I think the code would look like. 


  • CAVEAT #1 - I did not compile it, and you'll need to double-check that the for loop limits and ++/-- are correct.

  • CAVEAT #2 - I did not attempt to move the servos simultaneously.  In order to do this effectively, we'll need to really understand the gearing for the wiper.  Does it really have to move simultaneously?  Because they aren't geared the same, one servo may appear to stutter when it moves. (This is due to the fact that each will move different "actual" degrees in each 5ms step.)



Code: [Select]

//
// 2 servos operate as depicted (without plunger) in https://www.youtube.com/watch?v=yhlfb8BLzMk
//

#include <Servo.h>

Servo wiper;     // create servo object to control a servo
Servo turnstile; // a maximum of eight servo objects can be created

const int MIN_WIPER_DEGREES = 0;
const int MAX_WIPER_DEGREES = 25;  // actually geared to 338*
const int MID_WIPER_DEGREES = (MIN_WIPER_DEGREES + MAX_WIPER_DEGREES)/2;

const int MIN_TURNSTILE_DEGREES = 0;
const int MAX_TURNSTILE_DEGREES = 180;
const int MID_TURNSTILE_DEGREES = (MIN_TURNSTILE_DEGREES + MAX_TURNSTILE_DEGREES)/2;

const int STEP_DELAY = 5; // ms

void setup()
{
  wiper.attach(14);  // attaches the servo on pin A0 to the servo object
  turnstile.attach(15); // attaches the servo on pin A1 to the servo object

  //
  // start in position 1 -- wiper in max position, turnstile in max position (:28 in video)
  //

  wiper.Write(MAX_WIPER_DEGREES);
  turnstile.Write(MAX_TURNSTILE_DEGREES);
  delay(100);  // wait to get there
}

void loop()
{
  int degree; // for loop counter
  //
  // move to position 2 -- wiper in min position, turnstile in max position (:35 in video)
  //

  for (degree = MAX_WIPER_DEGREES; degree >= MIN_WIPER_DEGREES; degree--)
  {
    wiper.write(degree);
    delay(STEP_DELAY);
  }

  //
  // move to position 3 -- wiper in min position, turnstile at mid-point (:37 in video)
  //

  for(degree = MAX_TURNSTILE_DEGREES; degree >= MID_TURNSTILE_DEGREES;  degree--)
  {
    turnstile.write(degree);
    delay(STEP_DELAY);
  }

  //
  // do something here?  here is where the plunger acts
  //

  //
  // move to position 4 -- wiper in min position, turnstile at min position (:38 in video)
  //

  for(degree = MID_TURNSTILE_DEGREES; degree >= MIN_TURNSTILE_DEGREES;  degree--)
  {
    turnstile.write(degree);
    delay(STEP_DELAY);
  }

  //
  // move to position 5 -- wiper at max position, turnstile at min position (:45 in video)
  //

  for (degree = MIN_WIPER_DEGREES; degree <= MAX_WIPER_DEGREES; degree++)
  {
    wiper.write(degree);
    delay(STEP_DELAY);
  }

  //
  // move to position 6 -- wiper at max position, turnstile at mid-point (:47 in video)
  //

  for(degree = MIN_TURNSTILE_DEGREES; degree <= MID_TURNSTILE_DEGREES;  degree++)
  {
    turnstile.write(degree);
    delay(STEP_DELAY);
  }

  //
  // move back to position 1 -- wiper at max position, turnstile at max position (:53 in video)
  //

  for(degree = MID_TURNSTILE_DEGREES; degree <= MAX_TURNSTILE_DEGREES;  degree++)
  {
    turnstile.write(degree);
    delay(STEP_DELAY);
  }

  // repeat...

}
There are 10 types of people in the world, those that understand binary, and those that don't.

GRNDPNDR

Thanks, I'll check it out today and find out how it works and if I need to tweak it a bit.

I've been reviewing it and the code looks easy to follow, I can see what it's doing and how :)

it looks easy, but I would have spent weeks trying to come up with the same thing.

GRNDPNDR

I forgot to mention, at some point, somewhere, on it's own timer, I need to send a signal to a pin for X amount of seconds.

I need to use a transistor as a switch to control a solenoid to open and close briefly.

patduino

Do you mean that this action is timer driven, rather than respectively in a loop?
There are 10 types of people in the world, those that understand binary, and those that don't.

GRNDPNDR

yes, but once an hour or something like that.

I guess it could happen within the loop, that would probably be easier I think?

patduino

A whole lot easier in the loop.  Just delay for an hour at the end of the loop:

  delay(3600000);  // wait one hour

Pat.
There are 10 types of people in the world, those that understand binary, and those that don't.

GRNDPNDR

but I need to send that out to a digital pin I think.

patduino

What will the digital output pin control?  Maybe I'm missing something key here...
There are 10 types of people in the world, those that understand binary, and those that don't.

GRNDPNDR

Transistor base.

We have a 24V solenoid, I was going to use a transistor as a switch to turn the 24V solenoid on and off.
It has to operate without delaying the servo loops.

fkeel

dont use delay(). It will stop the servos from moving and wont have the desired effect. Take the code from the "blink without delay" example, modify it to "blink" every hour, and add it to your code.

p.
http://embodimentlabs.tumblr.com/
http://paulstrohmeier.info/

GRNDPNDR


dont use delay(). It will stop the servos from moving and wont have the desired effect. Take the code from the "blink without delay" example, modify it to "blink" every hour, and add it to your code.

p.


genius.... I'll give it a try as soon as my partner stops being stupid and understands that gears can't have play or they bind......it's been about 2 weeks now and he doesn't seem to believe me when I tell him the gearing shafts can't move (except torsionally)

GRNDPNDR

ok, this program works fairly well, however it's important that the "turnstile" move 90* then the "wiper" starts moving and while it's moving, the turnstile is also moving at the same time to a position of 180*.....same on the reverse.

is that possible or incredibly difficult to accomplish?

Go Up