Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Problems with buttons and structures (http://www.chiefdelphi.com/forums/showthread.php?t=126751)

skylerashe 18-02-2014 13:10

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

Mark McLeod 18-02-2014 13:24

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.

DaveCT 18-02-2014 13:26

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.

skylerashe 18-02-2014 13:29

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?

Mark McLeod 18-02-2014 13:31

Re: Problems with buttons and structures
 
Here's an example of the cascading select blocks that Dave mentioned:



All times are GMT -5. The time now is 08:53.

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