ArduSub // Using servo signal to control a stepper motor in ROV

Hello,

I am currently working on an ROV and planning to use ArduSub. However, I have a problem that I want to use two joysticks: one is to control the ROV itself and the other one is to control the manipulator of the ROV which will achieve two tasks: grip and rotate.

My problem is that since I’ll use ArduSub, I cannot use stepper motors in my manipulator directly. I need to change servo signals (inputs) to stepper motor outputs. So I want to use that joystick code to use stepper motors just like I use a servo by somehow translating the servo input from the joystick via Arduino (probably). Is this possible and if so could you please help me?

I am not very experienced at programming, so I apologize if I have any mistakes. Also, I am not native, so sorry for my grammar mistakes as well.

Any help will be appreciated.

Thank you in advance,
gwnche

Hello,

Steppers are not compatible straight away. Even if you translate the PWM to stepper signals, you will still need a stepper driver to drive it.

It is not a trivial task. You will need interrupts to read the PWM properly, translate this into a speed and direction, and control the stepper driver based on this information. It is possible that the interrupts mess with the timing of driving the stepper, but I think you will be fine.

Also note that stepper motors don’t have position feedback. You can tell them “move 10 steps”, but you cant tell them “go to 180 degrees” like you can with servos. This can be worked around by calibrating or (the lazy way) force mechanical limits.

Code-wise, my advice is (assuming using an Arduino):

  • Get a code reading pwm length with interrupt (you should find something online)
  • Translate the 1000~2000us pulse into a direction
  • Get a stepper-driving code working without PWM control
  • Merge both codes

Hardware-wise, you need to select a motor driver, that depend on the size of your stepper motors, 3D printers tipically use NEMA17 motors with A4988, A4982, DRV8825 with 2 Amps at most.

Hi,
Thank you so much for your answer. I was also wondering whether we could get the state of the joystick connected to qgroundcontrol so we can drive the stepper motors with our raspberry pi.
Is it possible to read the controller’s state or listen to another event sent by qgroundcontrol with our companion computer?

It’s possible to sniff MANUAL_CONTROL mavlink packets in order to get the joystick state on the companion computer.

So sorry for my inexperience at programming, but do we use the pymavlink to setup a mavlink client on the companion computer to sniff the messages? Does the usual communication between pixhawk and qgroundcontrol happen from port 9000 like in the example?

Also, thanks for the quick responses!

Take a look at our examples at the Ardusub Pymavlink docs.