Help with lx16a

I'm trying to build a robot arm using the hiwonder lx16a bus servos with an arduino mega for the controller. Now I have used both the single and tripple motor examples in the lx16a library to no avail. I should mention I am using the bus linker (debug board) and servos found here. I have tried every way possible of wiring these up from the diagram in the product listing, the examples and many other variations of these as possible. I have tried disabling the serial output from the arduino incase that was interferring as well and finally to no avail which leave me here asking for help.
Sorry for the bad penmenship and thanks in advance.
(Before someone mentions have I looked at the manual yes and I have read through it just for me to conclude its more a sales pack than an understanding and using the product manual.)

Please post code and schematics. Please also describe in what way the outcome mismatches the goal.

1 Like

What I am trying to do is just be able to get the servos to move even a default pattern for now just so that I know I can utilise an arduino to control them. (Note I was supplying 6v to the bus linker board). When ever I did try to run the code with the serial monitor open what I was getting was no response on ID 21 which is servo angle read command. It would just repeat this command over and over sending and waiting .25s before concluding on an error.
Bellow is the demo code from the arduino library for them slightly modified as I found their way serial printing wasn't working and bellow that is the general skematic which I did change the configs of the tx and rx pins on both sides and as I am using a mega did change to try utilise the 118 & 119 rx/tx pins incase the serial monitor was interfering but anything I tried I was getting the same result.

#include <Arduino.h>
#include <lx16a-servo.h>
LX16ABus servoBus;
LX16AServo servo(&servoBus, 1);
LX16AServo servo2(&servoBus, 2);
LX16AServo servo3(&servoBus, 3);

void setup() {
	servoBus.begin(&Serial1, 119, // on TX pin 1
			118); // use pin 2 as the TX flag for buffer
	Serial.begin(115200);
	servoBus.retry = 1; // enforce synchronous real time
	servoBus.debug(true);
	Serial.println("Beginning Coordinated Servo Example");

}
// 40ms trajectory planning loop seems the most stable

void loop() {
	int divisor = 3;
	for (int i = 0; i < 1000 / divisor; i++) {
		long start = millis();
		int16_t pos = 0;
		pos = servo.pos_read();
		int16_t pos2 = servo2.pos_read();
		int16_t pos3 = servo3.pos_read();

		uint16_t angle = i * 24 * divisor;

		servo2.move_time_and_wait_for_sync(angle, 10 * divisor);
		servo3.move_time_and_wait_for_sync(angle, 10 * divisor);
		servo.move_time_and_wait_for_sync(angle, 10 * divisor);

		servoBus.move_sync_start();

		//if(abs(pos2-pos)>100){
		Serial.print("\n\nPosition at ");
		Serial.print(pos);
		Serial.print(" and ");
		Serial.print(pos2);
		Serial.print("-> ");
		Serial.println(servo.isCommandOk() ? "OK" : "\n\nERR!!\n\n");
   
		Serial.print("Move to ");
    Serial.print(angle);
		Serial.print("-> ");
		Serial.println(servo.isCommandOk() ? "OK" : "\n\nERR!!\n\n");
		Serial.print("\n");
		//}
		long took = millis() - start;

		long time = (10 * divisor) - took;
		if (time > 0)
			delay(time);
		else {
			Serial.println("Real Time broken, took: " + String(took));
		}
	}
	Serial.println("Interpolated Set pos done, not long set");

	servoBus.retry = 5; // These commands must arrive
	servo.move_time(0, 10000);
	servo2.move_time(0, 10000);
	servo3.move_time(0, 10000);
	servoBus.retry = 0; // Back to low latency mode
	for (int i = 0; i < 1000 / divisor; i++) {
		long start = millis();
		int16_t pos = 0;
		pos = servo.pos_read();
		int16_t pos2 = servo2.pos_read();
		int16_t pos3 = servo3.pos_read();

		Serial.print("\n\nPosition at ");
		Serial.print(pos);
		Serial.print
		("and ");
		Serial.println(pos2);

		Serial.println("Voltage = " + String(servo.vin()));
		Serial.println("Temp = " + String(servo.temp()));

		long took = millis() - start;

		long time = (10 * divisor) - took;
		if (time > 0)
			delay(time);
		else {
			Serial.println("Real Time broken, took: " + String(took));
		}
	}
	Serial.println("Loop resetting");
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.