|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
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);
}
|
|
#2
|
||||
|
||||
|
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);
}
|
|
#3
|
|||||
|
|||||
|
Re: Passing a motor as an argument in a function
I have tried that, and it gives me these errors:
Quote:
|
|
#4
|
|||||
|
|||||
|
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; |
|
#5
|
|||||
|
|||||
|
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...
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |