Go to Post In my 30 year career, one thing I have learned is that if you truly enjoy your work, you'll be good at it. - DonRotolo [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
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 22-02-2011, 23:18
Lemonsy Lemonsy is offline
Registered User
FRC #3028
 
Join Date: Feb 2011
Location: Hidalgo, Texas
Posts: 2
Lemonsy is an unknown quantity at this point
Java to Labview, using "if else" statements and pressing buttons

I'm originally a java programmer, but I've taken on Labview since this past last year. I'm trying to make a code that will assign a value of 0 when a button ( button 1) is pressed and then change that value into a 1. When the button is then pressed again the value is changed back into a 0.

This code is for a claw that will open and close. Any advice, help, or screenshots?

int x=reader.nextInt(); // takes value of pressing the claw button
while (y==1) //the robot is turned on
{
if(x==-1)
{
claw=0; //open position
}
else(x==0)
{
claw=1; //close position
}

x=reader.nextInt(); //checks the next value of the claw button
y=OnOrOff.nextInt() //checks if robot is on or off
}
Reply With Quote
  #2   Spotlight this post!  
Unread 22-02-2011, 23:25
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,717
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: Java to Labview, using "if else" statements and pressing buttons

Here's a button toggle example.

As the example stands the green output alternates between a 1 or 0. You can eliminate the inside Case statement if you don't put anything inside it.
If you want a real number output use "Boolean To (0,1)" located on the boolean palette.

If the claw is solenoid operated you can just stick the activate inside the toggle where indicated and use this in Teleop.
A motor operated claw would require a longer cycle, but could be used, as is, inside Periodic Tasks or Autonomous Independent, not in Teleop.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 23-02-2011 at 10:27.
Reply With Quote
  #3   Spotlight this post!  
Unread 22-02-2011, 23:25
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
Re: Java to Labview, using "if else" statements and pressing buttons

x=reader.nextInt();
claw = !x;

There you go, I optimized it.
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.

Last edited by davidthefat : 22-02-2011 at 23:26. Reason: I forgot x=reader.nextInt();
Reply With Quote
  #4   Spotlight this post!  
Unread 23-02-2011, 00:31
WizenedEE's Avatar
WizenedEE WizenedEE is offline
Registered User
AKA: Adam
FRC #3238 (Cyborg Ferrets)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Anacortes, WA
Posts: 395
WizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to all
Re: Java to Labview, using "if else" statements and pressing buttons

I'm assuming you know about case structures.

To make an else if statement, you just go to the false case of the case structure and put another case structure inside that.

There are also other ways to do it, like taking all your inputs and making them into a number (with a boolean array to number function, if you're interested) and wiring that one number to the structure. However, it's easiest (although ugliest) to just nest the case structures.

I attached an optimized program for you.
Attached Thumbnails
Click image for larger version

Name:	Program Example.JPG
Views:	150
Size:	16.0 KB
ID:	10276  
Reply With Quote
  #5   Spotlight this post!  
Unread 24-02-2011, 20:59
Lemonsy Lemonsy is offline
Registered User
FRC #3028
 
Join Date: Feb 2011
Location: Hidalgo, Texas
Posts: 2
Lemonsy is an unknown quantity at this point
Re: Java to Labview, using "if else" statements and pressing buttons

Oh wow, thanks! I've tested both of them, but I need to discuss with my driver and team which they would prefer.

Much appreciated
Reply With Quote
  #6   Spotlight this post!  
Unread 24-02-2011, 22:55
frasnow's Avatar
frasnow frasnow is offline
Software
no team
Team Role: Mentor
 
Join Date: Jun 2010
Rookie Year: 2010
Location: Oregon
Posts: 83
frasnow is a splendid one to beholdfrasnow is a splendid one to beholdfrasnow is a splendid one to beholdfrasnow is a splendid one to beholdfrasnow is a splendid one to beholdfrasnow is a splendid one to beholdfrasnow is a splendid one to behold
Re: Java to Labview, using "if else" statements and pressing buttons

Quote:
Originally Posted by Mark McLeod View Post
LabVIEW can certainly make something simple look really complex. I'd be curious to know how long it took to draw that.
Quote:
Originally Posted by davidthefat View Post
x=reader.nextInt();
claw = !x;.
Simple, easy to read, and can be written in a few seconds. Even when you count the variable declaration.
Reply With Quote
  #7   Spotlight this post!  
Unread 25-02-2011, 00:07
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Java to Labview, using "if else" statements and pressing buttons

Quote:
Originally Posted by frasnow View Post
LabVIEW can certainly make something simple look really complex. I'd be curious to know how long it took to draw that.
I just redrew it in just under a minute.

Quote:
Code:
x=reader.nextInt();
claw = !x;.
Simple, easy to read, and can be written in a few seconds. Even when you count the variable declaration.
Alas, it doesn't do anything like what the original poster wants.
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 14:45.

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