Go to Post Spoiler: There will be no plasma cutters available in FIRST Choice - Jibsy [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 07-02-2009, 09:27
Chief Pride's Avatar
Chief Pride Chief Pride is offline
<3
AKA: James Kiefer
no team
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Kalamazoo, MI
Posts: 653
Chief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond repute
Passing a motor as an argument in a function

Hello, I am trying to pass a speed controller (victor) as an BYREF argument in a function and set its value, however, the motor wont turn on and I get no errors. Here is what it looks like:

Code:
void SpecialControl(SpeedController &Motor); /* prototype */
class Robot : public SimpleRobot
{
	Victor InitialMotor;
	public:
		Robot(void):		// these must be initialized in the same order 
		InitialMotor(1)
	{
		GetWatchdog().SetExpiration(0.1);
	}



void OperatorControl(void)
	{
		GetWatchdog().SetEnabled(true);
		SpecialControl(InitialMotor);
	}
};

void SpecialControl(SpeedController &Motor)
{
	Motor.Set(1);
}
Thanks in advance.
Reply With Quote
  #2   Spotlight this post!  
Unread 09-02-2009, 01:07
Redneck's Avatar
Redneck Redneck is offline
Hacker Hick
AKA: Jamie (2.0) Moran
FRC #0599 (Robodox)
Team Role: Engineer
 
Join Date: Aug 2004
Rookie Year: 2004
Location: California
Posts: 90
Redneck is just really niceRedneck is just really niceRedneck is just really niceRedneck is just really nice
Send a message via AIM to Redneck
Re: Passing a motor as an argument in a function

Give this a shot:
Code:
void SpecialControl(SpeedController *Motor); /* prototype */
class Robot : public SimpleRobot
{
	Victor *InitialMotor;
	public:
		Robot(void)
	        {
                       InitialMotor = new Victor(1);
		       GetWatchdog().SetExpiration(0.1);
	        }


                void OperatorControl(void)
	        {
		     GetWatchdog().SetEnabled(true);
		     SpecialControl(InitialMotor);
	        }
};

void SpecialControl(SpeedController *Motor)
{
	Motor->Set(1);
}
__________________


Which badges can you claim?
Reply With Quote
  #3   Spotlight this post!  
Unread 09-02-2009, 12:45
Chief Pride's Avatar
Chief Pride Chief Pride is offline
<3
AKA: James Kiefer
no team
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Kalamazoo, MI
Posts: 653
Chief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond repute
Re: Passing a motor as an argument in a function

I have tried that, and it gives me these errors:
Quote:
error: cannot convert `Victor' to `SpeedController*' for argument `1' to `void SpecialControl(SpeedController*)'
Thanks in advance.
Reply With Quote
  #4   Spotlight this post!  
Unread 09-02-2009, 14:25
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: Passing a motor as an argument in a function

Look carefully at this line, and make sure you didn't leave out anything.
Code:
	Victor *InitialMotor;
Reply With Quote
  #5   Spotlight this post!  
Unread 09-02-2009, 19:53
Chief Pride's Avatar
Chief Pride Chief Pride is offline
<3
AKA: James Kiefer
no team
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Kalamazoo, MI
Posts: 653
Chief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond repute
Re: Passing a motor as an argument in a function

Ah, finally, that compiles... I will see if it runs on the robot tomorrow. Thanks so much...
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
Team Argument! dmoody92 General Forum 30 05-02-2009 09:28
Generate_Pwms argument error in MPLAB LieAfterLie Programming 6 06-12-2007 17:01
Motor Ramp Up/Ramp Down Function Tom Bottiglieri Programming 12 03-12-2006 23:31
Motor drive function? Mike Programming 3 15-02-2006 11:55
Pbasic argument question... Ghetto_Child Programming 10 18-02-2002 09:23


All times are GMT -5. The time now is 14:53.

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