Go to Post Engineering is so much easier when you give all the components personalities. Then you just watch the drama unfold and try to fix it. - EricVanWyk [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 15-01-2011, 11:55
frenchie4111 frenchie4111 is offline
Registered User
None #1111
 
Join Date: Jan 2010
Location: Southriver
Posts: 23
frenchie4111 is an unknown quantity at this point
Multiple outputs

We have 4 buttons and each button controls the directions of 2 motors.
We have a case structure for each button where true sends a value (0.5, or -0.5) to the "Motor Set Output" and false sends a value of 0. We have run into a problem when we have multiple outputs set to a motor.

Attached is an image of the case structure for Button 1. We have tested it and it works. But we get lost when we try to add case structures for the rest of the buttons.
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	47
Size:	18.6 KB
ID:	9689  
__________________
[url="http://mylifeisnerdy.co.cc"]My Life Is NerdyURL]
Reply With Quote
  #2   Spotlight this post!  
Unread 15-01-2011, 12:43
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,579
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Multiple outputs

One way I like to do this is to use multiple selects. See the attached picture. This assumes that only one button will be pressed at a time.
Attached Thumbnails
Click image for larger version

Name:	multiple_selects.png
Views:	38
Size:	4.7 KB
ID:	9690  
Reply With Quote
  #3   Spotlight this post!  
Unread 15-01-2011, 14:10
MotorHead's Avatar
MotorHead MotorHead is offline
Programming Mentor
AKA: Jeff Beltramo
FRC #1922 (OZ-Ram)
Team Role: Coach
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Concord, NH
Posts: 68
MotorHead is a splendid one to beholdMotorHead is a splendid one to beholdMotorHead is a splendid one to beholdMotorHead is a splendid one to beholdMotorHead is a splendid one to beholdMotorHead is a splendid one to beholdMotorHead is a splendid one to behold
Re: Multiple outputs

Read each button and put into a binary array. Then convert the array to a number. Your select case can then test for which number shows up. If you are watching four buttons, there would be a possible 16 cases. But since you probably only need to detect if one button is pressed, your test cases would be 1, 2, 4, 8. A very similar technique is being used in the sample line follower code that came with LabView this year.

If you need sample code, let me know. I will be at the lab tonight and can make it real quick.
__________________
Jeff Beltramo
Team #1922
Concord, New Hampshire

Reply With Quote
  #4   Spotlight this post!  
Unread 16-01-2011, 23:45
SuperS_5's Avatar
SuperS_5 SuperS_5 is offline
[Certified LabVIEW Developer]
FRC #1219
 
Join Date: Dec 2010
Rookie Year: 2010
Location: Canada
Posts: 140
SuperS_5 will become famous soon enoughSuperS_5 will become famous soon enough
Re: Multiple outputs

Quote:
Originally Posted by MotorHead View Post
Read each button and put into a binary array. Then convert the array to a number. Your select case can then test for which number shows up. If you are watching four buttons, there would be a possible 16 cases. But since you probably only need to detect if one button is pressed, your test cases would be 1, 2, 4, 8.
If I really had to do something like this, I would make a subvi, using a typedef'ed enum. This enum would then be used on the case selector with the output options/code. This would allow future changes pretty easily.

Quote:
Originally Posted by Joe Ross View Post
One way I like to do this is to use multiple selects. ... This assumes that only one button will be pressed at a time.
I have to say that this would become hard to follow whenever extra code is added. It would also be very difficult to scale, and modify into the future. (Like on competition day)
__________________
Mike B
Reply With Quote
  #5   Spotlight this post!  
Unread 16-01-2011, 23:55
Dustin Shadbolt's Avatar
Dustin Shadbolt Dustin Shadbolt is offline
In a server room somewhere...
AKA: Dustin Shadbolt
FRC #1555 (Team PULSE)
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Monticello,Indiana
Posts: 320
Dustin Shadbolt is on a distinguished road
Re: Multiple outputs

