Go to Post Do what you want. Deal with the results. - 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 06-02-2015, 15:56
itwasntme455 itwasntme455 is offline
Registered User
AKA: Brandon
FRC #4791 (Pandroids)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2013
Location: South Bend, Indiana
Posts: 26
itwasntme455 is an unknown quantity at this point
motor programming

We need to make a motor turn to a certain point when a button is pushed and stopped even though the button is still being held.
Reply With Quote
  #2   Spotlight this post!  
Unread 06-02-2015, 16:18
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: motor programming

I don't know what part of the goal you are having problems with. Would it help if you could get just a single indication that the button had been pressed, and not have to worry whether or not it had been released?
Reply With Quote
  #3   Spotlight this post!  
Unread 06-02-2015, 16:25
itwasntme455 itwasntme455 is offline
Registered User
AKA: Brandon
FRC #4791 (Pandroids)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2013
Location: South Bend, Indiana
Posts: 26
itwasntme455 is an unknown quantity at this point
Re: motor programming

Quote:
Originally Posted by Alan Anderson View Post
I don't know what part of the goal you are having problems with. Would it help if you could get just a single indication that the button had been pressed, and not have to worry whether or not it had been released?
What we want to happen is when button A is pressed it will turn the motor for .5 seconds and button A will still be held down to continueslly turn another motor.
Reply With Quote
  #4   Spotlight this post!  
Unread 06-02-2015, 18:30
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,833
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

Treat them as two independent actions.

