Dynamixel multi-turn encoder problem

Hi all,
I'm using an MX-106T with its multi turn functionality. I suspect it only has an absolute encoder for the 360degrees and not past that.

I need it to reach two positions, I have a button each for the positions. -1500 to 5000. I'm successful doing this. The problem however is suppose the servo is at -1500 and you turn it off and then back on it thinks it's at ~2200 integer or something similar and does a full loop back to -1500. This is problematic because my device will circle back on itself and break.

I can't even put a statement in there telling it not to exceed certain points because it thinks it's at ~2200 when it starts back up which happens to fall in my operational range and I can't occlude those values.

Any ideas on how to solve this? Thanks

//------------------------------
//Libraries:
#include <DynamixelSerial.h>

//------------------------------
//Buttons:

//Dyna1:
const int Dyna1OpenButtonPin = 13;
const int Dyna1CloseButtonPin = 12;

//------------------------------
//Variables that will change:

//Dyna1:
int Dyna1OpenButtonState = 0; //variable for reading button status
int Dyna1CloseButtonState = 0; //variable for reading button status

//------------------------------
void setup() {

  //--------------------------------
  //Dynamixel Setup:
  Dynamixel.begin(1000000, 2); // Initialize Dynamixel at 1Mbps and at DIGITAL Pin Control 2
  delay(1000);
  //--------------------------------
  //Dyna1 Setup:
  pinMode(Dyna1OpenButtonPin, INPUT); //Initialize Dyna1 Open Button
  pinMode(Dyna1CloseButtonPin, INPUT); //Initialize Dyna1 Open Button
  //--------------------------------

}

void Dyna1Open() {

  //read state of Dyna1OpenButtonPin:
  Dyna1OpenButtonState = digitalRead(Dyna1OpenButtonPin);

  //in this case a HIGH state is the resting position for the switch
  if (Dyna1OpenButtonState == LOW) {
    // OPEN/Fully extend Dyna1:
    Dynamixel.moveSpeed(1, -1700, 500);
  } else {
  }

}

void Dyna1Close() {

  //read state of Dyna1CloseButtonPin:
  Dyna1CloseButtonState = digitalRead(Dyna1CloseButtonPin);

  //in this case a HIGH state is the resting position for the switch
  if (Dyna1CloseButtonState == LOW) {
    // Close Dyna1:
    Dynamixel.moveSpeed(1, 4000, 500);
  } else {
    
  }


}

}
void loop() {

  // Call Dyna1Open function:
  Dyna1Open();

  // Call Dyna1Close function:
  Dyna1Close();

}

That is why they invented limit switches

Any ideas on how to solve this?

Fix your code. If you need help, POST YOUR CODE!

PaulS:
Fix your code. If you need help, POST YOUR CODE!

If you could assist me to fix this with code that would be fantastic. I am not sure if it's simple though. Thanks!

blh64:
That is why they invented limit switches

Doesn't address the problem to just put a limit switch there. It's not reliable that way. That would be useful as a fail safe though.

ardoyouknowwhoiam:
Doesn't address the problem to just put a limit switch there. It's not reliable that way. That would be useful as a fail safe though.

Yes, it does. Your problem is your program has no "zero" position from which to work from. The limit switch will tell your program exactly where zero is each time it starts, if you write your program to search for it in the setup code.

Paul

Paul_KD7HB:
Yes, it does. Your problem is your program has no "zero" position from which to work from. The limit switch will tell your program exactly where zero is each time it starts, if you write your program to search for it in the setup code.

Paul

The issue I'm having is that the encoder is absolute for 360 and not during the multi turn. It scans its absolute encoder for its set positions because it's lost at first. I'm not sure how I could reprogram its innate values. Any ideas?

After spending all that money on the MX-106T, why did you not buy the associated controller which is reported to be usable with the Arduino?

Paul

Paul_KD7HB:
After spending all that money on the MX-106T, why did you not buy the associated controller which is reported to be usable with the Arduino?

Paul

The controller is just for interfacing with the actuator. You still need to write code for it though no?

ardoyouknowwhoiam:
The controller is just for interfacing with the actuator. You still need to write code for it though no?

Did I not see sample Arduino program for the device?

Paul

Paul_KD7HB:
Did I not see sample Arduino program for the device?

Paul

Where? Could you please link me. Thanks!

You say "my device will circle back on itself and break". Perhaps there is a way to add a limit switch that can prevent the device from breaking itself. If you put a small timing pulley on the motor shaft and have a timing belt on that pulley drive a larger pulley such that the larger pulley won't make a full turn, you could put a limit switch on the larger pulley. When power is lost and restored, drive the motor until the limit switch is reached and that will provide an absolute position from where to start.

ardoyouknowwhoiam:
Where? Could you please link me. Thanks!

I found this:

As an Arduino compatible microcontroller the Arbotix Robocontroller also benefits from a huge open source community of libraries and examples. Since its release in 2010 the Arbotix has quickly become a favorite among builders worldwide from hobby to high level research.

And this:

As an Arduino compatible board, the ArbotiX can be used with the Arduino IDE. We've also released an open source library and sample programs to help with controlling DYNAMIXEL AX/MX/RX/EX servos. You can find detailed information on setting up the ArboitX here

And here is: https://learn.trossenrobotics.com/arbotix

Paul