JRK 21v3 serial control from arduino

Hi

I’m trying to control the JRK from an Arduino Mega (which will be standalone along with the jrk eventually).
I can control the JRK using C from both windows and OS X when I connect the JRK only to a USB port and a 12v DC supply to drive the motor
This is using the serial dual port or chained mode (CRC box un-ticked !)

The problem arises when I try to drive the motor with the Arduino rather than computer. (computer loads code to arduino and arduino drives jrk)
I connect the Arduino to the computer USB port. The JRK gets power from the 12v DC supply as before
I connect the Arduino GND to JRK GND

The Arduino TX1 pin goes to JRK RX
The Arduino RX1 pin goes to JRX TX

I was originally trying to control the JRK via Arduino in serial dual mode as before but found I was getting no response (could see the Arduino Tx light flashing away)
I decided that I need to use UART mode on the JRK “This mode allows you to control the jrk (and send bytes to a serial program on the computer) using a microcontroller or other TTL serial device.”

In this configuration as soon as I supply power to the JRK its Red error light comes on and it still doesn’t work. I also tried connecting the JRK USB connector to a second USB port on my computer (green light comes on but red light stays on)

Is UART mode the correct mode for a standalone JRK and Arduino combo?
Am I missing some other connection here?

thanks
Steve

Hello, Steve.

Your connections seem fine, and UART mode is the correct one to use. However, it is hard to troubleshoot this without your code. Could you post the simplest Arduino sketch that demonstrates the problem? Could you also look into the jrk Configuration Utility program and see what error is causing the LED to come on?

I noticed you are using TX1 and RX1 pins on your Arduino Mega. Are you also using the Serial1 object in your code? If you are using the default Serial object, you should be using the TX0 and RX0 pins (pins 1 and 0).

- Jeremy

Hi Jeremy

I don’t normally use windows, prefer staying on mac so I don’t normally have the config tool handy.
However. did as you suggested, the error stopping the jrk is 0x0002 no power - it was connected to my 12v power supply however I had not noticed the cable connection on the power supply had come loose - all the dials on the psu were lit up so I assumed everything was good

Just reconnected everything and the power errors have stopped so off to retest

Thanks for your help in confirming I should be using UART , let you know how I get on

regards
Steve

Well I did try and here’s what happens ….

The red error light is gone however there is something strange happening

If I loop the Tx1 and Rx1 pins on the Arduino then it works - Serial1.available is TRUE
If I connect Tx1 and Rx1 to RX and Tx on Jrk then Serial1.available is FALSE

The arduino GND is connected to the GND on the JRK (below the 5v regulated output as per picture in user guide)

Here is the test code I’m using


// YELLOW WIRE IS RX ARDUINO & TX ON JRK
// BROWN WIRE IS TX ARDUINO & RX ON JRK
const int Tx1=18; //RX on JRK TX on Arduino
const int Rx1=19; //TX on JRK RX on Arduino
const int Tx2=16; //RX on JRK TX on Arduino
const int Rx2=17; //TX on JRK RX on Arduino
const int Tx3=14; //RX on JRK TX on Arduino
const int Rx3=15; //TX on JRK RX on Arduino
const int Tx0=1; //RX on JRK TX on Arduino
const int Rx0=0; //TX on JRK RX on Arduino


byte command[2];

int jrkGetFeedback()
{
  Serial1.write(0xA5);
  return Serial1.read();
}

int jrkGetError()
{
  Serial1.write(0xB3); 
  return Serial1.read();
}

int jrkGetTarget()
{
    Serial1.write(0xA3); 
    return Serial1.read();
}


int jrkSetTarget(int target)
{
  
  int bytesSent = 0;
  
  command[0] = 0xC0 + (target & 0x1F); // Command byte holds the lower 5 bits of target.
  command[1] = (target >> 5) & 0x7F;   // Data byte holds the upper 7 bits of target.
  bytesSent = Serial1.write(command[0]);
  bytesSent += Serial1.write(command[1]);
  
  Serial.println("Sending command ...");
  Serial.println(command[0]);
  Serial.println(command[0]);

  //command[0] = 208, command[1] = 208
  return bytesSent;
}





void setup() {
  
  Serial.begin(57600);
  Serial1.begin(57600);
  Serial1.write(0xAA);
}



void loop()
{
	int feedback;
        int target = 0x7D0;
        byte bytesSent;
       
       if( Serial1.available()){
          bytesSent = jrkSetTarget(target);
          Serial.print("bytesSent = ");
   	  Serial.println(bytesSent);
          //feedback = jrkGetError();
          //target = jrkGetTarget();

          Serial.print("Current Target is ");
   	  Serial.println(target);
       }
       else {
         Serial.println("Serial1 not available ");
       }
        delay(1000);
}

I made a slight mod to the code and config by connecting the JRK RESET pin to Arduino pin 10 and sending a 10 second reset

The Serial1 port is now available but no motor action

The result from the Serial output is

Current Target returned from jrkis 0
Current error returned from jrkis 0
Sending command …
ÐÐbytesSent = 2
Current Target returned from jrkis -1
Current error returned from jrkis 0
Serial1 not available
Sending command …
ÐÐbytesSent = 2
Current Target returned from jrkis 0
Current error returned from jrkis 0
Sending command …
ÐÐbytesSent = 2
Current Target returned from jrkis 0
Current error returned from jrkis 0

#define LOTARGET 0x83
#define HITARGET 0x84
#define LOFEEDBACK 0x85
#define HIFEEBACK 0x86
#define LOSCALEDFEEDBACK 0x87
#define HISCALEDFEEDBACK 0x88
#define LOERRORSUM 0x89
#define HIERRORSUM 0x8A
#define LODUTYCYCLETARGET 0x8B
#define HIDUTYCYCLETARGET 0x8C
#define LODUTYCYCLE 0x8D
#define HIDUTYCYCLE 0x8E
#define CURRENT = 0x8F	
#define LOPIDPERIODCOUNT 0x91
#define HIPIDPERIODCOUNT 0x92
#define DETECTBAUD 0xAA

// YELLOW WIRE IS RX ARDUINO & TX ON JRK
// BROWN WIRE IS TX ARDUINO & RX ON JRK
const int Tx1=18; //RX on JRK TX on Arduino
const int Rx1=19; //TX on JRK RX on Arduino
const int Tx2=16; //RX on JRK TX on Arduino
const int Rx2=17; //TX on JRK RX on Arduino
const int Tx3=14; //RX on JRK TX on Arduino
const int Rx3=15; //TX on JRK RX on Arduino
const int Tx0=1; //RX on JRK TX on Arduino
const int Rx0=0; //TX on JRK RX on Arduino
const int RESET=10;

byte command[2];

int jrkGetFeedback()
{
  Serial1.write(0xA5);
  return Serial1.read();
}

int jrkGetError()
{
  Serial1.write(0xB3); 
  return Serial1.read();
}

int jrkGetTarget()
{
    Serial1.write(0xA3); 
    return Serial1.read();
}


int jrkSetTarget(int target)
{
  
  int bytesSent = 0;
  
  command[0] = 0xC0 + (target & 0x1F); // Command byte holds the lower 5 bits of target.
  command[1] = (target >> 5) & 0x7F;   // Data byte holds the upper 7 bits of target.
  bytesSent = Serial1.write(command[0]);
  bytesSent += Serial1.write(command[1]);
  
  Serial.println("Sending command ...");
  Serial.write(command[0]);
  Serial.write(command[0]);

  //command[0] = 208, command[1] = 208+
  return bytesSent;
}





void setup() {
  
  pinMode(RESET, OUTPUT); 
  digitalWrite(RESET, LOW);
  delay(2000);
  digitalWrite(RESET, HIGH);
  Serial.begin(57600);
  Serial1.begin(57600);
  Serial1.write(0xAA);
}



void loop()
{
	int error;
        int jrkTarget;
        int target = 0x7D0;
        byte bytesSent;
       
       if( Serial1.available()){
          bytesSent = jrkSetTarget(target);
          Serial.print("bytesSent = ");
   	  Serial.println(bytesSent);
          error = jrkGetError();
          jrkTarget = jrkGetTarget();

          Serial.print("Current Target returned from jrkis ");
   	  Serial.println(jrkTarget);
          Serial.print("Current error returned from jrkis ");
   	  Serial.println(error);
   

       }
       else {
         Serial.println("Serial1 not available ");
                  digitalWrite(RESET, LOW);
                  delay(10000);
                  digitalWrite(RESET, HIGH);
       }
        delay(1000);
}

I eventually got the motor working using the same code.

Don’t know what the root issue is yet but here’s what I did

Ticked never sleep on config tool and set UART baud to 9600 in config and arduino and used the GND on the jrk AUX pins
I also suspect some of my wiring connections are not optimal, cheap breadboard connectors

At least I know the config works so can work on developing it further

Any recommendations for making better connections ?

I noticed the following when reading jrk variables on arduino

Here’s my arduino getJrkVariable, gives the correct results for me
Any idea why I need 3 bytes ?


int jrkGetTarget()
{
  return jrkGetVariable(0xA3);
}


int jrkGetVariable(byte command)
{
  char response[3];
  Serial1.write(command);
  Serial1.readBytes(response,3);
  //returning LSB in response[1]
  //first byte is always 0
  // current target = 2345 ie 00001001 00101001
  // actual return is 00000000 00101001
  // using 3 byte array produces correct result
  //  for 2345 get 00000000 00001001 00101001 as below
  return  word(response[2],response[1]);   // i.e. 2345
}

I would be happy to give recommendations for better connections. Could you post pictures of your setup so we can see how things are connected?

You should not have to read 3 bytes. What is the baud rate set to on the two devices? I suspect the first read is timing out and returning 0. Could you try changing your code to the following to test this?

int jrkGetVariable(byte command)
{
char response[2];
Serial1.write(command);
while (Serial1.available() < 2);
Serial1.readBytes(response,2);
return  word(response[1],response[0]);
}

- Jeremy

Hi

When using the serial commands to read JRK variables I’m getting strange and inconsistent values.

Am I calling correctly - I looked at the windows C code as an example?

Here is an example I’m calling

int jrkGetVariable(byte command)
{
  char response[2];
  Serial1.flush();
  Serial1.write(command);
  Serial1.readBytes(response,2);
  //returning LSB in response[1]
  //first byte is always 0
  // current target = 2345 ie 00001001 00101001
  // actual return is 00000000 00101001
  // using 3 byte array produces correct result
  //  for 2345 get 00000000 00001001 00101001 as below
  return  response[0] + 256*response[1];   
}

int jrkGetTarget()
{
  
  return jrkGetVariable(0xA3);
}


This results in the following output …

============================================================
Current Input returned from JRK 21v3 is =7
Current Target returned from JRK 21v3 is =6656
Current Feedback returned from JRK 21v3 is =-22548
Current ScaledFeedback returned from JRK 21v3 is =-3
Current Error Sum Integral returned from JRK 21v3 is =50
Current Duty Cycle Target returned from JRK 21v3 is =1784
Current Duty Cycle returned from JRK 21v3 is =1784
Current Current returned from JRK 21v3 is =1785
Current PID period count returned from JRK 21v3 is =1784

============================================================
Current Input returned from JRK 21v3 is =30
Current Target returned from JRK 21v3 is =-287
Current Feedback returned from JRK 21v3 is =-287
Current ScaledFeedback returned from JRK 21v3 is =32000
Current Error Sum Integral returned from JRK 21v3 is =-2048
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =-2041
Current PID period count returned from JRK 21v3 is =7687

============================================================
Current Input returned from JRK 21v3 is =-7936
Current Target returned from JRK 21v3 is =-7681
Current Feedback returned from JRK 21v3 is =-1
Current ScaledFeedback returned from JRK 21v3 is =-56
Current Error Sum Integral returned from JRK 21v3 is =1784
Current Duty Cycle Target returned from JRK 21v3 is =1784
Current Duty Cycle returned from JRK 21v3 is =1785
Current Current returned from JRK 21v3 is =1784
Current PID period count returned from JRK 21v3 is =30

============================================================
Current Input returned from JRK 21v3 is =-286
Current Target returned from JRK 21v3 is =-286
Current Feedback returned from JRK 21v3 is =4864
Current ScaledFeedback returned from JRK 21v3 is =-2047
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-1785
Current Duty Cycle returned from JRK 21v3 is =-2041
Current Current returned from JRK 21v3 is =7687
Current PID period count returned from JRK 21v3 is =-7680

============================================================
Current Input returned from JRK 21v3 is =-7681
Current Target returned from JRK 21v3 is =-1
Current Feedback returned from JRK 21v3 is =351
Current ScaledFeedback returned from JRK 21v3 is =1784
Current Error Sum Integral returned from JRK 21v3 is =1784
Current Duty Cycle Target returned from JRK 21v3 is =1785
Current Duty Cycle returned from JRK 21v3 is =1784
Current Current returned from JRK 21v3 is =30
Current PID period count returned from JRK 21v3 is =-286

============================================================
Current Input returned from JRK 21v3 is =-286
Current Target returned from JRK 21v3 is =-21760
Current Feedback returned from JRK 21v3 is =-2047
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =-1785
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =7687
Current Current returned from JRK 21v3 is =-7680
Current PID period count returned from JRK 21v3 is =-7681

============================================================
Current Input returned from JRK 21v3 is =-1
Current Target returned from JRK 21v3 is =246
Current Feedback returned from JRK 21v3 is =1784
Current ScaledFeedback returned from JRK 21v3 is =1784
Current Error Sum Integral returned from JRK 21v3 is =1785
Current Duty Cycle Target returned from JRK 21v3 is =1784
Current Duty Cycle returned from JRK 21v3 is =30
Current Current returned from JRK 21v3 is =-286
Current PID period count returned from JRK 21v3 is =-286

============================================================
Current Input returned from JRK 21v3 is =16896
Current Target returned from JRK 21v3 is =-2046
Current Feedback returned from JRK 21v3 is =-2041
Current ScaledFeedback returned from JRK 21v3 is =-1785
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =7687
Current Duty Cycle returned from JRK 21v3 is =-7680
Current Current returned from JRK 21v3 is =-7681
Current PID period count returned from JRK 21v3 is =-1

============================================================
Current Input returned from JRK 21v3 is =398
Current Target returned from JRK 21v3 is =1784
Current Feedback returned from JRK 21v3 is =1784
Current ScaledFeedback returned from JRK 21v3 is =1785
Current Error Sum Integral returned from JRK 21v3 is =1784
Current Duty Cycle Target returned from JRK 21v3 is =30
Current Duty Cycle returned from JRK 21v3 is =-286
Current Current returned from JRK 21v3 is =-286
Current PID period count returned from JRK 21v3 is =-9728

============================================================
Current Input returned from JRK 21v3 is =-2046
Current Target returned from JRK 21v3 is =-2041
Current Feedback returned from JRK 21v3 is =-1785
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =7687
Current Duty Cycle Target returned from JRK 21v3 is =-7680
Current Duty Cycle returned from JRK 21v3 is =-7681
Current Current returned from JRK 21v3 is =-1
Current PID period count returned from JRK 21v3 is =806

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =0
Current Error Sum Integral returned from JRK 21v3 is =0
Current Duty Cycle Target returned from JRK 21v3 is =0
Current Duty Cycle returned from JRK 21v3 is =0
Current Current returned from JRK 21v3 is =0
Current PID period count returned from JRK 21v3 is =2048

============================================================
Current Input returned from JRK 21v3 is =1791
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =-5094
Current ScaledFeedback returned from JRK 21v3 is =-856
Current Error Sum Integral returned from JRK 21v3 is =12800
Current Duty Cycle Target returned from JRK 21v3 is =-2048
Current Duty Cycle returned from JRK 21v3 is =-2041
Current Current returned from JRK 21v3 is =-1785
Current PID period count returned from JRK 21v3 is =-2041

============================================================
Current Input returned from JRK 21v3 is =7687
Current Target returned from JRK 21v3 is =-7680
Current Feedback returned from JRK 21v3 is =-7681
Current ScaledFeedback returned from JRK 21v3 is =-1
Current Error Sum Integral returned from JRK 21v3 is =125
Current Duty Cycle Target returned from JRK 21v3 is =1784
Current Duty Cycle returned from JRK 21v3 is =1784
Current Current returned from JRK 21v3 is =1786
Current PID period count returned from JRK 21v3 is =1783

============================================================
Current Input returned from JRK 21v3 is =30
Current Target returned from JRK 21v3 is =-282
Current Feedback returned from JRK 21v3 is =-282
Current ScaledFeedback returned from JRK 21v3 is =-14336
Current Error Sum Integral returned from JRK 21v3 is =-2048
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =-2041
Current PID period count returned from JRK 21v3 is =7687

============================================================
Current Input returned from JRK 21v3 is =-7680
Current Target returned from JRK 21v3 is =-7681
Current Feedback returned from JRK 21v3 is =-1
Current ScaledFeedback returned from JRK 21v3 is =275
Current Error Sum Integral returned from JRK 21v3 is =1784
Current Duty Cycle Target returned from JRK 21v3 is =1784
Current Duty Cycle returned from JRK 21v3 is =1785
Current Current returned from JRK 21v3 is =1784
Current PID period count returned from JRK 21v3 is =30

============================================================
Current Input returned from JRK 21v3 is =-286
Current Target returned from JRK 21v3 is =-286
Current Feedback returned from JRK 21v3 is =24320
Current ScaledFeedback returned from JRK 21v3 is =-2047
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =-2297
Current Current returned from JRK 21v3 is =7687
Current PID period count returned from JRK 21v3 is =-6656

============================================================
Current Input returned from JRK 21v3 is =-6657
Current Target returned from JRK 21v3 is =-1
Current Feedback returned from JRK 21v3 is =171
Current ScaledFeedback returned from JRK 21v3 is =1784
Current Error Sum Integral returned from JRK 21v3 is =1784
Current Duty Cycle Target returned from JRK 21v3 is =1784
Current Duty Cycle returned from JRK 21v3 is =1783
Current Current returned from JRK 21v3 is =30
Current PID period count returned from JRK 21v3 is =-282

============================================================
Current Input returned from JRK 21v3 is =-282
Current Target returned from JRK 21v3 is =-2560
Current Feedback returned from JRK 21v3 is =-2047
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =-1785
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =7687
Current Current returned from JRK 21v3 is =-7680
Current PID period count returned from JRK 21v3 is =-7681

============================================================
Current Input returned from JRK 21v3 is =-1
Current Target returned from JRK 21v3 is =578
Current Feedback returned from JRK 21v3 is =1784
Current ScaledFeedback returned from JRK 21v3 is =1784
Current Error Sum Integral returned from JRK 21v3 is =1785
Current Duty Cycle Target returned from JRK 21v3 is =1784
Current Duty Cycle returned from JRK 21v3 is =30
Current Current returned from JRK 21v3 is =-286
Current PID period count returned from JRK 21v3 is =-286

============================================================
Current Input returned from JRK 21v3 is =-29184
Current Target returned from JRK 21v3 is =-2046
Current Feedback returned from JRK 21v3 is =-2041
Current ScaledFeedback returned from JRK 21v3 is =-1785
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =7687
Current Duty Cycle returned from JRK 21v3 is =-7680
Current Current returned from JRK 21v3 is =-7681
Current PID period count returned from JRK 21v3 is =-1

============================================================
Current Input returned from JRK 21v3 is =474
Current Target returned from JRK 21v3 is =1784
Current Feedback returned from JRK 21v3 is =1784
Current ScaledFeedback returned from JRK 21v3 is =1785
Current Error Sum Integral returned from JRK 21v3 is =1784
Current Duty Cycle Target returned from JRK 21v3 is =30
Current Duty Cycle returned from JRK 21v3 is =-286
Current Current returned from JRK 21v3 is =-286
Current PID period count returned from JRK 21v3 is =9728

============================================================
Current Input returned from JRK 21v3 is =-2045
Current Target returned from JRK 21v3 is =-2041
Current Feedback returned from JRK 21v3 is =-1785
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =7687
Current Duty Cycle Target returned from JRK 21v3 is =-7680
Current Duty Cycle returned from JRK 21v3 is =-7681
Current Current returned from JRK 21v3 is =-1
Current PID period count returned from JRK 21v3 is =882

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =0
Current Error Sum Integral returned from JRK 21v3 is =0
Current Duty Cycle Target returned from JRK 21v3 is =0
Current Duty Cycle returned from JRK 21v3 is =0
Current Current returned from JRK 21v3 is =0
Current PID period count returned from JRK 21v3 is =-248

============================================================
Current Input returned from JRK 21v3 is =7
Current Target returned from JRK 21v3 is =6656
Current Feedback returned from JRK 21v3 is =-22548
Current ScaledFeedback returned from JRK 21v3 is =-3
Current Error Sum Integral returned from JRK 21v3 is =50
Current Duty Cycle Target returned from JRK 21v3 is =1784
Current Duty Cycle returned from JRK 21v3 is =1784
Current Current returned from JRK 21v3 is =1785
Current PID period count returned from JRK 21v3 is =1784

============================================================
Current Input returned from JRK 21v3 is =30
Current Target returned from JRK 21v3 is =-286
Current Feedback returned from JRK 21v3 is =-286
Current ScaledFeedback returned from JRK 21v3 is =32000
Current Error Sum Integral returned from JRK 21v3 is =-2048
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =-2041
Current PID period count returned from JRK 21v3 is =7687

============================================================
Current Input returned from JRK 21v3 is =-7680
Current Target returned from JRK 21v3 is =-8705
Current Feedback returned from JRK 21v3 is =-1
Current ScaledFeedback returned from JRK 21v3 is =-56
Current Error Sum Integral returned from JRK 21v3 is =1784
Current Duty Cycle Target returned from JRK 21v3 is =1784
Current Duty Cycle returned from JRK 21v3 is =1785
Current Current returned from JRK 21v3 is =1784
Current PID period count returned from JRK 21v3 is =30

============================================================
Current Input returned from JRK 21v3 is =-286
Current Target returned from JRK 21v3 is =-286
Current Feedback returned from JRK 21v3 is =4864
Current ScaledFeedback returned from JRK 21v3 is =-2047
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-1785
Current Duty Cycle returned from JRK 21v3 is =-2041
Current Current returned from JRK 21v3 is =7687
Current PID period count returned from JRK 21v3 is =-7680

============================================================
Current Input returned from JRK 21v3 is =-7681
Current Target returned from JRK 21v3 is =-1
Current Feedback returned from JRK 21v3 is =351
Current ScaledFeedback returned from JRK 21v3 is =1784
Current Error Sum Integral returned from JRK 21v3 is =1784
Current Duty Cycle Target returned from JRK 21v3 is =1784
Current Duty Cycle returned from JRK 21v3 is =1783
Current Current returned from JRK 21v3 is =30
Current PID period count returned from JRK 21v3 is =-282

============================================================

I’ve tried different variations of code e.g.
I do seem to get slightly better results with a 3 byte array as often the first byte returned is zero

int jrkGetVariable2(byte command[])// lo  hi
{
  char response[2];
  Serial1.flush();
  Serial1.write(command[0]);
  response[0] = Serial1.read();
  Serial1.write(command[1]);
  response[1] = Serial1.read();
  //returning LSB in response[1]
  //first byte is always 0
  // current target = 2345 ie 00001001 00101001
  // actual return is 00000000 00101001
  // using 3 byte array produces correct result
  //  for 2345 get 00000000 00001001 00101001 as below
  Serial.println(response[0]);
  Serial.println(response[1]);
  return  word(response[1],response[0]);   
}

Thanks Jeremy

Our forum posts may have crossed :wink:
ignore my recent post

Seems a bit better, the target I’m sending is 0x7F8 (2040) - a similar number does get returned occasionally

I’m running at 9600 baud

Here is the resultant log

Seral1 not available 
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =0
Current Error Sum Integral returned from JRK 21v3 is =0
Current Duty Cycle Target returned from JRK 21v3 is =0
Current Duty Cycle returned from JRK 21v3 is =0
Current Current returned from JRK 21v3 is =0
Current PID period count returned from JRK 21v3 is =2048

============================================================
Current Input returned from JRK 21v3 is =2047
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =-5094
Current ScaledFeedback returned from JRK 21v3 is =-600
Current Error Sum Integral returned from JRK 21v3 is =12800
Current Duty Cycle Target returned from JRK 21v3 is =-2048
Current Duty Cycle returned from JRK 21v3 is =-2041
Current Current returned from JRK 21v3 is =-1785
Current PID period count returned from JRK 21v3 is =-2041

============================================================
Current Input returned from JRK 21v3 is =7943
Current Target returned from JRK 21v3 is =-7680
Current Feedback returned from JRK 21v3 is =-7425
Current ScaledFeedback returned from JRK 21v3 is =255
Current Error Sum Integral returned from JRK 21v3 is =124
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =2041
Current PID period count returned from JRK 21v3 is =2040

============================================================
Current Input returned from JRK 21v3 is =30
Current Target returned from JRK 21v3 is =-30
Current Feedback returned from JRK 21v3 is =-30
Current ScaledFeedback returned from JRK 21v3 is =-14336
Current Error Sum Integral returned from JRK 21v3 is =-2048
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =-2041
Current PID period count returned from JRK 21v3 is =7687

============================================================
Current Input returned from JRK 21v3 is =-7680
Current Target returned from JRK 21v3 is =-7425
Current Feedback returned from JRK 21v3 is =255
Current ScaledFeedback returned from JRK 21v3 is =275
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2041
Current Current returned from JRK 21v3 is =2040
Current PID period count returned from JRK 21v3 is =30

============================================================
Current Input returned from JRK 21v3 is =-30
Current Target returned from JRK 21v3 is =-30
Current Feedback returned from JRK 21v3 is =24320
Current ScaledFeedback returned from JRK 21v3 is =-2047
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-1529
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =7943
Current PID period count returned from JRK 21v3 is =-8704

============================================================
Current Input returned from JRK 21v3 is =-8449
Current Target returned from JRK 21v3 is =255
Current Feedback returned from JRK 21v3 is =427
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2041
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =30
Current PID period count returned from JRK 21v3 is =-30

============================================================
Current Input returned from JRK 21v3 is =-30
Current Target returned from JRK 21v3 is =-2560
Current Feedback returned from JRK 21v3 is =-2047
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =-1785
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =7687
Current Current returned from JRK 21v3 is =-7680
Current PID period count returned from JRK 21v3 is =-7425

============================================================
Current Input returned from JRK 21v3 is =255
Current Target returned from JRK 21v3 is =578
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2041
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =31
Current Current returned from JRK 21v3 is =-30
Current PID period count returned from JRK 21v3 is =-27

============================================================
Current Input returned from JRK 21v3 is =-29184
Current Target returned from JRK 21v3 is =-2046
Current Feedback returned from JRK 21v3 is =-2041
Current ScaledFeedback returned from JRK 21v3 is =-1785
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =7687
Current Duty Cycle returned from JRK 21v3 is =-7680
Current Current returned from JRK 21v3 is =-7425
Current PID period count returned from JRK 21v3 is =255

============================================================
Current Input returned from JRK 21v3 is =729
Current Target returned from JRK 21v3 is =2040
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2041
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =30
Current Duty Cycle returned from JRK 21v3 is =-30
Current Current returned from JRK 21v3 is =-30
Current PID period count returned from JRK 21v3 is =9472

============================================================
Current Input returned from JRK 21v3 is =-2045
Current Target returned from JRK 21v3 is =-2041
Current Feedback returned from JRK 21v3 is =-1785
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =7687
Current Duty Cycle Target returned from JRK 21v3 is =-7680
Current Duty Cycle returned from JRK 21v3 is =-7425
Current Current returned from JRK 21v3 is =255
Current PID period count returned from JRK 21v3 is =881

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =0
Current Error Sum Integral returned from JRK 21v3 is =0
Current Duty Cycle Target returned from JRK 21v3 is =0
Current Duty Cycle returned from JRK 21v3 is =0
Current Current returned from JRK 21v3 is =0
Current PID period count returned from JRK 21v3 is =-248

============================================================
Current Input returned from JRK 21v3 is =7
Current Target returned from JRK 21v3 is =6656
Current Feedback returned from JRK 21v3 is =-22292
Current ScaledFeedback returned from JRK 21v3 is =253
Current Error Sum Integral returned from JRK 21v3 is =50
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =2041
Current PID period count returned from JRK 21v3 is =2040

============================================================
Current Input returned from JRK 21v3 is =30
Current Target returned from JRK 21v3 is =-31
Current Feedback returned from JRK 21v3 is =-31
Current ScaledFeedback returned from JRK 21v3 is =32000
Current Error Sum Integral returned from JRK 21v3 is =-2048
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =-2041
Current PID period count returned from JRK 21v3 is =7687

============================================================
Current Input returned from JRK 21v3 is =-7680
Current Target returned from JRK 21v3 is =-7425
Current Feedback returned from JRK 21v3 is =255
Current ScaledFeedback returned from JRK 21v3 is =200
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2041
Current Current returned from JRK 21v3 is =2040
Current PID period count returned from JRK 21v3 is =30

============================================================
Current Input returned from JRK 21v3 is =-30
Current Target returned from JRK 21v3 is =-30
Current Feedback returned from JRK 21v3 is =4864
Current ScaledFeedback returned from JRK 21v3 is =-2047
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-1785
Current Duty Cycle returned from JRK 21v3 is =-2041
Current Current returned from JRK 21v3 is =7687
Current PID period count returned from JRK 21v3 is =-7680

============================================================
Current Input returned from JRK 21v3 is =-7425
Current Target returned from JRK 21v3 is =255
Current Feedback returned from JRK 21v3 is =351
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2041
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =30
Current PID period count returned from JRK 21v3 is =-30

============================================================
Current Input returned from JRK 21v3 is =-30
Current Target returned from JRK 21v3 is =-21760
Current Feedback returned from JRK 21v3 is =-2047
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-2297
Current Duty Cycle returned from JRK 21v3 is =7687
Current Current returned from JRK 21v3 is =-7936
Current PID period count returned from JRK 21v3 is =-7681

============================================================
Current Input returned from JRK 21v3 is =255
Current Target returned from JRK 21v3 is =502
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2041
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =30
Current Current returned from JRK 21v3 is =-30
Current PID period count returned from JRK 21v3 is =-30

============================================================
Current Input returned from JRK 21v3 is =16896
Current Target returned from JRK 21v3 is =-2046
Current Feedback returned from JRK 21v3 is =-2041
Current ScaledFeedback returned from JRK 21v3 is =-1529
Current Error Sum Integral returned from JRK 21v3 is =-1785
Current Duty Cycle Target returned from JRK 21v3 is =7943
Current Duty Cycle returned from JRK 21v3 is =-8704
Current Current returned from JRK 21v3 is =-8449
Current PID period count returned from JRK 21v3 is =255

============================================================
Current Input returned from JRK 21v3 is =654
Current Target returned from JRK 21v3 is =2040
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2039
Current Duty Cycle Target returned from JRK 21v3 is =30
Current Duty Cycle returned from JRK 21v3 is =-26
Current Current returned from JRK 21v3 is =-26
Current PID period count returned from JRK 21v3 is =-9728

============================================================
Current Input returned from JRK 21v3 is =-2046
Current Target returned from JRK 21v3 is =-2041
Current Feedback returned from JRK 21v3 is =-1785
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =7943
Current Duty Cycle Target returned from JRK 21v3 is =-7936
Current Duty Cycle returned from JRK 21v3 is =-7681
Current Current returned from JRK 21v3 is =255
Current PID period count returned from JRK 21v3 is =805

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =0
Current Error Sum Integral returned from JRK 21v3 is =0
Current Duty Cycle Target returned from JRK 21v3 is =0
Current Duty Cycle returned from JRK 21v3 is =0
Current Current returned from JRK 21v3 is =0
Current PID period count returned from JRK 21v3 is =-248

============================================================
Current Input returned from JRK 21v3 is =7
Current Target returned from JRK 21v3 is =6656
Current Feedback returned from JRK 21v3 is =-22292
Current ScaledFeedback returned from JRK 21v3 is =253
Current Error Sum Integral returned from JRK 21v3 is =50
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =2040
Current PID period count returned from JRK 21v3 is =2039

============================================================
Current Input returned from JRK 21v3 is =30
Current Target returned from JRK 21v3 is =-26
Current Feedback returned from JRK 21v3 is =-26
Current ScaledFeedback returned from JRK 21v3 is =32000
Current Error Sum Integral returned from JRK 21v3 is =-2048
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =-2041
Current PID period count returned from JRK 21v3 is =7943

============================================================
Current Input returned from JRK 21v3 is =-7936
Current Target returned from JRK 21v3 is =-7681
Current Feedback returned from JRK 21v3 is =255
Current ScaledFeedback returned from JRK 21v3 is =200
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2041
Current Current returned from JRK 21v3 is =2040
Current PID period count returned from JRK 21v3 is =30

