Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Using Proxy Switch to Calculate RPM (http://www.chiefdelphi.com/forums/showthread.php?t=103046)

zero118 16-02-2012 22:38

Using Proxy Switch to Calculate RPM
 
Hello,

Our team is currently attempting to calculate the rpm of a wheel by utilizing a proxy switch. We will then use this calculated rpm with a PID loop do acquire a desired rpm; however, I am struggling to calculate the rpm in labVIEW.

I first tried to use the counter VI, a sequence structure, and a timer delay function, but I ran into problems (all these calculations are occurring in the teleop VI)

Here is the program i am using to calculate the rpm



Apparently the wait function I have in there makes the entire robot inactive.

How do I approach this problem?

Thanks!

Mark McLeod 16-02-2012 22:47

Re: Using Proxy Switch to Calculate RPM
 
The sequence needs to be moved to Periodic Tasks rather than Teleop.

Teleop cannot be delayed more than 20ms, or it will not be able to service the new driver commands that arrive every 20ms.

Kevin Sevcik 16-02-2012 22:55

Re: Using Proxy Switch to Calculate RPM
 
I'd double check the specs on your prox and make sure it's going to react quick enough to actually give you reliable RPM data. Some of them have a switching frequency down to 25Hz, which might be too slow for you.

zero118 16-02-2012 22:58

Re: Using Proxy Switch to Calculate RPM
 
Thank you for the reply! I will make sure to try that tomorrow.

I did notice that the timed tasks VI is outside the loop that contains the teleop VI. Does that mean that inside the time tasks VI, I should perform the above calculations in a while loop rather than a sequence structure?

Thanks!

Mark McLeod 16-02-2012 23:09

Re: Using Proxy Switch to Calculate RPM
 
You must have a While loop so that it keeps going all the time.

You only need a sequence structure if there is a series of discrete, timed or event driven steps you wish to make.

You didn't post your code so it's hard to say...

apalrd 16-02-2012 23:19

Re: Using Proxy Switch to Calculate RPM
 
Correct me if I'm wrong, but dosen't Counter Get return count time, which can be easily converted to speed with nothing more than a Counter Get and 1/x blocks?

zero118 16-02-2012 23:50

Re: Using Proxy Switch to Calculate RPM
 
This is what I have come up with. I have stored the calculated RPM in a variable so I can call it in the teleop VI. I also started the counter in the Begin VI.



Do you think thats a good approach?

And I will make sure to check the accuracy of the proxy switch!

I really appreciate your replies!

Thank you!

zero118 16-02-2012 23:53

Re: Using Proxy Switch to Calculate RPM
 
The Counter VI does have a "period" value, which returns the average time between pulses. I never actually contemplated using that. Do you think that would be a better idea?

Thad House 17-02-2012 00:23

Re: Using Proxy Switch to Calculate RPM
 
You dont actually need the reset. and using the period value would be a much better idea. with your method you would only get 1 reading per second. for the period, run it in a 1/x function then multiply it by 60 to get rpm's

Kevin Sevcik 17-02-2012 00:30

Re: Using Proxy Switch to Calculate RPM
 
If you're trying to use this value for closed loop control, then yes you probably want to use the period value instead, and update your value quicker. You'll also get vastly more useful data out of the period with much higher resolution. Counts only come in integer values, so the smallest change in RPM you can detect is 60 RPM. The period is going to be measured in rather smaller increments, so you should get much higher resolution data out of it. Also, you might be able to use the period measurement straight in your teleop loop instead, as long as the function block returns a good value even if it doesn't have a new period value yet.

zero118 17-02-2012 00:41

Re: Using Proxy Switch to Calculate RPM
 
Okay, I'll give the period strategy a shot! Thank you!

Also, i thought I should use the reset function because I wanted to find a relatively instantaneous rpm, which is also the reason I wanted to calculated the rpm every second using the time tasks VI. I thought if i didn't reset the counter, it would give me an average rpm, which would not be very useful. Am I interpreting it wrong?

Thank you again for the replies!

Thad House 17-02-2012 00:50

Re: Using Proxy Switch to Calculate RPM
 
The period does not look at the number of counts. It looks at the time it takes between 2 pulses, and thats what it outputs. the number of the counter doesnt matter.

Ether 17-02-2012 09:16

Re: Using Proxy Switch to Calculate RPM
 
Quote:

Originally Posted by zero118 (Post 1128554)
Also, i thought I should use the reset function because I wanted to find a relatively instantaneous rpm, which is also the reason I wanted to calculated the rpm every second using the time tasks VI. I thought if i didn't reset the counter, it would give me an average rpm, which would not be very useful. Am I interpreting it wrong?

You are interpreting it correctly. You need the reset* if you're doing your way. You don't need the reset if you do it the other way (get the elapsed time between counts).



* or instead of reset you could use a feedback node to subtract the previous reading



Hugh Meyer 17-02-2012 10:22

Re: Using Proxy Switch to Calculate RPM
 
Quote:

Originally Posted by Mark McLeod (Post 1128480)
Teleop cannot be delayed more than 20ms, or it will not be able to service the new driver commands that arrive every 20ms.

Mark,

Would you please reference a document or thread that explains the "new driver commands" and explains the 20 ms period.

Thanks.

Hugh


All times are GMT -5. The time now is 00:47.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi