Show Posts
Pages: [1]
1  Community / Gigs and Collaborations / Re: Simple project, willing to pay $$$ for basic coding - 4 Servos + Ping))) on: October 14, 2012, 06:44:25 pm
So four AA's is not a good way to power the servos? Could any one suggest an alternative capable of providing the charge necessary? 
2  Community / Gigs and Collaborations / Re: Simple project, willing to pay $$$ for basic coding - 4 Servos + Ping))) on: October 14, 2012, 08:28:12 am
Thank you so much everyone for all your support! Using the code that you guys suggested the servos now communicate with the sensor and it all works beautifully.....except for one small thing.

For some reason the servo's movement is now really jittery, especially when working at higher speeds. I don't know if its an issue with the code (somewhere in the loop prompt), or if its the batteries which cannot provide enough amperage for the servos under heavy loads (the battery pack is 4 AS's).

If anyone has an idea why this might bee, some suggestions to resolve the problem would be highly appreciated.

Thanks a million,

Michael
3  Community / Gigs and Collaborations / Re: Simple project, willing to pay $$$ for basic coding - 4 Servos + Ping))) on: October 10, 2012, 08:14:12 am
Inches is indeed a global variable. I would like the speed of all the servo's (roll, pitch, yaw, & boo) to be equally affected by the change in distance (defined in inches).

For example, if I'm 10 inches away from the sensor, I would like the speed of all the servos to be 1 ( servoSpeed[roll]= 1, servoSpeed[yaw]= 1 etc.)  If I increase that distance to 20 inches, all the servo's speed would change to 2.

To summarize it:       

-All the servos are moving at equal speeds.

-The value for speed is directly proportional to the distance in inches from the sensor.

I hope that answers your question. Thanks for posting!
Mike
4  Community / Gigs and Collaborations / Re: Simple project, willing to pay $$$ for basic coding - 4 Servos + Ping))) on: October 09, 2012, 07:01:29 pm
Thank you so much for all your help Pete!

I posted the code I have for controlling the speed of the servos a few posts back. The portion of the code where I physically input a value for speed is in the 3rd tab "loop", where I can change the 'servoSpeed[roll]= 1;' section.

The code I have for the sensor is listed below:

Code:
const int pingPin = 11;
unsigned int duration, inches;

void setup() {
  Serial.begin(9600);
}

void loop() {
  pinMode(pingPin, OUTPUT);          // Set pin to OUTPUT
  digitalWrite(pingPin, LOW);        // Ensure pin is low
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);       // Start ranging
  delayMicroseconds(5);              //   with 5 microsecond burst
  digitalWrite(pingPin, LOW);        // End ranging
  pinMode(pingPin, INPUT);           // Set pin to INPUT
  duration = pulseIn(pingPin, HIGH); // Read echo pulse
  inches = duration / 74 / 2;        // Convert to inches
  Serial.println(inches);            // Display result
  delay(200);              // Short delay
}

I hope thats all you need, let me know if I didn't express myself specifically enough at any stage  smiley-wink

Thanks again,
Mike
5  Community / Gigs and Collaborations / Re: Simple project, willing to pay $$$ for basic coding - 4 Servos + Ping))) on: October 09, 2012, 03:06:34 pm
I'm using the Ping ultrasound reader from Parallax.  I have hooked it up to the Arduino using the sample code they provided and it works fine (outputting distance values to the serial monitor).

6  Community / Gigs and Collaborations / Re: Simple project, willing to pay $$$ for basic coding - 4 Servos + Ping))) on: October 07, 2012, 09:16:14 am
Thanks for your reply Pete!

What I need to do makes sense in my mind (mapping a range from the sensor, working out an input range for the speed of the servo, and linking the two together) - the issue is I don't know how to modify the code in order to do that. 

Any suggestions would be really helpful....

- I know I need to define the sensor (aka assign it a name).

- Link it to pin, and set it as an input pin.

- Work out the input range of the sensor and map that to an output range for the servo speed.

