d.wilcox Posted September 26 Report Share Posted September 26 I am trying to count rotations of a servo. It doesn't have to be exact, +/- 1 rotation is good enough. The only way of measuring the position of the servo is the encoder count, which i can read via serial coms from the drive. It's an int32 value. Unfortunately it does not output the index of the encoder, otherwise i'd just use that. This number will continue to grow at the rate of 4000 pulses per rev until it reaches the limit of the int32 and then i believe it resets to zero and starts over. I was thinking the best way to count the revs is to only pay attention to the 4th digit. Is there any way to do that? I was thinking of adding the int32 to an array and extract it that way, but i'm not 100% sure on that. Link to comment Share on other sites More sharing options...
MVP 2023 kratmel Posted September 26 MVP 2023 Report Share Posted September 26 Please post servo model # or pdf link to this servo manual. I think rotation # must be also present in servo drive parameters. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted September 27 MVP 2023 Report Share Posted September 27 In the event you are unable to obtain the encoder index, it's simple enough to count revs. Just do the following: -Compare the servo count with a temporary register. -If different, increment another register for pulse count. -Store the servo count to the temporary register. -When the pulse count equals 4000, you have one revolution and can reset the pulse count. Repeat. Link to comment Share on other sites More sharing options...
d.wilcox Posted September 27 Author Report Share Posted September 27 1 hour ago, Flex727 said: In the event you are unable to obtain the encoder index, it's simple enough to count revs. Just do the following: -Compare the servo count with a temporary register. -If different, increment another register for pulse count. -Store the servo count to the temporary register. -When the pulse count equals 4000, you have one revolution and can reset the pulse count. Repeat. i'm not sure if i'm following correctly. it is a continuous count. it'll go to 2,147,483,647 and then start back over at zero. i dont think that would work, but maybe i'm misunderstanding. Link to comment Share on other sites More sharing options...
d.wilcox Posted September 27 Author Report Share Posted September 27 15 hours ago, kratmel said: Please post servo model # or pdf link to this servo manual. I think rotation # must be also present in servo drive parameters. it does not. confirmed with the manufacturer. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted September 27 MVP 2023 Report Share Posted September 27 15 minutes ago, d.wilcox said: i'm not sure if i'm following correctly. it is a continuous count. it'll go to 2,147,483,647 and then start back over at zero. i dont think that would work, but maybe i'm misunderstanding. Maybe this will be a bit more clear. Sorry it's written in VisiLogic rather than UniLogic, but I think you'll get the gist. And a signed 32-bit integer will go to -2,147,483,647, not zero, but that's irrelevant to this issue. 1 Link to comment Share on other sites More sharing options...
MVP 2023 kratmel Posted September 27 MVP 2023 Report Share Posted September 27 The method proposed here by Flex will probably not work. With a rapid change in speed, the network feedback will be inconsistent and uneven. Therefore, the 4000 counter (Temp) will not correctly correspond to the revolutions of the shaft. p.s. Please post servo model # and if possible max shaft speed Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted September 27 MVP 2023 Report Share Posted September 27 41 minutes ago, kratmel said: The method proposed here by Flex will probably not work. It has worked well for me, but I agree that if the pulses are coming in faster than the scan rate you might have a problem. How about this modification: Link to comment Share on other sites More sharing options...
MVP 2023 kratmel Posted September 27 MVP 2023 Report Share Posted September 27 Then the third rung may fail. As Joe said using "=" in counter track gives a 1 in 4000 chance that the rung won't work and very often... So even after modification this method will fail. Since it is impossible to predict that exactly 4000 will be accumulated as a result. And if there is a difference (you try to use >= in rung 3), the total revolution counter will have an error. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted September 29 MVP 2023 Report Share Posted September 29 On 9/27/2024 at 2:52 PM, kratmel said: As Joe said using "=" in counter track gives a 1 in 4000 chance that the rung won't work and very often... Yes, I neglected to change that to >=. That was unnecessary before but is now. On 9/27/2024 at 2:52 PM, kratmel said: the total revolution counter will have an error. Yes it will, but the OP indicated that +/- 1 rotation would be good enough. It may have an error greater than that, but I don't see a way to improve it if the index value is not available. I was just offering a plan B if Plan A wasn't available. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now