Go to Post Anything that promotes science and technology is okay in my book. - Dan Richardson [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-10-2009, 00:25
nighterfighter nighterfighter is offline
1771 Alum, 1771 Mentor
AKA: Matt B
FRC #1771 (1771)
Team Role: Mentor
 
Join Date: Sep 2009
Rookie Year: 2007
Location: Suwanee/Kennesaw, GA
Posts: 835
nighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant future
Pneumatics Code

Hey, thanks to some great help from Jon236, Alan Anderson and Mark McLeod, I think I got some code that *might* work with the pneumatics system...

If someone could take a look over it and maybe give me some pointers, that'd be great! (School is closed until Tuesday...Furlough days. )

Code:
#include "WPILib.h"
#include "1771Constants.h"
#include <iostream>
using namespace std;

namespace Team1771
{
class Team1771Robot : public SimpleRobot 
{
	RobotDrive driveTrain;
	Joystick leftStick;
	Joystick rightStick;
	Joystick manipulator;
	Compressor compressorControl;
	Solenoid turret;
	
	
	

public:
	Team1771Robot(void): 
		driveTrain(LEFT_DRIVE_MOTOR_PORT, 
				   RIGHT_DRIVE_MOTOR_PORT), 
		leftStick(LEFT_JOYSTICK_PORT),
		rightStick(RIGHT_JOYSTICK_PORT),
		manipulator(MANIPULATOR_JOYSTICK_PORT),
		compressorControl(3,3,COMPRESSOR_PORT,7),
		turret(5)												//THIS *HAS* TO BE CHANGED
//I just made up random number
//TODO: Figure out how to hook it up!!!
		{
	
		compressorControl.Start();
		};
	
	void Autonomous(void)
	{
		GetWatchdog().SetEnabled(false);
		while(IsAutonomous() && !IsDisabled())
		{}
	}
	
	void OperatorControl(void) 
	{	
		GetWatchdog().SetEnabled(false);
		while (IsOperatorControl() && !IsDisabled()) 
		{
			
			//FIRE AWAY CAP'N!
			if(manipulator.GetRawButton(1))
			{
				
				//Seeing if I have enough. Just a rough estimate.
				if(compressorControl.GetPressureSwitchValue() < 100)
				{
					cout << "Not enough power to fire. " << endl;
					cout << compressorControl.GetPressureSwitchValue() << endl;					
					Wait(1);
				}
				else //Fire into the crowd! Rawr!
				{
					//Uncomment to see pressure values before firing
					/*
					cout << compressorControl.GetPressureSwitchValue() << endl;
					*/
					turret.Set(1); //I think this will tell the solenoid(I think its the solenoid?) 
					//to switch and let the air fire from the chamber.
					turret.Set(0);//Then that should turn it off?					
					//TODO: Figure out if 1 is letting air in, or if 0 is.					
					//Uncomment this below for seeing how much pressure we lose from firing.
					/*
					cout << compressorControl.GetPressureSwitchValue() << endl;
					*/
					Wait(1);
				}
	
			}
			
			
		}
	}
};
START_ROBOT_CLASS(Team1771Robot);
}



One of my questions that I already have however, is with the Compressor.Start()
I noticed in the Compressor.h file, there is a function called void SetRelayValue(Relay::Value relayValue). Does the Compressor class automatically call this is needed?
From what I understand, calling compressorControl.Start() will turn on the compressor, and automatically keep the pressure to a certain level.
Reply With Quote
  #2   Spotlight this post!  
Unread 10-10-2009, 10:25
Lord_Jeremy's Avatar
Lord_Jeremy Lord_Jeremy is offline
Lord_Jeremy the Procrastinator
AKA: Jeremy Agostino
FRC #1546 (Chaos Inc.)
Team Role: Electrical
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Baldwin, New York
Posts: 45
Lord_Jeremy is an unknown quantity at this point
Send a message via ICQ to Lord_Jeremy Send a message via AIM to Lord_Jeremy Send a message via MSN to Lord_Jeremy Send a message via Yahoo to Lord_Jeremy
Re: Pneumatics Code

Hey. Admittedly I don't have too much experience programming for the new control system (I was delegated to electronics this past year), but a couple things look kind of fishy. First of all, I don't think you're supposed to be disabling the Watchdog like that. From what I remember of the documentation and example code, you should be Feed()ing it. Also, I don't think doing
Code:
turret.Set(1)
and then
Code:
turret.Set(0)
on the next line will make it fire. The way I see it, there are a couple ways to get this to do what you want. The first way would be to just do
Code:
turret.Set(manipulator.GetRawButton(1))
so that it fires the solenoid when you press the button. I'm assuming you're using a Festo single-solenoid valve, of course. The other way would be to write it so that when you press the button, it sets the solenoid to 1 and then starts a counter. Then, when the counter reaches 0, it sets the solenoid to 0. It could probably look like this
Code:
int shootercounter

void Pneumatics()
{
	if( shootercounter > 0 )
		shootercounter--	//decrement the counter
	else
		turret.Set(0);	//close the valve

	if( manipulator.GetRawButton(1) )
	{
		//open the valve for 200 cycles
		shootercounter = 200;
		turret.Set(1);
	}
}
Though there's definitely a better way to do it with timers, I'm not sure how to use timers in the new system.
__________________
Compiling...
Compiling...

Last edited by Lord_Jeremy : 10-10-2009 at 10:28.
Reply With Quote
  #3   Spotlight this post!  
Unread 10-10-2009, 12:25
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,817
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Pneumatics Code

Another issue is the pressure switch doesn't behave the way you want.
The pressure switch value will only be 1 or 0.

It will trip to 1 if the pressure is or falls below 95 psi.
Once tripped it will remain at 1 until pressure rises to 115 psi.
At 115 psi it resets to 0 and stays that way until pressure falls below 95 psi again.
So part of the automatic compressor operation is built in to the pressure switch they send us in the KOP.

You'd have to buy (fairly expensive) a pressure transducer to get a constant readout of current pressure the way you want.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 10-10-2009 at 12:30.
Reply With Quote
  #4   Spotlight this post!  
Unread 10-10-2009, 17:40
nighterfighter nighterfighter is offline
1771 Alum, 1771 Mentor
AKA: Matt B
FRC #1771 (1771)
Team Role: Mentor
 
Join Date: Sep 2009
Rookie Year: 2007
Location: Suwanee/Kennesaw, GA
Posts: 835
nighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant future
Re: Pneumatics Code

As for the watchdog, it doesn't matter for us now. We have been programming it that way, and whenever we did try feeding it, it would gives us Watchdog errors.

For the turret.Set(1) and turret.Set(0), I added a Wait in between them for 2 seconds. That should make the solenoid open up for 2 seconds, right?

For the pressure switch readings, I guess that means you can't get it to be over 115 PSI? When we hooked it up manually (using 2 batteries and manually sparking them to fire) we fired it at 120 PSI, but we used a manual gauge thing.

If I use compressorControl.Start(), does that mean it will never put the pressure above 115?
Reply With Quote
  #5   Spotlight this post!  
Unread 10-10-2009, 23:30
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,817
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Pneumatics Code

Quote:
Originally Posted by nighterfighter View Post
For the pressure switch readings, I guess that means you can't get it to be over 115 PSI? When we hooked it up manually (using 2 batteries and manually sparking them to fire) we fired it at 120 PSI, but we used a manual gauge thing.

If I use compressorControl.Start(), does that mean it will never put the pressure above 115?
(Note: this is for non-FRC competition use)
Start() will always cut off at 115psi using the current KOP pneumatic system and won't run again until the pressure falls to 95psi.
There were some older KOP pressure switches that were set at 120psi and you might be able to buy a switch pre-set for 120psi.
If you can't launch anywhere in the range of 95-115psi, then you probably want to use your own code rather than Start().

If your goal is to launch only at a particular pressure each time, then you'll either have to watch the gauge and operate the compressor manually, or dump enough pressure each use to trip the pressure switch (by dropping to 95psi) and let it build up to 115psi, or buy a pressure transducer.

If it must be at 120psi every time, then you could force the compressor to run a minute more after the pressure switch cuts off to build up to 120psi.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 10-10-2009 at 23:52.
Reply With Quote
  #6   Spotlight this post!  
Unread 11-10-2009, 00:10
nighterfighter nighterfighter is offline
1771 Alum, 1771 Mentor
AKA: Matt B
FRC #1771 (1771)
Team Role: Mentor
 
Join Date: Sep 2009
Rookie Year: 2007
Location: Suwanee/Kennesaw, GA
Posts: 835
nighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant future
Re: Pneumatics Code

Okay, thanks a lot!

The only reason I had it test the pressure in my code, was because I wouldn't want it to fire if it only had like 60 PSI.

As far as my solenoid firing, would that work? My thought was that it would switch the valves on the FESTO Solenoid for a second, allowing air to shoot out.
Reply With Quote
  #7   Spotlight this post!  
Unread 11-10-2009, 09:40
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,817
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Pneumatics Code

With the Wait() added, as Jeremy suggested, the solenoid should operate the way you expect.

The solenoids we get in the Kit won't supply the fast, sudden pressure you need to launch a t-shirt though. There are different solutions for how to do the valve that other teams have used.

T-shirt launchers have been talked about a lot on Chief Delphi, so check out some of those threads for how other teams have done it:
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #8   Spotlight this post!  
Unread 11-10-2009, 11:59
nighterfighter nighterfighter is offline
1771 Alum, 1771 Mentor
AKA: Matt B
FRC #1771 (1771)
Team Role: Mentor
 
Join Date: Sep 2009
Rookie Year: 2007
Location: Suwanee/Kennesaw, GA
Posts: 835
nighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant future
Re: Pneumatics Code

Okay, thanks for answering all my questions. (I ask a lot. )

Maybe I could use the Axis camera to look at the pressure gauge...

Edit: For the solenoid, although it is attatched to the spike motor, do I need to declare it as Solenoid firingCannon or Relay firingCannon?

Last edited by nighterfighter : 11-10-2009 at 16:56. Reason: Solenoid / Relay
Reply With Quote
  #9   Spotlight this post!  
Unread 11-10-2009, 18:58
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,817
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Pneumatics Code

Declare it as a solenoid if you've attached it to the Pneumatic Bumper.

Declare it as a Relay if you've attached it to a Spike, controlled in turn by a Digital Sidecar Relay output.

You can still do your check for sufficient pressure. Just never fire if it's "1" and wait for it to turn to "0" again.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 11-10-2009 at 19:02.
Reply With Quote
  #10   Spotlight this post!  
Unread 11-10-2009, 19:05
nighterfighter nighterfighter is offline
1771 Alum, 1771 Mentor
AKA: Matt B
FRC #1771 (1771)
Team Role: Mentor
 
Join Date: Sep 2009
Rookie Year: 2007
Location: Suwanee/Kennesaw, GA
Posts: 835
nighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant future
Re: Pneumatics Code

Okay, thanks.

If it becomes declared as a Relay, what is the equivalent of the Solenoid's boolean of 0/1? I assume kForward?
Reply With Quote
  #11   Spotlight this post!  
Unread 11-10-2009, 19:24
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,817
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Pneumatics Code

A single solenoid like a Festo would be kForward and kOff.

A double solenoid would be kForward and kReverse.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #12   Spotlight this post!  
Unread 11-10-2009, 21:58
Lord_Jeremy's Avatar
Lord_Jeremy Lord_Jeremy is offline
Lord_Jeremy the Procrastinator
AKA: Jeremy Agostino
FRC #1546 (Chaos Inc.)
Team Role: Electrical
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Baldwin, New York
Posts: 45
Lord_Jeremy is an unknown quantity at this point
Send a message via ICQ to Lord_Jeremy Send a message via AIM to Lord_Jeremy Send a message via MSN to Lord_Jeremy Send a message via Yahoo to Lord_Jeremy
Re: Pneumatics Code

Quote:
Originally Posted by Mark McLeod View Post
A double solenoid would be kForward and kReverse.
Er, I think that would depend on the type of double solenoid you used and how it was wired to the spike. For instance the ones Team 1546 used last year (the same ones supplied in the KoP previously) actually had two sets of solenoid power terminals. To use one spike for both solenoids, you'd need to rig up a couple diodes. I think there's a diagram of what to do in regards to that somewhere around here. I don't recall if a different type of double solenoid valve was included in the KoP last year, so my advice may be out of date.
__________________
Compiling...
Compiling...
Reply With Quote
  #13   Spotlight this post!  
Unread 11-10-2009, 22:20
nighterfighter nighterfighter is offline
1771 Alum, 1771 Mentor
AKA: Matt B
FRC #1771 (1771)
Team Role: Mentor
 
Join Date: Sep 2009
Rookie Year: 2007
Location: Suwanee/Kennesaw, GA
Posts: 835
nighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant future
Re: Pneumatics Code

Awesome guys, thanks.

I think I have some code that *should* work, I'll have to wait until Tuesday to find out...

Thanks for answering my questions, I ask too many. I get bored if im not in school, and if I can't actually test my code. x_x
Reply With Quote
  #14   Spotlight this post!  
Unread 12-10-2009, 10:46
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,817
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Pneumatics Code

Quote:
Originally Posted by Lord_Jeremy View Post
Er, I think that would depend on the type of double solenoid you used and how it was wired to the spike.
Yea, there are different methods of wiring the solenoid to the spike.
We only see one solenoid type in FRC. They are all simple coils that get energized or not, essentially, two single solenoids in one package.

Typically, the major variations you'll see in wiring a double solenoid on FRC robots are:
  • Use two outputs on the Pneumatic Bumper w/o a spike at all (diagram 3 below). This is the easiest choice.
  • Use diodes to direct the current flow from the spike to a either side of the solenoid (2nd diagram below). Jeremy's favorite method.
  • Cross-wire the sides of the solenoid to a spike (first diagram below). This is the way I usually tell people to wire a double solenoid to a Spike.
All three methods work fine. It's just a matter of choice and circumstances.
Attached Thumbnails
Click image for larger version

Name:	DoubleSolenoidSpikeWiring.jpg
Views:	50
Size:	18.2 KB
ID:	8113  Click image for larger version

Name:	DoubleSolenoidDiodesSpikeWiring.jpg
Views:	49
Size:	10.3 KB
ID:	8114  Click image for larger version

Name:	DoubleSolenoidBumperWiring.jpg
Views:	48
Size:	21.6 KB
ID:	8115  
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 12-10-2009 at 11:14. Reason: Added diagrams
Reply With Quote
  #15   Spotlight this post!  
Unread 12-10-2009, 17:11
nighterfighter nighterfighter is offline
1771 Alum, 1771 Mentor
AKA: Matt B
FRC #1771 (1771)
Team Role: Mentor
 
Join Date: Sep 2009
Rookie Year: 2007
Location: Suwanee/Kennesaw, GA
Posts: 835
nighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant future
Re: Pneumatics Code

Hey, I got an idea!

Since I can't really know the pressure (without buying an expensive item...we are flat broke for this project. ) I decided to make my own gauge...thing.

I made a new integer, called compressorValue, and I will use that to store the value of the pressure left. I can do some tests, and see how much pressure is used by firing one shot, and how much is added in X amount of seconds of the compressor running...

But, this is where my question is. :/
Will the times change based on the pressure? Eg: Will it increase quicker at first, then increase slower as the pressure builds? Or is the compressor (the ones that came in the KoP) powerful enough that this resistance is negligible?
Reply With Quote
Reply


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems integrating CMUCAM code and IFI Default Code Windward Programming 2 06-02-2007 16:48
problems using gyro/adc code with camera default code tanstaafl Programming 7 22-01-2006 23:09
Pneumatics-Code [and piston output length] reilly Programming 5 13-02-2005 11:42
Pneumatics-Code [and piston output length] reilly Technical Discussion 0 10-02-2005 12:21
Team THRUST - Kevin's Code and Camera Code Combine Chris_Elston Programming 3 31-01-2005 22:28


All times are GMT -5. The time now is 13:54.

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