check code

I just want you guys to review a code that a teammate wrote. He told me to write that added to the code is allowing the motor to spin at half speed if button 1 is pressed.

This code currently does not do anything different when the button is pressed. You want the motor to run at half speed or half the speed that the joystick commands when the button is pressed? The following assumes that you wanted the first option.

The 0.5 constant in the case statement is not connected to anything.

For the false case of each case block the joystick axis value should pass through the case block.

For the true case the 0.5 constant should be wired to the small orange block on the right edge of the case that will appear when you wire the joystick value through the false case.

edited to what I think you said.

Correct, the orange wire coming out of each block that says “axis 2(y)” should pass through the false case instead of over the case block.

after going through the case block, does it go to the tank drive vi

Oops, looks like a forgot to ask something on my first pass.

Do you want both motors to run at 1/2 speed by pushing one trigger (button 1)?

Or do you want each side to run at 1/2 speed when the trigger is pressed on that sides joystick?

The second one is what the code currently does. So ,for example, if the left trigger is pressed the left side will run at a constant .5 and the right side will still run according to the joystick. If both triggers are pressed, both sides will run at constant speed.

Is that what you wanted?

wanted to both joysticks pressed for half speed. So does the second pic look okay.

Yes, if you want each joystick and button #1 to control each side separately I believe the fixed code is correct.

so i do not have to put in axis (y) in the true, only in the false. Also only one end is go9ng to the case structure of the constant. Does that look okay.

Correct, when the button is pressed (true case) you want the motor to run at a constant speed so you do not need the joystick value.

The constant originates in the case so it only goes out, no need for anything to come in.

Thank you for the help, will test out tomorrow and reply on how it went.

If you need additional assistance and would like something more real-time, you can use the AIM, MSN, or Yahoo Messenger info in my profile or contact me on Gtalk (My gmail address is the same as my username here).

I’m not sure if I’m heading out to our shop tomorrow or not, so I may or may not be available by the above methods tomorrow afternoon/evening.

I tried the revised code but it shows error on build process of a broken vi.
Can I get a second opinion? Also the Ethernet cable going from the classmate will not click into the Ethernet port of the classmate it just falls out. Anyone else having these problems

The first problem, I can’t help with.

The ethernet port: If another cable also doesn’t click, look carefully at the classmate’s connector, make sure it’s not broken. If another cable clicks & locks, then it was the cable end.

Could be the floating multiply block on the left side of the picture.

You can click the broken grey arrow at the top of the block diagram and it will pull up a list of errors. Double clicking on an error in the list will highlight the offending VI.

You need to feed the Tank Drive with the default joystick inputs, unless overridden by the trigger. Your figure looks only half-fixed.

My attached pic doesn’t directly apply to you, but if you look closely you can see where we used button 1 (trigger) to modify the throttle input. When the case is FALSE, we pass the normal value thru, but when the case is TRUE (i.e. the trigger is pulled), we override with a constant.

For us, the constant is 1.0 … but if you want half power, then put a 0.5 in there and you’ve got it. (and we’re doing our override to Axis3(Throttle), you’d want to do your case statement over the Y-Axis wires between the Joystick GET and the TankDrive VI.


The picture shows one true case and one false case (presumably to show an example of each case to assure things are coded properly)

KK … sorry … after re-looking at the pic in post #3, I can see what they’re showing now … My example does the uncluster outside of the case … but essentially they’re the same … assuming that the other cases look like the ones that they’re showing.


Could it be that instead of writing “0.5” as the motor inputs when the trigger is pulled, they’d rather take the actual “Y” value, and cut it in half? If that’s the case, then they should move the uncluster to the outside of the case statement, run both cases straight through, then modify the TRUE case with a MULTIPLY block with a 0.5 constant.