JRKG2 With Glideforce LACT8: Manual Momentary Raise/Lower Switch Programming

I just got my JRKG2 controller working with a Glideforce LACT8 motor and a 20 amp DC power supply. It is a really impressive setup, using the analog feedback version of the motor. The user guides were really useful in getting things working together.
I am tasked with building an upgraded piece of test equipment for a group of operators who are currently using a similar unit. The existing unit uses a DC gearmotor to raise and lower a load with a momentary UP/OFF/DOWN switch. I am trying to get a similar setup to control the JRK controller using the SDA/Analog input. The 2 things I have gotten to work so far are:
1: A 2 position SPDT switch with the center pin connected to SDA and the other 2 to SCL and GND. This works as expected, with the motor going to whichever position the switch is set to (Love the PID, acceleration and deceleration functions!).
2. A 3 position SPDT switch (center is OFF) hooked up as #1 above, but with 2 same value resistors acting as a voltage divider, setting SDA at 1/2 of 5V. This also works as expected, with the 3 motor settings at UP, DOWN, and halfway.

My question is this: The operators (engineers) want the ability to stop the lift motor at any desired position between the 2 setpoints, as with their existing machine. It is possible to do this with a nice rotary potentiometer, but they do not want to learn new things. The lift motor is now at my machinist for fitting in the new mechanism, so I will not be able to play with it for a few days. In the meantime, is it possible to set up Input Scaling (Maximum, Neutral max/min, Deadband width, Minimum, and Degree (Linear, etc.)) such that a SPDT or DPDT 3 position momentary switch could be used to mimic the direct control they have with their current system?
(I include DPDT as I have thought about switching the 5V from SCL through one set of poles to the second set and having the motor stop on the “Detect disconnect with power pin (SCL)” option when the switch is released, but from what I have read, that won’t work when switching SDA to 0V, as the SDA will not drop by at least a factor of two while SCL is low.
It can be a difficult thing to make a complex thing work like a simple thing. The benefits of current, acceleration/deceleration and speed control are highly desirable over the existing setup, with much larger surge currents and clunky relay wiring.
Can someone offer any advice on if this is possible and how to accomplish it?
Thank you.


Could you clarify how you would like the system to work? It kind of sounds like you are describing open-loop speed control, where the actuator will extend or retract while the user is holding the switch up or down, and stay stationary when the switch is in the neutral position. If that’s the case, you should be able to get that kind of behavior when the switch is connected as you described in case #2 with the feedback mode switched to “None”. However, please note that in this configuration, the actuator will be able to extend and retract through its full stroke length.



The intent is to use a momentary switch to manually raise and lower an assembly connected to the actuator. I ordered the setup listed above so as to have positional feedback as well as to have better control of acceleration/deceleration. I’m really liking the smoothness and functionality of this Pololu controller. I am unable to see a way of accomplishing the features needed without adding a controller for the controller, so I started experimenting with the Arduino library examples.
I got an UNO to communicate via I2C with the JRK controller using an (ON)-OFF-(ON) switch and code to send the motor to desired upper and lower set points, with the default being a STOP command. The UNO was too big to go in the small motor controller box I mounted to where the motor cord comes out, so I ported the code to a Seed Studios XAIO Samd21 board I had laying around. The code did not work with the Samd21 chip for some reason, so I then tried an esp8266 Wemos D1 Mini clone. I now have the desired operation, as well as programmable flexibility. It is even possible to add some wifi capability to the controller. (I know- child’s play to experienced roboticists, but I’m learning, and hoping this might help someone else learning, too.)
Attached is the code I used, modified from the Pololu library I2C example. I hope to add some more feedback functionality to it as time goes by.

// This example shows how to control the Jrk G2 over I2C by
// sending Set Target commands.
// The Jrk's input mode must be set to "Serial/I2C/USB".  The
// Jrk's device number must be set to its default value of 11.
// Please see https://github.com/pololu/jrk-g2-arduino for
// details on how to make the connections between the Arduino and
// the Jrk G2.
// 11/14/23 GC this code will attempt to use a seeeduino XAIO to control a Pololu jrk G2 motor controller via I2C for the 3WP.
// Inputs will be connected to a (mom) off (mom) DPDT 3 position switch
// goal is to have an UP/STOP/DOWN switch to move the lift motor to any desired position and stop it when released.
// Use D1, D2 as switch inputs  Enable INPUT_PULLUP and drive them LOW
// The switch can only be in 1 position at a time, so only 1 command can be sent at a time.
// optional raise motor on other errors or auto lift
// Observed values were approx 200 retracted, 4095 extended; adjust as necessary
// Assumes Pololu controller is properly adjusted to minimize errors beforehand.
// 11/17/23: code will not run on seeed xaio (no I2C); will run on UNO if up pin set to 3; trying on Wemos D1 mini... WORKS!

#include <JrkG2.h>

JrkG2I2C jrk;

const int upPin = 12;    // the number of the UP button pin (D6 on Wemos)
const int downPin = 13;  // the number of the DOWN button pin (D7 on Wemos)
const int gndPin = 15;   // Ground on the Wemos for the up/down switch
int upPinState = 0;     // variable for reading the pushbutton status
int downPinState = 0;

void setup() {
  pinMode(upPin, INPUT_PULLUP);  // initialize the up/down pins as an inputs:
  pinMode(downPin, INPUT_PULLUP);
  pinMode(gndPin, OUTPUT);
  digitalWrite(gndPin, LOW);

void loop() {
  //Wire.beginTransmission(4); // transmit to device #4   //specific code for xaio samd21.  Don't know if it is needed or if JrkG2.h takes it into account
  // read the state of the UP switch:
  upPinState = digitalRead(upPin);
  downPinState = digitalRead(downPin);

  // check if the switches are activateded. Active LOW

  if ((upPinState == LOW) && (downPinState == HIGH)) {
    Serial.println("UP command");
  } else if ((downPinState == LOW) && (upPinState == HIGH)) {
    Serial.println("DOWN command");
  } else {
    jrk.stopMotor();    //issue a STOP commabnd (default)


I am glad you were able to get it working how you want; thank you for sharing your solution and code!