Encoder Problem

I connected both rear motor encoders to my pixhawk 6x board model 2a. Used Aux 1&2 for the left motor and Aux 3 & 4 for the Right motor. Settings were confirmed by referencing the pix6x info on Ardu website. When I checked the logs (WENC) there was no data after driving it.

Encoder 1 (Left Rear):
WENC_TYPE = 1
WENC_PINA = 50 (Blue signal wire + Ground Wire)
WENC_PINB = 51 (Green Signal Wire)
SERVO9_FUNCTION = -1 (GPIO)
SERVO10_FUNCTION = -1 (GPIO)
WENC_CPR = 2448
WENC_RADIUS = 0.08
WENC_POS_X = −0.145
WENC_POS_Y = -0.19 (left)

Encoder 2 (RightRear):
WENC2_TYPE = 1
WENC2_PINA = 52 (Blue signal wire + Ground Wire)
WENC2_PINB = 53 (Green Signal Wire)
SERVO11_FUNCTION = -1 (GPIO)
SERVO12_FUNCTION = -1 (GPIO)
WENC2_CPR = 2448
WENC2_RADIUS = 0.08
WENC2_POS_X = −0.145
WENC2_POS_Y = 0.19 (Right)

For reference, each motor encoder works when connected to Aux5 and Aux 6 with the settings below with data recorded on the logs for the drive session.
WENC_TYPE = 1
WENC2_PINA = 54
WENC2_PINB = 55
SERVO13_FUNCTION = -1 (GPIO)
SERVO14_FUNCTION = -1 (GPIO)
WENC_CPR = 2448
WENC_RADIUS = 0.08

Can someone tell me if Aux 1-4 operate differently from Aux 5-6? Seems weird that it works on aux 4-5 but not 1-4.

On a Pixhawk1 with IOMCU AUX’s are processor pins and PWM’s are on IOMCU (possibly your case).

On balance bots on Pixhawk1 with DIR/PWM motor controller I use AUX1-2 for DIR’s (outputs) and AUX3-6 for WENC’s (inputs with interrupt capability). PWM’s (duty cycle) on MAIN1-2. Additionally to your WENC/SERVO parameters I use:
MOT_PWM_TYPE,3
RELAY_PIN,50
RELAY_PIN2,51
RELAY_PIN3,-1
RELAY_PIN4,-1
RELAY_PIN5,-1
RELAY_PIN6,-1

Thanks for the reply Webillo.
Unfortunately, V4.7.1 no longer has any of those variables.

Hi @badgersix,

The pins have been slightly renamed a few versions ago so that the number appears earlier.

So for example RELAY_PIN (from AP-4.4) is now RELAY1_PIN in 4.5 and higher.

Hope that helps

On v4.7.1 I see:

MOT_PWM_TYPE,3
RELAY1_DEFAULT,0
RELAY1_FUNCTION,5
RELAY1_INVERTED,0
RELAY1_PIN,50
RELAY2_DEFAULT,0
RELAY2_FUNCTION,6
RELAY2_INVERTED,0
RELAY2_PIN,51
RELAY3_FUNCTION,0
RELAY4_FUNCTION,0
RELAY5_FUNCTION,0
RELAY6_FUNCTION,0

I will take a look when I get back to the office. Thanks for your input.