V5 Blocks - Issue with Toggle in Controller Code

My group uses the VEXcode V5 Blocks.
When we tried the code with a controller, a few things happen:

  1. Driving (4 green motors, with 200 rpm) using the joysticks works fine. (forward/reverse on left joystick, turning on right joystick)
  2. Driving using the left D-pad is a little strange. It goes at half speed, and acts like a toggle–pressing a button makes it go forwards or backwards, and we can’t turn it off unless we use a joystick (this seems to switch control back to the joysticks). We aren’t using and worrying about the D-pads for driving anymore.
  3. Moving the motor group that controls the arms, connected to R1 and R2 works fine.
  4. a. Moving the claw motor (1 red motor, with 100rpm) using the right D-pad does not work fine. When we tried the code: “spin (claw motor) forward/reverse,” it acted like a toggle and didn’t shut off after we stopped pressing the button until after we disconnected driver control.
    b. We then changed the claw motor code to: “spin (claw motor) forward/reverse for 90 degrees.” This code spun the motor 90 degrees every time you pressed a button, and shut off immediately afterwards. Unfortunately, it has been acting up recently, and does not spin the motor occasionally after the button is pressed. We aren’t sure whether the problem in this is in the motor, the robot gearing, or in the code. (not using this code at the moment).

tl;dr: My main question (in problems 2 and 4a) on this topic is how to disable a toggle in the V5 Blocks code? As the drive velocity is preset to 50% and certain other settings are also preset, so I assume that there is a toggle preset on the D-pads. Is there a way to disable the toggle present for when you use the spin (motor) forward code in Blocks, or do I have to work around this by making the motor spin a certain amount of degrees each button press?

The code and pictures of our claw is posted below. My main problem is with the section that deals with controller buttons “x” and “b”. The poster of this (I) am currently isolated at home due to covid protocol, but I am able to communicate with my team.

VEXcode 21-22 v0.1.v5blocks (17.2 KB)
Vex 4arm claw1

Vex 4arm claw spacing1

Motors remember the last state. So if you tell them to drive forward they will continue to drive forward until you give them another command.

If you add conditions to the buttons (if pressed and when not pressed) you will get a better experience.

You also might get better results with driving if you use Velocity instead of direction.
image

Looking further at your code you are also mixing two sets of programming. You have the drive and turn already established in your Devices list and then you also have code (Button Up / Button Down) to tell the chassis to move forward. It moves slower with the buttons because the default velocity is 50% but when you use the sticks it is applying the full (-100 to +100) range.

1 Like

That makes sense. I’m guessing that having the joystick at neutral acts as an “else” block to give the stop command?

I had always assumed that controller up/down/left/right and 1-4 positions were referring to the four joystick directions. Do they refer to a single joystick, the joystick scheme you selected (as in dual vs single joystick control), the D-pad, or something else?

We had set the drive velocity to 100% to change it from the default velocity of 50%, but we also only used the joysticks to control the drive. I’m guessing that we don’t need to change the velocity if we use the joysticks.

image

Wouldn’t an “elif” block work just as well?

Thanks for the response!

The joystick gives a -100 to +100 range with the center being zero. You set the velocity (not direction) and the motors change speed based on this value.

Every control element is separate - not like a gaming console. The joysticks return a range for each direction and the buttons return a true (1) or false (0).

Yes, essentially the same thing.

1 Like

I think I got it now–I found the 1-4 numbers on the controller that refer to each joystick range.

1 Like

My team has more problems.

When the turn velocity block is above the drive velocity block, only the drive was working. When we switched it around, only the turn was working. Does anyone know why only one was working at a time?
And will a forever loop as shown in the picture solve this?
At a tournament right now.