Go to Post Wait...engineers have personalities? - Mark McLeod [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 18-02-2014, 13:10
skylerashe skylerashe is offline
Registered User
FRC #5287
 
Join Date: Feb 2014
Location: Orange, TX
Posts: 2
skylerashe is an unknown quantity at this point
Problems with buttons and structures

I am attempting to make two motors run at the same time when a button is pressed and stop when its released I have gotten it to work for one button but I need it reversed with the second and its very glitch when I try that it runs like every five seconds which I find very strange here is the code for reference http://imgur.com/y21fcb6 I have the false set to zero for the motors to stop running thanks for any help
Reply With Quote
  #2   Spotlight this post!  
Unread 18-02-2014, 13:24
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: Problems with buttons and structures

You can't set the same motor to different values in two different places at the same time in your code.

One motor = one call to Set

You are telling the motors to go and to stop at the same time.
Whichever code gets executed last wins the race.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #3   Spotlight this post!  
Unread 18-02-2014, 13:26
DaveCT DaveCT is offline
Registered User
AKA: Dave Schroeder
FRC #0177 (Bobcats)
Team Role: Engineer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Connecticut
Posts: 9
DaveCT is an unknown quantity at this point
Re: Problems with buttons and structures

If you have the false cases setting the motors to zero then you have the same code turning the motors on and turning the motors off. (ie when you press button 2, the first case statement evaluates as false, setting the motors to zero, the second case statement evaluates to true, which tries to turn the motors on) The order of execution is indeterminate in the code you provided which means that you're going to get unpredictable results.

There are a couple of ways to achieve what you want. One would be to nest the two case structures. (check button 2 in the false case of button 1). Another would be to use cascading select blocks to determine which value to send to the Set Motor blocks.

Hope that helps.
__________________
Team 177 | Software Engineer
Reply With Quote
  #4   Spotlight this post!  
Unread 18-02-2014, 13:29
skylerashe skylerashe is offline
Registered User
FRC #5287
 
Join Date: Feb 2014
Location: Orange, TX
Posts: 2
skylerashe is an unknown quantity at this point
Re: Problems with buttons and structures

Ok I see where my error is now but I don't quite get how to fix it any examples of something similar?
Reply With Quote
  #5   Spotlight this post!  
Unread 18-02-2014, 13:31
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: Problems with buttons and structures

Here's an example of the cascading select blocks that Dave mentioned:

__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
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 20:14.

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