1

I recently bought this linear actuator and motor controller from Pololu:

There are several steps that I have to follow in order to set this thing up before I can test it. These instructions can be found here: Pololu JRK USB Motor Controller User’s Guide » Setting Up Your System

I would like to program this using PWM method because I would like to keep the Serial RX for other sensors. From my little experiment, by using a potentiometer, I noticed this pattern:

Position: Voltage

  1. Fully extended : 0 V
  2. At Rest : 2.35V
  3. Fully Retracted : 4.77V.

For this system, I will be controlling it using a PS2 controller. So, by using only the Y_axis of the analog joystick of a PS2 Controller (Up: 0, Rest: 128 and Down: 255), I program it as follows:

//Move Linear Actuator with PS2 on JRK21v3 Controller

#define pwm 6           //red wire 
#define dir 7           //yellow wire

//PS2 controller
#include <SoftwareSerial.h>
#include <Cytron_PS2Shield.h>

Cytron_PS2Shield ps2(10, 11); // SoftwareSerial: Rx and Tx pin

void setup()
{
  pinMode(pwm,OUTPUT);

  ps2.begin(9600); 
  Serial.begin(9600); 
}

void loop()
{
  int Y_axis = ps2.readButton(PS2_JOYSTICK_RIGHT_Y_AXIS);  // 0 - 255
  Serial.print("Y_axis:");
  Serial.println(Y_axis);

  analogWrite(pwm, Y_axis);
}

When I tested it, the linear actuator jitters/vibrates when it is at rest position. What could possibly cause this? Is it the duty cycle due to the PWM? How can I fix this or are there any other better methods?

0

The Pololu jrk 21v3 motor controller supports four input modalities: via USB, via TTL-level serial, via RC / pulse width control, and via the mode you are trying to use, an analog 0-5V input.

It appears you are trying to use a PWM output to produce an analog signal control mode. A PWM signal is a pulsed digital output rather than an analog signal. The 21v3 may be jittering its control setpoint back and forth between 0V and 5V at a high frequency, which will make the linear actuator jitter.

Try adding an RC low-pass filter to the PWM output, ie between your PWM pin 6 and the input to the 21v3. (Note, it might make more sense to use a software-serial output to control the 21v3, instead of using a PWM output with a low-pass filter, which may still allow use of hardware serial for your other sensors...)

To verify if an RC filter will work, try at first with large R (eg 5KΩ to 10KΩ) and large C (eg 5μF to 10μF) to see if the jitter goes away. If so, you then can tune the filter to find how small you can make R or C and still avoid jitter. A filter with smaller RC will allow higher-frequency control than will one with larger RC, but may be more prone to jitter. R should be somewhat less than the input impedance of the 21v3's analog input. To determine that value, look at the data sheet of whatever chip that input goes into.

3
  • Thanks. Yes, I agree that the motor jitters since PWM is a pulsed type signal. But how is that different from the controlling it via the serial pin RX, TX? Aren't the signals from those pins in digital form too instead of analog? That would cause the motor to jitter too right? I dont think arduino outputs analog signal, am I right?
    – goddar
    Nov 8 '15 at 11:56
  • True, most Arduino devices don't output analog signals. (Due and Teensy, perhaps others, have some DAC outputs.) ¶ The Pololu Jrk 21v3 has a processor on it. When that processor receives motor speed setpoint information via USB or serial it controls an attached DC motor to that speed. When it gets a hobby-RC pulse train it measures the duty cycle and proportionally controls an attached DC motor. When it gets an analog voltage level it measures the voltage and proportionally controls an attached DC motor. When it gets PWM that you've called analog it controls speed erratically. Nov 8 '15 at 19:39
  • The jitter would not be from the frame rate of the pwm on the actiator but from the sampling effects of the driver reading a pwm signal (rather than an analog one) at uncoordinated instants in time. Try servo pwm mode. Mar 16 '16 at 13:23
2

I got this working using the Servo library.

  • You set the input method to PWM.
  • Connect your RX on the motor controller and hook it up to the servo pin.
  • Connect the ground of the Arduino to the ground of the JRK 21v3.
  • Then use the knob servo sample by hooking up a pot to a Arduino.
  • The calibrate the JRK 21v3 by selecting learn.

Now you can use the actuator as a servo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.