Controlling a JRK 21V3 via Arduino with TTL

Hi all.

I am new on the forum so please be gentle :wink:
I am controlling the JRK 21V3 via the Servo library.

But I was told to rather use serial command via TTL as it is less stressfull for the Arduino. I have the Arduino hooked up to a Rapberry Pi via the USB cable.

The Pi is the brain (hosting user interface) and sends commands to the Arduino via the USB serial cable. So as the UNO only has one serial port I will have to use Software Serial, if that does not work I can upgrade to the Mega.

Are there any people who has connected the controller via TTL to the Arduino and would you share your sample code ?
I just need to move the actuator. I don’t need any feedback from the controller.

Kind Regards.

Since you are new to using Serial commands, I suggest simplifying your setup by removing the Raspberry Pi until you get a better understanding of using the Arduino with the jrk controller. Using the Arduino’s Software Serial with the jrk should be fine.

We do not have any sample Arduino code for using serial commands with the jrk, but you can find the supported serial commands for driving a motor with the jrk in the “Motor Control Commands” section of the jrk user’s guide. If you try writing your own Arduino sketch and run into questions, you can post what you have so far, and I would be glad to take a look.


OK so I got it working.

For those who want to control the motor controller vir TTL here is a sample Arduino Sketch.

I just did a simple sketch, it gets input from a potentiometer on pin A0 and then maps the input to 4096.

Only if the pot value changed will it send the command to the controller. This way I am able to get commands from the USB port and still send commands to the controller. I also set the Input on the Controller to UART, Fixed baud rate at 19200.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to

int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the controller
int old_outputValue = 0;    // Keep the old value per cycle to see if it changed

byte command[2];
int bytesSent = 0;

void setup() {
  // initialize USB serial communications at 19200 bps:

 // initialize  software serial (motor controller port) communications at 19200 bps:

void loop() {

  //Set the 
  old_outputValue = outputValue;
  // read the analog in value from the pot
  sensorValue = analogRead(analogInPin);
  // map it to the range of the controller input:
  outputValue = map(sensorValue, 0, 1023, 0, 4096);

  //If the input has changed then transmit it to the controller and print it on the 
  if(outputValue != old_outputValue){
     command[0] = 0xC0 + (outputValue & 0x1F); // Command byte holds the lower 5 bits of target.
     command[1] = (outputValue >> 5) & 0x7F;   // Data byte holds the upper 7 bits of target.
     bytesSent = mySerial.write(command[0]);
     bytesSent += mySerial.write(command[1]);
     // print the results to the serial monitor:
     Serial.print("sensor = ");
     Serial.print("\t output = ");
  // wait 10 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
1 Like