Go to Post This is still about fun. Remember that. - Koko Ed [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 07-02-2013, 02:09
Martian86 Martian86 is offline
Registered User
FRC #1159
Team Role: Alumni
 
Join Date: Sep 2012
Rookie Year: 2011
Location: California
Posts: 28
Martian86 is just really niceMartian86 is just really niceMartian86 is just really niceMartian86 is just really niceMartian86 is just really nice
Problem programming buttons

We need buttons 1-4 on our game controller to set two different motors to the same speed when each button is pressed; each button is a different speed setting. Only one of them works properly for some reason (more on that in a minute), but the other three are identical as far as I can tell other than the button number and speed assignment.

The one that works:
Button 1--> Case structure: two true constants of -.67 and two false constants of 0-->WPIMotorControlSetOutput.vi (a separate one for each constant) --> WPIMotorControlRefNum Registry Get.vi (a separate one for each set output) -->motor names (since I lack creativity their names are "motor 1" and "motor 2")

The ones that don't work are exactly the same except the button numbers are different and the true constants in the case structure are different.

As I said, the button 1 programming works: it runs the motor at 2/3 speed. Buttons 2, 3, and 4 either don't work at all or make the motor twitch a little. Some of the things we've tried and what happened:
-Use different game controller: no difference
-Use different motor: no difference
-Use different PWMs: no difference
-Change speed in the button 1 code: button 1 sets motor to whatever speed we specified
-Disable code for buttons 3 and 4: button 1 still works and button 2 does not

At this point I'm not sure what I did, but I think I messed something up or accidentally deleted something, so I'm not too sure how credible this next piece of troubleshooting was; thankfully I had my pre-troubleshooting code saved elsewhere; I'll try it again tomorrow with that. Anyway, my next step:

-With buttons 3 and 4 still disabled, I changed the button assignment for the piece of code that we know works from button 1 to button 3. After this, none of the buttons worked.

Any ideas on what could be wrong? Thanks in advance for your input.

Last edited by Martian86 : 07-02-2013 at 02:15.
Reply With Quote
  #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,113
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
  #3   Spotlight this post!  
Unread 07-02-2013, 12:59
dsherw00d dsherw00d is offline
Registered User
FRC #0378
 
Join Date: Jan 2012
Location: Newfane NY
Posts: 44
dsherw00d is a jewel in the roughdsherw00d is a jewel in the roughdsherw00d is a jewel in the rough
Re: Problem programming buttons

Out team did the same thing - used T/F case structures each having a motor set. It mostly worked at .6 and the others would just move the motor in small increments. After thinking about it we came up with the same conclusion as above - all non pressed buttons are F and setting the motor to 0 while the pressed one is setting it to .6 for example. I'm not sure why .6 seems to work for us and many others that tried this method. My guess is that is has something to do with PWM, the motor frequency, and the DS communication packet delivery.

We moved to using cascaded select statements and it works fine.
Reply With Quote
  #4   Spotlight this post!  
Unread 07-02-2013, 19:56
Martian86 Martian86 is offline
Registered User
FRC #1159
Team Role: Alumni
 
Join Date: Sep 2012
Rookie Year: 2011
Location: California
Posts: 28
Martian86 is just really niceMartian86 is just really niceMartian86 is just really niceMartian86 is just really niceMartian86 is just really nice
Re: Problem programming buttons

Quote:
Originally Posted by Alan Anderson View Post
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.
Did that, it works now. Thanks!
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:48.

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