Go to Post Teams whose goal is to play on Einstein think about strategy differently from teams whose goal is to be selected for an alliance at a district event. - alopex_rex [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-2012, 15:20
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: PID Velocity Control

Try to avoid global variables whenever possible, especially in LabVIEW.

In this case, they severely chop up your data flow, which makes it hard to see exactly what your order of operations is. As written, you do not guarantee the order or timing of when Cur. Rotations and Prev Rotations are read going in to the RPM calculation - You may end up with them being grabbed such that Cur is read too soon or too late, so your output can bobble between zero, expected, and multiples of expected. It could even go negative if you were attempting to update faster and you had a lot of other stuff going on.

Also, it looks like your while loop grabs the value from Cur Rotations once at the start of the owning VI, and then writes that same value to Prev Rotations every 50 milliseconds. Is this the intended behavior?

As Ether said, a feedback node or a shift register is likely what you are looking for here.
Reply With Quote
  #2   Spotlight this post!  
Unread 15-02-2012, 15:44
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: PID Velocity Control

The Encoder Get VI has a Rate output at the bottom that takes care of quite a bit of that for you. The output is in pulses per second so you will have to scale appropriately if you want RPM.
Reply With Quote
  #3   Spotlight this post!  
Unread 15-02-2012, 15:54
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
Re: PID Velocity Control

Quote:
Originally Posted by RufflesRidge View Post
The Encoder Get VI has a Rate output at the bottom that takes care of quite a bit of that for you. The output is in pulses per second so you will have to scale appropriately if you want RPM.
Wow its good that I didn't see that before and waste a few hours trying to figure this out.

So it gives me the rate of the encoder perfectly?
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
Reply With Quote
  #4   Spotlight this post!  
Unread 15-02-2012, 16:15
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: PID Velocity Control

Quote:
Originally Posted by j.cole View Post
Wow its good that I didn't see that before and waste a few hours trying to figure this out.

So it gives me the rate of the encoder perfectly?
Yes, you can look inside the Encoder Get VI to see (kind of) how this works. The help for the VI (what I checked before posting the first time) says that it is in pulses per second, put that does not appear to be correct based on looking at the internals and usage/comments in some previous team code.

The rate returned is actually Distance Per Count (set when opening) * Pulses/sec. So if you are just using rate for this encoder and not distance you can set your distance per count such that the rate returns in RPM.

To do this take Revs/min = the formula I wrote above and solve for the Distance Per Count term.
Reply With Quote
  #5   Spotlight this post!  
Unread 15-02-2012, 16:54
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: PID Velocity Control

Quote:
Originally Posted by RufflesRidge View Post
The Encoder Get VI has a Rate output at the bottom that takes care of quite a bit of that for you. The output is in pulses per second so you will have to scale appropriately if you want RPM.
For very high RPMs (such as a shooter wheel) you might be better off reading counts every 20ms and then scaling delta_counts to RPM.

http://www.chiefdelphi.com/forums/sh...6&postcount=19


Attached Thumbnails
Click image for larger version

Name:	encoder rate.jpg
Views:	80
Size:	38.3 KB
ID:	11917  

Last edited by Ether : 15-02-2012 at 17:00.
Reply With Quote
  #6   Spotlight this post!  
Unread 15-02-2012, 17:29
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
Re: PID Velocity Control

Quote:
Originally Posted by Ether View Post
For very high RPMs (such as a shooter wheel) you might be better off reading counts every 20ms and then scaling delta_counts to RPM.

http://www.chiefdelphi.com/forums/sh...6&postcount=19


I see what thats for because I'm doing some testing right now and the encoder rate is really jumpy. My lead adviser mentioned he saw someone else posting the same issue so I'm gonna look for that form and test this out to see if it works. Thanks for all your help so far guys.
I looked up shift registers by the way and I understand the concepts now.
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
Reply With Quote
  #7   Spotlight this post!  
Unread 15-02-2012, 17:54
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: PID Velocity Control

Quote:
Originally Posted by j.cole View Post
I see what thats for because I'm doing some testing right now and the encoder rate is really jumpy.
Yup. Try delta_counts and you should see a much less noisy signal. Did you see the little drawing I attached to the previous post? It shows a feedback node.
Reply With Quote
  #8   Spotlight this post!  
Unread 15-02-2012, 18:00
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
Re: PID Velocity Control

Didn't work. I tested it at 1/4 voltage and the value I was getting from the encoder was jumping from 2.6 max to 1.8 min. Is there any way to average that number and stay in the middle? I've been our programmer for 3 years but I'm new to advanced programming techniques.
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
Reply With Quote
  #9   Spotlight this post!  
Unread 15-02-2012, 18:34
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
Re: PID Velocity Control

Alright I think I found the problem. I changed the Decoding Rate in the begin from 4x to 2x. That dropped the variation from +-.5 to +-.05 . I'm going to try 1x now and see what it looks like.
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
Reply With Quote
  #10   Spotlight this post!  
Unread 15-02-2012, 19:08
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: PID Velocity Control

Quote:
Originally Posted by j.cole View Post
Didn't work.
What "didn't work" ?? There's no context available for disambiguation.


Last edited by Ether : 15-02-2012 at 21:03.
Reply With Quote
  #11   Spotlight this post!  
Unread 16-02-2012, 13:17
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
Re: PID Velocity Control

Doing the delta counts didn't fix the problem which was the jumpyness of the encoder values at a constant voltage. I think that properly tuned I could negate the effects of that variation.
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
Reply With Quote
  #12   Spotlight this post!  
Unread 16-02-2012, 13:31
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: PID Velocity Control

Quote:
Originally Posted by j.cole View Post
Doing the delta counts didn't fix the problem which was the jumpyness of the encoder values at a constant voltage.
At what encoder speed (RPM) were you seeing jumpyness of the encoder values using the delta_counts method?


Reply With Quote
  #13   Spotlight this post!  
Unread 17-02-2012, 10:55
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
Re: PID Velocity Control

(I just took the delta counts so I'd say it's RPS not RPM) But I tried everywhere between .5 RPS and 5 RPS and the variance is still the same. I want to say it has something to do with the rate TeleOp runs but I don't know.
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
Reply With Quote
  #14   Spotlight this post!  
Unread 17-02-2012, 11:07
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: PID Velocity Control

Quote:
Originally Posted by j.cole View Post
(I just took the delta counts so I'd say it's RPS not RPM) But I tried everywhere between .5 RPS and 5 RPS and the variance is still the same. I want to say it has something to do with the rate TeleOp runs but I don't know.
If there's excessive jitter in TeleOp, try dividing delta_counts by the actual elapsed time instead of the assumed 20ms.

Is this for a shooter wheel or something else?


Reply With Quote
  #15   Spotlight this post!  
Unread 15-02-2012, 15:47
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
Re: PID Velocity Control

The intended operation is to get the RPM of the motor. Now what I expected to happen was that every half a second the program would take the current value and write it to the previous value. And then take the previous value and subtract it from the current value. Giving me my total rotations for that half second.
I've never used shift registers because I have no understanding of them at all and it was easier to do it a different way than learn something, which I should have done in the first place. 5 weeks in is a little bit late eh?
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
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:06.

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