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

Can I use this with the Arduino Portenta Machine Control? #35

Open
wallahi06 opened this issue Feb 7, 2024 · 1 comment
Open

Can I use this with the Arduino Portenta Machine Control? #35

wallahi06 opened this issue Feb 7, 2024 · 1 comment

Comments

@wallahi06
Copy link

No description provided.

@imatrisciano
Copy link

I spent most of today trying to figure this question out and want to share my results

Technically it can be used, but the only 8 digital outputs of the Portenta Machine Control go through a current limiting chip and the signal edges are really slow. This means that we need to setup a huge step width, leading to a ton of CPU time wasted doing spin locks.
Also for some reason the digitalWrite function used to set the output pins does not correctly detect the pin, so we call PinNameToIndex when telling AccelStepper the pin names

#include <Arduino.h>
#include <Arduino_PortentaMachineControl.h>
#include <pinDefinitions.h>
#include <AccelStepper.h>


AccelStepper stepper(AccelStepper::MotorInterfaceType::DRIVER, PinNameToIndex(MC_DO_DO0_PIN), PinNameToIndex(MC_DO_DO1_PIN)); // Step on DO0, Dir on DO1

void setup()
{
	MachineControl_DigitalOutputs.begin();
	stepper.enableOutputs();
	stepper.setMinPulseWidth(130); // this is necessary. Maybe you can get it to work with something closer to 100us, but 130us seems like a safe value
	stepper.setAcceleration(1000); // choose any value you want
	stepper.setMaxSpeed(1000); // I wouldn't go above 1000, but values up to 1500 might work
	stepper.setSpeed(100); // choose any value up to MaxSpeed
}

void loop()
{
	stepper.runSpeed();
}

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