Single encoder servo motor direction

More
02 Sep 2022 17:27 #251036 by Byass
can I use pwmgen.N.dir? since it is what determines the motor direction in my setup
if so can you direct me to how it can be done?

thanks.

Please Log in or Create an account to join the conversation.

More
02 Sep 2022 17:34 #251039 by cmorley
As I said currently there is no way to tell the encoder component (after being loaded) to count in different directions while in counter mode. The source code would need to be changed and rcompiled - it's c programming code. Id this something you are familiar with?

Please Log in or Create an account to join the conversation.

More
02 Sep 2022 17:34 - 02 Sep 2022 17:42 #251040 by PCW
No matter what you do in software, this will not work for
position control because you will accumulate errors at reversals.
For example, when decelerating at low speeds, the motion
direction will be opposite of the PID output, and there is no
reliable way to detect the actual motion reversal with just one
encoder signal.
Also as tommylight mentioned, you will lose position with external
forces from cutting etc

 
Last edit: 02 Sep 2022 17:42 by PCW. Reason: reformat

Please Log in or Create an account to join the conversation.

More
02 Sep 2022 17:44 - 02 Sep 2022 17:44 #251043 by cmorley
Maybe you could explain your motivation for doing this the way you want to?

I'm with PCW and Tommy here I would not bother trying this unless it was just an exercise, I want to play with what I have just for fun, or I need something hacked together that probably won't work very well.

Though the direction pin might be useful regardless.
Last edit: 02 Sep 2022 17:44 by cmorley.

Please Log in or Create an account to join the conversation.

More
02 Sep 2022 17:46 - 02 Sep 2022 17:47 #251044 by PCW
The Hostmot2 encoder does exactly that (B is direction in counter mode)
Last edit: 02 Sep 2022 17:47 by PCW.

Please Log in or Create an account to join the conversation.

More
02 Sep 2022 17:50 - 02 Sep 2022 17:50 #251046 by cmorley
does the software encoder component do that? I looked at the code and it might but it uses lut and look up list so I didn't try to decipher more.
 
Last edit: 02 Sep 2022 17:50 by cmorley.

Please Log in or Create an account to join the conversation.

More
02 Sep 2022 18:02 #251049 by cmorley
I tested - software encoder does not use phase-b for direction.

Please Log in or Create an account to join the conversation.

More
02 Sep 2022 18:03 - 02 Sep 2022 18:03 #251050 by PCW
The manual page says the B input is ignored in counter mode
Last edit: 02 Sep 2022 18:03 by PCW.

Please Log in or Create an account to join the conversation.

More
06 Sep 2022 22:53 #251363 by andypugh
I would probably write a custom component, but I think that this can be done with standard HAL components.

You probably need three sum2 components.

Use sum2.2 (the last one) at the bottom of the list, with in0 connected to the encoder counts and with an in1 of 0 to supply a one-period-delayed value of the total encoder counts.

Take that value into one input of sum2.0 and take the current encoder counts to in0 and the delayed counts to in1. Set the gain to -1 to give a subtraction.

Then use sum2.1 to calculate your bidirectional counts. in0 is looped to the output, and represents your encoder counts.
in1 is the one-period delta that was calculated by sum2.0
Then set the gain to +1 or -1 depending on motor direction.

Calculate position by a HAL scale component (after converting counts to float)

Please Log in or Create an account to join the conversation.

Time to create page: 0.100 seconds
Powered by Kunena Forum