Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Programmer a motor with a trigger (http://www.chiefdelphi.com/forums/showthread.php?t=74420)

programmr 14-02-2009 08:12

Programmer a motor with a trigger
 
hello, the idea im trying to do is program leftStick Get Raw Button(1) to set the drive motors on pwm1 and pwm 2 leftmotor and rightmotor to run at a speed of .2, now if i have set 0.2 and set 0.2, the left motor goes in reverse, if i do -0.2, it doesnt move at all, what is the proper way to set these two motors to the same speed by holding a trigger?

Greg McKaskle 14-02-2009 08:14

Re: Programmer a motor with a trigger
 
First make sure that the Open Motor or Drive ref is for the right kind of motor controller. The PWM period is different and especially talking to a victor as if it is a jaguar is not a good idea.

If that isn't it, try bumping the value a bit higher. -0.2 may not be enough to move it.

Greg McKaskle

programmr 14-02-2009 08:34

Re: Programmer a motor with a trigger
 
i tried that, but here let me give you the code i tried and maybe you could find somethign thats wrong

RobotDrive* myRobot;
Jaguar* leftmotor;
Jaguar* rightmotor;
myRobot = new RobotDrive(1, 2);
leftmotor = new Jaguar(1);
rightmotor = new Jaguar(2);


if (!ds->GetDigitalIn(ARCADE_MODE)) {
myRobot->TankDrive(leftStick, rightStick);
}
else {
myRobot->ArcadeDrive(leftStick);
}

if (rightStick->GetRawButton(1)) {
leftmotor->Set(-0.5);
rightmotor->Set(0.5);
}
else {
leftmotor->Set(0.0);
rightmotor->Set(0.0);
}

that's what i have, can someone please help tell me why the left motor doesnt work when i do this. if i have both positive numbers, then the left motor goes in reverse

Greg McKaskle 14-02-2009 08:39

Re: Programmer a motor with a trigger
 
I'm not a jaguar expert. Is there a jumper that affects this?

Greg McKaskle

programmr 14-02-2009 08:41

Re: Programmer a motor with a trigger
 
no there isnt a jumper that affects this.. does anyone else have any ideas?

programmr 14-02-2009 12:47

Re: Programmer a motor with a trigger
 
does anyone else have any ideas as to why this doesnt work....???? PLEASE HELP! Thank You

Greg McKaskle 14-02-2009 18:43

Re: Programmer a motor with a trigger
 
OK, I had more time to look up what I was thinking. The jaguar has jumpers that need to be installed if you are not using the limit switches. If you don't have the jumpers, I think that can result in a motor controller that will not move in one of the directions.

It seems like something to double check.

Greg McKaskle

Golto 14-02-2009 19:06

Re: Programmer a motor with a trigger
 
try this (modify as needed)

Code:

while (IsOperatorControl)
if (LeftStick.GetRawButton(1) == true)
{
    roller.Set(1.0);
}
if (LeftStick.GetRawButton(1) == false)
{
    roller.Set(0.0);
}
Wait(0.005);

LeftStick is your left joystick variable
Roller is the function to be used with the trigger

No need for semaphores, and don't worry, the cRIO is so fast, you'd never notice the lag.

This is part of 558's codebase. If you need more help email me:

pplude@freehugalliance.com

yarb65 14-02-2009 22:00

Re: Programmer a motor with a trigger
 
I think the original question was about getting a motor to reverse using a button. I have tried using a -1 and nothing happens when button is pushed. I am using a Victor and Windriver. If someone has actually done it, how?

Golto 14-02-2009 23:16

Re: Programmer a motor with a trigger
 
would something along the lines of

Code:

if (LeftStick.GetRawButton(1) == true)
{
RobotDrive = RobotDrive * (-1);
}

work?


All times are GMT -5. The time now is 02:19.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi