Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Multiple outputs (http://www.chiefdelphi.com/forums/showthread.php?t=89196)

frenchie4111 15-01-2011 11:55

Multiple outputs
 
1 Attachment(s)
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.

Joe Ross 15-01-2011 12:43

Re: Multiple outputs
 
1 Attachment(s)
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.

MotorHead 15-01-2011 14:10

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.

SuperS_5 16-01-2011 23:45

Re: Multiple outputs
 
Quote:

Originally Posted by MotorHead (Post 1000771)
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 (Post 1000691)
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)

Dustin Shadbolt 16-01-2011 23:55

Re: Multiple outputs
 
Quote:

Originally Posted by MotorHead (Post 1000771)
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!

SuperS_5 17-01-2011 00:40

Re: Multiple outputs
 
2 Attachment(s)
Here is an example. The zip is just the subVIs.

robotjac 26-01-2011 17:40

Re: Multiple outputs
 
1 Attachment(s)
This is the error code I get when tried to use the codes. Can you tell me what I did wrong?

Mark McLeod 26-01-2011 17:52

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.

robotjac 26-01-2011 18:33

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.

Mark McLeod 26-01-2011 19:15

Re: Multiple outputs
 
2 Attachment(s)
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.

robotjac 26-01-2011 23:34

Re: Multiple outputs
 
Thank you! Everything is working great now.

Mark McLeod 02-02-2011 15:46

Re: Multiple outputs
 
1 Attachment(s)
As an aside, here is how I would select between multiple joystick or custom DS buttons.

IisMathwizard 02-02-2011 15:54

Re: Multiple outputs
 
I would've broke both the motors up into two case structures and then have a boolean series hooked up to nested case structures.


All times are GMT -5. The time now is 10:14.

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