Go to Post "What connection is the most vital to the success of your robot?" The one between the drivers brain and hands, and the one between the coaches brain and mouth. None of the other ones matter if those two don't work. - dlavery [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 15-02-2015, 14:31
RoboBucs RoboBucs is offline
Registered User
FRC #5005
 
Join Date: Jan 2015
Location: Chattanooga, TN
Posts: 72
RoboBucs is an unknown quantity at this point
Use a button to make a motor move a certain number of rotations

Ok I was curious to see if this would work for making a motor move an exact amount of rotations when a button is pressed, thanks.

Reply With Quote
  #2   Spotlight this post!  
Unread 15-02-2015, 14:50
Levansic's Avatar
Levansic Levansic is offline
Registered User
AKA: Len Evansic
FRC #0585 (Cyber Penguins)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Tehachapi, CA
Posts: 185
Levansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud of
Re: Use a button to make a motor move a certain number of rotations

It depends on how you set your motors in Begin.vi, and what type of motor controllers you are using. Most likely, this will cause your motors to run at full speed forward or backward, while the button is pressed.

If you are using encoders and configured Talon SRX's to use CAN and position control with proper PID values, you may get a twitch. You will need proper software setup, encoders, and good PID values to do what you want to do accurately.

The drive reference contains data that will configure the various drive and motor vi's to interpret their inputs properly. By default, the maximum input/output is 1, which corresponds to a 100% forward or backward. Your ±3.76... input will be seen as a saturated maximum of 1. The default mode if you just open a can Talon SRX will be Percent Vbus, which works the same as PWM, and doesn't use feedback from an encoder.

All of this being said, you can approximate the closed-loop control to do what you want with a sensibly low speed and a timer, but this will take a LOT of experimentation, and the results will be highly variable.
Reply With Quote
  #3   Spotlight this post!  
Unread 15-02-2015, 15:02
RoboBucs RoboBucs is offline
Registered User
FRC #5005
 
Join Date: Jan 2015
Location: Chattanooga, TN
Posts: 72
RoboBucs is an unknown quantity at this point
Re: Use a button to make a motor move a certain number of rotations

Quote:
Originally Posted by Levansic View Post
It depends on how you set your motors in Begin.vi, and what type of motor controllers you are using. Most likely, this will cause your motors to run at full speed forward or backward, while the button is pressed.

If you are using encoders and configured Talon SRX's to use CAN and position control with proper PID values, you may get a twitch. You will need proper software setup, encoders, and good PID values to do what you want to do accurately.

The drive reference contains data that will configure the various drive and motor vi's to interpret their inputs properly. By default, the maximum input/output is 1, which corresponds to a 100% forward or backward. Your ±3.76... input will be seen as a saturated maximum of 1. The default mode if you just open a can Talon SRX will be Percent Vbus, which works the same as PWM, and doesn't use feedback from an encoder.

All of this being said, you can approximate the closed-loop control to do what you want with a sensibly low speed and a timer, but this will take a LOT of experimentation, and the results will be highly variable.
Alright, the number I put there was supposed to be the number of rotations that the motors would make each time they're pressed, the motors have built in encoders, where would I put that number so that the motors will run 3.76 rotations each time the button is pressed? Thanks
Reply With Quote
  #4   Spotlight this post!  
Unread 15-02-2015, 15:11
Levansic's Avatar
Levansic Levansic is offline
Registered User
AKA: Len Evansic
FRC #0585 (Cyber Penguins)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Tehachapi, CA
Posts: 185
Levansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud of
Re: Use a button to make a motor move a certain number of rotations

What is the number of pulses per rev for the built-in encoders? I think the only legal motors that have built-in encoders have 7 pulses per revolution and a 71:1 step down through the typically attached gearboxes. Are these the ones that you are using?

If so, that could correspond to 7 x 4 x 71 = 1988 counts per revolution. The factor of four is because the encoder is quadrature, and has four registered pulse edges per pulse cycle. That means you would be seeking a count of approximately 7475. The math changes if you are using a different gearbox. Note that the numbers I am using are integers. You can't have fractional pulses.

All of this assumes that you set the output type as position in Begin.vi, and that you have appropriate PID terms.
Reply With Quote
  #5   Spotlight this post!  
Unread 15-02-2015, 15:25
RoboBucs RoboBucs is offline
Registered User
FRC #5005
 
Join Date: Jan 2015
Location: Chattanooga, TN
Posts: 72
RoboBucs is an unknown quantity at this point
Re: Use a button to make a motor move a certain number of rotations

Quote:
Originally Posted by Levansic View Post
What is the number of pulses per rev for the built-in encoders? I think the only legal motors that have built-in encoders have 7 pulses per revolution and a 71:1 step down through the typically attached gearboxes. Are these the ones that you are using?

If so, that could correspond to 7 x 4 x 71 = 1988 counts per revolution. The factor of four is because the encoder is quadrature, and has four registered pulse edges per pulse cycle. That means you would be seeking a count of approximately 7475. The math changes if you are using a different gearbox. Note that the numbers I am using are integers. You can't have fractional pulses.

All of this assumes that you set the output type as position in Begin.vi, and that you have appropriate PID terms.
Ok, that definently helps me with understanding these encoders, thank you, I just don't know where I would put that 7475 number in labview at, do you know?
Reply With Quote
  #6   Spotlight this post!  
Unread 15-02-2015, 15:31
Levansic's Avatar
Levansic Levansic is offline
Registered User
AKA: Len Evansic
FRC #0585 (Cyber Penguins)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Tehachapi, CA
Posts: 185
Levansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud of
Re: Use a button to make a motor move a certain number of rotations

You would put it as an input to the drive (where you have it), but you have to have the drive motors properly configured. One other thing, is that you need a little more logic to latch the value. The Teleop.vi runs approximately every 20 ms. As soon as you let go of the button, your input will be to drive the motor back to the 0 position. This isn't what you want.

If you intend to drive your robot completely with position commands, you will need a state machine that keeps track of the current values, incrementing and decrementing the intended position.

It is much easier to drive in speed or voltage mode.
Reply With Quote
  #7   Spotlight this post!  
Unread 15-02-2015, 15:40
RoboBucs RoboBucs is offline
Registered User
FRC #5005
 
Join Date: Jan 2015
Location: Chattanooga, TN
Posts: 72
RoboBucs is an unknown quantity at this point
Re: Use a button to make a motor move a certain number of rotations

Quote:
Originally Posted by Levansic View Post
You would put it as an input to the drive (where you have it), but you have to have the drive motors properly configured. One other thing, is that you need a little more logic to latch the value. The Teleop.vi runs approximately every 20 ms. As soon as you let go of the button, your input will be to drive the motor back to the 0 position. This isn't what you want.

If you intend to drive your robot completely with position commands, you will need a state machine that keeps track of the current values, incrementing and decrementing the intended position.

It is much easier to drive in speed or voltage mode.
It won't be completely, it's only with this specific arm, we can use joystick movement for it rather than buttons, it would just be easier for our driver to put a button and have the motors move that amount for that arm every single time. I also have 2 questions, what do you mean by speed or voltage mode and what's wrong with the way I have the drive motors configured? It's probably something stupid, I'm still used to using unbundle by name for buttons from last year rather than arrays, thank you so much for your help so far!
Reply With Quote
  #8   Spotlight this post!  
Unread 15-02-2015, 16:03
RoboBucs RoboBucs is offline
Registered User
FRC #5005
 
Join Date: Jan 2015
Location: Chattanooga, TN
Posts: 72
RoboBucs is an unknown quantity at this point
Re: Use a button to make a motor move a certain number of rotations

Ok I think I'm starting to understand this, so would I put the 7475 number as distance per count in begin for the encoder? Past that I'm not sure how I can assign a button to work under that motor count for the encoder and the motor in teleop
Reply With Quote
  #9   Spotlight this post!  
