d.wilcox Posted Thursday at 10:17 PM Report Share Posted Thursday at 10:17 PM 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 Thursday at 11:17 PM MVP 2023 Report Share Posted Thursday at 11:17 PM 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 Friday at 01:00 PM MVP 2023 Report Share Posted Friday at 01:00 PM 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 Friday at 02:40 PM Author Report Share Posted Friday at 02:40 PM 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 Friday at 02:41 PM Author Report Share Posted Friday at 02:41 PM 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 Friday at 03:01 PM MVP 2023 Report Share Posted Friday at 03:01 PM 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 Friday at 06:53 PM MVP 2023 Report Share Posted Friday at 06:53 PM 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 Friday at 07:36 PM MVP 2023 Report Share Posted Friday at 07:36 PM 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 Friday at 07:52 PM MVP 2023 Report Share Posted Friday at 07:52 PM 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...
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