Go to Post Avoid the impulse to shoot from the hip, and find out the full picture before deciding where you stand. - gblake [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 12-02-2010, 18:46
ChrisArmour ChrisArmour is offline
Registered User
FRC #3133
 
Join Date: Feb 2010
Location: scottsdale
Posts: 14
ChrisArmour is an unknown quantity at this point
Programming Toggle Swiches

I am new with labview and have gotten everything but the autonomous done.

i need help trying to set up switches.

i have two switches.

if both of them are on then do no autonomous.

if toggle one on and toggle two off, do autonomous code one

if toggle one is off, 2 on, do autonomous code 2

if both on do automous code three

Last edited by ChrisArmour : 12-02-2010 at 19:15.
Reply With Quote
  #2   Spotlight this post!  
Unread 12-02-2010, 19:02
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Programming Toggle Swiches

Chris,

Read them both in as Boolean then convert to a number. Each will be a zero or a one.

Now multiply #2 by 2 and add to #1. You now have a number ranging from 0 to 3.

Put this into a switch or case statement (depending on your programming language).

You're done...

Mike
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
Reply With Quote
  #3   Spotlight this post!  
Unread 12-02-2010, 19:05
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Programming Toggle Swiches

There are a couple things to do here. One task is to get toggle switches connected to the Cypress board. You also need to write code. If you want to write the code first, or do the tasks in parallel with someone else, you can disconnect the board from the DS and simply change the digital inputs on the I/O screen directly (this assumes you are using the compatible mode for I/O).

Once this works, or the physical toggles are connected and control the switches on the screen of the DS I/O tab, you want to read those in Autonomous. The VI for this is in palette at WPILib>>Driver Station>>Compatibility I/O>>Get Digital Inputs. It returns an array, and you can retrieve the Booleans from the array using an array indexer or other means. I'd recommend combining the Booleans together into a number and wiring the number to a switch statement around most of your autonomous code. You'll probably find it useful to get the refnums in common code outside the switch, and then put the various autonomous with. You can also make the autonomous routines into subVIs too and simply call them from within the switch statement.

Greg McKaskle
Reply With Quote
  #4   Spotlight this post!  
Unread 13-02-2010, 12:05
ChrisArmour ChrisArmour is offline
Registered User
FRC #3133
 
Join Date: Feb 2010
Location: scottsdale
Posts: 14
ChrisArmour is an unknown quantity at this point
Re: Programming Toggle Swiches

Thanks Mike I think we managed to get that code made but I don't think it will quite work with the system we have.

We will have three switches with on/ off positions that will controll three different autonomous modes. The problem is that we are not sure how to connect the switches to the code. We need the code to recieve the position of all the switches form DIO 3-5. We tried to use the select but said that we were using the wrong type of input for "S", but it is the same concept. If button one is on, and others off, then run autonomous for feild section one. If button two on, and others off, then run autonomous for feild section two. If button 3 on and others off, then run autonomous for reild section 3.

Could anyone give me some tips, we are kind off hitting a wall.
Reply With Quote
  #5   Spotlight this post!  
Unread 13-02-2010, 16:22
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Programming Toggle Swiches

Quote:
Originally Posted by ChrisArmour View Post
Thanks Mike I think we managed to get that code made but I don't think it will quite work with the system we have.

We will have three switches with on/ off positions that will controll three different autonomous modes. The problem is that we are not sure how to connect the switches to the code. We need the code to recieve the position of all the switches form DIO 3-5. We tried to use the select but said that we were using the wrong type of input for "S", but it is the same concept. If button one is on, and others off, then run autonomous for feild section one. If button two on, and others off, then run autonomous for feild section two. If button 3 on and others off, then run autonomous for reild section 3.

Could anyone give me some tips, we are kind off hitting a wall.
Chris,

I really think that converting to a number and then feedng a switch is far easier and less confusing to do.

Mike
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble programming Digital I/O toggle switches in C++ drhall General Forum 5 02-04-2009 22:43
Programming toggle switches to DS for different autonomous routines? grosh NI LabVIEW 9 30-03-2009 20:42
Programming Toggle Switches in Labview seanl Programming 1 16-02-2009 13:02
Programming Joystick Buttons to toggle a motor on and off programmr C/C++ 6 25-01-2009 17:47
3 way toggle switch programming LeadRiccardoT Programming 3 17-02-2003 02:02


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

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