Arduino nano with Adxl345 serial error ox0800 JRK21V3

Hello,

i want to drive a motor with an Arduino nano and a Adxl345, it use to work but now i got a serial error
on the JRK21V3. It should keep a basket horzontal for a handycapt person who needs oxygen.
I build this in 2016 and it worked. Now i have to build another one but it won`t function.
The code is below, can someone help me ?

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);
/* Assign a unique ID to this sensor at the same time */
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);

////////////////////////////////////////////////////////////////////////////////////////////////////

float multiplier = 1 ;     //change this value to adjust motor sensitivity, decimals are ok 
int dir = 1;         // change to -1 to invert direction

////////////////////////////////////////////////////////////////////////////////////////////////////

int outputValue = 0;        // value output to the controller
int old_outputValue = 0; 
byte command[2];
int bytesSent = 0;
void displaySensorDetails(void)
{
  sensor_t sensor;
  accel.getSensor(&sensor);
  Serial.println("------------------------------------");
  Serial.print  ("Sensor:       "); Serial.println(sensor.name);
  Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
  Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
  Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" m/s^2");
  Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" m/s^2");
  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" m/s^2");  
  Serial.println("------------------------------------");
  Serial.println("");
  delay(500);
}

void displayDataRate(void)
{
  Serial.print  ("Data Rate:    "); 
  
  switch(accel.getDataRate())
  {
    case ADXL345_DATARATE_3200_HZ:
      Serial.print  ("3200 "); 
      break;
    case ADXL345_DATARATE_1600_HZ:
      Serial.print  ("1600 "); 
      break;
    case ADXL345_DATARATE_800_HZ:
      Serial.print  ("800 "); 
      break;
    case ADXL345_DATARATE_400_HZ:
      Serial.print  ("400 "); 
      break;
    case ADXL345_DATARATE_200_HZ:
      Serial.print  ("200 "); 
      break;
    case ADXL345_DATARATE_100_HZ:
      Serial.print  ("100 "); 
      break;
    case ADXL345_DATARATE_50_HZ:
      Serial.print  ("50 "); 
      break;
    case ADXL345_DATARATE_25_HZ:
      Serial.print  ("25 "); 
      break;
    case ADXL345_DATARATE_12_5_HZ:
      Serial.print  ("12.5 "); 
      break;
    case ADXL345_DATARATE_6_25HZ:
      Serial.print  ("6.25 "); 
      break;
    case ADXL345_DATARATE_3_13_HZ:
      Serial.print  ("3.13 "); 
      break;
    case ADXL345_DATARATE_1_56_HZ:
      Serial.print  ("1.56 "); 
      break;
    case ADXL345_DATARATE_0_78_HZ:
      Serial.print  ("0.78 "); 
      break;
    case ADXL345_DATARATE_0_39_HZ:
      Serial.print  ("0.39 "); 
      break;
    case ADXL345_DATARATE_0_20_HZ:
      Serial.print  ("0.20 "); 
      break;
    case ADXL345_DATARATE_0_10_HZ:
      Serial.print  ("0.10 "); 
      break;
    default:
      Serial.print  ("???? "); 
      break;
  }  
  Serial.println(" Hz");  
}

void displayRange(void)
{
  Serial.print  ("Range:         +/- "); 
  
  switch(accel.getRange())
  {
    case ADXL345_RANGE_16_G:
      Serial.print  ("16 "); 
      break;
    case ADXL345_RANGE_8_G:
      Serial.print  ("8 "); 
      break;
    case ADXL345_RANGE_4_G:
      Serial.print  ("4 "); 
      break;
    case ADXL345_RANGE_2_G:
      Serial.print  ("2 "); 
      break;
    default:
      Serial.print  ("?? "); 
      break;
  }  
  Serial.println(" g");  
}

void setup(void) 
{
pinMode(A0,INPUT);
  Serial.begin(9600);
  Serial.println("Accelerometer Test"); Serial.println("");
  mySerial.begin(19200);
  delay(100);
  mySerial.write(0xAA);
  /* Initialise the sensor */
  if(!accel.begin())
  {
    /* There was a problem detecting the ADXL345 ... check your connections */
    Serial.println("Ooops, no ADXL345 detected ... Check your wiring!");
    while(1);
  }

  /* Set the range to whatever is appropriate for your project */
  accel.setRange(ADXL345_RANGE_16_G);
  // displaySetRange(ADXL345_RANGE_8_G);
  // displaySetRange(ADXL345_RANGE_4_G);
  // displaySetRange(ADXL345_RANGE_2_G);
  
  /* Display some basic information on this sensor */
  displaySensorDetails();
  
  /* Display additional settings (outside the scope of sensor_t) */
  displayDataRate();
  displayRange();
  Serial.println("");
}

void loop(void) 
{
  
   old_outputValue = outputValue;
  /* Get a new sensor event */ 
  sensors_event_t event; 
  accel.getEvent(&event);
   //outputValue = map(analogRead(A0)*multiplier, 0, 1023, -127, 127);
 outputValue = map(((event.acceleration.x)*multiplier*dir), -10, 10, -127, 127);
  /* Display the results (acceleration is measured in m/s^2) */
 if (mySerial.available()){
 Serial.print("Incomming: ");
Serial.print(mySerial.read(),BIN);
Serial.println();
}
  if (outputValue != old_outputValue) {
   Serial.print("X: ");
  Serial.print(event.acceleration.x);
  Serial.print("  ");
  Serial.print("m/s^2 ");
  Serial.println(outputValue);
    if(outputValue>=0){
    mySerial.write(0xE1);
    mySerial.write(outputValue); 
    }
    if(outputValue<0){
    mySerial.write(0xE0);
    mySerial.write(-(outputValue)); 
    }   
  mySerial.write(0xB3);
  }
   delay(200);

The Pololu settings are,

INITIALIZED 0
INPUT_MODE SERIAL
INPUT_MINIMUM 0
INPUT_MAXIMUM 4095
OUTPUT_MINIMUM 0
OUTPUT_NEUTRAL 2048
OUTPUT_MAXIMUM 4095
INPUT_INVERT 0
INPUT_SCALING_DEGREE 0
INPUT_POWER_WITH_AUX 0
INPUT_ANALOG_SAMPLES_EXPONENT 5
INPUT_DISCONNECT_MINIMUM 0
INPUT_DISCONNECT_MAXIMUM 4095
INPUT_NEUTRAL_MAXIMUM 2048
INPUT_NEUTRAL_MINIMUM 2048
SERIAL_MODE UART_FIXED_BAUD_RATE
SERIAL_FIXED_BAUD_RATE 9600
SERIAL_TIMEOUT 0
SERIAL_ENABLE_CRC 0
SERIAL_NEVER_SUSPEND 0
SERIAL_DEVICE_NUMBER 11
FEEDBACK_MODE NONE
FEEDBACK_MINIMUM 0
FEEDBACK_MAXIMUM 4095
FEEDBACK_INVERT 0
FEEDBACK_POWER_WITH_AUX 0
FEEDBACK_DEAD_ZONE 0
FEEDBACK_ANALOG_SAMPLES_EXPONENT 5
FEEDBACK_DISCONNECT_MINIMUM 0
FEEDBACK_DISCONNECT_MAXIMUM 4095
PROPORTIONAL_MULTIPLIER 0
PROPORTIONAL_EXPONENT 0
INTEGRAL_MULTIPLIER 0
INTEGRAL_EXPONENT 0
DERIVATIVE_MULTIPLIER 0
DERIVATIVE_EXPONENT 0
PID_PERIOD 10
PID_INTEGRAL_LIMIT 1000
PID_RESET_INTEGRAL 0
MOTOR_PWM_FREQUENCY 0
MOTOR_INVERT 0
MOTOR_MAX_DUTY_CYCLE_WHILE_FEEDBACK_OUT_OF_RANGE 600
MOTOR_MAX_ACCELERATION_FORWARD 600
MOTOR_MAX_ACCELERATION_REVERSE 600
MOTOR_MAX_DUTY_CYCLE_FORWARD 600
MOTOR_MAX_DUTY_CYCLE_REVERSE 600
MOTOR_MAX_CURRENT_FORWARD 81
MOTOR_MAX_CURRENT_REVERSE 81
MOTOR_CURRENT_CALIBRATION_FORWARD 37
MOTOR_CURRENT_CALIBRATION_REVERSE 37
MOTOR_BRAKE_DURATION_FORWARD 0
MOTOR_BRAKE_DURATION_REVERSE 0
MOTOR_COAST_WHEN_OFF 0
ERROR_ENABLE 2
ERROR_LATCH 0

Hello.

The first thing I noticed is that it looks like you have the Jrk configured for a fixed baud rate of 9600, but you’re setting up mySerial() for a baud rate of 19200. It looks like you’re sending 0xAA first, which the Jrk can use to detect the baud rate automatically if you change the serial interface setting to “UART, detect baud rate” in the “Input” tab of the Jrk Configuration Utility.

If you continue receiving errors, can you post a screen capture of the “Errors” tab of the Jrk Control Center, a copy of your updated settings file, and some pictures of your setup that show all of your connections?

Brandon

Hello Brandon,

I put the Jrk in " UART detect baud rate " and my problem is solved, thanks for your quick reaction. Do i have to change settings when i use a Jrk G2 21V3 instead of a Jrk 21V3 ?

Jos

Hello, Jos.

Yes, many of the settings on the Jrk G2 21v3 work similarly to the ones on the original Jrk 21v3, but they are not identical, and it is not possible to save a copy of the settings file from one and apply it to the other directly. The Jrk G2 also has different configuration software from the original Jrks.

If you are thinking about upgrading to the Jrk G2, it would probably be useful to review the “Comparison to the original Jrk controllers” section of the Jrk G2 Motor Controller User’s Guide.

- Patrick