Unread 15-02-2015, 16:07
Levansic's Avatar
Levansic Levansic is offline
Registered User
AKA: Len Evansic
FRC #0585 (Cyber Penguins)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Tehachapi, CA
Posts: 185
Levansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud of
Re: Use a button to make a motor move a certain number of rotations

Can you post the snippet of code from Begin.vi where you setup these motors?
Reply With Quote
  #10   Spotlight this post!  
Unread 15-02-2015, 16:10
RoboBucs RoboBucs is offline
Registered User
FRC #5005
 
Join Date: Jan 2015
Location: Chattanooga, TN
Posts: 72
RoboBucs is an unknown quantity at this point
Re: Use a button to make a motor move a certain number of rotations

Quote:
Originally Posted by Levansic View Post
Can you post the snippet of code from Begin.vi where you setup these motors?
Reply With Quote
  #11   Spotlight this post!  
Unread 15-02-2015, 16:17
RoboBucs RoboBucs is offline
Registered User
FRC #5005
 
Join Date: Jan 2015
Location: Chattanooga, TN
Posts: 72
RoboBucs is an unknown quantity at this point
Re: Use a button to make a motor move a certain number of rotations

Quote:
Originally Posted by Levansic View Post
Can you post the snippet of code from Begin.vi where you setup these motors?
Would I have to set it up like this? (I just forgot to rename the second encoder in begin)


Reply With Quote
  #12   Spotlight this post!  
Unread 15-02-2015, 16:27
Levansic's Avatar
Levansic Levansic is offline
Registered User
AKA: Len Evansic
FRC #0585 (Cyber Penguins)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Tehachapi, CA
Posts: 185
Levansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud of
Re: Use a button to make a motor move a certain number of rotations

Your snippets are illuminating.

OK, here's the rest of the story. Unfortunately, you won't have a simple way of just sending a number to the motor controller, as you are using PWM Victors, which have no understanding of encoders or close loop modes.

You will need to implement a PID control in LabView, where the encoder inputs are compared to your desired position. The outputs will drive the motor voltages up and down, until the desired position is realized.

LabView has several built-in PID functions, and there are many threads here about how to use them.
Reply With Quote
  #13   Spotlight this post!  
Unread 15-02-2015, 16:37
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,100
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: Use a button to make a motor move a certain number of rotations

Quote:
Originally Posted by Levansic View Post
Your snippets are illuminating.
They're not snippets. They're just screenshots.
Reply With Quote
  #14   Spotlight this post!  
Unread 15-02-2015, 16:42
RoboBucs RoboBucs is offline
Registered User
FRC #5005
 
Join Date: Jan 2015
Location: Chattanooga, TN
Posts: 72
RoboBucs is an unknown quantity at this point
Re: Use a button to make a motor move a certain number of rotations

Quote:
Originally Posted by Levansic View Post
Your snippets are illuminating.

OK, here's the rest of the story. Unfortunately, you won't have a simple way of just sending a number to the motor controller, as you are using PWM Victors, which have no understanding of encoders or close loop modes.

You will need to implement a PID control in LabView, where the encoder inputs are compared to your desired position. The outputs will drive the motor voltages up and down, until the desired position is realized.

LabView has several built-in PID functions, and there are many threads here about how to use them.
How do they have no way of understanding encoders if the encoders are built in?
Reply With Quote
  #15   Spotlight this post!  
Unread 15-02-2015, 16:42
Levansic's Avatar
Levansic Levansic is offline
Registered User
AKA: Len Evansic
FRC #0585 (Cyber Penguins)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Tehachapi, CA
Posts: 185
Levansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud of
Re: Use a button to make a motor move a certain number of rotations

Quote:
Originally Posted by Ether View Post
They're not snippets. They're just screenshots.
You are quite correct. Those chunks of screenshot carry the same human-readable info, which is what I was after.
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:25.

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