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

"hold_mode" not working #7

Open
BlueGene00 opened this issue May 7, 2023 · 2 comments
Open

"hold_mode" not working #7

BlueGene00 opened this issue May 7, 2023 · 2 comments

Comments

@BlueGene00
Copy link

Hello,

I am currently testing TMC429 and TMC4361A.

For the TMC4361A, I am using this library:
https://github.com/tommag/TMC4361_Arduino

In my application, i want to to set a constant speed and target position. This is possible with the "hold_mode" mode on both chips.

On the TMC4361 it is working very nicely with the library above, so I just set maxSpeed and targetPosition and the movement is performed.

I tried the same with the TMC429 library, but got no success. Hold_mode is not implemented, so I just added:

void TMC429::setHoldMode(size_t motor)
{
  setMode(motor,HOLD_MODE);
}

The main code is looking somehow like this:

void setup()
{

  tmc429.setup(CHIP_SELECT_PIN, CLOCK_FREQUENCY_MHZ);
  tmc429.initialize();
  tmc429.setHoldMode(MOTOR);
}

void loop()
{

  tmc429.setTargetVelocityInHz(MOTOR, 5000);
  tmc429.setMaxVelocity(MOTOR, 5000);
  tmc429.setTargetPosition(MOTOR, 5000);

}

But this will lead to no movement. With ramp_mode example, everything is working fine, so it is not a general issue with the setup.

Any idea what is misssing to make it run?

@peterpolidoro
Copy link
Member

I had never used hold mode, but I did some reading in the datasheet and modified the library so it should work now. Hold mode does not use target velocity, it works by setting "actual velocity" directly. I added your method, "setHoldMode" and also a method called "setHoldVelocity". The units of the hold velocity are not in Hz. I could add another method called "setHoldVelocityInHz", but that would require setting the max velocity to determine the scaling factor between the hold velocity units and Hz. If that would be useful, let me know and I will add that as well.

@peterpolidoro
Copy link
Member

I went ahead and added the "setHoldVelocityInHz" method and updated the example to show its use.

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

2 participants