Multi axis differential encoder output simulation

I am attempting to retrofit a control panel which currently uses mpg wheel encoders to a joystick with momentary NO switches . So my arduino input pins will be hi or low when jogging depending on configuration, not variable like an analog joystick.

I have 3 axis , all 3 which need to be able to produce different quadrature encoder outputs (A/B, per axis) simultaneously if more than one input is selected. Each axis can only have one direction active at a time due to the joystick configuration.

My input pins will be X+, X-, Y+, Y-, Z+,Z-

Using Arduino Nano

I have tried a few versions of sketches and am only able to get one axis encoder output at a time.

I would appreciate guidance on how to achieve this.

Each axis follows the quadrature pattern (table). X+ will increment the table index, X- will decrement the table index and output the current pattern. The same for Y and Z.

It's your decision whether the channels shall have auto-repeat.

Read this thread. Synthesis of quadrature signals.

a7

Thanks for the thread to read. Since the nano has three timers, could each timer be utilized for one axis to generate PWM 90 degrees out of phase and be able to process inputs from the 6 input pins simultaneously to generate the appropriate A/B signals for each axis depending upon the +/- direction input?

For example timer 0 would be utilized for X axis, Timer 1 would be utilized for Y axis! And timer 3 would be utilized for Z axis, and each timer would be used to provide A/B PWM signals for each axis, each independent.

I would only require auto repeat as long as the contact on each axis input pin is closed.

How is the PWM frequency related to the joystick clicks? I had expected that each click advances the simulated encoder one step.

When the joystick is engaged in the desired direction, the PWM for each axis is required to be continuous. For example, if you have a momentary push button, the PWM Channel A/B phasing for that momentary push button would be continuous for the duration it is making contact.

Think of the design as 6 momentary push buttons, one for X+, X-,Y +, Y-, Z+,Z-. One button for each axis could be pressed simultaneously, however only one direction in each axis would be selected in the combination at any given moment.

Each PWM channel would need to have it's AB phasing adjusted to match the desired direction for that a channel.

  • A positive (+) movement would have A phase start first, then B phase 90 degrees out of phase from A
  • A Negative (-)- movement would likewise have B phase start first, then A phase 90 degrees out of phase from A.

The A&B phasing relationship for each associated PWM channel may be different from other PWM channels depending on the direction selected. All PWM channels require A&B to be 90 degrees out of phase.

The timing of the PWM start phase is not critical as long as the A/B phase relationship is appropriate for the desired direction of movment ( +/-).

The PWM frequency will need to be 180Hz or greater with a 75% duty cycle for proper operation.

The joystick can close contacts on X&Y simultaneously for diagonal jog. Possible combinations would be:

One direction Jog:

Joystick 1 (8 position)

  • X+ (PWM CH 0 AB)
  • X- (PWM CH 0 BA)
  • Y+ (PWM CH 1 AB)
  • Y- (PWM CH 0 BA)
    (Diagonal Jog- contacts may close at different times)
  • X+ Y+:Y+,X+ (PWM CH 0 AB) + (PWM CH 1 AB)
  • X+, Y-:Y-,X+ (PWM CH 0 AB) + (PWM CH 1 BA)
  • X-, Y+: Y+,X- (PWM CH 0 BA) + (PWM CH 1 AB)
  • X-, Y-: Y-,X- (PWM CH 0 BA) + (PWM CH 1 BA)

Joystick 2 ( 2 position )

  • Z+ (PWM CH 2 AB)
  • Z- (PWM CH 2 BA)

My concern is that the Nano may only be able to accommodate one PWM channel movement when I add de-bounce for the switches.

If the Nano is not able to handle simultaneous movements on 3 PWM A/B channels independently with independent phasing, I may need to look at two Nano's to achieve the required design.
The output pins on this design my not be correct based on the associated timers:
Wokwi circuit design - code work in process

One Mega will be sufficient. It has 5 timers with 3 channels each.

Do I understand you right, that the joystick mimics 3 motors running on individual speed? I.e. the PWM frequency corresponds to the motor rpm?

The joystick will be used to provide input to the Arduino to simulate MPG encoder A/B quadrature output to a quadrature input of a Raspberry Pi Pico.

The speed of the PWM will not control the speed of motors, that is controlled after the encoder input of the RPi Pico.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.