============================================================
Current Input returned from JRK 21v3 is =-30
Current Target returned from JRK 21v3 is =-30
Current Feedback returned from JRK 21v3 is =4864
Current ScaledFeedback returned from JRK 21v3 is =-2047
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-1529
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =7943
Current PID period count returned from JRK 21v3 is =-8960

============================================================
Current Input returned from JRK 21v3 is =-6401
Current Target returned from JRK 21v3 is =255
Current Feedback returned from JRK 21v3 is =351
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2041
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =30
Current PID period count returned from JRK 21v3 is =-31

============================================================
Current Input returned from JRK 21v3 is =-31
Current Target returned from JRK 21v3 is =-21760
Current Feedback returned from JRK 21v3 is =-2047
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-2297
Current Duty Cycle returned from JRK 21v3 is =7687
Current Current returned from JRK 21v3 is =-7936
Current PID period count returned from JRK 21v3 is =-7681

============================================================
Current Input returned from JRK 21v3 is =255
Current Target returned from JRK 21v3 is =502
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2041
Current Duty Cycle Target returned from JRK 21v3 is =2041
Current Duty Cycle returned from JRK 21v3 is =31
Current Current returned from JRK 21v3 is =-34
Current PID period count returned from JRK 21v3 is =-34

============================================================
Current Input returned from JRK 21v3 is =16896
Current Target returned from JRK 21v3 is =-2046
Current Feedback returned from JRK 21v3 is =-2041
Current ScaledFeedback returned from JRK 21v3 is =-1785
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =7687
Current Duty Cycle returned from JRK 21v3 is =-7936
Current Current returned from JRK 21v3 is =-7681
Current PID period count returned from JRK 21v3 is =255

============================================================
Current Input returned from JRK 21v3 is =654
Current Target returned from JRK 21v3 is =2040
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2041
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =30
Current Duty Cycle returned from JRK 21v3 is =-30
Current Current returned from JRK 21v3 is =-30
Current PID period count returned from JRK 21v3 is =-9728

============================================================
Current Input returned from JRK 21v3 is =-2046
Current Target returned from JRK 21v3 is =-2041
Current Feedback returned from JRK 21v3 is =-1785
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =7687
Current Duty Cycle Target returned from JRK 21v3 is =-7680
Current Duty Cycle returned from JRK 21v3 is =-7425
Current Current returned from JRK 21v3 is =255
Current PID period count returned from JRK 21v3 is =805

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =0
Current Error Sum Integral returned from JRK 21v3 is =0
Current Duty Cycle Target returned from JRK 21v3 is =0
Current Duty Cycle returned from JRK 21v3 is =0
Current Current returned from JRK 21v3 is =2048
Current PID period count returned from JRK 21v3 is =2047

============================================================
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =-5094
Current Feedback returned from JRK 21v3 is =-600
Current ScaledFeedback returned from JRK 21v3 is =12800
Current Error Sum Integral returned from JRK 21v3 is =-2048
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =-2041
Current PID period count returned from JRK 21v3 is =7687

============================================================
Current Input returned from JRK 21v3 is =-7936
Current Target returned from JRK 21v3 is =-7425
Current Feedback returned from JRK 21v3 is =255
Current ScaledFeedback returned from JRK 21v3 is =125
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2041
Current Current returned from JRK 21v3 is =2040
Current PID period count returned from JRK 21v3 is =30

============================================================
Current Input returned from JRK 21v3 is =-30
Current Target returned from JRK 21v3 is =-30
Current Feedback returned from JRK 21v3 is =-14336
Current ScaledFeedback returned from JRK 21v3 is =-2048
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =-2297
Current Current returned from JRK 21v3 is =7687
Current PID period count returned from JRK 21v3 is =-7936

============================================================
Current Input returned from JRK 21v3 is =-7681
Current Target returned from JRK 21v3 is =255
Current Feedback returned from JRK 21v3 is =276
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2039
Current Current returned from JRK 21v3 is =30
Current PID period count returned from JRK 21v3 is =-26

============================================================
Current Input returned from JRK 21v3 is =-26
Current Target returned from JRK 21v3 is =24576
Current Feedback returned from JRK 21v3 is =-2047
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =-1785
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =7687
Current Current returned from JRK 21v3 is =-7680
Current PID period count returned from JRK 21v3 is =-7425

============================================================
Current Input returned from JRK 21v3 is =255
Current Target returned from JRK 21v3 is =427
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2039
Current Duty Cycle returned from JRK 21v3 is =30
Current Current returned from JRK 21v3 is =-26
Current PID period count returned from JRK 21v3 is =-26

============================================================
Current Input returned from JRK 21v3 is =-2304
Current Target returned from JRK 21v3 is =-2047
Current Feedback returned from JRK 21v3 is =-2041
Current ScaledFeedback returned from JRK 21v3 is =-1785
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =7687
Current Duty Cycle returned from JRK 21v3 is =-7936
Current Current returned from JRK 21v3 is =-7681
Current PID period count returned from JRK 21v3 is =255

============================================================
Current Input returned from JRK 21v3 is =579
Current Target returned from JRK 21v3 is =2040
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2041
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =30
Current Duty Cycle returned from JRK 21v3 is =-30
Current Current returned from JRK 21v3 is =-30
Current PID period count returned from JRK 21v3 is =-28928

============================================================
Current Input returned from JRK 21v3 is =-2046
Current Target returned from JRK 21v3 is =-2041
Current Feedback returned from JRK 21v3 is =-1785
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =7687
Current Duty Cycle Target returned from JRK 21v3 is =-7936
Current Duty Cycle returned from JRK 21v3 is =-7681
Current Current returned from JRK 21v3 is =255
Current PID period count returned from JRK 21v3 is =731

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =0
Current Error Sum Integral returned from JRK 21v3 is =0
Current Duty Cycle Target returned from JRK 21v3 is =0
Current Duty Cycle returned from JRK 21v3 is =0
Current Current returned from JRK 21v3 is =-248
Current PID period count returned from JRK 21v3 is =7

============================================================
Current Input returned from JRK 21v3 is =6656
Current Target returned from JRK 21v3 is =-22292
Current Feedback returned from JRK 21v3 is =253
Current ScaledFeedback returned from JRK 21v3 is =50
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =2039
Current PID period count returned from JRK 21v3 is =30

============================================================
Current Input returned from JRK 21v3 is =-26
Current Target returned from JRK 21v3 is =-26
Current Feedback returned from JRK 21v3 is =32000
Current ScaledFeedback returned from JRK 21v3 is =-2048
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-1529
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =7687
Current PID period count returned from JRK 21v3 is =-7424

============================================================
Current Input returned from JRK 21v3 is =-7169
Current Target returned from JRK 21v3 is =255
Current Feedback returned from JRK 21v3 is =200
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2041
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =30
Current PID period count returned from JRK 21v3 is =-30

============================================================
Current Input returned from JRK 21v3 is =-30
Current Target returned from JRK 21v3 is =5120
Current Feedback returned from JRK 21v3 is =-2047
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =-1529
Current Duty Cycle Target returned from JRK 21v3 is =-1785
Current Duty Cycle returned from JRK 21v3 is =7943
Current Current returned from JRK 21v3 is =-8960
Current PID period count returned from JRK 21v3 is =-8705

============================================================
Current Input returned from JRK 21v3 is =255
Current Target returned from JRK 21v3 is =351
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2041
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =30
Current Current returned from JRK 21v3 is =-30
Current PID period count returned from JRK 21v3 is =-30

============================================================
Current Input returned from JRK 21v3 is =-21760
Current Target returned from JRK 21v3 is =-2047
Current Feedback returned from JRK 21v3 is =-2041
Current ScaledFeedback returned from JRK 21v3 is =-1785
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =7687
Current Duty Cycle returned from JRK 21v3 is =-7680
Current Current returned from JRK 21v3 is =-7425
Current PID period count returned from JRK 21v3 is =255

============================================================
Current Input returned from JRK 21v3 is =503
Current Target returned from JRK 21v3 is =2040
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2041
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =30
Current Duty Cycle returned from JRK 21v3 is =-30
Current Current returned from JRK 21v3 is =-30
Current PID period count returned from JRK 21v3 is =17152

============================================================
Current Input returned from JRK 21v3 is =-2046
Current Target returned from JRK 21v3 is =-2041
Current Feedback returned from JRK 21v3 is =-1785
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =7687
Current Duty Cycle Target returned from JRK 21v3 is =-7680
Current Duty Cycle returned from JRK 21v3 is =-7425
Current Current returned from JRK 21v3 is =255
Current PID period count returned from JRK 21v3 is =655

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =0
Current Error Sum Integral returned from JRK 21v3 is =0
Current Duty Cycle Target returned from JRK 21v3 is =0
Current Duty Cycle returned from JRK 21v3 is =0
Current Current returned from JRK 21v3 is =2048
Current PID period count returned from JRK 21v3 is =2047

============================================================
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =-5094
Current Feedback returned from JRK 21v3 is =-600
Current ScaledFeedback returned from JRK 21v3 is =12800
Current Error Sum Integral returned from JRK 21v3 is =-2048
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =-2041
Current PID period count returned from JRK 21v3 is =7687

============================================================
Current Input returned from JRK 21v3 is =-7680
Current Target returned from JRK 21v3 is =-7425
Current Feedback returned from JRK 21v3 is =255
Current ScaledFeedback returned from JRK 21v3 is =125
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =2039
Current PID period count returned from JRK 21v3 is =30

============================================================
Current Input returned from JRK 21v3 is =-26
Current Target returned from JRK 21v3 is =-26
Current Feedback returned from JRK 21v3 is =-14336
Current ScaledFeedback returned from JRK 21v3 is =-2048
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-1785
Current Duty Cycle returned from JRK 21v3 is =-2041
Current Current returned from JRK 21v3 is =7687
Current PID period count returned from JRK 21v3 is =-7680

============================================================
Current Input returned from JRK 21v3 is =-7425
Current Target returned from JRK 21v3 is =255
Current Feedback returned from JRK 21v3 is =276
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2041
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =30
Current PID period count returned from JRK 21v3 is =-31

============================================================
Current Input returned from JRK 21v3 is =-31
Current Target returned from JRK 21v3 is =24576
Current Feedback returned from JRK 21v3 is =-2047
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =-1785
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =7687
Current Current returned from JRK 21v3 is =-7680
Current PID period count returned from JRK 21v3 is =-7425

============================================================
Current Input returned from JRK 21v3 is =255
Current Target returned from JRK 21v3 is =427
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2041
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =30
Current Current returned from JRK 21v3 is =-30
Current PID period count returned from JRK 21v3 is =-30

============================================================
Current Input returned from JRK 21v3 is =-2304
Current Target returned from JRK 21v3 is =-2047
Current Feedback returned from JRK 21v3 is =-2041
Current ScaledFeedback returned from JRK 21v3 is =-1785
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =7687
Current Duty Cycle returned from JRK 21v3 is =-7680
Current Current returned from JRK 21v3 is =-7425
Current PID period count returned from JRK 21v3 is =255

============================================================
Current Input returned from JRK 21v3 is =579
Current Target returned from JRK 21v3 is =2040
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2042
Current Error Sum Integral returned from JRK 21v3 is =2041
Current Duty Cycle Target returned from JRK 21v3 is =31
Current Duty Cycle returned from JRK 21v3 is =-26
Current Current returned from JRK 21v3 is =-26
Current PID period count returned from JRK 21v3 is =-28928

============================================================
Current Input returned from JRK 21v3 is =-2046
Current Target returned from JRK 21v3 is =-2041
Current Feedback returned from JRK 21v3 is =-1785
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =7687
Current Duty Cycle Target returned from JRK 21v3 is =-7680
Current Duty Cycle returned from JRK 21v3 is =-7425
Current Current returned from JRK 21v3 is =255
Current PID period count returned from JRK 21v3 is =731

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =0
Current Error Sum Integral returned from JRK 21v3 is =0
Current Duty Cycle Target returned from JRK 21v3 is =0
Current Duty Cycle returned from JRK 21v3 is =0
Current Current returned from JRK 21v3 is =-248
Current PID period count returned from JRK 21v3 is =7

============================================================
Current Input returned from JRK 21v3 is =6656
Current Target returned from JRK 21v3 is =-22292
Current Feedback returned from JRK 21v3 is =253
Current ScaledFeedback returned from JRK 21v3 is =50
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2041
Current Current returned from JRK 21v3 is =2040
Current PID period count returned from JRK 21v3 is =30

============================================================
Current Input returned from JRK 21v3 is =-30
Current Target returned from JRK 21v3 is =-30
Current Feedback returned from JRK 21v3 is =32000
Current ScaledFeedback returned from JRK 21v3 is =-2048
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-1785
Current Duty Cycle returned from JRK 21v3 is =-2041
Current Current returned from JRK 21v3 is =7687
Current PID period count returned from JRK 21v3 is =-7680

============================================================
Current Input returned from JRK 21v3 is =-7425
Current Target returned from JRK 21v3 is =255
Current Feedback returned from JRK 21v3 is =200
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2039
Current Current returned from JRK 21v3 is =30
Current PID period count returned from JRK 21v3 is =-31

============================================================
Current Input returned from JRK 21v3 is =-31
Current Target returned from JRK 21v3 is =5120
Current Feedback returned from JRK 21v3 is =-2047
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-2297
Current Duty Cycle returned from JRK 21v3 is =7687
Current Current returned from JRK 21v3 is =-6656
Current PID period count returned from JRK 21v3 is =-6401

============================================================
Current Input returned from JRK 21v3 is =255
Current Target returned from JRK 21v3 is =351
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2041
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =30
Current Current returned from JRK 21v3 is =-30
Current PID period count returned from JRK 21v3 is =-30

============================================================
Current Input returned from JRK 21v3 is =-21760
Current Target returned from JRK 21v3 is =-2047
Current Feedback returned from JRK 21v3 is =-2041
Current ScaledFeedback returned from JRK 21v3 is =-1785
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =7687
Current Duty Cycle returned from JRK 21v3 is =-7680
Current Current returned from JRK 21v3 is =-8449
Current PID period count returned from JRK 21v3 is =255

============================================================
Current Input returned from JRK 21v3 is =503
Current Target returned from JRK 21v3 is =2040
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2041
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =30
Current Duty Cycle returned from JRK 21v3 is =-30
Current Current returned from JRK 21v3 is =-30
Current PID period count returned from JRK 21v3 is =17152

============================================================
Current Input returned from JRK 21v3 is =-2046
Current Target returned from JRK 21v3 is =-2041
Current Feedback returned from JRK 21v3 is =-1785
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =7687
Current Duty Cycle Target returned from JRK 21v3 is =-7936
Current Duty Cycle returned from JRK 21v3 is =-7681
Current Current returned from JRK 21v3 is =255
Current PID period count returned from JRK 21v3 is =655

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =0
Current Error Sum Integral returned from JRK 21v3 is =0
Current Duty Cycle Target returned from JRK 21v3 is =0
Current Duty Cycle returned from JRK 21v3 is =0
Current Current returned from JRK 21v3 is =-248
Current PID period count returned from JRK 21v3 is =7

============================================================
Current Input returned from JRK 21v3 is =6656
Current Target returned from JRK 21v3 is =-22292
Current Feedback returned from JRK 21v3 is =253
Current ScaledFeedback returned from JRK 21v3 is =50
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2041
Current Current returned from JRK 21v3 is =2040
Current PID period count returned from JRK 21v3 is =30

============================================================
Current Input returned from JRK 21v3 is =-30
Current Target returned from JRK 21v3 is =-30
Current Feedback returned from JRK 21v3 is =32000
Current ScaledFeedback returned from JRK 21v3 is =-2048
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-1785
Current Duty Cycle returned from JRK 21v3 is =-2041
Current Current returned from JRK 21v3 is =7687
Current PID period count returned from JRK 21v3 is =-7680

============================================================
Current Input returned from JRK 21v3 is =-7425
Current Target returned from JRK 21v3 is =255
Current Feedback returned from JRK 21v3 is =200
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2042
Current Duty Cycle returned from JRK 21v3 is =2041
Current Current returned from JRK 21v3 is =31
Current PID period count returned from JRK 21v3 is =-26

============================================================
Current Input returned from JRK 21v3 is =-26
Current Target returned from JRK 21v3 is =5120
Current Feedback returned from JRK 21v3 is =-2047
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =-1785
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =7687
Current Current returned from JRK 21v3 is =-7680
Current PID period count returned from JRK 21v3 is =-7425

============================================================
Current Input returned from JRK 21v3 is =255
Current Target returned from JRK 21v3 is =351
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2042
Current Duty Cycle Target returned from JRK 21v3 is =2041
Current Duty Cycle returned from JRK 21v3 is =31
Current Current returned from JRK 21v3 is =-34
Current PID period count returned from JRK 21v3 is =-34

============================================================
Current Input returned from JRK 21v3 is =-21760
Current Target returned from JRK 21v3 is =-2047
Current Feedback returned from JRK 21v3 is =-2041
Current ScaledFeedback returned from JRK 21v3 is =-1785
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =7687
Current Duty Cycle returned from JRK 21v3 is =-7680
Current Current returned from JRK 21v3 is =-7425
Current PID period count returned from JRK 21v3 is =255

============================================================
Current Input returned from JRK 21v3 is =503
Current Target returned from JRK 21v3 is =2040
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2041
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =30
Current Duty Cycle returned from JRK 21v3 is =-30
Current Current returned from JRK 21v3 is =-30
Current PID period count returned from JRK 21v3 is =17152

============================================================
Current Input returned from JRK 21v3 is =-2046
Current Target returned from JRK 21v3 is =-2041
Current Feedback returned from JRK 21v3 is =-1785
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =7687
Current Duty Cycle Target returned from JRK 21v3 is =-7680
Current Duty Cycle returned from JRK 21v3 is =-7425
Current Current returned from JRK 21v3 is =255
Current PID period count returned from JRK 21v3 is =655

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =0
Current Error Sum Integral returned from JRK 21v3 is =0
Current Duty Cycle Target returned from JRK 21v3 is =0
Current Duty Cycle returned from JRK 21v3 is =0
Current Current returned from JRK 21v3 is =-248
Current PID period count returned from JRK 21v3 is =7

============================================================
Current Input returned from JRK 21v3 is =6656
Current Target returned from JRK 21v3 is =-22292
Current Feedback returned from JRK 21v3 is =253
Current ScaledFeedback returned from JRK 21v3 is =50
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2041
Current Current returned from JRK 21v3 is =2040
Current PID period count returned from JRK 21v3 is =30

============================================================
Current Input returned from JRK 21v3 is =-30
Current Target returned from JRK 21v3 is =-30
Current Feedback returned from JRK 21v3 is =32000
Current ScaledFeedback returned from JRK 21v3 is =-2048
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-1529
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =7687
Current PID period count returned from JRK 21v3 is =-7424

============================================================
Current Input returned from JRK 21v3 is =-7169
Current Target returned from JRK 21v3 is =255
Current Feedback returned from JRK 21v3 is =200
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2041
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =30
Current PID period count returned from JRK 21v3 is =-30

============================================================
Current Input returned from JRK 21v3 is =-30
Current Target returned from JRK 21v3 is =5120
Current Feedback returned from JRK 21v3 is =-2047
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =-1785
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =7687
Current Current returned from JRK 21v3 is =-7680
Current PID period count returned from JRK 21v3 is =-7425

============================================================
Current Input returned from JRK 21v3 is =255
Current Target returned from JRK 21v3 is =351
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2041
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =30
Current Current returned from JRK 21v3 is =-30
Current PID period count returned from JRK 21v3 is =-30

============================================================
Current Input returned from JRK 21v3 is =-21760
Current Target returned from JRK 21v3 is =-2047
Current Feedback returned from JRK 21v3 is =-2041
Current ScaledFeedback returned from JRK 21v3 is =-1785
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =7687
Current Duty Cycle returned from JRK 21v3 is =-7680
Current Current returned from JRK 21v3 is =-7425
Current PID period count returned from JRK 21v3 is =255

============================================================
Current Input returned from JRK 21v3 is =503
Current Target returned from JRK 21v3 is =2040
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2041
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =30
Current Duty Cycle returned from JRK 21v3 is =-30
Current Current returned from JRK 21v3 is =-30
Current PID period count returned from JRK 21v3 is =17152

============================================================
Current Input returned from JRK 21v3 is =-2046
Current Target returned from JRK 21v3 is =-2041
Current Feedback returned from JRK 21v3 is =-1785
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =7687
Current Duty Cycle Target returned from JRK 21v3 is =-7936
Current Duty Cycle returned from JRK 21v3 is =-7681
Current Current returned from JRK 21v3 is =255
Current PID period count returned from JRK 21v3 is =655

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =-248
Current Error Sum Integral returned from JRK 21v3 is =7
Current Duty Cycle Target returned from JRK 21v3 is =6656
Current Duty Cycle returned from JRK 21v3 is =-22292
Current Current returned from JRK 21v3 is =253
Current PID period count returned from JRK 21v3 is =51

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =-248
Current Error Sum Integral returned from JRK 21v3 is =7
Current Duty Cycle Target returned from JRK 21v3 is =6656
Current Duty Cycle returned from JRK 21v3 is =-22292
Current Current returned from JRK 21v3 is =253
Current PID period count returned from JRK 21v3 is =51

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =-248
Current Error Sum Integral returned from JRK 21v3 is =7
Current Duty Cycle Target returned from JRK 21v3 is =6656
Current Duty Cycle returned from JRK 21v3 is =-22292
Current Current returned from JRK 21v3 is =253
Current PID period count returned from JRK 21v3 is =51

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =-248
Current Error Sum Integral returned from JRK 21v3 is =7
Current Duty Cycle Target returned from JRK 21v3 is =6656
Current Duty Cycle returned from JRK 21v3 is =-22292
Current Current returned from JRK 21v3 is =253
Current PID period count returned from JRK 21v3 is =51

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =0
Current Error Sum Integral returned from JRK 21v3 is =0
Current Duty Cycle Target returned from JRK 21v3 is =0
Current Duty Cycle returned from JRK 21v3 is =0
Current Current returned from JRK 21v3 is =0
Current PID period count returned from JRK 21v3 is =2048

============================================================
Current Input returned from JRK 21v3 is =2047
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =-5094
Current ScaledFeedback returned from JRK 21v3 is =-600
Current Error Sum Integral returned from JRK 21v3 is =12800
Current Duty Cycle Target returned from JRK 21v3 is =-2048
Current Duty Cycle returned from JRK 21v3 is =-2041
Current Current returned from JRK 21v3 is =-1785
Current PID period count returned from JRK 21v3 is =-2041

============================================================
Current Input returned from JRK 21v3 is =7687
Current Target returned from JRK 21v3 is =-7680
Current Feedback returned from JRK 21v3 is =-7425
Current ScaledFeedback returned from JRK 21v3 is =255
Current Error Sum Integral returned from JRK 21v3 is =124
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =2040
Current PID period count returned from JRK 21v3 is =2039

============================================================
Current Input returned from JRK 21v3 is =30
Current Target returned from JRK 21v3 is =-31
Current Feedback returned from JRK 21v3 is =-31
Current ScaledFeedback returned from JRK 21v3 is =-14336
Current Error Sum Integral returned from JRK 21v3 is =-2048
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =-2041
Current PID period count returned from JRK 21v3 is =7687

============================================================
Current Input returned from JRK 21v3 is =-7680
Current Target returned from JRK 21v3 is =-7425
Current Feedback returned from JRK 21v3 is =255
Current ScaledFeedback returned from JRK 21v3 is =275
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2041
Current Current returned from JRK 21v3 is =2040
Current PID period count returned from JRK 21v3 is =30

============================================================
Current Input returned from JRK 21v3 is =-30
Current Target returned from JRK 21v3 is =-30
Current Feedback returned from JRK 21v3 is =24320
Current ScaledFeedback returned from JRK 21v3 is =-2047
Current Error Sum Integral returned from JRK 21v3 is =-2041
Current Duty Cycle Target returned from JRK 21v3 is =-1785
Current Duty Cycle returned from JRK 21v3 is =-2041
Current Current returned from JRK 21v3 is =7687
Current PID period count returned from JRK 21v3 is =-7680

============================================================
Current Input returned from JRK 21v3 is =-7425
Current Target returned from JRK 21v3 is =255
Current Feedback returned from JRK 21v3 is =427
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2040
Current Duty Cycle Target returned from JRK 21v3 is =2041
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =30
Current PID period count returned from JRK 21v3 is =-31

============================================================
Current Input returned from JRK 21v3 is =-31
Current Target returned from JRK 21v3 is =-2560
Current Feedback returned from JRK 21v3 is =-2047
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =-1785
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =7687
Current Current returned from JRK 21v3 is =-7680
Current PID period count returned from JRK 21v3 is =-7425

============================================================
Current Input returned from JRK 21v3 is =255
Current Target returned from JRK 21v3 is =578
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2040
Current Error Sum Integral returned from JRK 21v3 is =2042
Current Duty Cycle Target returned from JRK 21v3 is =2041
Current Duty Cycle returned from JRK 21v3 is =31
Current Current returned from JRK 21v3 is =-34
Current PID period count returned from JRK 21v3 is =-26

============================================================
Current Input returned from JRK 21v3 is =-29184
Current Target returned from JRK 21v3 is =-2046
Current Feedback returned from JRK 21v3 is =-2041
Current ScaledFeedback returned from JRK 21v3 is =-1529
Current Error Sum Integral returned from JRK 21v3 is =-1785
Current Duty Cycle Target returned from JRK 21v3 is =7943
Current Duty Cycle returned from JRK 21v3 is =-8704
Current Current returned from JRK 21v3 is =-8449
Current PID period count returned from JRK 21v3 is =255

============================================================
Current Input returned from JRK 21v3 is =729
Current Target returned from JRK 21v3 is =2040
Current Feedback returned from JRK 21v3 is =2040
Current ScaledFeedback returned from JRK 21v3 is =2042
Current Error Sum Integral returned from JRK 21v3 is =2041
Current Duty Cycle Target returned from JRK 21v3 is =31
Current Duty Cycle returned from JRK 21v3 is =-34
Current Current returned from JRK 21v3 is =-34
Current PID period count returned from JRK 21v3 is =9728

============================================================
Current Input returned from JRK 21v3 is =-2045
Current Target returned from JRK 21v3 is =-2041
Current Feedback returned from JRK 21v3 is =-1785
Current ScaledFeedback returned from JRK 21v3 is =-2041
Current Error Sum Integral returned from JRK 21v3 is =7687
Current Duty Cycle Target returned from JRK 21v3 is =-7680
Current Duty Cycle returned from JRK 21v3 is =-7425
Current Current returned from JRK 21v3 is =255
Current PID period count returned from JRK 21v3 is =881

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =-248
Current Error Sum Integral returned from JRK 21v3 is =7
Current Duty Cycle Target returned from JRK 21v3 is =6656
Current Duty Cycle returned from JRK 21v3 is =-22292
Current Current returned from JRK 21v3 is =253
Current PID period count returned from JRK 21v3 is =51

============================================================
Serial1 not available 
Current Input returned from JRK 21v3 is =0
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =0
Current ScaledFeedback returned from JRK 21v3 is =0
Current Error Sum Integral returned from JRK 21v3 is =0
Current Duty Cycle Target returned from JRK 21v3 is =0
Current Duty Cycle returned from JRK 21v3 is =0
Current Current returned from JRK 21v3 is =0
Current PID period count returned from JRK 21v3 is =2048

============================================================
Current Input returned from JRK 21v3 is =2047
Current Target returned from JRK 21v3 is =0
Current Feedback returned from JRK 21v3 is =-5094
Current ScaledFeedback returned from JRK 21v3 is =-600
Current Error Sum Integral returned from JRK 21v3 is =12800
Current Duty Cycle Target returned from JRK 21v3 is =-2048
Current Duty Cycle returned from JRK 21v3 is =-2041
Current Current returned from JRK 21v3 is =-1785
Current PID period count returned from JRK 21v3 is =-2041

============================================================
Current Input returned from JRK 21v3 is =7687
Current Target returned from JRK 21v3 is =-7680
Current Feedback returned from JRK 21v3 is =-7425
Current ScaledFeedback returned from JRK 21v3 is =255
Current Error Sum Integral returned from JRK 21v3 is =124
Current Duty Cycle Target returned from JRK 21v3 is =2040
Current Duty Cycle returned from JRK 21v3 is =2040
Current Current returned from JRK 21v3 is =2040
Current PID period count returned from JRK 21v3 is =2039

============================================================
Current Input returned from JRK 21v3 is =30
Current Target returned from JRK 21v3 is =-31
Current Feedback returned from JRK 21v3 is =-31
Current ScaledFeedback returned from JRK 21v3 is =-14336
Current Error Sum Integral returned from JRK 21v3 is =-2048
Current Duty Cycle Target returned from JRK 21v3 is =-2041
Current Duty Cycle returned from JRK 21v3 is =-1785
Current Current returned from JRK 21v3 is =-2041
Current PID period count returned from JRK 21v3 is =7687

============================================================

Out of curiosity I plotted the readings on a graph, does seem like a pattern

not sure of what though?


Hi Jeremy

I think I noticed a typo in your code so I changed it (you had a semi colon after the while loop)
If I remove the semi colon I get consistent but wrong results


int jrkGetVariable(byte command)
{
char response[2];
Serial1.write(command);
while (Serial1.available() < 2)
Serial1.readBytes(response,2);

return  word(response[1],response[0]);
}

This returns the following

Current Input returned from JRK 21v3 is =-1
Current Target returned from JRK 21v3 is =-1
Current Feedback returned from JRK 21v3 is =-1
Current ScaledFeedback returned from JRK 21v3 is =-1
Current Error Sum Integral returned from JRK 21v3 is =-1
Current Duty Cycle Target returned from JRK 21v3 is =-1
Current Duty Cycle returned from JRK 21v3 is =-1
Current Current returned from JRK 21v3 is =-1
Current PID period count returned from JRK 21v3 is =-1

===================================================

If however, I replace byte by unsigned char then the resultant values are all 256

Think I fixed it

I had been running the following code to test reading the jrk variables, however I noticed on the jrk config utility I had the Serial Rx error and Serial overrun etc checked (I had been playing around a few weeks ago). So I unchecked them and just left the recommended errors on

I then decided to try to reduce the load on the buffers by reducing the number of serial1 calls to just jrkGetTarget() - its returning the correct answer now (or nearly, consistently returns 2041 when it should be 2040) and I’m not getting the inconsistent stopping and starting I was getting before. I was calling RESET to clear the error before

  if( Serial1.available()){
    dropped = 0;
    jrkSetTarget(motorSpeed);
  //  input = jrkGetInput();
    target = jrkGetTarget();
    //feedback = jrkGetFeedback();
   // scaledFeedback = jrkGetScaledFeedback();
   // errorSum = jrkGetErrorSumIntegral();
   // dutyCycleTarget = jrkGetDutyCycleTarget();
   // dutyCycle = jrkGetDutyCycle();
   // current = jrkGetCurrent();
   // pid = jrkGetPID();
 //   Serial.print("Current Input returned from JRK 21v3 is =");
//Serial.println(input);
    Serial.print("Current Target returned from JRK 21v3 is =");
    Serial.println(target);
/*    Serial.print("Current Feedback returned from JRK 21v3 is =");
    Serial.println(feedback);
    Serial.print("Current ScaledFeedback returned from JRK 21v3 is =");
    Serial.println(scaledFeedback);
    Serial.print("Current Error Sum Integral returned from JRK 21v3 is =");
    Serial.println(errorSum);
    Serial.print("Current Duty Cycle Target returned from JRK 21v3 is =");
    Serial.println(dutyCycleTarget);
    Serial.print("Current Duty Cycle returned from JRK 21v3 is =");
    Serial.println(dutyCycle);
    Serial.print("Current Current returned from JRK 21v3 is =");
    Serial.println(current);
    Serial.print("Current PID period count returned from JRK 21v3 is =");
    Serial.println(pid);*/
    Serial.println("");
    Serial.println("============================================================");
  }
  else {
    dropped = dropped + 1;
   
   Serial.println("Serial1 not available ");
                  digitalWrite(RESET, LOW);
                  delay(5000);
                  digitalWrite(RESET, HIGH); 
  }

Thanks for letting us know. I am glad you were able to figure it out. By the way, the semicolon in my code was intentional; the program waits in the empty loop until the 2 bytes are available.

- Jeremy

Thanks Jeremy

It’s working great now, I can change motor speed dynamically now and I can move onto the next steps. By the way, I love the PID correction!

PS any advice on handling buffer read / write?
Should I increase or decrease baud rate - i.e. is overrun likely to be because I’m not emptying fast enough or because I’m trying to write too quickly?

It should’t be a big problem because I was only using the serial printing for test purposes rather than program control

I am glad you got it working!

Although increasing the baud rate might make it more likely to fill up the buffer, our products should be able to accept a constant stream of serial commands at the baud rates that we claim they support.

- Jeremy