View Single Post
  #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;
}