![]() |
PID Velocity Control
2 Attachment(s)
Should this code work to get the velocity of the motor using an encoder. (See pictures they should explain better than I could). Plug that number into the process variable and see if it works. I'm going to increase the refresh rate to get a more accurate reading.
|
Re: PID Velocity Control
Quote:
Can't you just use a feedback node to compare CurrentRotations to the previous value? |
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. |
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.
|
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? |
Re: PID Velocity Control
Quote:
So it gives me the rate of the encoder perfectly? |
Re: PID Velocity Control
Quote:
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. |
Re: PID Velocity Control
Quote:
Quote:
You might be interested in http://www.frcmastery.com/ - They have some great videos specific to LabVIEW for FRC. |
Re: PID Velocity Control
1 Attachment(s)
Quote:
http://www.chiefdelphi.com/forums/sh...6&postcount=19 |
Re: PID Velocity Control
Quote:
I looked up shift registers by the way and I understand the concepts now. |
Re: PID Velocity Control
Quote:
|
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.
|
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.
|
Re: PID Velocity Control
Quote:
|
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.
|
| All times are GMT -5. The time now is 11:14. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi