Go to Post [You know you've overdoes on FIRST when...] You're willing to take an 8 AM for the team. - ttldomination [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 03-02-2014, 10:56
TechWarlock TechWarlock is offline
Programming Dude
AKA: Jacob
FRC #1396 (Pyrobots)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2011
Location: New York
Posts: 24
TechWarlock is an unknown quantity at this point
Solenoid Breakout Code Help

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_FixedIndoo r);
// 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)
{
Solenoid*solenoidOne;
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);
  #2   Spotlight this post!  
Unread 03-02-2014, 11:28
eddie12390's Avatar
eddie12390 eddie12390 is offline
Registered User
AKA: Eddie
FRC #3260 (SHARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Pittsburgh
Posts: 285
eddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of light
Re: Solenoid Breakout Code Help

You should upload it to Pastebin or something similar for easier interpreting. It's hard to keep of brackets without any spacing.
  #3   Spotlight this post!  
Unread 03-02-2014, 11:56
TechWarlock TechWarlock is offline
Programming Dude
AKA: Jacob
FRC #1396 (Pyrobots)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2011
Location: New York
Posts: 24
TechWarlock is an unknown quantity at this point
Re: Solenoid Breakout Code Help

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
  #4   Spotlight this post!  
Unread 03-02-2014, 12:15
eddie12390's Avatar
eddie12390 eddie12390 is offline
Registered User
AKA: Eddie
FRC #3260 (SHARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Pittsburgh
Posts: 285
eddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of light
Re: Solenoid Breakout Code Help

Quote:
Originally Posted by TechWarlock View Post
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.
  #5   Spotlight this post!  
Unread 03-02-2014, 12:19
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
Post Re: Solenoid Breakout Code Help

Hint: surround your code with [ code] and [ /code] tags. It'll preserve whitespace that way.


Code:
	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?

Code:
		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.
  #6   Spotlight this post!  
Unread 03-02-2014, 12:26
TechWarlock TechWarlock is offline
Programming Dude
AKA: Jacob
FRC #1396 (Pyrobots)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2011
Location: New York
Posts: 24
TechWarlock is an unknown quantity at this point
Re: Solenoid Breakout Code Help

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
  #7   Spotlight this post!  
Unread 03-02-2014, 12:32
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: Solenoid Breakout Code Help

I think you're working from documentation that is out of date by many years.

Quote:
Originally Posted by TechWarlock View Post
the 8 is supposed to represent the slot we put the NI 9472 into
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.
  #8   Spotlight this post!  
Unread 03-02-2014, 12:41
TechWarlock TechWarlock is offline
Programming Dude
AKA: Jacob
FRC #1396 (Pyrobots)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2011
Location: New York
Posts: 24
TechWarlock is an unknown quantity at this point
Re: Solenoid Breakout Code Help

Quote:
Originally Posted by Alan Anderson View Post
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!
  #9   Spotlight this post!  
Unread 03-02-2014, 15:47
cgranata cgranata is offline
Team Captain
FRC #1396 (Pyrobots)
Team Role: Electrical
 
Join Date: Oct 2012
Rookie Year: 2010
Location: Staten Island, NY
Posts: 39
cgranata is an unknown quantity at this point
Re: Solenoid Breakout Code Help

Quote:
Originally Posted by Alan Anderson View Post
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 [code] tag!
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 02:47.

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