- Link the two values somehow in the code.....


How could I modify my code to do those tasks?

Thank you!

Mike

7  Community / Gigs and Collaborations / Re: Simple project, willing to pay $$$ for basic coding - 4 Servos + Ping))) on: October 05, 2012, 04:31:06 pm
And as for the budget, I really wouldn't know - I can't really gauge how difficult a task this would be for someone to code....  I also don't know what people usually ask for in these kind of scenarios.... smiley-red

Any advice?
8  Community / Gigs and Collaborations / Re: Simple project, willing to pay $$$ for basic coding - 4 Servos + Ping))) on: October 05, 2012, 04:27:09 pm
Yes I do indeed mean servos.  Lame old cheap 180 degree servos. I know they are not the most precise, or in any way the most reliable motors out there - at the moment I'm really just out to build a proof of concept but I can't adjust the code accordingly. 

I'm not entirely sure how but I am definitely able to adjust the speed of the servos...Maybe it has to do with altering the frequency of the internal loop?

It would probably make more sense if I showed you the code I already have:

1st Tab:
Code:
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

#include <Servo.h>

#define roll  0
#define pitch 1
#define yaw   2
#define Boo   3

#define UP    1
#define DOWN  0
#define HOLD  2

Servo servo[4];  // create servo object to control a servo

int direct[4] = {0,0,0,0};
int steps[4];
int pos[4] = {0,0,0,0};
int target[4];
int hold[4];
int maxCount[4];
int minCount[4];

long servoMin[4];
long servoMax[4];
long servoPauseMin[4];
long servoPauseMax[4];
long servoSpeed[4];

long previousMillis[4] = {0,0,0,0};        // will store last time LED was updated
unsigned long currentMillis[4];
long interval = 4000;           // interval at which to blink (milliseconds)

2nd Tab - Drive: 
Code:
void drive(int servos, int minTarget, int maxTarget,int minHold, int maxHold, int speeds) {
 
  if(direct[servos] == UP){
     if (pos[servos] < maxTarget){
        pos[servos] = pos[servos] + speeds ;
     }
     else if (pos[servos] >= maxTarget){
       
      maxCount[servos]++;
        if(maxCount[servos] >= maxHold){
           maxCount[servos] = 0;
           direct[servos] = DOWN;
        }
      }
  }
 
  if(direct[servos] == DOWN){
      if(pos[servos] > minTarget){
            pos[servos] = pos[servos] - speeds ;
          }
      else if (pos[servos] <= minTarget){
       
         minCount[servos]++;
        if(minCount[servos] >= minHold){
           minCount[servos] = 0;
           direct[servos] = UP;
           Serial.print("........................................................" );
        }
      }
  }
 
  /*
  Serial.print("\t servo" );                       
  Serial.print(servos);
  Serial.print(" = ");
  Serial.print(pos[servos]);
  Serial.print(" ");
  Serial.print(minTarget);
  Serial.print(" ");
  Serial.print(maxTarget);
   Serial.print("\t direction = " );                       
  Serial.println(direct[servos]);
  //if(servos == 2) Serial.println();
  */
 
  servo[servos].write(pos[servos]);
   delay(15);
}

3rd Tab - Loop:
Code:
void loop() {    //(servo, its minimum target, maximum target, pause at the min position, pause at max position, its speed)
   
       // servo[pitch].write(80);    //pitch range = 20 - 80
       //servo[roll].write(120);    //roll range = 100 - 130
   
     
        servoMin[roll] = 0;
        servoMax[roll]= 180;
        servoPauseMin[roll] = 0;
        servoPauseMax[roll] = 0;
        servoSpeed[roll]= 1;
       
        servoMin[pitch]= 0;
        servoMax[pitch] = 180;
        servoPauseMin[pitch]= 0;
        servoPauseMax[pitch]= 0;
        servoSpeed[pitch]= 2;
       
        servoMin[yaw]= 0;
        servoMax[yaw] = 180;
        servoPauseMin[yaw]= 0;
        servoPauseMax[yaw]= 0;
        servoSpeed[yaw]= 2;
       
        servoMin[Boo]= 0;
        servoMax[Boo] = 180 ;
        servoPauseMin[Boo]= 0;
        servoPauseMax[Boo]= 0;
        servoSpeed[Boo]=  1;
 /*
     
        servoMin[roll] = random(0, 100);
        servoMax[roll]= random(servoMin[roll], 180);
        servoPauseMin[roll] = random(0, 2000);
        servoPauseMax[roll] = random(0, 2000);
        servoSpeed[roll]= random(0, 5);
       
        servoMin[pitch]= random(0, 100);
        servoMax[pitch] = random(servoMin[pitch], 180);
        servoPauseMin[pitch]= random(0, 2000);
        servoPauseMax[pitch]= random(0, 2000);
        servoSpeed[pitch]= random(0, 5); 
       
        servoMin[yaw]= random(0, 100);
        servoMax[yaw] = random(servoMin[yaw], 180);
        servoPauseMin[yaw]= random(0, 1000);
        servoPauseMax[yaw]= random(0, 1000);
        servoSpeed[yaw]= random(0, 5);
 */
       
      drive(roll,servoMin[roll],servoMax[roll],servoPauseMin[roll], servoPauseMax[roll],servoSpeed[roll]);
      drive(pitch, servoMin[pitch],servoMax[pitch],servoPauseMin[pitch],servoPauseMax[pitch],servoSpeed[pitch]);
      drive(yaw,servoMin[yaw],servoMax[yaw],servoPauseMin[yaw],servoPauseMax[yaw],servoSpeed[yaw]);
      drive(Boo,servoMin[Boo],servoMax[Boo],servoPauseMin[Boo],servoPauseMax[Boo],servoSpeed[Boo]);
     
     
     
     //drive(roll,180,0,1000,1000,1);
    // drive(pitch,180,0,1000,1000,4);
     //drive(yaw,180,0,1000,1000,2);
       
}

4th Tab - Setup:
Code:
void setup() {
 
 
   randomSeed(analogRead(0));
   
   Serial.begin(9600);
   
  servo[roll].attach(2);  // attaches the servo on pin 9 to the servo object
  servo[pitch].attach(3);  // attaches the servo on pin 9 to the servo object
  servo[yaw].attach(4);  // attaches the servo on pin 9 to the servo object
  servo[Boo].attach(5);  // attaches the servo on pin 9 to the servo object
 
  pos[roll] = 90;
  pos[pitch] = 90;
  pos[yaw] = 90;
  pos[Boo] = 90;
 
}
9  Community / Gigs and Collaborations / Re: Simple project, willing to pay $$$ for basic coding - 4 Servos + Ping))) on: October 05, 2012, 03:32:01 pm
Nope that was someone else. Similar project though--- I'm using Servo's rather than stepper motors, and mine has nothing to do with optics etc.
10  Community / Gigs and Collaborations / Simple project, willing to pay $$$ for basic coding - 4 Servos + Ping))) on: October 05, 2012, 03:22:46 pm
Hello everyone! I'm a bit of a novice to Arduino programming as this is only my second project smiley-wink.

Basically, I have four servos connected to an Arduino, and I would like their speed to be regulated by a Ping ultrasonic proximity sensor.

At the moment, my code enables me to control all Servos manually by inputing values for speed. Pretty much I would like to move the servo, measure a distance, change speed, move the servo, measure a distance, change speed etc. That way if I move close to the servo's they gradually move to a halt, and as I step away they gradually build up speed. 

Can this be done? Would anyone be willing to modify my code to implement the Ping changing Servo speed for a negotiable amount of $?

Please email me at fathersonholyghostarts@gmail.com with any bids or questions.

I would post my code below but I don't know how to post seperate tabs of code in the forum.

Thanks in advance...

Mike

Pages: [1]