Hi CD!
I was wondering if anyone could take 5 minutes and briefly review our code for the Solenoid Breakout attached to the NI Module 9472.
We code in C++ using Windriver Workbench.
Thanks in advance!
#include “WPIlib.h”
#include “compressor.h”
class RobotDemo : public SimpleRobot
{
RobotDrive Frankbot; // robot drive system
Joystick leftjoy;
Joystick rightjoy;
Joystick joystick3;
Relay Pulley;
Relay piston1;
Relay Arm; // PistonHelper
Relay PistonHelper; //Actual Arm
// Jaguar Winch;
public:
RobotDemo(void):
Frankbot(1, 2), //these are the PWM ports
leftjoy(1),
rightjoy(2),
joystick3(3),
Pulley(2),
piston1(4),
Arm (5),
PistonHelper (8)
// Winch (4)
{
// usermessages = DriverStationLCD::GetInstance();
// Camera->WriteResolution(AxisCamera::kResolution_160x120);
// Camera->WriteCompression(20);
// Camera->WriteWhite
// Balance(AxisCameraParams::kWhiteBalance_FixedIndoor);
// Camera->WriteMaxFPS(30);
// Camera = &AxisCamera::GetInstance();
// myRobot.SetExpiration(0.1); // test
}
void Autonomous(void)
{
Compressor *c = new Compressor(1, 1);
c->Start();
}
void OperatorControl(void)
{
SolenoidsolenoidOne;
Solenoid solenoidTwo;
solenoidOne = new Solenoid(8,1);
solenoidTwo = new Solenoid (8,8);
int up = 4;
int down = 5;
int WinchIn = 2;
int WinchOut = 1;
int ArmIn = 1;
int ArmOut = 2;
int On = 6;
int Off = 3;
int ArmUp = 2;
int ArmDown = 1;
int Sol1 = 3;
int Sol2 = 4;
static float speedModifier = 1.00;
// static float winchspeed = 1.00;
Compressor *c = new Compressor(1, 1);
c->Start();
Frankbot.SetSafetyEnabled(true);
while (IsOperatorControl())
{
if(leftjoy.GetRawButton(Sol1)){
solenoidOne->Set(true);
solenoidTwo->Set(false);
}
else{
solenoidOne->Set(false);
solenoidTwo->Set(true);
}
}
}
};
START_ROBOT_CLASS(RobotDemo);
You should upload it to Pastebin or something similar for easier interpreting. It’s hard to keep of brackets without any spacing.
Aside from the brackets is there anything else, i’ve been playing around with this code and i cant seem to get it to work at all, Thank You
I’m not sure as it’s too difficult to read in its current state.
Hint: surround your code with code] and /code] tags. It’ll preserve whitespace that way.
solenoidOne = new Solenoid(8,1);
solenoidTwo = new Solenoid (8,8);
What do you expect these two lines to do? In particular, what is the first “8” supposed to represent?
if(leftjoy.GetRawButton(Sol1)){
solenoidOne->Set(true);
solenoidTwo->Set(false);
}
else{
solenoidOne->Set(false);
solenoidTwo->Set(true);
}
This looks like a job for a dual solenoid instead of two single solenoids.
the 8 is supposed to represent the slot we put the NI 9472 into, and yeah we are using a double solenoid
class RobotDemo : public SimpleRobot
{
RobotDrive Frankbot; // robot drive system
Joystick leftjoy;
Joystick rightjoy;
Joystick joystick3;
Jaguar Flipper;
Relay piston1;
Relay Arm; // PistonHelper
Relay PistonHelper; //Actual Arm
Solenoid sol1;
Solenoid sol2;
// Jaguar Winch;
public:
RobotDemo(void):
Frankbot(1, 2), //these are the PWM ports
leftjoy(1),
rightjoy(2),
joystick3(3),
Flipper(7),
piston1(6),
Arm (5),
PistonHelper (8),
sol1(3, 1),
sol2(3, 2)
public:
RobotDemo(void):
sol1(3, 1),
sol2(3, 2)
if(leftjoy.GetRawButton(sol)){
sol1.Set(true);
sol2.Set(false);
}
else if(leftjoy.GetRawButton(sol4)){
sol2.Set(true);
sol1.Set(false);
}
else {
sol1.Set(false);
sol2.Set(false);
}
i made some adjustments, but the code still doesnt work
I think you’re working from documentation that is out of date by many years.
The first parameter doesn’t specify the slot number in the chassis. It specifies the “module number”, which is either 1 (for the first module of a given type) or 2 (for the second module). If you’re putting your NI 9472 module in slot 3, it’s module number 1. If you’re putting it in slot 4 of a 4-slot cRIO or slot 7 of an 8-slot cRIO, it’s module number 2.
Slot 8 of an 8-slot cRIO is always empty.
I think you’re working from documentation that is out of date by many years.
The first parameter doesn’t specify the slot number in the chassis. It specifies the “module number”, which is either 1 (for the first module of a given type) or 2 (for the second module). If you’re putting your NI 9472 module in slot 3, it’s module number 1. If you’re putting it in slot 4 of a 4-slot cRIO or slot 7 of an 8-slot cRIO, it’s module number 2.
Slot 8 of an 8-slot cRIO is always empty.
Thanks so much everyone! We got it working! My team and I appreciate all of your help!
I think you’re working from documentation that is out of date by many years.
The first parameter doesn’t specify the slot number in the chassis. It specifies the “module number”, which is either 1 (for the first module of a given type) or 2 (for the second module). If you’re putting your NI 9472 module in slot 3, it’s module number 1. If you’re putting it in slot 4 of a 4-slot cRIO or slot 7 of an 8-slot cRIO, it’s module number 2.
Slot 8 of an 8-slot cRIO is always empty.
Thank you Alan for your quick reply to the matter!! I appreciate you taking the time to read through our code (even though it was messy). Thanks for letting us know about the
tag!