Go to Post I blame FIRST for being the best thing that has happened to me. - vivek16 [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
  #16   Spotlight this post!  
Unread 09-02-2015, 08:00
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: motor programming

Quote:
Originally Posted by itwasntme455 View Post
What is the wait 20 for in the bottom left corner?
It's a throttle. It makes it so that the joystick button is only checked every 20 milliseconds inside the large While loop. Without it, the code in that loop will be running As Fast As Possible, which is undesired for two reasons. First, new joystick data only arrives every 20 milliseconds, and there's no point in checking any faster than that. Second, and more importantly, if the code is running without any delays, it can starve the rest of the program of CPU resources.
Reply With Quote
  #17   Spotlight this post!  
Unread 09-02-2015, 08:04
mshafer1 mshafer1 is offline
Programming Mentor
AKA: Matthew Shafer
FRC #3937 (Breakaway)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2008
Location: Arkansas
Posts: 53
mshafer1 is an unknown quantity at this point
Re: motor programming

Quote:
Originally Posted by itwasntme455 View Post
What is the wait 20 for in the bottom left corner?
The wait 20 is in there because this loop is designed to be dropped in Periodic Tasks and run in parallel with Teleop (which should contain your drive code). The wait command actually releases the processor to do other things for a split second then come back and rerun this loop.
Please note two things. 1) the code posted by Mark is a snippet, you can download the picture and drag it into LabVIEW and it will turn back into code.
2) it is advisable to move the part that he has labeled labeled for teleop into the loop (one joystick gets values, one index array, three branches of the button value) - mostly because these actions are related (increase cohesion).

Last edited by mshafer1 : 09-02-2015 at 12:50. Reason: answer to reply
Reply With Quote
  #18   Spotlight this post!  
Unread 09-02-2015, 08:30
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: motor programming

Quote:
Originally Posted by mshafer1 View Post
2) it is advisable to move the part that he has labeled labeled for teleop into the loop (one joystick gets values, one index array, three branches of the button value) - because some believe that calling the joystick in multiple places will cause delays in one or the other part of the code, but mostly because these actions are related (increase cohesion).
I advise against moving the part intended for Teleop into the loop. If you do that, the elevator motor will always run at least as long as the brake motor. A brief tap of the button will not result in a brief movement of the elevator that way.
Reply With Quote
  #19   Spotlight this post!  
Unread 09-02-2015, 08:45
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,731
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: motor programming

Please don't add superstitions. That's actively harmful.

As Alan said, the code must be separated.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 09-02-2015 at 08:54.
Reply With Quote
  #20   Spotlight this post!  
Unread 09-02-2015, 16:14
mshafer1 mshafer1 is offline
Programming Mentor
AKA: Matthew Shafer
FRC #3937 (Breakaway)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2008
Location: Arkansas
Posts: 53
mshafer1 is an unknown quantity at this point
Re: motor programming

Quote:
Originally Posted by Alan Anderson View Post
I advise against moving the part intended for Teleop into the loop. If you do that, the elevator motor will always run at least as long as the brake motor. A brief tap of the button will not result in a brief movement of the elevator that way.
Perhaps I should have been more clear.
Attached Thumbnails
Click image for larger version

Name:	elevatorWithBreak.png
Views:	27
Size:	59.2 KB
ID:	18241  
Reply With Quote
  #21   Spotlight this post!  
Unread 09-02-2015, 16:21
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,034
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: motor programming

Quote:
Originally Posted by mshafer1 View Post
Perhaps I should have been more clear.
In what way is your proposed change superior to what Mark posted?


Reply With Quote
  #22   Spotlight this post!  
Unread 09-02-2015, 16:43
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: motor programming

Quote:
Originally Posted by mshafer1 View Post
Perhaps I should have been more clear.
That won't work right either. While the brake motor is running, the button state isn't being read. I don't have LabVIEW installed on the computer I'm using, but it looks like the brake motor is going to continually run five seconds in reverse, then pause for an instant and do it again. I suspect some of the wiring is swapped from where it ought to be. However, adding the other button for the other elevator direction won't be straightforward. You're overthinking things and getting requirements confused with theoretical "best practices" that are based more on hearsay than on reality.
Reply With Quote
  #23   Spotlight this post!  
Unread 09-02-2015, 20:42
mshafer1 mshafer1 is offline
Programming Mentor
AKA: Matthew Shafer
FRC #3937 (Breakaway)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2008
Location: Arkansas
Posts: 53
mshafer1 is an unknown quantity at this point
Re: motor programming

I was missing a case structure, but we need to remember that the point of FRC is not to develop hacks and bad programming habits.
As far as not reading the joystick again during the entire engage/disengage of the break, that is almost necessary unless a sensor is implemented or they choose to implement a piston or some other two state actuator.
Attached Thumbnails
Click image for larger version

Name:	elevatorWithBreak.png
Views:	8
Size:	66.7 KB
ID:	18254  
Reply With Quote
  #24   Spotlight this post!  
Unread 09-02-2015, 22:33
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: motor programming

Quote:
Originally Posted by mshafer1 View Post
As far as not reading the joystick again during the entire engage/disengage of the break, that is almost necessary unless a sensor is implemented or they choose to implement a piston or some other two state actuator.
Again, I don't have access to LabVIEW to look at the other cases, but it still looks like your code is going to require the elevator to run for at least five seconds when the button is pressed, and will require it to stay stopped for at least five seconds when the button is released. That does not meet the requirements given by the person asking for help.

And it still doesn't account for the second button.

Last edited by Alan Anderson : 09-02-2015 at 22:41.
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 03:46.

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