Single encoder servo motor direction

More
02 Sep 2022 11:02 #250988 by Byass
Hello,
Ive been trying to get some pittman dc servo motors to work with the etch servo configuration. These motors use a single optical encoder thus Im using encoder.N.counter-mode set to true and the motor position is determined by encoder.N.position im also using a l298n to control the motors thus each motor direction is determined by two parallel port output pins.

but the problem is that when i run the motors in different directions the motor position changes only in one direction (the position keeps going up).

how can I make that it adds or subtract from the current position based on the motor direction?

thanks,

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

More
02 Sep 2022 14:15 #251006 by PCW
You need to set counter mode false
(assuming the encoders have A and B signals = quadrature)

You cannot use a single sensor encoder for position control.
(because the actual motor direction does not always
match the commanded direction)

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

More
02 Sep 2022 15:12 #251015 by Byass
the encoders only have one signal

I don't get why wouldn't the actual motor direction match the commanded direction?

thanks,

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

More
02 Sep 2022 16:08 #251018 by cmorley
Because a single sensor cannot detect direction.
The two sensor quadrature encoder was designed to encode direction as well as relative position..

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

More
02 Sep 2022 16:26 #251020 by Byass
yes I know that

what I meant is that in my setup the motor direction is directly controlled via the parallel port using an l298n h bridge. thus the software always knows the motor direction.

I want to use the single encoder to count steps to be used with the already determined motor direction to calculate the motor position.

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

More
02 Sep 2022 16:45 #251022 by cmorley
Ahh I see what you are getting at. You want to be able to change the count direction with an external pin at run time.

Just looking at the pin list, I don't see an existing way, but it would be relatively easy to hack on an extra pin to do it if you know to modify the source and recompile.

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

More
02 Sep 2022 16:47 #251023 by tommylight

I want to use the single encoder to count steps to be used with the already determined motor direction to calculate the motor position.

It is not possible to use a single encoder signal for position, the controller must know what way is the motor turning to be able to position it and to hold the desired position.
Example, the motor is standing still, you turn it by hand and the controller gets the signal that the motor has moved, but what direction? So what direction should the controller command the motor to move to bring it back to where it was?
-
You can use a single encoder signal to count the turns so can monitor and regulate the speed in velocity mode.

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

More
02 Sep 2022 16:51 #251025 by cmorley
I think he can make this work but he needs a count direction pin

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

More
02 Sep 2022 16:54 #251027 by Byass
what I originally intended was to change the count direction using software (for example if the pwmgen.N.dir is 0 then add counts if the pwmgen.N.dir is 1 then remove counts). I wanted to know how can that be done

if I understood you right, you meant simulate the phase-B signal using another pin so that the software thinks that the motor is running in different directions?

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

More
02 Sep 2022 17:12 #251033 by cmorley
Sort of. currently in the code, count is always increased.
One could add a pin so that it could be increased or decreased based on the pin being true or false.

I would add a new pin rather then using the phase-B just to make it clearer.

I am assuming you need to change the direction while running.
If you just need to change the direction to match your motor and it will never change then negate the scale.

Chris

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

Time to create page: 0.092 seconds
Powered by Kunena Forum