Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Controlling robot with arduino (http://www.chiefdelphi.com/forums/showthread.php?t=116235)

toyalima 19-04-2013 04:53

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?

ThaDeanesta 19-04-2013 06:10

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.

protoserge 19-04-2013 06:57

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?

Roger 19-04-2013 08:50

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

ajlapp 19-04-2013 09:19

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.

fb39ca4 19-04-2013 10:54

Re: Controlling robot with arduino
 
Quote:

Originally Posted by ThaDeanesta (Post 1264702)
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.

mman1506 19-04-2013 18:27

Re: Controlling robot with arduino
 
Quote:

Originally Posted by Roger (Post 1264730)
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

Alan Anderson 19-04-2013 20:26

Re: Controlling robot with arduino
 
Quote:

Originally Posted by mman1506 (Post 1264916)
The speed controllers communicate using PWM

Specifically "hobby servo PWM".

Gdeaver 20-04-2013 07:54

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.

jacob9706 20-04-2013 21:21

Re: Controlling robot with arduino
 
Quote:

Originally Posted by toyalima (Post 1264696)
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

ajlapp 21-04-2013 10:37

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.

dtengineering 21-04-2013 12:31

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

Foster 21-04-2013 14:53

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.

ken.3038 24-04-2013 13:20

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?

tanguma26 28-04-2013 23:27

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.

ajlapp 29-04-2013 09:05

Re: Controlling robot with arduino
 
Quote:

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.
You cannot hook the solenoid to the relay pins on the Sidecar as the RobotOpen Controller does not communicate directly with those pins.

You can wire a Spike to the DIO outputs and use that to control your solenoid. See here for previous attempts at doing this. Control Spike using Arduino

Alternately you can use our RobotOpen Solenoid Shield which directly interfaces with the KOP pneumatics bumper and gives you control of 8 solenoid outputs. The Solenoid shield stacks under the control shield and is addressable using the same RobotOpen interface and libraries.

RobotOpen Solenoid Shield

Anatole 29-04-2013 14:52

Re: Controlling robot with arduino
 
EDIT: Woops, didn't notice that post up there ^

tanguma26 29-04-2013 18:39

Re: Controlling robot with arduino
 
Thank you for your response and we are going to look into the solenoid shield it seem like a good investment. Also I have an other question is there a way to monitor the battery usage on the robot throw the arduino. I know that the cRio uses the first slot to monitor the battery of the robot. I have search and the only thing that I have found is a component call voltwatch but it connects to the battery and it displays the voltage on a display that the device has.

-Thank you

dtengineering 29-04-2013 20:12

Re: Controlling robot with arduino
 
Quote:

Originally Posted by tanguma26 (Post 1269489)
Thank you for your response and we are going to look into the solenoid shield it seem like a good investment. Also I have an other question is there a way to monitor the battery usage on the robot throw the arduino. I know that the cRio uses the first slot to monitor the battery of the robot. I have search and the only thing that I have found is a component call voltwatch but it connects to the battery and it displays the voltage on a display that the device has.

-Thank you

Put a voltage divider on the +12v line. Use a 2k resistor on the high side and a 1k resistor on the low... you'll end up with a voltage output between 0-4v.

Well, technically it will be higher than that when the battery is fully charged, becuase the battery will be at about 13.3V. In any case, you can use one of the analog inputs on the Arduino to measure the voltage from the voltage divider. Use serial.Println to display the analog reading, and compare it to the voltage you measure... this gives you a conversion factor to turn the raw ADC voltage reading into a true battery voltage reading.

Jason

tanguma26 30-04-2013 01:09

Re: Controlling robot with arduino
 
I understand how to wire it on the arduino but i am having some problems on the programming an its logic so far following the example from the library I have

ROAnalog analogZero(0);// Analog Channel 0 declaring which analog input to use

and

RODashboard.publish("Analog0", analogZero.read()); // Display on dashboard


but were is the logic of the conversion going to go. Is it on the enable loop and if it is do I use a "int read();"

tr6scott 30-04-2013 08:16

Re: Controlling robot with arduino
 
http://youtu.be/jde3CIXQ8Jw



I picked up the relay board off of eBay, this was prior to 221 developing the solenoid shield. If I did it today, I would just by the shield.

Code:

#include <SPI.h>
#include <Ethernet.h>
#include <RobotOpen.h>

/* I/O Setup */
USBJoystick usb1('0');  // Assign the logitech USBJoystick object to bundle 0
//==================
int JoyBtn3 = LOW;
int LastJoyBtn3 = LOW;
long LastJoyBtn3time;
long JoyBtn3Debounce = 250;
int JoyBtn3Toggle = LOW;
//==============================
int lastJsBtn1 = LOW;
int JsBtn1;
int DeJsBtn1;
int lastDeJsBtn1 = LOW;
long lastDebounceTime = 0;
long debounceDelay = 50;
int toggletrue = LOW;
int SD1 = LOW;
//==============================
int LastEnabled = LOW;
int Enabled1Shot = LOW;
//===============================
int CaseVar = 1;
long AENT;
long ASTALL = 1000;
long BENT;
long BSTALL = 1000;
long CENT;
long CSTALL = 1000;
int ShootBtn;
int LOHI;
// Variables for the Pressure Switch and Compressor logic.
int PS;
int DePS;
int lastPS;
int Compressor = LOW;
long PSdebounceDelay = 500;
long PSlastDebounceTime = 0;
// Varialbes for Cheesy Drive
int DriveSelect;
int Throttle = 0;
int ThrottleABS = 0;
int Wheel = 0;
float QTSens = 1.0;
float STSens = 1.2;
float RLAdjustment = 0.0;
int RHPower;
int LHPower;
float BatMultiplier = 4.0;
long batvolt=0.0;
const int analogInPin = A0;
int sensorValue;

void setup()
{
  /* Initiate comms */
  RobotOpen.begin();
  // Serial.begin(9600); // Serial Monitor
  pinMode(SIDECAR_DIGITAL1, OUTPUT);
  pinMode(SIDECAR_DIGITAL2, OUTPUT);
  pinMode(SIDECAR_DIGITAL3, OUTPUT);
  pinMode(SIDECAR_DIGITAL4, OUTPUT);
  pinMode(SIDECAR_DIGITAL5, OUTPUT);
  pinMode(SIDECAR_DIGITAL6, OUTPUT);
  pinMode(SIDECAR_DIGITAL7, INPUT);
  pinMode(SIDECAR_DIGITAL8, INPUT);
}

/* This is your primary robot loop - all of your code
 * should live here that allows the robot to operate
 */

void enabled() {
  int DriveSelect = digitalRead(SIDECAR_DIGITAL8);
  if (DriveSelect == HIGH) {
    //    digitalWrite(SIDECAR_DIGITAL5, LOW); // used digital 5 for debug     
    // Do Tank Drive
    // Constantly update PWM values with joystick values
    RobotOpen.setPWM(SIDECAR_PWM1, usb1.makePWM(ANALOG_LEFTY, INVERT));
    RobotOpen.setPWM(SIDECAR_PWM2, usb1.makePWM(ANALOG_LEFTY, INVERT));
    RobotOpen.setPWM(SIDECAR_PWM3, usb1.makePWM(ANALOG_RIGHTY, INVERT));
    RobotOpen.setPWM(SIDECAR_PWM4, usb1.makePWM(ANALOG_RIGHTY, INVERT));
  }
  else
    // Do HALO Drive with QuickTurn
  {
    //  digitalWrite(SIDECAR_DIGITAL5, HIGH); // used digital 5 for debug     
    //Throttle = usb1.getIndex(ANALOG_LEFTY)-127;
    //Wheel = usb1.getIndex(ANALOG_RIGHTX)-127;
    Throttle = usb1.makePWM(ANALOG_LEFTY, INVERT)-127;
    Wheel = usb1.makePWM(ANALOG_RIGHTX, NORMAL)-127;
    //Wheel = usb1.getIndex(ANALOG_RIGHTX)-127;
    // The Value returned from the Joystick is between 0 and 255, subracting 127 makes it -127 to 128)
    // We like approx. 10% Dead band around 0 on the sticks, so we will apply that first.
    if (Throttle < 22 && Throttle > -22) {
      Throttle = 0;
    }
    if (Wheel < 22 && Wheel > -22) {
      Wheel = 0;
    }
    // Now need to check if QuickTurn can be active, ie throttle is less than 25%
    if (Throttle < 32 && Throttle > -32) {
      //Quickturn can be used.
      //digitalWrite(SIDECAR_DIGITAL5, LOW); // used digital 5 for debug     
      RLAdjustment = Wheel * QTSens;
    }
    else
    {
      // SpeedTurn to be used.
      //digitalWrite(SIDECAR_DIGITAL5, HIGH); // used digital 5 for debug     
      ThrottleABS = abs(Throttle);
      //    RLAdjustment = (ThrottleABS * Wheel * STSens) / 127;
      RLAdjustment = ((ThrottleABS / 127.0) * Wheel * STSens) ;
    }
    LHPower = Throttle + RLAdjustment + 127;
    RHPower = Throttle - RLAdjustment + 127;
    LHPower = constrain(LHPower, 0, 255);
    RHPower = constrain(RHPower, 0, 255);
    //RobotOpen.setPWM(SIDECAR_PWM1, makePWM(LHPower, NORMAL));
    RobotOpen.setPWM(SIDECAR_PWM1, LHPower);
    RobotOpen.setPWM(SIDECAR_PWM2, LHPower);
    RobotOpen.setPWM(SIDECAR_PWM3, RHPower);
    RobotOpen.setPWM(SIDECAR_PWM4, RHPower);
  }

  // Dbounce the Pressure Switch
  int PS = digitalRead (SIDECAR_DIGITAL7);
  if (PS != lastPS) {
    PSlastDebounceTime = millis();
  }
  if ((millis() - PSlastDebounceTime) > PSdebounceDelay) {
    DePS = PS;
  }
  lastPS = PS;
  Compressor = ! DePS; // Compressor Runs when Pressure Switch is not on.

  //Debounce the Short/Long Toggle
  int reading = usb1.getBtn(BTN1, NORMAL);
  if (reading != lastJsBtn1) {
    lastDebounceTime = millis();
  }
  if ((millis() - lastDebounceTime) > debounceDelay) {
    JsBtn1 = reading;
  }
  DeJsBtn1 = reading;

  // TOGGLE Code for Digital Output 1 =====================================
  if (DeJsBtn1 == HIGH && lastDeJsBtn1 == LOW && SD1 == HIGH) {
    SD1 = LOW;
    toggletrue = HIGH;
  }
  if (DeJsBtn1 == HIGH && lastDeJsBtn1 == LOW && SD1 == LOW && toggletrue == LOW) {
    SD1 = HIGH;
    LOHI = 1;
  }
  lastDeJsBtn1 = DeJsBtn1;
  toggletrue = LOW;

  // Ball Gatherer Motor 
  JoyBtn3 = usb1.getBtn(BTN3, NORMAL);
  // if the input just went from LOW and HIGH and we've waited long enough
  // to ignore any noise on the circuit, toggle the output pin and remember
  // the time
  if (JoyBtn3 == HIGH && LastJoyBtn3 == LOW && millis() - LastJoyBtn3time > JoyBtn3Debounce) {
    if (JoyBtn3Toggle == HIGH)
      JoyBtn3Toggle = LOW;
    else
      JoyBtn3Toggle = HIGH;

    LastJoyBtn3time = millis();   
  }
  LastJoyBtn3 = JoyBtn3;
  // =============================================================== 
  if (JoyBtn3Toggle == HIGH) {
    RobotOpen.setPWM(SIDECAR_PWM5, 227); // 203=0.6 in labview, Austin Tai said that was what they used.
      // digitalWrite(SIDECAR_DIGITAL5, HIGH); // used digital 5 for debug 
  }
  else
  {
    RobotOpen.setPWM(SIDECAR_PWM5, 127);
    //digitalWrite(SIDECAR_DIGITAL5, LOW); // used digital 5 for debug
  }
  //========================================================================
  switch (CaseVar) {
  case 1:
    AENT = millis();
    CaseVar = 2;
    break;
  case 2:
    digitalWrite(SIDECAR_DIGITAL2, LOW);
    digitalWrite(SIDECAR_DIGITAL3, LOW);
    if ((AENT + ASTALL) < millis()) {
      CaseVar = 3;
    }
    break;
  case 3:
    BENT =millis();
    CaseVar = 4;
    LOHI = 0;
    break;
  case 4:
    digitalWrite(SIDECAR_DIGITAL2, HIGH);
    digitalWrite(SIDECAR_DIGITAL3, LOW);
    if ((BENT + BSTALL) < millis()) {
      CaseVar = 5;
    }
    break;
  case 5:
    ShootBtn = usb1.getBtn(BTN2, NORMAL);
    digitalWrite(SIDECAR_DIGITAL2, LOW);
    digitalWrite(SIDECAR_DIGITAL3, LOW);
    if (ShootBtn == HIGH) {
      CaseVar = 6;
    }
    if (LOHI == 1) {
      CaseVar = 3;
    }
    break;
  case 6:
    CENT = millis();
    CaseVar = 7;
    break;
  case 7:
    digitalWrite(SIDECAR_DIGITAL2, LOW);
    digitalWrite(SIDECAR_DIGITAL3, HIGH);
    if ((CENT + CSTALL) < millis()) {
      CaseVar = 1;
    }
    break;
  }
}



/* This is called while the robot is disabled
 * You must make sure to set all of your outputs
 * to safe/disable values here
 */
void disabled() {
  SD1 = LOW;
  digitalWrite(SIDECAR_DIGITAL2, LOW);
  digitalWrite(SIDECAR_DIGITAL3, LOW);
  digitalWrite(SIDECAR_DIGITAL4, LOW);
  digitalWrite(SIDECAR_DIGITAL5, LOW);
  Compressor = LOW;
  LastEnabled = LOW;
  // PWMs are automatically disabled
}


/* This loop ALWAYS runs - only place code here that can run during a disabled state
 * This is also a good spot to put driver station publish code
 * You can use either publishAnalog, publishDigital, publishByte, publishShort, or publishLong
 * Specify a bundle ID with a single character (a-z, A-Z, 0-9) - Just make sure not to use the same twice!
 */
void timedtasks() {
  sensorValue = analogRead(analogInPin); 
  batvolt = (sensorValue/1023.0)*5.0*BatMultiplier;
  RobotOpen.publishInt(CaseVar, 'A');  // Bundle A
  RobotOpen.publishInt(Throttle, 'T'); // Bundle C
  RobotOpen.publishInt(ThrottleABS, 'N'); // Bundle C
  RobotOpen.publishInt(Wheel, 'W'); // Bundle D
  RobotOpen.publishInt(RLAdjustment, 'D');  // Bundle B
  RobotOpen.publishInt(LHPower, 'R'); // Bundle C
  RobotOpen.publishInt(RHPower, 'L'); // Bundle D
  RobotOpen.publishInt(JoyBtn3Toggle, 'G');  // Bundle E
  RobotOpen.publishLong(batvolt, 'B');  // Bundle F
  RobotOpen.publishAnalog(ANALOG0, 'H');  // Bundle F
  digitalWrite(SIDECAR_DIGITAL1, SD1);
  digitalWrite(SIDECAR_DIGITAL6, Compressor);

  //==================
  //  Serial.print("The BallMotor PWM = ");
  //Serial.println(BallMotor);
  //===================
}


/* This is the main program loop that keeps comms operational
 * There's no need to touch anything here!!!
 */
void loop() {
  RobotOpen.pollDS();
  if (RobotOpen.enabled())
    enabled();
  else
    disabled();
  timedtasks();
  RobotOpen.outgoingDS();
}


tanguma26 06-05-2013 18:08

Re: Controlling robot with arduino
 
Is there a way to use the 2009/2010 wireless setup to run with the Arduino? I have follow the instructions from those years but I cant get it ti work I am using a lynksys E2000 router and a WGA600N game adapter any help would be appreciated

-Thank you


All times are GMT -5. The time now is 22:05.

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