Go to Post The game transcends the competition, and this is beautiful. - Taylor [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: 3 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 23-09-2014, 13:12
panther83 panther83 is offline
Registered User
no team
 
Join Date: Feb 2014
Location: Washington, IL
Posts: 10
panther83 is an unknown quantity at this point
Exclamation 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
  #2   Spotlight this post!  
Unread 23-09-2014, 22:29
shadowfios shadowfios is offline
Registered User
FRC #2046
 
Join Date: Feb 2013
Location: United States
Posts: 3
shadowfios is an unknown quantity at this point
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?
  #3   Spotlight this post!  
Unread 23-09-2014, 22:41
panther83 panther83 is offline
Registered User
no team
 
Join Date: Feb 2014
Location: Washington, IL
Posts: 10
panther83 is an unknown quantity at this point
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.
  #4   Spotlight this post!  
Unread 23-09-2014, 22:48
shadowfios shadowfios is offline
Registered User
FRC #2046
 
Join Date: Feb 2013
Location: United States
Posts: 3
shadowfios is an unknown quantity at this point
Re: Arduino with Robot-Open programming help

have you defined usb1 as such:
Code:
ROJoystick usb1(1);
  #5   Spotlight this post!  
Unread 24-09-2014, 11:31
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: Arduino with Robot-Open programming help

Quote:
Originally Posted by panther83 View Post
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.
  #6   Spotlight this post!  
Unread 24-09-2014, 13:05
panther83 panther83 is offline
Registered User
no team
 
Join Date: Feb 2014
Location: Washington, IL
Posts: 10
panther83 is an unknown quantity at this point
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();
}
  #7   Spotlight this post!  
Unread 24-09-2014, 13:06
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: 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();
}
__________________
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)
  #8   Spotlight this post!  
Unread 24-09-2014, 14:13
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: Arduino with Robot-Open programming help

Quote:
Originally Posted by panther83 View Post
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.
  #9   Spotlight this post!  
Unread 25-09-2014, 10:41
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: 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.
__________________
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)
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 03:01.

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