|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Multiple cases worry
Hi chiefdelphi !
I am worried about my code because I cant test it now. I have motor which when button 4 is pressed it goes forward and if its not pressed it must stop, but also when I press 5 it needs to go reverse and if its not pressed it stops. So I made the cases but the thing that is worrying me is will false case ( with output = 0 ) effect on other case which needs to spins it reverse when button 5 is pressed... Here is screen shot |
|
#2
|
|||||
|
|||||
|
Re: Multiple cases worry
That's not going to work.
You're right that it will try to set the motor to different speeds at the same time. You want something that cascades like this, so the motor can only be set to one value: ![]() The Select shown here is found on the Programming -> Comparison palette. You don't need to use it. Regular Case statements can be used to accomplish the same thing. Last edited by Mark McLeod : 05-03-2013 at 17:06. |
|
#3
|
||||
|
||||
|
Re: Multiple cases worry
It's generally not good practice to set the same motor in multiple places. When you tell the same motor to go forward and stop at the same time, it could do anything. And if someone presses buttons 4 and 5 at the same time, you're asking for full forward and full reverse at the same time.
To get your intended output, I would use two select statements (one triggered by each button) to produce one value to feed to a single Motor Set Output like Mark's example above. The logic being If Button4, then 1, elseif Button5 then -1, else 0. Last edited by vhcook : 05-03-2013 at 17:07. Reason: Beat to the punch |
|
#4
|
|||
|
|||
|
Re: Multiple cases worry
Thank you very much
![]() I corrected it and now I can sleep peacefully ![]() |
|
#5
|
||||
|
||||
|
Re: Multiple cases worry
Actually you can test your code - using simulation. I just tried this using Mark McLeod's example code. Here is what I did:
1. I created a new robot project using the default choice: Arcade Drive Robot - hardware or simulation 2. I removed all the Robot Drive VIs from Begin, Teleop, and Finish (since I will use one of the robot drive motors to test his code). 3. In the project under My Computer I opened Robot Simulation Readme.html to see the actuators on the simulated robot. Notice the Right Motor is connected to PWM 2 of Digital Module 1. 4. I implemented Mark's code except I used PWM 2 instead of PWM 5. 5. In the lower left corner of Robot Main.vi, I right-clicked and chose .../My Computer as the target. 6. When I ran Robot Main.vi the FRC Simulation Viewer opened. I turned on Follow/Zoom and zoomed in for a close-up view of the robot. 7. With the Driver Station running and Teleop Enabled, when I pressed the joystick buttons I could see the robot wheels spinning - one direction or the other depending on which button I pressed. On the Tutorials tab of the LabVIEW Getting Started Window there is a tutorial where you can learn more about simulation. While you can't simulate everything, it is useful for testing. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|