Go to Post The other day, I stuck my head into a box of Rhino treads and got a sugar high. - Andy Baker [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 25-01-2013, 15:02
chriz4gx chriz4gx is offline
Registered User
AKA: Christopher Villar
FRC #2871 (Beantown Botz)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Boston,MA
Posts: 45
chriz4gx is an unknown quantity at this point
Code Not Working Properly

So I'm having a hard time trying to figure out why my code isnt working properly.I want that when I press button 3 on joystick 1 it would give a output of 0.75 to the motor connected to pwm 3. It works properly but I thought I programmed it that when u press again(Button 3) it would turn off. So pretty much I want Button 3 to be like a motor on and off switch. Im really stuck and cant figure out why the shooter wont turn off when I press it again. Thxs any help would be greatly appreciated
Attached Files
File Type: vi Shooter.vi (32.4 KB, 6 views)
Reply With Quote
  #2   Spotlight this post!  
Unread 25-01-2013, 15:46
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: Code Not Working Properly

I looked at the VI and have a few suggestions.

You are using a feedback node which can keep track of previous values, but you aren't really using the value stored in it.

The attached image shows how to use the feedback node to update the motor when the button changes and the new state determines what the motor does. It may be even better to select the value and update the motor in only one place.

Greg McKaskle
Attached Thumbnails
Click image for larger version

Name:	Clipboard 1.png
Views:	10
Size:	26.7 KB
ID:	13653  
Reply With Quote
  #3   Spotlight this post!  
Unread 26-01-2013, 09:22
chriz4gx chriz4gx is offline
Registered User
AKA: Christopher Villar
FRC #2871 (Beantown Botz)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Boston,MA
Posts: 45
chriz4gx is an unknown quantity at this point
Re: Code Not Working Properly

Can you upload a picture of the whole code. Sort of confused of where exactly I place the feedback node
Reply With Quote
  #4   Spotlight this post!  
Unread 26-01-2013, 10:02
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: Code Not Working Properly

The code takes the button value and compares to the last value, the value delayed by the feedback node. When different the button was either just pressed, or just released. The you can distinguish by using selects, cases, or an AND node with the current value. Once you know whether it just went down or came up, update the motor to the appropriate value, as your code already was doing.

By the way, the bottom * portion of the feedback node is for initialization. My code left it blank which may not be appropriate. The better choice is probably to wire the button to both the input of the node and the * initializer.

Greg McKaskle
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 21:50.

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