Go to Post ... you know you are a nerd when you want safety glasses for your birthday! :P - Ashley Christine [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 23-01-2012, 20:00
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Jaguar Direction Control

Hello -

I've got a fan hooked up to a PWM Jaguar speed controller. I'm trying to make the fan turn full speed when I hold button 7, and turn full speed in the opposite direction when I hold button 8.

I've linked case structures to proper buttons (see pictures below).

I've opened the motor (plugged into PWM 7) twice (one to move forward, one to move in reverse) and set the refnum name to Shooter and NegShooter (reverse). The reason I opened the motor twice was because while I could get the motor to accept one case structure (containing the correct value) as a value, I could not get the motor to accept two.


Button 8 works fine, however when I hit button 7, nothing happens. What's wrong here?

Here's some images of code.




Thanks.
Reply With Quote
  #2   Spotlight this post!  
Unread 23-01-2012, 21:49
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: Jaguar Direction Control

Don't want to be impatient, but I would love to have this done for our meeting tomorrow!
Reply With Quote
  #3   Spotlight this post!  
Unread 23-01-2012, 22:00
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Jaguar Direction Control

You don't want to open the motor twice. That causes problems. See my attached screenshot for a better way to do it.
Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	29
Size:	10.1 KB
ID:	11539  
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
Reply With Quote
  #4   Spotlight this post!  
Unread 23-01-2012, 22:02
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: Jaguar Direction Control

Ah, I see.

Now, I want Button 7 to set the value to 1, and button 8 to set it to -1. When neither are pressed, I'd like the motor to have a value of 0, thus my thought for case structures..
Reply With Quote
  #5   Spotlight this post!  
Unread 23-01-2012, 22:32
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Jaguar Direction Control

Updated screenshot. You can do it this way, or any other way that works. It's really up to you...
Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	29
Size:	10.8 KB
ID:	11541  
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
Reply With Quote
  #6   Spotlight this post!  
Unread 23-01-2012, 22:33
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: Jaguar Direction Control

Ah, I see. Thanks.

Would calling the Shooter motor twice in the same VI be a no-no as well?
Reply With Quote
  #7   Spotlight this post!  
Unread 23-01-2012, 22:39
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Jaguar Direction Control

That should be okay. Just make sure that each iteration of the code, that you only set each motor once. You don't have to set every motor every iteration, and you can set multiple motors per iteration, but don't set a single motor more than once per iteration. It's just bad practice and a waste of memory (it won't actually break anything if you do so).
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
Reply With Quote
  #8   Spotlight this post!  
Unread 23-01-2012, 22:45
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: Jaguar Direction Control

I see.

Here's what I've come up with. It checks to see if the sums equal 0 (which would be the case if both buttons were pressed, or if neither were pressed), which activates the True case structure, stopping the motor. If it's not equal to 0, it sets it to the value.

Spot any potential problems?

FALSE


TRUE
Reply With Quote
  #9   Spotlight this post!  
Unread 23-01-2012, 22:47
msulaimain's Avatar
msulaimain msulaimain is offline
Registered User
AKA: Muhammad Sulaiman
FRC #3346 ([{Kamikaze Komets}])
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2009
Location: USA
Posts: 36
msulaimain can only hope to improve
Send a message via AIM to msulaimain Send a message via Yahoo to msulaimain
Re: Jaguar Direction Control

I'm not a Labview kind of guy, but in C++, you create if, then and else statements. I hope that you can relate that to Labview. Hope it helps.
__________________
int main()
{
::::::::: include=>commitment;
::::::::: int=>school name=>Asheboro::High
::::::::: int=>team name=>Kamikaze::Komets;
::::::::: Priority_Queue=>FRC Championship::2012;
::::::::: Max_Element=>Teamwork;
}
Reply With Quote
  #10   Spotlight this post!  
Unread 23-01-2012, 22:48
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: Jaguar Direction Control

There are if and else statements, but I've yet to look into them. Thanks for the advise, I'll look into them and see if they can be of use.
Reply With Quote
  #11   Spotlight this post!  
Unread 23-01-2012, 22:49
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Jaguar Direction Control

That will work, but think about what you're doing. You're checking if a value is equal to zero - if it is, then use a different zero constant for your motor output. If it's not equal to zero, then set it to that value.

Here's a question for you: why do you need that case structure? Is it necessary or a waste of processor cycles? How can you write that to be the most efficient?

when you program long enough, you eventually view everything in terms of processor cycles and efficiency...


EDIT: in response to above, case structures in LabVIEW are actually extremely powerful. They can function as both an if/else as well as switch statement (to compare to C(++)), depending on what you wire into it. Read about it.

Edit 2: Oh, and one more thing. On your most recent screenshot, on your 1 and -1 constants, see the little red dots? They're called coercion dots. They happen when LabVIEW automatically changes a datatype of something (in this case from int to double). You want to avoid those, if possible, as they unnecessarily drain resources (it's not a big draw, but an avoidable one). Right click on your int constants, and under Representation, choose DBL (for double) to make the wire orange/keep one constant datatype.
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android

Last edited by plnyyanks : 23-01-2012 at 22:54.
Reply With Quote
  #12   Spotlight this post!  
Unread 23-01-2012, 22:53
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: Jaguar Direction Control

Well, here was our plan. We want to have 4 different motor 'profiles' bound to buttons on the joystick we are using for ball launching/collecting. For example, 'Profile 1' sets the output to -1 for 2.5 seconds, 'Profile 2' sets the output to .75 for 1.3 seconds and so on...

So, with the changing outputs and times, I thought these case structures would come in handy later down the road.

EDIT: Thanks for the tip regarding the coercion dots. I actually had about 8 of those in total in our teleop.vi !

Last edited by DominickC : 23-01-2012 at 22:59.
Reply With Quote
  #13   Spotlight this post!  
Unread 23-01-2012, 23:10
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: Jaguar Direction Control

Alright, after reading your link, I'm thinking about doing this.

If button 7 is pressed, this initiates a stacked sequence. The first frame of this sequence calls the motor "shooter" and sets the output to whatever value defined outside of the sequence. This frame runs for how many milliseconds we define it to run for. It then moves on to the second frame, calling the motor "shooter" and setting the output to 0.

How's the logic sounding?
Reply With Quote
  #14   Spotlight this post!  
Unread 23-01-2012, 23:34
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: Jaguar Direction Control

I just took a look at Programming>>Timing, and I'm utterly confused. How can I time a step within a stacked sequence?
Reply With Quote
  #15   Spotlight this post!  
Unread 23-01-2012, 23:54
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: Jaguar Direction Control

So, this is what I'm trying to accomplish.

Set a button on the joystick to set the output of a motor to a certain speed for a defined period of time before resetting the output to 0.

Here's what I've come up with. I've got the first frame wired to the output of the Select module. Now that I look at it, I don't believe it'll work I think it'll set the output to 0 then move on to the next frame.


Would my problem be solved if I wired a button directly to the stacked sequence which set the output of the motor to the value I want on the first frame, then returns it to 0 on the final frame?
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 22:21.

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