Quote:
Originally Posted by MotorHead View Post
Read each button and put into a binary array. Then convert the array to a number. Your select case can then test for which number shows up. If you are watching four buttons, there would be a possible 16 cases. But since you probably only need to detect if one button is pressed, your test cases would be 1, 2, 4, 8. A very similar technique is being used in the sample line follower code that came with LabView this year.

If you need sample code, let me know. I will be at the lab tonight and can make it real quick.
Hey Jeff,

I was interested in seeing that code as a example that could learn from. Thanks!
Reply With Quote
  #6   Spotlight this post!  
Unread 17-01-2011, 00:40
SuperS_5's Avatar
SuperS_5 SuperS_5 is offline
[Certified LabVIEW Developer]
FRC #1219
 
Join Date: Dec 2010
Rookie Year: 2010
Location: Canada
Posts: 140
SuperS_5 will become famous soon enoughSuperS_5 will become famous soon enough
Re: Multiple outputs

Here is an example. The zip is just the subVIs.
Attached Thumbnails
Click image for larger version

Name:	JoyStickToEnum.png
Views:	38
Size:	4.2 KB
ID:	9709  
Attached Files
File Type: zip JoyStickButtonToEnum.zip (14.8 KB, 16 views)
__________________
Mike B
Reply With Quote
  #7   Spotlight this post!  
Unread 26-01-2011, 17:40
robotjac robotjac is offline
Registered User
no team
 
Join Date: Jan 2011
Location: San Diego, CA
Posts: 5
robotjac is an unknown quantity at this point
Re: Multiple outputs

This is the error code I get when tried to use the codes. Can you tell me what I did wrong?
Attached Thumbnails
Click image for larger version

Name:	Buttons.jpg
Views:	19
Size:	105.9 KB
ID:	9831  
Reply With Quote
  #8   Spotlight this post!  
Unread 26-01-2011, 17:52
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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 outputs

1) Your Motor Output needs to be told which motor you are talking about.
2) You have not defined what to do with all the possible cases of joystick buttons. At the very least you need a "default" case to cover all uncovered bases.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #9   Spotlight this post!  
Unread 26-01-2011, 18:33
robotjac robotjac is offline
Registered User
no team
 
Join Date: Jan 2011
Location: San Diego, CA
Posts: 5
robotjac is an unknown quantity at this point
Re: Multiple outputs

Can you send me some screen examples? I'm new and I can't visualize what you're telling me. Thank you.
Reply With Quote
  #10   Spotlight this post!  
Unread 26-01-2011, 19:15
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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 outputs

Here's what you need:

1) Add a Motor reference (this motor needs to be opened in Begin.vi)

2) Put the cursor on the cases and right-click to choose "Add Case for Every Value"
Then look for every new case that needs a motor value added to it.
The output tunnel carrying the motor value will be solid when you have them all. It'll have a white center if you haven't fixed all the missing cases.
Attached Thumbnails
Click image for larger version

Name:	AddMotorRef.jpg
Views:	24
Size:	17.4 KB
ID:	9834  Click image for larger version

Name:	AddEveryCase.jpg
Views:	22
Size:	38.0 KB
ID:	9835  
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 26-01-2011 at 19:31.
Reply With Quote
  #11   Spotlight this post!  
Unread 26-01-2011, 23:34
robotjac robotjac is offline
Registered User
no team
 
Join Date: Jan 2011
Location: San Diego, CA
Posts: 5
robotjac is an unknown quantity at this point
Re: Multiple outputs

Thank you! Everything is working great now.
Reply With Quote
  #12   Spotlight this post!  
Unread 02-02-2011, 15:46
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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 outputs

As an aside, here is how I would select between multiple joystick or custom DS buttons.
Attached Thumbnails
Click image for larger version

Name:	WhichButton.jpg
Views:	139
Size:	23.3 KB
ID:	9938  
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 03-02-2011 at 07:15.
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 21:19.

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