Go to Post studies have shown that postive feedback works better. Driver should get a shock until he obtains target lock, then it stops. Performance incentive :^) - KenWittlief [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-03-2013, 16:51
askeer askeer is offline
Registered User
no team
 
Join Date: Feb 2013
Location: USA
Posts: 4
askeer is an unknown quantity at this point
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
Attached Thumbnails
Click image for larger version

Name:	ss1.jpg
Views:	46
Size:	62.2 KB
ID:	14269  
Reply With Quote
  #2   Spotlight this post!  
Unread 05-03-2013, 17:03
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
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.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 05-03-2013 at 17:06.
Reply With Quote
  #3   Spotlight this post!  
Unread 05-03-2013, 17:05
vhcook's Avatar
vhcook vhcook is online now
Reader of Things
AKA: Victoria
FRC #1939 (Kuh-nig-its)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Kansas City, MO
Posts: 546
vhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond reputevhcook has a reputation beyond repute
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
Reply With Quote
  #4   Spotlight this post!  
Unread 05-03-2013, 17:12
askeer askeer is offline
Registered User
no team
 
Join Date: Feb 2013
Location: USA
Posts: 4
askeer is an unknown quantity at this point
Re: Multiple cases worry

Thank you very much
I corrected it and now I can sleep peacefully
Reply With Quote
  #5   Spotlight this post!  
Unread 06-03-2013, 09:04
Doug Norman's Avatar
Doug Norman Doug Norman is offline
Registered User
no team (National Instruments)
Team Role: Engineer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Austin, TX
Posts: 137
Doug Norman will become famous soon enoughDoug Norman will become famous soon enough
Re: Multiple cases worry

Quote:
Originally Posted by askeer View Post
I am worried about my code because I cant test it now.
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.
__________________
Doug Norman
National Instruments
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 22:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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