Go to Post I had a few jokes about the illness and germs at some of the competitions, but I don't want to spread them around. - tsaksa [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 02-18-2012, 10:08 AM
blazingswrd blazingswrd is offline
Registered User
FRC #0116
 
Join Date: Feb 2012
Location: Herndon
Posts: 1
blazingswrd is an unknown quantity at this point
Spike Relay Help!!!

Hey all,

My team is using a spike relay to power a motor in our elevator. Unfortunately, I've been unable to figure out how the relay class works and all of the examples of the relay class that I've been able to find are all in Java. Where can I find a good example of this class so I can go find and figure it out?

Thanks!

Last edited by blazingswrd : 02-18-2012 at 10:08 AM. Reason: grammer changes
Reply With Quote
  #2   Spotlight this post!  
Unread 02-18-2012, 10:29 AM
DavisC DavisC is offline
Registered User
FRC #0539 (Titans)
Team Role: College Student
 
Join Date: Jul 2011
Rookie Year: 2010
Location: Virginia
Posts: 200
DavisC is just really niceDavisC is just really niceDavisC is just really niceDavisC is just really nice
Re: Spike Relay Help!!!

Code:
#include "WPILib.h"

class RobotDemo : public SimpleRobot
{
	RobotDrive myRobot;
	Joystick stick;
	
	// This declares the Relay
	Relay Elevator;

public:
	RobotDemo(void):
		myRobot(1, 2),
		stick(1),
		
		// This sets up the Relay
		Elevator(3)
	
	{
		myRobot.SetExpiration(0.1);
	}

	void Autonomous(void)
	{
		myRobot.SetSafetyEnabled(false);
		myRobot.Drive(0.5, 0.0);
		Wait(2.0);
		myRobot.Drive(0.0, 0.0);
	}

	void OperatorControl(void)
	{
		myRobot.SetSafetyEnabled(true);
		while (IsOperatorControl())
		{
			myRobot.ArcadeDrive(stick);
			
			
			// This sets the relay
			
			// if stick (USB 1), Trigger (Button 1) == pressed
			if(stick.GetRawButton(1) == true)
				// set Elevator (PWM 3) to forward
				Elevator.Set(Relay::kForward);
			else
				// if stick (USB 1), Button 2 == pressed
				if(stick.GetRawButton(2) == true)
					// set Elevator (PWM 3) Reverse
					Elevator.Set(Relay::kReverse);
				else
					// if stick (USB 1), Button 3 == pressed
					if(stick.GetRawButton(3) == true)
						// set Elevator (PWM 3) to Off
						Elevator.Set(Relay::kOff);
			
			Wait(0.005);
		}
	}
};

START_ROBOT_CLASS(RobotDemo);
This uses the Relay on PWM 3 and triggered by Buttons 1, 2, and 3 to run Forward, Reverse, and Off (respectively).

This is the Simple Robot code just modified to have a Relay too.
__________________
FRC Team 539
Student Member: 2010 Breakaway - 2014 Aerial Assist
Mentor: 2015 Recycle Rush - present
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


All times are GMT -5. The time now is 10:27 AM.

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