![]() |
Re: Speed PID Function
Quote:
|
Re: Speed PID Function
Quote:
|
Re: Speed PID Function
http://www.chiefdelphi.com/media/photos/37282?
I am running the Victor at 35% |
Re: Speed PID Function
Quote:
I don't know if the rate implementation has changed since then. Your noise seems a little higher then what I saw before, but that could easily be explained by differences in setup. Saying that you're running a Victor at 35% doesn't answer Ether's question without also defining what motor you're using. In your chart, what are the units for "data". |
Re: Speed PID Function
this is where my confusion lies.
I thought the getRate function was reading the RPM's I guess not. I looked at the method itself and it shows that the equation for getRate is... setdistanceperpulse/getPeriod or right now for me. 1/the time between each pulse What my software mentor told me is that what were going to do is probably sample from the getRaw data encoder function. since we are getting 2.5 revolutions per second @ 35% power based on a test I did. since there are 1440 pulses per revolution. |
Re: Speed PID Function
Well, from a test I have done today, the encoder that came with the KOPs from a previous year outputs 250 ± 5 for every revolution. So it is not directly 360 degrees. Keep that in mind. What I am doing is just using the raw output and getting the RPM from that.
|
Re: Speed PID Function
Yeah I'm going to be using the RAW from now on as well.
I forget...is there is a way of subtracting consecutive samples and dividing them by 2 to find the rate. |
Re: Speed PID Function
Quote:
1 RPM = 1/60 rev/sec = 1440/60 pulses/sec = 24 pulses/sec So RPM = (delta_pulses/dt)/24 ...where delta_pulses is the change in the raw count from the previous cycle, and dt is the cycle time in seconds. Don't forget: you must scale your setpoint to the same units as your process_variable. |
Re: Speed PID Function
Quote:
If your cycle time is 20 milliseconds (TeleOp) and you have 1440 pulses/rev, then to get RPM you would take the difference in pulses and divide by 24*0.02 = 0.48 |
Re: Speed PID Function
The encoder returns 1440 per REV.
I am getting about 2.5-2.7 REVS a second. |
Re: Speed PID Function
In post #24, "cycle time" is not the time it takes for your encoder to rotate once.
it is the delta time between the two GetRaw() readings you are subtracting to get "delta_pulses" (the change in pulse count). if you are running the PID in TeleOp, that would be approximately 20 milliseconds. |
Re: Speed PID Function
I just got a VERY constant rate from using this function I wrote.
Code:
public void getSpeed(){ |
Re: Speed PID Function
Quote:
|
Re: Speed PID Function
Quote:
If it's getting reset, you're only getting a new speed every 10 cycles. If it's not, then once it becomes non-zero it stays that way, and you re-zero the counter every cycle so the filter does nothing (except skew the calculation). What you want is a circular buffer (ring buffer) that you populate each cycle and use each cycle to get a new speed, like this: Code:
public void getSpeed(){ |
My mentor explained to me this way.
Your first 9 values are going to be very skewed so wait until you have at least 9 values in your array before you start averaging. Now counter is a pointer variable it ONLY points to a position in the array. I add all the values and get an average every time after 9 samples. I haven't tested changing speeds yet. Only constants. |
| All times are GMT -5. The time now is 08:53. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi