Announcement

Collapse
No announcement yet.

Programing in labview?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Programing in labview?

    Alright. So I'm fairly new to using labview, and im looking to set up our Logitech ATK3 joystick to send specific commands to our robot to start a motor when pushed or to turn on a motor and stay on on command. If anyone could give me assistance that would be amazing. Thanks.

  • #2
    Re: Programing in labview?

    The button states from the joysticks attached to the Driver Station are one of the outputs of the Joystick Get VI. They are output as a cluster which you will want to unbundle using the Unbundle By Name VI to access specific buttons.

    To run a motor while a button is held you can use a Select VI to pick a different speed input depending on whether the button is pressed or not. If this isn't what you are trying to do, please add a bit more detail about exactly what you want to do on the Joystick and what you want the motor to do in response and I can try to help further.
    FIRST®
    FRC Robotics Engineer

    Comment


    • #3
      Re: Programing in labview?

      Alright. In the long run, I want a button on my joystick to start a motor for our launching system. I want this button to be more of a on and off switch for the motor. The other button i want more of a toggle motor switch for our bridge dropping system. I want to be able to hit this button and start the motor and when i let go of it it turns the motor off. I hope this is helpful in some way.

      Comment


      • #4
        Re: Programing in labview?

        The second paragraph in my post above should help with the second case you described. It will run the motor while the button is held and stop when it is released.

        I would actually describe your first case as a toggle. When you push the button the motor turns on (and stays on after release). When you push the button again the motor turns off. I usually break this problem down into two steps.
        • The first step is to catch the "rising edge" of the button press. We are trying to make something happen when the button is pressed, so our code should output true only one time when the button is changing from false to true. To accomplish this I use the Greater Than VI from the Comparison Palette and a feedback node. The feedback node can be viewed as a one cycle delay. The output at the tip of the arrow is the value from the tail of the arrow during the previous cycle.
        • The second step is to set up a toggle that changes when we pass in a True signal, but holds it's value otherwise. My usual choice for this part is the XOR function (in the Boolean palette). The truth table for the XOR function is as follows
          Code:
          Input1|Input2|Output
          False | False| False
          False | True | True
          True  | False| True
          True  | True | False

        Now if you look at Input2 as the current state of the motor (the previous output) you may see how this acts as a toggle. When the Input (Input1) is False, the output matches the previous value (Input2). When the input (Input1) is True, the output is the opposite of the previous value (Input2).

        If you put both pieces together, you end up with the toggle behavior it sounds like you are looking for.

        EDIT: The code attached to this post had a slight error in it that would cause incorrect behavior. Please see the image I have attached to a later post for the correct code.
        Last edited by Kevin O'Connor; 02-19-2012, 08:21 PM.
        FIRST®
        FRC Robotics Engineer

        Comment


        • #5
          Re: Programing in labview?

          So, let me get this right. if a take that file you sent me and directly put it into the coding for WPI_JoystickGet.vi then i should be able to run it??

          Comment


          • #6
            Re: Programing in labview?

            The example I posted is something similar to what you would put in your Teleop VI. You will still have to Open the appropriate joystick and motor in Begin and save the refnum. Then modify the refnums from the example to match.
            FIRST®
            FRC Robotics Engineer

            Comment


            • #7
              Re: Programing in labview?

              Where would i find the selected nodes on the the path?
              Attached Files

              Comment


              • #8
                Re: Programing in labview?

                Originally posted by Dokusou View Post
                Where would i find the selected nodes on the the path?
                Those are the feedback nodes. They are on the Structures palette under Programming.
                FIRST®
                FRC Robotics Engineer

                Comment


                • #9
                  Re: Programing in labview?

                  ok, so i put this program into a blank vi. i used a boolean button set to switch until released, as a joystick button would be. i wired it up just like you did only into a boolean light and a numeric indicator with the same numbers as you have for the motor. when i run it and press the button, the light stays on a second but does not toggle. if i hold the button, the light flashes on and off and the indicator shuffles between one and zero. sometimes if i time it right i can get the light to stay on when button is off.
                  any help you can give?

                  Comment


                  • #10
                    Re: Programing in labview?

                    ok, i put a time delay into the program i said earlier and it works with no cycling. if i made it this into a subvi, would it slow down the who vi i put that subvi into?

                    Comment


                    • #11
                      Re: Programing in labview?

                      My apologies, the originally posted code had an error which leads to the behavior you noted. The first feedback node should be connected to the button, not to the output of the Greater Than node. An image showing the correct code is attached.
                      Attached Files
                      FIRST®
                      FRC Robotics Engineer

                      Comment


                      • #12
                        Re: Programing in labview?

                        Ok, so with the motor refnum where would i go to find that. Is there a specific refnum for a motor that i need to set. And is this supposed to go into the teleop.VI or create a new VI for this?

                        Comment


                        • #13
                          Re: Programing in labview?

                          Motor refnums should be set for each of your motors in Begin.VI and then retrieved wherever they are needed in your code. You choose the refnu when you set it in begin. Teleop would be a perfectly fine place to put this code.
                          FIRST®
                          FRC Robotics Engineer

                          Comment


                          • #14
                            Re: Programing in labview?

                            Ok, So i can find the refnum for per say my motor that will shoot he ball in Begin.vi and go to the Motor got node and set the refnum up there to read from it. now do i need to set the refnum to the same thing in the constant box at the end of the wire??

                            Comment


                            • #15
                              Re: Programing in labview?

                              Right, in Begin.VI you should have a Motor Open VI, then a Motor Set Refnum VI with some name (ex. "Shooter Motor"). In Teleop, you would have a Motor Get Refnum with the matching string (ex. "Shooter Motor).
                              FIRST®
                              FRC Robotics Engineer

                              Comment

                              Working...
                              X