Go to Post We like playing with power tools, stripping wire, or just stripping for alliance partners... - Amanda Morrison [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 18-09-2015, 21:42
cwengineer's Avatar
cwengineer cwengineer is offline
Engineering Mentor
AKA: Corey
FRC #3265 (RoboTribe)
Team Role: Engineer
 
Join Date: Sep 2015
Rookie Year: 2007
Location: Georgia
Posts: 6
cwengineer is an unknown quantity at this point
RobotOpen Digital Sidecar Programming

I am working on an off-season project using an Arduino and a the RobotOpen Control Shield connected to the DSC. I have the Arduino communicating with the RobotOpen DS.
The problem I am running into is the code to interface with the DSC.
Using RobotOpen Documentation I tried ROPWM but the DSC PWM pins don't seem to output.

Does anyone have any experience with the RobotOpen Controller running the DSC?

My code is pulled right from their ArcadeDrive example and my left/right motors are plugged into the DSC PWM 0/1.
My ultrasonic sensor portion of the code works fine.

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

/* I/O Setup */
ROJoystick usb1(1);         // Joystick #1
ROPWM leftDrive(0);
ROPWM rightDrive(1);

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() {
  int leftPower = constrain((usb1.rightY() + usb1.rightX()), 0, 255);
  int rightPower = constrain((usb1.rightY() - usb1.rightX()), 0, 255);

  leftDrive.write(leftPower);
  rightDrive.write(rightPower);

}

/* 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());
  RODashboard.publish("Distance", SonarRead(0));
}

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

int SonarRead(byte anPin) {
  return (analogRead(anPin) + 2) / 2;
}
  #2   Spotlight this post!  
Unread 19-09-2015, 08:54
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: RobotOpen Digital Sidecar Programming

Are you getting feedback lights from the shield? Green for enabled and red for disabled?

Are you using the Chrome based driver station?

Are you using the most up to date version of the RobotOpen library?

What Arduino IDE version are you using?
__________________
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)
  #3   Spotlight this post!  
Unread 19-09-2015, 11:04
cwengineer's Avatar
cwengineer cwengineer is offline
Engineering Mentor
AKA: Corey
FRC #3265 (RoboTribe)
Team Role: Engineer
 
Join Date: Sep 2015
Rookie Year: 2007
Location: Georgia
Posts: 6
cwengineer is an unknown quantity at this point
Re: RobotOpen Digital Sidecar Programming

The enable/disable lights on the shield were working but after testing a couple things this morning they aren't working now.
I am using the Chrome DS.
I can't find a version for the RO library, but I believe I have the most recent.
I am using Arduino IDE 1.6.5.

Should I be using the RobotOpenShield Library or just the RobotOpen Library?
The shield did not come with any documentation.
  #4   Spotlight this post!  
Unread 19-09-2015, 11:09
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: RobotOpen Digital Sidecar Programming

You should be using the "shield" version of the library. The most up to date version is here:

https://github.com/221robotics/Robot...ive/master.zip

What Arduino board are you using?
__________________
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)
  #5   Spotlight this post!  
Unread 19-09-2015, 12:05
cwengineer's Avatar
cwengineer cwengineer is offline
Engineering Mentor
AKA: Corey
FRC #3265 (RoboTribe)
Team Role: Engineer
 
Join Date: Sep 2015
Rookie Year: 2007
Location: Georgia
Posts: 6
cwengineer is an unknown quantity at this point
Re: RobotOpen Digital Sidecar Programming

I am using the AndyMark Ethernet Arduino.
I tried deleting the old library, downloading the new library you sent, restarting the Arduino IDE and using the example code from ArcadeDrive.

I can connect, the enable/disable LEDs work, but still no signal passed to the DSC PWM channels. I tried swapping out the DSC and the ribbon cable, but still nothing.

Any ideas?
  #6   Spotlight this post!  
Unread 19-09-2015, 14:07
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: RobotOpen Digital Sidecar Programming

Are you confident that the pwm cable is good?

Is the ribbon cable fully seated?

Is the speed controller functioning properly?

Is your joystick actually sending data? You can check this by "publishing" your power value to the dashboard.
__________________
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)
  #7   Spotlight this post!  
Unread 19-09-2015, 14:42
cwengineer's Avatar
cwengineer cwengineer is offline
Engineering Mentor
AKA: Corey
FRC #3265 (RoboTribe)
Team Role: Engineer
 
Join Date: Sep 2015
Rookie Year: 2007
Location: Georgia
Posts: 6
cwengineer is an unknown quantity at this point
Re: RobotOpen Digital Sidecar Programming

I plugged in a couple of servos to test the PWM outputs and still nothing.
The cable is seated and the joystick is sending data to the Arduino and back when enabled.

I've tested the digital IO on the DSC and it works.
I've also tested the analog, but that seems to be a direct connection to the Arduino analog pins, so that's probably not helpful.

Could it be the ATMega on the shield? How can I go about testing that?
  #8   Spotlight this post!  
Unread 19-09-2015, 14:52
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: RobotOpen Digital Sidecar Programming

Can you re-post your code now that you've updated the library.
__________________
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)
  #9   Spotlight this post!  
Unread 19-09-2015, 15:14
cwengineer's Avatar
cwengineer cwengineer is offline
Engineering Mentor
AKA: Corey
FRC #3265 (RoboTribe)
Team Role: Engineer
 
Join Date: Sep 2015
Rookie Year: 2007
Location: Georgia
Posts: 6
cwengineer is an unknown quantity at this point
Re: RobotOpen Digital Sidecar Programming

All values are updating to the DS, but no PWM output from the DSC.

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

/* I/O Setup */
ROJoystick usb1(1);         // Joystick #1
ROPWM leftDrive(0);
ROPWM rightDrive(1);

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

/* This is your primary robot loop - all of your code
 * should live here that allows the robot to operate
 */
void enabled() {
  int leftPower = constrain((usb1.leftY() + usb1.leftX()), 0, 255);
  int rightPower = constrain((usb1.leftY() - usb1.leftX()), 0, 255);

  leftDrive.write(leftPower);
  rightDrive.write(rightPower);

}

/* 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());
  RODashboard.publish("Left", constrain((usb1.leftY() + usb1.leftX()), 0, 255));
  RODashboard.publish("Right", constrain((usb1.leftY() - usb1.leftX()), 0, 255));
  RODashboard.publish("Digital", digitalRead(SIDECAR_DIGITAL1));
  RODashboard.publish("Distance", SonarRead(0));
}

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

int SonarRead(byte anPin) {
  return (analogRead(anPin) + 2) / 2;
}
  #10   Spotlight this post!  
Unread 19-09-2015, 21:54
cwengineer's Avatar
cwengineer cwengineer is offline
Engineering Mentor
AKA: Corey
FRC #3265 (RoboTribe)
Team Role: Engineer
 
Join Date: Sep 2015
Rookie Year: 2007
Location: Georgia
Posts: 6
cwengineer is an unknown quantity at this point
Re: RobotOpen Digital Sidecar Programming

I took a break from this robot, then swapped out the PWM cables, restarted the laptop, reloaded the code, tested again and it works beautifully now.
I don't think it was the cables and am still a little bugged by what was causing the problem, but at this point I'm glad it's working.

Is there a spec sheet on this shield to tell me which Arduino pins are being used for what? I want to know which pins are open to use for custom circuits.
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:12.

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