Do the .5 sec motor action in Periodic Tasks (here's an example from last year-note the joystick Get is no longer correct)
Do the while holding action in Teleop (another example, only implement the button 2 part of this example)
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 06-02-2015 at 18:38.
Reply With Quote
  #5   Spotlight this post!  
Unread 07-02-2015, 12:58
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: motor programming

Here's how I would do it. This code can go in either Teleop or one of the Periodic Task loops.

The part with a green right-facing feedback node and a "greater than" is a standard LabVIEW idiom for getting a single TRUE pulse when a button is first pressed.

The part at the top left is computing a boolean output saying whether or not the current tick count has reached a saved value, and setting that value to 500 ms in the future when it gets the "button has just been pressed" signal.
Attached Thumbnails
Click image for larger version

Name:	Pandroids.png
Views:	84
Size:	23.4 KB
ID:	18190  
Reply With Quote
  #6   Spotlight this post!  
Unread 07-02-2015, 15:01
itwasntme455 itwasntme455 is offline
Registered User
AKA: Brandon
FRC #4791 (Pandroids)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2013
Location: South Bend, Indiana
Posts: 26
itwasntme455 is an unknown quantity at this point
Re: motor programming

Quote:
Originally Posted by Alan Anderson View Post
Here's how I would do it. This code can go in either Teleop or one of the Periodic Task loops.

The part with a green right-facing feedback node and a "greater than" is a standard LabVIEW idiom for getting a single TRUE pulse when a button is first pressed.

The part at the top left is computing a boolean output saying whether or not the current tick count has reached a saved value, and setting that value to 500 ms in the future when it gets the "button has just been pressed" signal.
ok, so next question is when we release button A we want the motor to go in the opposite direction for 5 seconds and stop. How would I do that?
Reply With Quote
  #7   Spotlight this post!  
Unread 07-02-2015, 17:31
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: 58
mshafer1 is an unknown quantity at this point
Re: motor programming

It sounds like you need to use a state machine, there's several tutorials at This LabVIEW Tutorial Site, it sounds like you would have a forward, second motor, and reverse (or more descriptive for what those motors do). A state machine can be implemented in either periodic tasks or in Teleop (only caveat is that when done in Teleop, one either needs to insert a while loop that only runs once (constant on the terminal), or use the main program while loop and pass the data in and out of Teleop.
Reply With Quote
  #8   Spotlight this post!  
Unread 07-02-2015, 18:00
itwasntme455 itwasntme455 is offline
Registered User
AKA: Brandon
FRC #4791 (Pandroids)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2013
Location: South Bend, Indiana
Posts: 26
itwasntme455 is an unknown quantity at this point
Re: motor programming

Quote:
Originally Posted by mshafer1 View Post
It sounds like you need to use a state machine, there's several tutorials at This LabVIEW Tutorial Site, it sounds like you would have a forward, second motor, and reverse (or more descriptive for what those motors do). A state machine can be implemented in either periodic tasks or in Teleop (only caveat is that when done in Teleop, one either needs to insert a while loop that only runs once (constant on the terminal), or use the main program while loop and pass the data in and out of Teleop.
So the motor that will run constantly will control our elevator, when button A (move up) is held down or button B is held down(move down). The motor we want to run for 5 seconds one direction when button A or B is pressed will release a brake mechanism then when button A or B is released it will spin the motor back 5 second to the original spot to reengage the brake.
Reply With Quote
  #9   Spotlight this post!  
Unread 07-02-2015, 19:12
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: motor programming

If you had given a fuller description of your requirements to begin with, we could have avoided giving half answers that don't quite do what you want. Keep that in mind for future times when you need more help than you let on. :-)

Is it possible to add some feedback to your "brake" system? Installing a pair of limit switches, so the software can tell when it's fully engaged or fully released, would help. If you can do that, the programming gets a whole lot easier.

If sensor feedback is not possible, then the suggestion of a state machine makes sense. You need a place to store the current state, either a global variable or a feedback node. You need to identify the inputs, in this case the A "up" and B "down" buttons. You need a timer, which the tick count code I presented can provide. And then you need to define what conditions cause the code to move from state to state, and what the motors are supposed to do in each state.
Reply With Quote
  #10   Spotlight this post!  
Unread 08-02-2015, 14:47
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: 58
mshafer1 is an unknown quantity at this point
Re: motor programming

Quote:
Originally Posted by Alan Anderson View Post
If you had given a fuller description of your requirements to begin with, we could have avoided giving half answers that don't quite do what you want. Keep that in mind for future times when you need more help than you let on. :-)

Is it possible to add some feedback to your "brake" system? Installing a pair of limit switches, so the software can tell when it's fully engaged or fully released, would help. If you can do that, the programming gets a whole lot easier.

If sensor feedback is not possible, then the suggestion of a state machine makes sense. You need a place to store the current state, either a global variable or a feedback node. You need to identify the inputs, in this case the A "up" and B "down" buttons. You need a timer, which the tick count code I presented can provide. And then you need to define what conditions cause the code to move from state to state, and what the motors are supposed to do in each state.

Mr. Anderson has made a good point, sensor feedback on the position of the elevator is more likely to work than timing - (that way the system can know if the brake is engaged yet or not). If contact through a limit switch is undesirable (which it may be in your case) you could consider a potentiometer or encoder on the brake motor or you could get a little adventurous using the IR sensors or a magnet and reed switch to detect of the brake is in proximity or not.

With regards to different actions in Timed tasks and teleop, it is advisable to only control a manipulator (including all subsystems of a given manipulator) in one place, in part for debugging (why is it doing that? . . . oh, it might be getting a signal from this other vi over in a different part of the code . . . not a good idea) and for simplicity (understandably).
Reply With Quote
  #11   Spotlight this post!  
Unread 08-02-2015, 15:22
itwasntme455 itwasntme455 is offline
Registered User
AKA: Brandon
FRC #4791 (Pandroids)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2013
Location: South Bend, Indiana
Posts: 26
itwasntme455 is an unknown quantity at this point
Re: motor programming

Thanks for all the help but I am very confused. This is the first time I have used LabVIEW so some of the things you guys are suggesting isn't making since to me. Also our team doesn't have the resources to get some of the senors you are suggesting. Can someone give me an example to just make the motor turn for 5 seconds when button A or B is pressed and then turn 5 seconds in reverse when button A or B is released? Again thanks for all the help.
Reply With Quote
  #12   Spotlight this post!  
Unread 08-02-2015, 18:20
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,833
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

I think this does what you ask for one button.
However, adding a second button can bring some additional complexity to handle pressing both buttons at once and avoiding letting the release of one of them from trying to engage the brake with the other button is still powering the elevator.

It has two separate elements.
The hold the button action happens in Teleop.vi
The Disengage/Engage brake happens in Periodic Tasks (this can also be implemented using a state machine).

The important point is that the joystick can be checked and acted on anywhere as many times as you need.
In the Periodic Tasks example, one action must complete before the other action can occur, but you might want to restructure it a little to force an Engage to only follow a Disengage and vice versa. For the Periodic Tasks segment, I'd probably nest the Engage behind the Disengage in such a way that you cannot have two Engages or Disengages in a row.

When adding Button B you'll have to be careful that the motors do not get two conflicting orders at the same time.

In adding Button B to the Teleop code you'll have to use Selects to prioritize one button over the other.
Attached Thumbnails
Click image for larger version

Name:	SimultaneousActions.png
Views:	56
Size:	59.7 KB
ID:	18220  
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 08-02-2015 at 20:53.
Reply With Quote
  #13   Spotlight this post!  
Unread 08-02-2015, 22:41
itwasntme455 itwasntme455 is offline
Registered User
AKA: Brandon
FRC #4791 (Pandroids)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2013
Location: South Bend, Indiana
Posts: 26
itwasntme455 is an unknown quantity at this point
Re: motor programming

Quote:
Originally Posted by Mark McLeod View Post
I think this does what you ask for one button.
However, adding a second button can bring some additional complexity to handle pressing both buttons at once and avoiding letting the release of one of them from trying to engage the brake with the other button is still powering the elevator.

It has two separate elements.
The hold the button action happens in Teleop.vi
The Disengage/Engage brake happens in Periodic Tasks (this can also be implemented using a state machine).

The important point is that the joystick can be checked and acted on anywhere as many times as you need.
In the Periodic Tasks example, one action must complete before the other action can occur, but you might want to restructure it a little to force an Engage to only follow a Disengage and vice versa. For the Periodic Tasks segment, I'd probably nest the Engage behind the Disengage in such a way that you cannot have two Engages or Disengages in a row.

When adding Button B you'll have to be careful that the motors do not get two conflicting orders at the same time.

In adding Button B to the Teleop code you'll have to use Selects to prioritize one button over the other.
Where do i find those green arrows?
Reply With Quote
  #14   Spotlight this post!  
Unread 08-02-2015, 22:54
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: motor programming

Quote:
Originally Posted by itwasntme455 View Post
Where do i find those green arrows?
Feedback nodes are in the Structures subpalette, along with While and For and Case blocks. They start out black when you place them, then change color to reflect the type of the wire connected to them. In this case, green for boolean. They point to the left by default, but can be switched to point the other direction on their right-click menu.
Reply With Quote
  #15   Spotlight this post!  
Unread 08-02-2015, 23:06
itwasntme455 itwasntme455 is offline
Registered User
AKA: Brandon
FRC #4791 (Pandroids)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2013
Location: South Bend, Indiana
Posts: 26
itwasntme455 is an unknown quantity at this point
Re: motor programming

Quote:
Originally Posted by Mark McLeod View Post
I think this does what you ask for one button.
However, adding a second button can bring some additional complexity to handle pressing both buttons at once and avoiding letting the release of one of them from trying to engage the brake with the other button is still powering the elevator.

It has two separate elements.
The hold the button action happens in Teleop.vi
The Disengage/Engage brake happens in Periodic Tasks (this can also be implemented using a state machine).

The important point is that the joystick can be checked and acted on anywhere as many times as you need.
In the Periodic Tasks example, one action must complete before the other action can occur, but you might want to restructure it a little to force an Engage to only follow a Disengage and vice versa. For the Periodic Tasks segment, I'd probably nest the Engage behind the Disengage in such a way that you cannot have two Engages or Disengages in a row.

When adding Button B you'll have to be careful that the motors do not get two conflicting orders at the same time.

In adding Button B to the Teleop code you'll have to use Selects to prioritize one button over the other.
What is the wait 20 for in the bottom left corner?
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:23.

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