Serial on the MkR WiFi 1010 (and yes I am using "Serial1")

I Can't for the life of me figure this out and I have all but given up. Hardware is an official Mkr WiFi1010 and using IDE 1.8.10. I decided to post this here because at this point I am going to treat this as a hardware problem unless I can somehow prove otherwise. I am trying to interface the Arduino Mkr WiFi1010 with a 5v Serial "BusLinker" from Lobot. It is the serial interface board for Lobot (LewanSoul) Serial Servos.

I have the two connected together via a level converter (generic clone of the sparkfun).

They are using separate power supplies. For the sake of this post you can assume I have everything connected correctly (Arduino VCC to LV, Arduino GND to GND, BusLinker 5v to HV Buslinker GND to GND, TX and RX (14,13) crossed at the logic converter and all GND tied.).

I am using a very stripped down example from the sample code (See Below) and have changed everything to Serial1.

I Tried 4 different logic converters thinking the problem was there and to no avail, so then tested the logic converters and the inputs cycle when pulled to ground properly.

Next I completely removed the logic converter and tried with a voltage divider, still no dice.

I checked voltages before ever connecting the Mkr and voltage was always at VCC on the LV side of the logic converter/ voltage divider.

I even tried using the Sercom example to add another serial interface to pins 0,1 and still nothing.

The crazy thing is, that I can connect a 5v arduino to tx and rx, tie the grounds and everything works perfectly.

I can write the data to "Serial" (not Serial1) on the Mkr asnd see the same terminal output that I see on the 5v Arduino.

What am I missing here?? This is is driving me crazy. Is there some way I can confirm that my Mkr is actually outputting the Serial data?

Please tell me there is some smart person out there who ran into a similar issue and knows the fix. I literally feel like I am out of options other than going out and buying and oscilloscope to connect to the Mkr and hunt to see if the data is there.

Here's the simple sample code:

#define GET_LOW_BYTE(A) (uint8_t)((A))
//Macro function  get lower 8 bits of A
#define GET_HIGH_BYTE(A) (uint8_t)((A) >> 8)
//Macro function  get higher 8 bits of A
#define BYTE_TO_HW(A, B) ((((uint16_t)(A)) << 8) | (uint8_t)(B))
//Macro Function  put A as higher 8 bits   B as lower 8 bits   which amalgamated into 16 bits integer

#define LOBOT_SERVO_FRAME_HEADER         0x55
#define LOBOT_SERVO_MOVE_TIME_WRITE      1
#define LOBOT_SERVO_MOVE_TIME_READ       2
#define LOBOT_SERVO_MOVE_TIME_WAIT_WRITE 7
#define LOBOT_SERVO_MOVE_TIME_WAIT_READ  8
#define LOBOT_SERVO_MOVE_START           11
#define LOBOT_SERVO_MOVE_STOP            12
#define LOBOT_SERVO_ID_WRITE             13
#define LOBOT_SERVO_ID_READ              14
#define LOBOT_SERVO_ANGLE_OFFSET_ADJUST  17
#define LOBOT_SERVO_ANGLE_OFFSET_WRITE   18
#define LOBOT_SERVO_ANGLE_OFFSET_READ    19
#define LOBOT_SERVO_ANGLE_LIMIT_WRITE    20
#define LOBOT_SERVO_ANGLE_LIMIT_READ     21
#define LOBOT_SERVO_VIN_LIMIT_WRITE      22
#define LOBOT_SERVO_VIN_LIMIT_READ       23
#define LOBOT_SERVO_TEMP_MAX_LIMIT_WRITE 24
#define LOBOT_SERVO_TEMP_MAX_LIMIT_READ  25
#define LOBOT_SERVO_TEMP_READ            26
#define LOBOT_SERVO_VIN_READ             27
#define LOBOT_SERVO_POS_READ             28
#define LOBOT_SERVO_OR_MOTOR_MODE_WRITE  29
#define LOBOT_SERVO_OR_MOTOR_MODE_READ   30
#define LOBOT_SERVO_LOAD_OR_UNLOAD_WRITE 31
#define LOBOT_SERVO_LOAD_OR_UNLOAD_READ  32
#define LOBOT_SERVO_LED_CTRL_WRITE       33
#define LOBOT_SERVO_LED_CTRL_READ        34
#define LOBOT_SERVO_LED_ERROR_WRITE      35
#define LOBOT_SERVO_LED_ERROR_READ       36

#define ID1   1

int step = 0;
int pos[4] = {100, 200, 300, 400};


void setup() {
// put your setup code here, to run once:
  
  Serial1.begin(115200);

}

void loop() {
  // put your main code here, to run repeatedly:

  SerialServoMove(ID1, pos[step++], 500);

  if (step == 4) {
    step = 0;
  }

  delay(3000);

}




byte LobotCheckSum(byte buf[])
{
  byte i;
  uint16_t temp = 0;
  for (i = 2; i < buf[3] + 2; i++) {
    temp += buf[i];
  }
  temp = ~temp;
  i = (byte)temp;
  return i;
}



void SerialServoMove(uint8_t id, int16_t position, uint16_t time)
{
  byte buf[10];
  if (position < 0)
    position = 0;
  if (position > 1000)
    position = 1000;
  buf[0] = buf[1] = LOBOT_SERVO_FRAME_HEADER;
  buf[2] = id;
  buf[3] = 7;
  buf[4] = LOBOT_SERVO_MOVE_TIME_WRITE;
  buf[5] = GET_LOW_BYTE(position);
  buf[6] = GET_HIGH_BYTE(position);
  buf[7] = GET_LOW_BYTE(time);
  buf[8] = GET_HIGH_BYTE(time);
  buf[9] = LobotCheckSum(buf);

  Serial1.write(buf, 10);
}

If you took a look, it is much appreciated.

Thanks!

I finally figured this out on accident months later. I didn't realize there was a semi-official library for the lx16 servo in the Arduino catalog:

When I started looking through the info, the authors explain why this wasn't working for me and provide a solution:

"The LX-* servos all use a 3.3v driven bi directional asynchronus serial. It is similar to UART, but uses both signals on one pin. Because of this, the Master TX line has to be connected only while transmitting. The correct way to do this is a buffer chip 74HC126."

and instructions!

Case closed :slight_smile:

For the sake of this post you can assume I have everything connected correctly.

Errr....

"The LX-* servos all use a 3.3v driven bi directional asynchronus serial. It is similar to UART, but uses both signals on one pin. Because of this, the Master TX line has to be connected only while transmitting. The correct way to do this is a buffer chip 74HC126."

Connected correctly? Never assume things are connected correctly and absolutely never ask us to assume that.

Well done for getting it working and for providing an update, I would give Karma for that but it doesn't seem to be possible on a mobile phone.

PerryBebbington:
Errr....
Connected correctly? Never assume things are connected correctly and absolutely never ask us to assume that.

Well done for getting it working and for providing an update, I would give Karma for that but it doesn't seem to be possible on a mobile phone.

Added for you :smiling_imp: