Has anyone used the PMC with the AccelStepper.h library?
If so, did you have to modify the library?
If anyone has managed to get this working an example sketch would be very greatly appreciated.
/ Einar
Has anyone used the PMC with the AccelStepper.h library?
If so, did you have to modify the library?
If anyone has managed to get this working an example sketch would be very greatly appreciated.
/ Einar
Were you ever able to get this to work? I'm looking to use it as well if possible. So far it just keeps hanging the PMC...
Nope sir, right now I am manually running the steppers and made my own basic program to count the steps in each direction and provide an output/goal position.
/ Einar
Hello everyone, I also have the same problem at the moment.
There is the Arduino_PortentaMachineControl.h
library. This allows you to output something to a digital output pin with MachineControl_DigitalOutputs.write(3, HIGH);
I don't know how to write the code so that I can use it with the AccelStepper library.
The pins are defined as constants there, for example:
const int stepPin = 3;
const int directionPin = 4;
const int enablePin = 5;
But how do I use the MachineControl_DigitalOutputs.write(3, HIGH); to rewrite this digital pin 3 so that it can be used as pin 3 for the stepPin? Does anyone here have any ideas?
It might be possible possible to rewrite the AccelStepper library and add the relevant libraries (#include "Arduino_PortentaMachineControl.h" etc etc) and also switch out "standard" Arduino commands with PMC commands.
For example:
myPin.write(HIGH); ---> MachineControl_DigitalOutputs.write(myPin, HIGH);
etc.
But I don't have much experience editing other peoples libraries frankly...
One path which Im investigating now is using the Portenta Machine Controls PWM capabilities to control a stepper smoothly with acceleration and de-acceleration.
https://docs.arduino.cc/learn/microcontrollers/analog-output/
That is a common way to do it in industry (apparently!) but I'm unsure yet as to how complex the code to that will actually end up being.
Will inform you if I work out a solution!
Cheers / Einar
The AccelStepper library is a popular Arduino library used for controlling stepper motors with acceleration and deceleration. It's commonly used in various projects that involve precise control of stepper motors, such as robotics, CNC machines, and 3D printers.
Did you ask ChatGPT to tell you what the AccelStepper library was and then post the response here? lol
There is a mode in Accelstepper where it calls userdefined functions when a step is due (forward or backward). With this mode it should be possible to get it working on portenta.
I asked the question on their github and got this answer!
You could also rewrite the accelStepper library by changing the step method but keep in mind that the 24V drivers are very slow on the machine control and ranking up some speed is not possible.
Have a great day!