Pages: [1]   Go Down
Author Topic: Simultaneous possible?  (Read 975 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I have a robot project where it needs to drive around and pick up golf balls. The idea my team and I came up with is to use arms to push the balls when a sensor on the arm detects the robot. We are going to use a servo to control both arms by gear system. My question is while its driving forward and detects a ball, is there a way to keep driving forward while the servo arm sweeps the ball into a collector?

Thanks.
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 109
Posts: 4066
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes.
I don't see the problem.  Start the motors, the robot moves forward and does not need intervention from the Arduino to keep it going.
Now do anything you like with the Arduino.

You say that the robot will drive around.  How will it know which way to go, when to turn and when to stop going forward because of an obstacle that is not a golf ball ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4762
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You might look to simpler solutions with fewer parts. Final manufacture cost includes every part and everything that has to be done to it to build the solution.

Have you ever seen PacMan?
Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12549
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes it's possible, but note that the Servo library disables PWM output on some pins and some motor shields use those same pins to provide PWM speed control. If you want to use both in the same project, make sure your motor shield doesn't clash with the Servo library.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes.
I don't see the problem.  Start the motors, the robot moves forward and does not need intervention from the Arduino to keep it going.
Now do anything you like with the Arduino.

You say that the robot will drive around.  How will it know which way to go, when to turn and when to stop going forward because of an obstacle that is not a golf ball ?

Basically the robot is just going in a square path. Id like to have a counter within the program that will turn the robot a certain counts since there is a set number of balls placed. So for example when the counter hits 3 it knows to stop and turn 90 degrees and continue to drive and collect til another number is reached then stop and turn, etc. The golf balls are placed at the same place for every trial run so it wont need to know to turn at different places.

GoForSmoke: Not really sure what your talking about? If you mean using the one servo to control both arms, the purpose for that is to free up ports on the arduino for other needed sensors.

PeterH: Thanks for the information. I have the arduino brand motor board rev 3, do you know if that will interfere? I am new to arduino and tried looking into libraries but from what I can see they are basically programs that act kind of like functions for scripts. Not sure what the servo library even does? If you have any information that would be great


Thanks everyone.
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 109
Posts: 4066
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Turning the robot after a certain count or time is no problem.  What will be a problem unless you have a means to control it is keeping it moving straight and turning 90 degrees when required.

Have you got any code written, even if it is only to turn a motor on and off ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Turning the robot after a certain count or time is no problem.  What will be a problem unless you have a means to control it is keeping it moving straight and turning 90 degrees when required.

Have you got any code written, even if it is only to turn a motor on and off ?

There is a golf ball at each corner of the square path the robot needs to go around so when it senses the ball and the counter reaches a certain number then itll turn.

The coding I did was

Code:
#include <Servo.h>
Servo servoOne; // Define Servo

void setup() {
  
  //Setup Channel A
  pinMode(12, OUTPUT); //Initiates Motor Channel A pin
  pinMode(9, OUTPUT); //Initiates Brake Channel A pin

  //Setup Channel B
  pinMode(13, OUTPUT); //Initiates Motor Channel A pin
  pinMode(8, OUTPUT);  //Initiates Brake Channel A pin
  
  int ballsensor = 1 //Ball Sensor
  pinMode(ballsensor,INPUT); //Ball Sensor on pin 1
  servoOne.attach(10); // Servo on pin 10
}

b=0;

servoOne.write(45); // Turn Servo Left to 45 degrees


while(b<3){
  //Motor A forward @ full speed
  digitalWrite(12, HIGH); //Establishes forward direction
  digitalWrite(9, LOW);   //Disengage the Brake
  analogWrite(3, 255);   //Spins the motor at full speed

  //Motor B backward @ half speed
  digitalWrite(13, HIGH);  //Establishes forward direction
  digitalWrite(8, LOW);   //Disengage the Brake
  analogWrite(11, 255);    //Spins the motor at full speed

if (ballsensor=1){ //If ball is sensed, b increases by 1

servoOnen.write(90); // Turn Servo to center position (90 degrees)
servoOnen.write(45); //Turn Servo to 45 degrees

++b              //Increases b by 1

}}

while (b==3){
    //Motor A brake
  digitalWrite(12, LOW); //Stops forward direction
  digitalWrite(9, HIGH);   //Engages the Brake
  analogWrite(3, 0);   //Stops the motor

  //Motor B brake
  digitalWrite(13, LOW);  //Stops forward direction
  digitalWrite(8, HIGH);   //Engages the Brake
  analogWrite(11, 0);    //Stops the motor
 


I have no idea if this will work since we havent had the change to hook any motors or sensors up yet, but this is the hopefully beginning of the coding. I looked around to find coding and based whats written off of that so not sure if this will sync up or what but theres the start.
« Last Edit: February 12, 2013, 08:53:32 pm by mwebby93 » Logged

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 50
Posts: 2202
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

use the code tags when posting code!

You can't use Servo with a standard motor shield (they both try to make use of the timer on pin 9).

Mark
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

use the code tags when posting code!

You can't use Servo with a standard motor shield (they both try to make use of the timer on pin 9).

Mark

Didnt realize, modified my post. Anyway, so I just cant use the servo library then? What exactly does that library do? Is there any special coding I will have to include to make servos work correctly?

Thanks
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 109
Posts: 4066
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


There is a golf ball at each corner of the square path the robot needs to go around so when it senses the ball and the counter reaches a certain number then itll turn.

The question still remains, how are you going to ensure that it runs straight and turns 90 degrees ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have no idea if this will work since we havent had the change to hook any motors or sensors up yet,
That doesn't mean that you couldn't have at least tried to compile it. That would alleviate any concern about whether it would run, or not.

Code:
}}
Don't come back with code like this. Each } goes on its own line. I prefer each { on a new line, too. And you definitely need to learn about Tools + Auto Format.
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 109
Posts: 4066
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It won't compile anyway because the code posted comes to an abrupt end like this
Code:
  //Motor B brake
  digitalWrite(13, LOW);  //Stops forward direction
  digitalWrite(8, HIGH);   //Engages the Brake
  analogWrite(11, 0);    //Stops the motor
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It won't compile anyway because the code posted comes to an abrupt end like this
Code:
 //Motor B brake
  digitalWrite(13, LOW);  //Stops forward direction
  digitalWrite(8, HIGH);   //Engages the Brake
  analogWrite(11, 0);    //Stops the motor


I am in the middle of writing up some of the coding, I havent finished which is why it stops there.


UKHeliBob: The track we have to run on doesn't have a line for it to follow and get the outside balls.

___________________
I   .          .          .   I
I              .               I
I              _              I  
I   .---.---I_I---.---.    I  
I                              I
I              .               I
I   .          .          .    I
I___________________I

Hard to show but each . is a golf ball. The only lines are a cross horizontal and vertical intersecting through the box in the middle. I didnt put in the vertical line but it is in the middle of the track where the four . are lined up vertical.

The one idea we had was to have two distance sensors on one side of the robot (front and back) that is closest to the outside wall of the track and if they are the same value the wheels spin the same speed. If one is greater than the other then the wheels spin different speeds to correct it then continue at the same speed when the distance is the same again.

Any input or opinion of that idea would be greatly appreciated.

Thanks for everyones help so far. I am very new to the arduino coding. The only background I have is a digital electronics class where we used the board of education. But then again we only had little time with the board doing some very basic programs.
« Last Edit: February 13, 2013, 01:31:44 pm by mwebby93 » Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 109
Posts: 4066
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Using the outer walls to provide a distance measurement and keeping the robot parallel to them sounds like it could work. 

Is the objective to collect as many/all of the golf balls in the shortest possible time or something else ?  Using the vertical and horizontal lines would allow you to collect 8 of the balls using a line follower and the distance of the outer balls on the lines indicates the distance to maintain away from the wall to get the other 4. 

What you need to do is to work out the shortest path for the robot to travel to collect all the balls using the lines and the walls as reference points.  What sort of size is the pattern and how big will your robot be ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Using the outer walls to provide a distance measurement and keeping the robot parallel to them sounds like it could work.  

Is the objective to collect as many/all of the golf balls in the shortest possible time or something else ?  Using the vertical and horizontal lines would allow you to collect 8 of the balls using a line follower and the distance of the outer balls on the lines indicates the distance to maintain away from the wall to get the other 4.  

What you need to do is to work out the shortest path for the robot to travel to collect all the balls using the lines and the walls as reference points.  What sort of size is the pattern and how big will your robot be ?

The design that my team has come up with involves driving down the middle of the balls and collecting the balls on each side of the bot at the same time. Basically you have 8 balls on a large outside square and 4 on the inside, smalled square. Our idea is to have the robot do a path in the middle of these two squares and when it senses a ball on the outside arm (on the "large square") it will swing both arms on each side to collect any balls there.

The track is 8'x8' with the outside perimeter of the 8 golf balls 16" from the outside wall. The balls on the out most "square" are spaced 36" apart and the balls that line up on the lines are 16" apart. We have already designed how to collect the balls on one trip around the track. Our robot is 7.5" wide before the arms swing out. Once they swing out, it will have a "wing span" of about 18". Provided the wall sensor(s) mounted on the chassis of the robot, it would have to read the wall from about 20" away.

Our task is to collect all 12 balls and deposit them in the middle box under a minute. Our goal is to do this in under 30 seconds. We think it can be done a lot quicker but that is the goal we have set for now. Its the reason that we are trying to collect all of the balls on one trip around so its quicker and less travel the robot would need to do.


*edit: the robot's dimensions are 11.5" long x 7.5" wide which is set by the design we have and then the height can be up to 10" but with our design to get the balls into the center box we will have a chassis plate about 4" high and then another, smaller, plate at about 7" high that will hold the micro controller and circuits.

BTW, the outside walls and center box are made from 2x4s
« Last Edit: February 13, 2013, 04:36:20 pm by mwebby93 » Logged

Pages: [1]   Go Up
Jump to: