Go to Post Of course, the banana might mean nothing. It could just mean that Dave needs more potassium in his diet. :) - KathieK [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 07-02-2013, 08:26
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: Problem programming buttons

If I understand what you're describing, you have four essentially independent Case Structures. Each of them sets the same motors in the True case. What do the False cases do? It sounds like they all set the motors to zero.

I think you've made a common programming error. If the second button is pressed, its True case sets the motors to the value you want -- but because the first button is not pressed, its False case immediately sets the motors to zero. Having multiple Motor Set functions is a recipe for this sort of race condition.

Instead of having the Case do everything, just have it produce the values you want to run the motor with, and put a single RefNum Get and Motor Set Value outside the Case Structures. Chain the Case Structures together so that the False case just feeds its inputs straight through to its outputs without change, and the True case ignores the inputs and wires the desired constants to its outputs. Feed zeros into the first Case Structure so that the motors will be off when no buttons are pressed.

Or you can use Select functions instead of Case structures.

Or you can get fancy and encode the four buttons into a number, then use that number to select among many different Cases in a single structure.
Reply With Quote
 


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 12:02.

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