Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Arduino with Robot-Open programming help (http://www.chiefdelphi.com/forums/showthread.php?t=130629)

panther83 23-09-2014 13:12

Arduino with Robot-Open programming help
 
I have a arduino with robot open connected to a relayboard (we only are using one of the 4). It is all wired correctly but we need code so when the "A" button is pressed on our logitech controller, it will activate the relay and send power to our solenoid for a second to activate our t-shirt launcher. The code for this will be put into our existing code for a 4motor tank drive coded modified from the example code from robot open/arduino. I personally have no idea what im doing in programming. :( The relay is hooked up to port 9

shadowfios 23-09-2014 22:29

Re: Arduino with Robot-Open programming help
 
I assume you mean port 8 on the relay shield, as there is no port 9.
you would have to add:
Code:

ROSolenoid solenoid(9);
before your enabled() function. The 9 is because Robot-Open 0-indexs ports.
you would also need to add:
Code:

if (usb1.btnA())   
solenoid.on();
else
solenoid.off();

inside the enabled() function.
This would cause the solenoid to mimic the button presses.
However I cannot test this code as I do not have the hardware myself.
also is it necessary for the burst to be 1 second?

panther83 23-09-2014 22:41

Re: Arduino with Robot-Open programming help
 
When we try to do if statements it gives us an error that it does not have a type.

shadowfios 23-09-2014 22:48

Re: Arduino with Robot-Open programming help
 
have you defined usb1 as such:
Code:

ROJoystick usb1(1);

Alan Anderson 24-09-2014 11:31

Re: Arduino with Robot-Open programming help
 
Quote:

Originally Posted by panther83 (Post 1401262)
When we try to do if statements it gives us an error that it does not have a type.

We can't give good advice based on a paraphrase of your code and a paraphrase of the error message. Show us exactly what you're trying to compile, and exactly what the error says. Someone here will probably recognize exactly what needs to be corrected.

panther83 24-09-2014 13:05

Re: Arduino with Robot-Open programming help
 
this is our current code, we are trying to hook it up to one of the digital ports on the side car itself instead on directly to the arduino robot shield


Code:
#include <SPI.h>
#include <Ethernet.h>
#include <EEPROM.h>
#include <RobotOpen.h>



/* I/O Setup */
ROJoystick usb1(1); // Joystick #1
ROPWM leftmotorone(1);
ROPWM rightmotorone(0);
ROPWM leftmotortwo(2);
ROPWM rightmotortwo(3);



void setup()
{
/* Initiate comms */
RobotOpen.begin(&enabled, &disabled, &timedtasks);
pinMode(SIDECAR_DIGITAL7, OUTPUT);
}


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

void enabled() {
// Constantly update PWM values with joystick values
// Analog sticks feed back values from 0-255
// 255 - usb1.leftY() to invert a drive
leftmotorone.write(255 - usb1.leftY());
rightmotorone.write(usb1.rightY());
leftmotortwo.write(255 - usb1.leftY());
rightmotortwo.write(usb1.rightY());
if (usb1.btnA(1))
digitalWrite(SIDECAR_DIGITAL7, HIGH);
else
digitalWrite(SIDECAR_DIGITAL7, LOW);

}


/* This is called while the robot is disabled
* PWMs and Solenoids are automatically disabled
*/
void disabled() {
// safety code
}


/* 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
*/
void timedtasks() {
RODashboard.publish("Uptime Seconds", ROStatus.uptimeSeconds());
}


// !!! DO NOT MODIFY !!!
void loop() {
RobotOpen.syncDS();
}

ajlapp 24-09-2014 13:06

Re: Arduino with Robot-Open programming help
 
The code below, copied from the "digital" example provided with the library should work fine.

Code:

#include <SPI.h>
#include <SD.h>
#include <Ethernet.h>
#include <Servo.h>
#include <EEPROM.h>
#include <RobotOpen.h>



/* I/O Setup */
ROJoystick usb1(1);              // Joystick #1
RODigitalIO dig1Out(9, OUTPUT);  // DIO channel 9, output mode


void setup()
{
  /* Initiate comms */
  RobotOpen.begin(&enabled, &disabled, &timedtasks);
}


/* This is your primary robot loop - all of your code
 * should live here that allows the robot to operate
 */
void enabled() {
  if (usb1.btnA())
    dig1Out.on();
  else
    dig1Out.off();
}


/* This is called while the robot is disabled
 * All outputs are automatically disabled (PWM, Solenoid, Digital Outs)
 */
void disabled() {
  // safety code
}


/* 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
 */
void timedtasks() {
  RODashboard.publish("Uptime Seconds", ROStatus.uptimeSeconds());
}


// !!! DO NOT MODIFY !!!
void loop() {
  RobotOpen.syncDS();
}


Alan Anderson 24-09-2014 14:13

Re: Arduino with Robot-Open programming help
 
Quote:

Originally Posted by panther83 (Post 1401347)
this is our current code...
Code:

if (usb1.btnA(1))

What are the correct arguments for the btnA method? Examples show it with empty parentheses usb1.btnA() but you have tried to pass it a number.

You didn't show us the error message, but I'm guessing it says something clear about the mismatch between the expected and supplied parameter types.

ajlapp 25-09-2014 10:41

Re: Arduino with Robot-Open programming help
 
This issue was solved for the OP offline.

They didn't have their Arduino libraries setup properly...on top of the improper code.


All times are GMT -5. The time now is 02:43.

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