Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Joystick issues (http://www.chiefdelphi.com/forums/showthread.php?t=133618)

RoboBucs 28-01-2015 15:56

Joystick issues
 
Ok so whenever we run the robot, the robot moves forward and backward if we move the joystick left and right, and if we move the joystick forward and backward, nothing happens. Here's our code
[IMG][/IMG]
[IMG][/IMG]

RoboBucs 28-01-2015 15:57

Re: Joystick issues
 
Oh and we are using a y splitter for the PWM motors.

Mark McLeod 28-01-2015 15:59

Re: Joystick issues
 
You have both motors wired to the x axis of a single joystick. The first output of Index Array unless overridden by an explicit index is Axis 0 or the x axis on a flight stick.
You probably want to use the normal y axis instead.
Either wire from the second output (y-axis), rather than the first output on the Index Array, or add a constant on the left side of both Index Arrays of "1"

Since you are only using one joystick, but using it for tank drive, your robot will only ever go forwards and backwards.
You don't have anything to turn.
It's more common to use two joysticks or at least two different sticks on an xBox-like controller to control the two sides separately.

If you want arcade drive, then you'll have to mix the x/y of the single joystick yourself, since you're avoiding 2 Motor Drive/Arcade.

RoboBucs 28-01-2015 16:24

Re: Joystick issues
 
Is there a way to make it so that one joystick controls forward/back and the other joystick controls left/right?

Donjoe 28-01-2015 16:25

Re: Joystick issues
 
Everything Mark said, and just FYI, you don't need to keep calling the same joystick multiple times (the RefNum Registry Get and JoystickGetValues). You can just branch off the array wires and go to the other places you want to use the joystick...similar to how they branched off to send the values to the Smart Dashboard.

Mark McLeod 28-01-2015 16:29

Re: Joystick issues
 
Quote:

Originally Posted by RoboBucs (Post 1435287)
Is there a way to make it so that one joystick controls forward/back and the other joystick controls left/right?

We call that Arcade drive.
You can look inside the Arcade drive vi to see what it does to mix the x and y of a single joystick in order to get it to turn.

RoboBucs 28-01-2015 16:33

Re: Joystick issues
 
Quote:

Originally Posted by Mark McLeod (Post 1435291)
We call that Arcade drive.
You can look inside the Arcade drive vi to see what it does to mix the x and y of a single joystick in order to get it to turn.

But we can't use an arcade drive vi with the single motor vi's can we?

RoboBucs 28-01-2015 16:38

Re: Joystick issues
 
Like, the way I have it now, each joystick controls one set of wheels at a time, but never both at the same time.

RoboBucs 28-01-2015 16:46

Re: Joystick issues
 
Man I just can't think of what to do here, every now and then when I change something the motors sound like a gear is loose and make this grinding noise, but other times they dont, but I dont see why I can't get this to work by having one joystick go forward/backward and the other handle left/right.

RoboBucs 28-01-2015 16:50

Re: Joystick issues
 
Quote:

Originally Posted by Mark McLeod (Post 1435291)
We call that Arcade drive.
You can look inside the Arcade drive vi to see what it does to mix the x and y of a single joystick in order to get it to turn.

Like here's what I have now
[IMG][/IMG]

RoboBucs 28-01-2015 17:15

Re: Joystick issues
 
Ok now, and this makes no sense whatsoever, when I code it some ways, it sounds like gears are stripping in the motor, but sometimes it doesnt. Any ideas?

Mark McLeod 28-01-2015 17:21

Re: Joystick issues
 
You cannot have more than one Motor Set Output per motor.
Your code is always giving conflicting orders to the motors.
One joystick is telling the motors to do one thing while the other joystick is contradicting those orders and telling them to do something completely different.
They are fighting each other.

I really suggest you try doing it the normal way until you understand a bit more about how motors work.

Alan Anderson 28-01-2015 17:35

Re: Joystick issues
 
You're obviously thrashing around without a good idea of what the original robot program did or where you need to end up.

Stop.

Save your work and set it aside.

Start over with a fresh default robot project. Don't change anything except to make sure the Open 2 Motor Drive function is using the same PWM outputs the left and right motors are connected to. Invert either the left or the right motor if the robot doesn't drive forward when you push the joystick forward.

If you aren't able to make it drive properly by just defining those few things, ask for help again.

Only after you have the drive motors working the way you want them to should you start adding other things like additional motors, solenoids, etc.

RoboBucs 28-01-2015 18:08

Re: Joystick issues
 
Quote:

Originally Posted by Alan Anderson (Post 1435329)
You're obviously thrashing around without a good idea of what the original robot program did or where you need to end up.

Stop.

Save your work and set it aside.

Start over with a fresh default robot project. Don't change anything except to make sure the Open 2 Motor Drive function is using the same PWM outputs the left and right motors are connected to. Invert either the left or the right motor if the robot doesn't drive forward when you push the joystick forward.

If you aren't able to make it drive properly by just defining those few things, ask for help again.

Only after you have the drive motors working the way you want them to should you start adding other things like additional motors, solenoids, etc.

Alright, well I can't test it until tomorrow, but would something like this work?
[IMG][/IMG]

Alan Anderson 28-01-2015 18:22

Re: Joystick issues
 
Quote:

Originally Posted by RoboBucs (Post 1435350)
...would something like this work?

I'm afraid not. You're still sending different commands to each motor in multiple places. You're "using" the Arcade Drive function in a completely inappropriate way. It won't run anyway, because you haven't given it the inputs it requires.

I'm serious -- it's going to be much, much easier to throw away what you have and start over than it would be to try to correct it. Really. Just make a new Arcade Drive robot project, make sure the left and right motors are defined with the proper PWM channels, and be prepared to invert the right motor (or perhaps the left motor, depending on your gearboxes).

RoboBucs 28-01-2015 18:33

Re: Joystick issues
 
The problem with doing that is that we can't use an arcade drive with the robot because we can't use an open two motor, unless you have a way to make it work by assigning the same pwm twice(or some other way around that). We have both of our left motors wired through PWM 0 and both of our right motors wired through pwm 1. Which is what's making it so absolutely frustrating, we had it moving fine back when we weren't using a cable splitter and I could use open 2 motors with an arcade drive, but 2 of our pwm wires messed up so now we have no choice but to use a splitter.

Mark McLeod 28-01-2015 18:46

Re: Joystick issues
 
Yes it will work.
Create a new project and it will do what you want out of the box.
Do not touch anything in the code.
Keep your PWM splitters where they are.

RoboBucs 28-01-2015 20:17

Re: Joystick issues
 
Quote:

Originally Posted by Mark McLeod (Post 1435373)
Yes it will work.
Create a new project and it will do what you want out of the box.
Do not touch anything in the code.
Keep your PWM splitters where they are.

Looking at this now I cannot believe how stupid I am :o I've been working on this for 3 days and I just can't believe how stupidly simple this is. Thank you both so much for your help!


All times are GMT -5. The time now is 20:08.

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