|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
Re: Jaguar Direction Control
Don't want to be impatient, but I would love to have this done for our meeting tomorrow!
|
|
#3
|
|||||
|
|||||
|
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.
|
|
#4
|
|||
|
|||
|
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.. |
|
#5
|
|||||
|
|||||
|
Re: Jaguar Direction Control
Updated screenshot. You can do it this way, or any other way that works. It's really up to you...
|
|
#6
|
|||
|
|||
|
Re: Jaguar Direction Control
Ah, I see. Thanks.
Would calling the Shooter motor twice in the same VI be a no-no as well? |
|
#7
|
|||||
|
|||||
|
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).
|
|
#8
|
|||
|
|||
|
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 ![]() |
|
#9
|
||||
|
||||
|
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.
|
|
#10
|
|||
|
|||
|
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.
|
|
#11
|
|||||
|
|||||
|
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. Last edited by plnyyanks : 23-01-2012 at 22:54. |
|
#12
|
|||
|
|||
|
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. |
|
#13
|
|||
|
|||
|
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? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|