Trying to find the middle of the actuator stroke

I have looked through the command reference, and cannot find (at least I can’t, lol) any commands/code to help me do the following. Any guidance or help would be appreciated!

I have a GLideforce LACT4P-12V-20 light duty linear actuator with feedback. It has a 4" stroke.
I want to have it set itself to the “middle of the stroke” or about 2" in. At this point, it doesn’t have to be precise, I will eventually use an inclinometer or something like it to get the linear actuator leveled at the right height. Any thoughts on what commands or any code on how to do this?

Thank you!


Can you specify what electronics you are using to control your actuator?

- Patrick

Hi Patrick! I am using a Jrk G2 21v3 USB Motor controller with feedback. This is attached to an Arduino Mega 2560. I wanted to do the “calibration” or truing it to “flat” (or the 2" mark) at the setup. I am using an Adafruit PS2 joystick to move the linear actuator back and forth.

If you have not done so already, I recommend first configuring your Jrk G2 over USB through the Jrk G2 Configuration Utility software with the settings file we provide for using it with that actuator, and adding your joystick once it is working how you want.

You can find a download link for that settings file and the instructions for uploading them on the linear actuator’s product page under the “Using a Jrk G2 motor controller with a linear actuator with feedback” header. Once that settings file is uploaded, simply moving the slider under the status tab to the middle should move your actuator to the middle of its range. If you want to be sure it is the center, you can follow the instructions for calibrating analog feedback in the “Setting up analog feedback” section of the Jrk G2 user’s guide.

From there, it should be possible for you to just connect your joystick directly to the Jrk (i.e. you do not need the Arduino). There are instructions for that in the “Setting up analog control” section of the user’s guide.

However, if you do want to control your Jrk G2 and actuator through an Arduino, then you could use either the Jrk’s serial or I2C interfaces. Once that is set up you should be able to command the actuator to its midpoint by using the [“Set target” command] (jrk.setTarget(uint16_t target) using our Jrk G2 Arduino library) to set the target to 2048.

- Patrick

Thanks Patrick!

OK, so here is where I am at, and then a question. Bottom line, using your advice, I did get this to work. So when I call jrk.SetTarget(2048), it automatically goes to the middle of the stroke that I had setup/determined using the configuration utility.

I used the Blue, Yellow and White control wires from the Glideforce LACT4P-12V-20, and hooked them up to the Jrk G2 21v3 motor controller. I connected the blue wire to the FBA pin on the Jrk, the Yellow wire to the Aux, and the White wire to the Pot-/GND pin. From my Arduino, I am using I2C, I initiated it in the setup routine, then called the set target command to move it to the position I wanted to. A word of advice to anyone trying this, make sure and add an adequate delay (based on the parameters you have) after calling this positional command, otherwise your actuator will behave oddly. I used 5 secs, just to be sure.

Here is my question. I have read through the Jrk library to find the appropriate command (I am programming through the Arduino IDE) that will allow me to control the actuator manually based on sight, rather than position. By this, I mean I have a joystick that uses a 10K pot, reading it from the Arduino, and as long as it is in Position 1 (up) it will move the actuator forward, when it is moved back it moved the actuator backward, and when it is in the “rest” position, the actuator stops moving. I also looked through the forum, and I have yet to be able to find anything (other than the setTarget command, but I cannot use that now because I am using it for position), that will allow me to drive the actuator forward (or backward) manually/until the user changes directions. I hope this makes sense.

Any ideas? Suggestions on how to do this, or point me to something that will help me to understand what to do?

Appreciate the help!


Nvm…one of these “midnight flashes” occured to me.

in the loop() statement, I read the analog pin attached to the wiper on the joystick, then use a conditional if statement to see if it is pushed up, down or in the neutral position. Once I did that, I simply use the setTarget command to the appropriate motor controller at the extremes. Forward I use setTarget(4095), reverse I use setTarget(0), and I issue the stopMotor() command when it is neutral position.

Now I am going to try to hook up the second motor controller on the I2C bus, and see if I can use the same joystick to control both actuators. It SEEMS like it should be pretty straightforward, but most things do when they are in your head.


Hello, Mike.

It sounds like you want to control the speed of your actuator with your joystick, or at least, get basic forward, reverse, stop control. If you do not need position control during your Arduino program, then the easiest method would probably be to just change the Jrk’s feedback mode to “None” to do open-loop speed control.

However, if you do need some position control at some point in your program, such as moving to the middle on start up, then updating the target position based on the direction of your joystick, would probably be the way to go. For example, you can write a program to have the Arduino increase or decrease a position variable if the joystick is pushed forward or backward respectively.

In case it is useful, you might also be able to use the “Force duty cycle target” or “Force duty cycle” commands to override the position feedback algorithm and drive the actuator directly. Those are described in the “Command Reference” section of the Jrk G2 user’s guide.

- Patrick