Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Hitec HSR-M9382TH? #2

Open
hikari20XX opened this issue Feb 8, 2024 · 9 comments
Open

Support for Hitec HSR-M9382TH? #2

hikari20XX opened this issue Feb 8, 2024 · 9 comments

Comments

@hikari20XX
Copy link

Hello,

I was wondering if this library would recognize a Hitec HSR-M9382TH servo motor if connected (since they both use the DPC-11 programmer figured it might be worth a shot)? So far I've been unable to verify the that the servo is connected in the serial monitor, but will continue troubleshooting in the meantime. I've replicated the breadboard layout in the README (using an Arduino Nano), and I've confirmed that the servo is receiving the correct voltage and is drawing amperage indicative of idling. Any insights or wisdom is greatly appreciated.

Thanks again for your time.

@hikari20XX
Copy link
Author

Update: I realized that I had omitted a resistor, and now in the serial monitor when I try to set the pin the response is Error: Corrupt response from servo.

@timmaxw
Copy link
Owner

timmaxw commented Feb 8, 2024

I've never tried an HSR-series servo, but I'm not surprised that it doesn't work.

(Hitec's marketing for the D-series advertises shiny new "32-bit chip technology", so I think the D-series might use a different processor+firmware than Hitec's other lines? IDK.)

@hikari20XX
Copy link
Author

Thanks for getting back to me so quickly, I really appreciate it. Do you have any advice for developing a library for it, or adding compatibility for it in your library? Like did you use Ghidra when developing your library, or did you have a DPC-11 and captured the communication between the programmer and servo with an oscilloscope/logic analyzer?

@timmaxw
Copy link
Owner

timmaxw commented Feb 9, 2024

I used a DPC-11 and a logic analyzer. I put some notes in the repo here, which may or may not be helpful for reverse-engineering the HSR-series:

@TTN-
Copy link

TTN- commented May 11, 2024

FYI have tried the programmer sketch with a D645MW servo, but no joy. Comes back with Error: Corrupt response from servo.

@timmaxw
Copy link
Owner

timmaxw commented May 11, 2024

That's a bummer. I wonder why the D645MW doesn't work; I would have expected the protocol to be pretty similar.

I don't have a D645MW, so I can't debug this myself. If you're interested in debugging this, the next step would be to modify the HitecDServo::readRawRegister() method to print which part of the message was corrupt.

@TTN-
Copy link

TTN- commented May 11, 2024

Thanks. I'm not a very good programmer it's been a while so I'll be super verbose:

HitecDServo.cpp from Example3_ReadSettings was modded:

#include "HitecDServo.h"

#include "HitecDServoInternal.h"

HitecDServo::HitecDServo() : pin(-1) { }

int HitecDServo::attach(int _pin) {
  if (attached()) {
    detachAndReset();
  }

  pin = _pin;
  pinMode(pin, OUTPUT);
  digitalWrite(pin, LOW);

  pinBitMask = digitalPinToBitMask(pin);
  uint8_t port = digitalPinToPort(pin);
  pinInputRegister = portInputRegister(port);
  pinOutputRegister = portOutputRegister(port);

  int res;
  uint16_t temp;

  res = readRawRegister(HD_REG_MODEL_NUMBER, &temp);
  Serial.println("read: HD_REG_MODEL_NUMBER as: ");
  Serial.println(temp);
  Serial.println(res);

  res = readRawRegister(HD_REG_RANGE_LEFT_APV, &temp);
  Serial.println("read: HD_REG_RANGE_LEFT_APV as: ");
  Serial.println(temp);
  Serial.println(res);

    res = readRawRegister(HD_REG_RANGE_RIGHT_APV, &temp);
  Serial.println("read: HD_REG_RANGE_RIGHT_APV as: ");
  Serial.println(temp);
  Serial.println(res);

    res = readRawRegister(HD_REG_RANGE_CENTER_APV, &temp);
  Serial.println("read: HD_REG_RANGE_CENTER_APV as: ");
  Serial.println(temp);
  Serial.println(res);

Then power cycle the servo, and then run the arduino, result:

06:07:58.411 -> read: HD_REG_MODEL_NUMBER as: 
06:07:58.411 -> 309
06:07:58.411 -> read: HD_REG_RANGE_LEFT_APV as: 
06:07:58.411 -> 309
06:07:58.458 -> read: HD_REG_RANGE_RIGHT_APV as: 
06:07:58.458 -> 309
06:07:58.458 -> read: HD_REG_RANGE_CENTER_APV as: 
06:07:58.458 -> 309
06:07:58.506 -> Error: Corrupt response from servo.

Something is off. Got 2K pullup from D2 to 5V. Servo powered from external 5V power source, and grounds are shared between Arduino and servo so that should be fine wiring wise. Have verified with multimeter, it does pull up with reference to arduino gnd.

@timmaxw
Copy link
Owner

timmaxw commented May 11, 2024

What does it print if you run it with this patch? main...debug

@TTN-
Copy link

TTN- commented May 11, 2024

Tim I'll throw up a logic analyzer dump in #3 later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants