Go to Post Your attribute of personal sacrifice is very noble, but FIRST needs YOU to be successful first. - DanKein [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rating: Thread Rating: 15 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 19-04-2013, 04:53
toyalima toyalima is offline
Registered User
no team
 
Join Date: Apr 2013
Rookie Year: 2012
Location: New York
Posts: 1
toyalima is an unknown quantity at this point
Controlling robot with arduino

Hi,
I am trying to control one of our old robots with arduino. But I really don't know where to begin. Arduino UNO has 6 PWM pins to which I can connect the victors. But I am not sure how I can control with joysticks. Could you please give me some clue?
  #2   Spotlight this post!  
Unread 19-04-2013, 06:10
ThaDeanesta ThaDeanesta is offline
Registered User
AKA: Kyle
FRC #0175 (Buzz Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Connecticut
Posts: 6
ThaDeanesta is an unknown quantity at this point
Smile Re: Controlling robot with arduino

It is doable, but requires much more effort than its worth.

First, you'd need to get an Arduino Ethernet Shield to connect the Arduino to an ip network.

You'd then need to write a client application that controls the robot, along with sending the joystick button states, axis values, and other data to the arduino, over the network. (Not as easy as it sounds)

You'd also need to write a program for the arduino that SAFELY gets the values from the computer (joystick and control mode: disabled or enabled), and uses them to set the values of victors/spikes/solenoids/etc... Be sure to implement important safety features like having the robot automatically disable when communication is lost, not driving out of control, etc.

It's a long process, and can be a great learning experience. IF you're looking for a quick and easy way to get an old robot running, this is not the way to do it.

Feel free to contact me if you want more details or have any questions.
  #3   Spotlight this post!  
Unread 19-04-2013, 06:57
protoserge's Avatar
protoserge protoserge is offline
CAD, machining, circuits, fun!
AKA: Some call me... Tim?
FRC #0365 (MOE) & former 836 Mentor)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2002
Location: Wilmington, DE
Posts: 754
protoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond repute
Re: Controlling robot with arduino

First off, this is a great project! I would definitely suggest you do this. It's not anything that hasn't been done before so you should find plenty of information in a quick Google search (remember there is nothing really different between the FRC robot and a robot someone made in their workshop using RC car components - the building blocks are the same. You may want to look at ArduRover and ArduPilot.

There are actually some products readily available to help, such as this shield that interfaces with the digital sidecar <http://www.andymark.com/product-p/am-2258.htm>

I assume you will simply be replicating what the FRC control system does on this old robot, so I would suggest to first list out all the motors, motor controllers, sensors, spike relays and the method which they are controlled in software (PID loop, PWM, Meccanum drive, tank drive, etc.) This will help you build a plan for the pins and the coding.

From there on out, you will be tackling each subsystem: drive, manipulator/shooter/scoring/collecting device, and any other features of the robot in code. I'd focus on getting it controlled one motor controller at a time and work up to more complex loops as your skill increases.

Are you using pneumatics?
  #4   Spotlight this post!  
Unread 19-04-2013, 08:50
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 688
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: Controlling robot with arduino

An Arduino Motor Shield will help, too.

Arduino site: http://arduino.cc/en/Main/ArduinoMotorShieldR3
Ladyada tutorial: http://www.ladyada.net/make/mshield/
Sparkfun's version: https://www.sparkfun.com/products/9815
  #5   Spotlight this post!  
Unread 19-04-2013, 09:19
ajlapp ajlapp is offline
Registered User
AKA: Anthony Lapp
None #0118 (Team RUSH and Robonauts)
 
Join Date: Sep 2001
Rookie Year: 1996
Location: Ortonville, MI
Posts: 648
ajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond repute
Re: Controlling robot with arduino

This is not a hard challenge! Check out our RobotOpen driver station app...

www.robotopen.biz

Our HTML5 app will allow you to read USB gamepads and directly control your Arduino board. It offers two way communications, data logging, live parameters and a host of other features.

Free open-source download.

We have shields as well if you'd like to interface with an existing digital sidecar or pneumatics bumper.
__________________
Anthony Lapp
FIRST Engineering Mentor
Owner/Operator 221 Robotic Systems
221 Robotics Systems - Quality Hardware, Made in the USA
RobotOpen
anthony@221robotics.com
Twitter us: @221RobotSystems
Team 1 --> 94 --> 68 --> 221 --> 857 --> 27 --> 118
Design Engineer/Fabricator and 17 year vet
Team Rush (FRC27) and Robonauts (FRC118)
  #6   Spotlight this post!  
Unread 19-04-2013, 10:54
fb39ca4 fb39ca4 is offline
Registered User
FRC #1899
 
Join Date: Jan 2012
Location: Bellevue, WA
Posts: 195
fb39ca4 is a name known to allfb39ca4 is a name known to allfb39ca4 is a name known to allfb39ca4 is a name known to allfb39ca4 is a name known to allfb39ca4 is a name known to all
Re: Controlling robot with arduino

Quote:
Originally Posted by ThaDeanesta View Post
First, you'd need to get an Arduino Ethernet Shield to connect the Arduino to an ip network.
Alternatively, you can get a cheap RC plane controller with a receiver that outputs PWM signals.
  #7   Spotlight this post!  
Unread 19-04-2013, 18:27
mman1506's Avatar
mman1506 mman1506 is offline
Hater of Tiny Molex Connectors
AKA: Marcus Quintilian
no team (WARP7)
Team Role: Alumni
 
Join Date: Mar 2012
Rookie Year: 2012
Location: Toronto
Posts: 807
mman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond reputemman1506 has a reputation beyond repute
Re: Controlling robot with arduino

Quote:
Originally Posted by Roger View Post
An Arduino Motor Shield will help, too.

Arduino site: http://arduino.cc/en/Main/ArduinoMotorShieldR3
Ladyada tutorial: http://www.ladyada.net/make/mshield/
Sparkfun's version: https://www.sparkfun.com/products/9815
A motor shield will not be useful for anything FIRST related. The speed controllers communicate using PWM
__________________
2014-2015: FRC 865 Warp7 Team Captain
2016: FRC 865 Mentor

2017: Free Agent Mentor, Inspector
  #8   Spotlight this post!  
Unread 19-04-2013, 20:26
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Controlling robot with arduino

Quote:
Originally Posted by mman1506 View Post
The speed controllers communicate using PWM
Specifically "hobby servo PWM".
  #9   Spotlight this post!  
Unread 20-04-2013, 07:54
Gdeaver Gdeaver is offline
Registered User
FRC #1640
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 2001
Location: West Chester, Pa.
Posts: 1,370
Gdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond repute
Re: Controlling robot with arduino

There is a USB Host shield for the Arduino. There are 3rd party library's available that would allow a wireless PlayStation 3 controler to work with the arduino. This would give a minimal blue tooth connection to the arduino for control.
  #10   Spotlight this post!  
Unread 20-04-2013, 21:21
jacob9706 jacob9706 is offline
Registered User
AKA: Jacob Ebey
FRC #3574 (High Tekerz)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Seattle
Posts: 101
jacob9706 is on a distinguished road
Re: Controlling robot with arduino

Quote:
Originally Posted by toyalima View Post
Hi,
I am trying to control one of our old robots with arduino. But I really don't know where to begin. Arduino UNO has 6 PWM pins to which I can connect the victors. But I am not sure how I can control with joysticks. Could you please give me some clue?
I have yet to order one but these look promising http://www.team221.com/robotopen/product.php?id=105
__________________
/*
* Team 3574 Alumni
*
* 2011 - Highest Seeded Rookie
* 2011 - Rookie All-Star
* 2012 - Engineering Inspiration
* 2012 - Olympic Deans List Winner
* 2013 - Engineering Inspiration
* 2013 - Judges Award (For unique circular robot and the way the team works together.)
*/
  #11   Spotlight this post!  
Unread 21-04-2013, 10:37
ajlapp ajlapp is offline
Registered User
AKA: Anthony Lapp
None #0118 (Team RUSH and Robonauts)
 
Join Date: Sep 2001
Rookie Year: 1996
Location: Ortonville, MI
Posts: 648
ajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond repute
Re: Controlling robot with arduino

Like I stated above, you only need our RobotOpen Control Shield if you want to continue using your digital Sidecar.

Some features will be lost of course, but in general our driver station app will perform as expected using just an Ethernet enabled Arduino.
__________________
Anthony Lapp
FIRST Engineering Mentor
Owner/Operator 221 Robotic Systems
221 Robotics Systems - Quality Hardware, Made in the USA
RobotOpen
anthony@221robotics.com
Twitter us: @221RobotSystems
Team 1 --> 94 --> 68 --> 221 --> 857 --> 27 --> 118
Design Engineer/Fabricator and 17 year vet
Team Rush (FRC27) and Robonauts (FRC118)
  #12   Spotlight this post!  
Unread 21-04-2013, 12:31
dtengineering's Avatar
dtengineering dtengineering is offline
Teaching Teachers to Teach Tech
AKA: Jason Brett
no team (British Columbia FRC teams)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Vancouver, BC
Posts: 1,833
dtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond repute
Re: Controlling robot with arduino

You can do this cheaply and easily... you just have to think outside the cRio/FRC "box" a bit. I currently have a small "fleet" of vehicles running using Victor 888 controllers and CIM motors attached to Arduino Unos. It works great, and is quite easy to do... I've etched custom shields to attach the speed control pins and joystick (or bluetooth) connections, but you could do this easily enough using a breadboard, and then solder it up onto some perfboard/protoboard. I did have to recalibrate the Victors, as the Arduino was giving me slightly longer pulses than expected, but that is really easy to do... just push the "calibration" button on the Victor and move the joystick full circle to give "max" and "min" signals to the Victor, then let go of the stick.

Here's some code for controlling Victors on Pin8 and Pin9 using "joystick" mode, from a joystick connected to A2 and A3. The code will also print the values to your serial monitor. The downside is that it requires a joystick to be wired to your uno/robot at all times. (Which, in the application we have, where the driver is sitting on the vehicle... works great!)

Code:
#include <Servo.h> //include the Servo library for controlling the Victor speed controls

Servo motor_l;     //left motor servo object will be attached to pin 8
Servo motor_r;     //right motor servo object will be attached to pin 9
const int joy1_x = 2;   //the first joystick's x axis will be on analog input A2
int joy1_x_val;            // the value that we read from joystick 1's x axis
const int joy1_y = 3;   //the first joystick's y axis will be on analog input A3
int joy1_y_val;            // the value that we read from joystick 1's y axis
const int joy1_sw = 3;   //the first joystick's switch will be on digital input 3
const int led = 13;      //an led indicator to show whats going on (there should be one on the arduino board)
int left_motor;      //the value between 0 (full reverse) and 180 (full forward) to send to the left motor
int right_motor;      // the value to send to the right motor (90=stop)

void setup () {
  motor_l.attach(8); //attach the servo object to the correct digital output pins
  motor_r.attach(9);
  
  Serial.begin(9600);
  
  pinMode (led,OUTPUT);
  pinMode (joy1_sw,INPUT_PULLUP);
  digitalWrite (led,HIGH);
  delay (250);
}

void loop () {
  joy1_x_val=map (analogRead(joy1_x),0,1023,0,180); //read the joystick's analog value (0-1023)
  joy1_y_val=map (analogRead(joy1_y),0,1023,0,180); //and map it to the servo range of (0-180)
  left_motor= (joy1_y_val - joy1_x_val)+90;          // then mix the signals for "one stick drive"
  right_motor= (joy1_y_val + joy1_x_val)-90;
  motor_l.write(left_motor);                        //assign the resulting values to the servo pins
  motor_r.write(right_motor);
  
  Serial.print("Joy1x:");
  Serial.print(joy1_x_val);
  Serial.print("\t");
  Serial.print("Joy1y:");
  Serial.print(joy1_y_val);
  Serial.print("\t");
  Serial.print("Left Motor:");
  Serial.print(left_motor);
  Serial.print("\t");
  Serial.print("Right Motor:");
  Serial.println(right_motor);
  
  digitalWrite (led,digitalRead(joy1_sw));
  
  delay (10);
  
}
But this is the code I really like... purchase a bluetooth serial dongle, and connect it to pin0 and pin1 on the Arduino. (Note that you'll have to remove the dongle when programming the Arduino.) The download BlueBots to your Android phone. Pair your phone to the dongle, run BlueBots and you've got wireless control of your robot... from your phone.

By the way, you can get BlueBots Pro for $1.65... definitely worth it to support the developer considering that you'll replace about $1,000 of robot control equipment with a $30 Arduino, $10 bluetooth dongle and an Android phone that you may already own.

Code:
#include <Servo.h>

Servo motorL;
Servo motorR;
int motorLspeed;
int motorRspeed;

int joyX=0;
int joyY=0;
int slide1=0;
int slide2=0;
int checksum=0;
int double_check=0;


unsigned long last_time=millis();
void setup () {
  Serial.begin(9600);
  motorL.attach(8);
  motorR.attach(9);
}
// Read the data packed from Bluebot's joystick mode
void loop () {
  if (Serial.available()>0) {
    double_check=0;
    if (Serial.read()==125) { //125 indicates a joystick packet
      joyX=Serial.read(); // type mismatch issues occur
        if (joyX>128) joyX=joyX-256; //so make sure we get the negatives correct
      joyY=Serial.read();
        if (joyY>128) joyY=joyY-256;
      slide2=Serial.read();
      slide1=Serial.read();
      checksum=Serial.read(); //see Bluebots help file for checksum
      double_check=(125+joyX+joyY+slide1+slide2)%256;
      last_time=millis();
    }
  }
 // Timeout routine to stop motors if signal is lost for 500ms
 // also stops the motors if the checksum indicates lost data
 // This section would be better if I used 2x oversampling and
 // only killed the motors if two checksums in sequence were flawed
 // This section can be commented out, but it does play a safety role
 // in the event that Bluetooth communication is lost
  if ((millis()-last_time)>500||(checksum!=double_check)){
   joyX=0;
   joyY=0;
   slide2=62;
   slide1=62;
   if (millis()-last_time>500)Serial.println("Time Out");
   if (checksum!=double_check)Serial.println("Checksum Error");
  }
  
  // Map and send motor outputs
  motorLspeed=joyY-joyX;
  motorLspeed=map(motorLspeed,-124,124,0,180);
  motorLspeed=constrain(motorLspeed,0,180);
  
  motorRspeed=joyY+joyX;
  motorRspeed=map(motorRspeed,-124,124,0,180);
  motorRspeed=constrain(motorRspeed,0,180);
  
  motorL.write(motorLspeed);
  motorR.write(motorRspeed);
  
  delay(10);
  
/* Debugging print routine
  Serial.print("X");
  Serial.print(joyX);
  Serial.print(" Y");
  Serial.print(joyY);
  Serial.print(" S1 ");
  Serial.print(slide1);
  Serial.print(" S2 ");
  Serial.print(slide2);
  Serial.print(" Chk ");
  Serial.print(checksum); 
  Serial.print(" DblChk ");
  Serial.print((double_check));
  Serial.print(" MotL ");
  Serial.print(motorLspeed);
  Serial.print(" MotR ");
  Serial.println(motorRspeed);
  delay(100);
//*/  
}
And remember to keep your fingers away from the motors and chains/belts when experimenting!

Jason

Last edited by dtengineering : 21-04-2013 at 12:41.
  #13   Spotlight this post!  
Unread 21-04-2013, 14:53
Foster Foster is offline
Engineering Program Management
VRC #8081 (STEMRobotics)
Team Role: Mentor
 
Join Date: Jul 2007
Rookie Year: 2005
Location: Delaware
Posts: 1,394
Foster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond repute
Re: Controlling robot with arduino

Highly recommend the Romeo robotic controller board. It supports XBee devices, so all you need is this device as a remote controller. All up, Romeo, controller, 2 - Xbees and battery sets will be $175.
__________________
Foster - VEX Delaware - 17 teams -- Chief Roboteer STEMRobotics.org
2010 - Mentor of the Year - VEX Clean Sweep World Championship
2006-2016, a decade of doing VEX, time really flies while having fun
Downingtown Area Robotics Web site and VEXMen Team Site come see what we can do for you.
  #14   Spotlight this post!  
Unread 24-04-2013, 13:20
ken.3038 ken.3038 is offline
Registered User
FRC #3038 (I.C.E.)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Minnesota
Posts: 13
ken.3038 is an unknown quantity at this point
Re: Controlling robot with arduino

6 weeks ago I saw AndyMark had the Arduino kit for $130 and now they have sold out. Could this possibly replace the CRio?
  #15   Spotlight this post!  
Unread 28-04-2013, 23:27
tanguma26 tanguma26 is offline
Registered User
FRC #3999
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Killeen
Posts: 48
tanguma26 is an unknown quantity at this point
Re: Controlling robot with arduino

I have just purchase one of this arduino from AnyMark and I have done all the programming and I am ready to test it on a robot that we have design and pour our personal money. My question is how can you attached a solenoid? Would you hook it on the relay ports on the sidecard? or would you use a spike to operate the solenid, we are using 12V solenoids. Also I though about using this cheap relays that we use at my school for simple projects but the coil is rated at 12VDC as well and as far as I know the sidecard can put out a max of 5V.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 15:17.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi