Hi everyone! I am trying to make a node to drive a stepper motor whit ivanmason/accelstepper, but i can´t implement an Start Imput.The node is working fine,it`s start on upload and reset. Please help! I have try evrithing i think it work.
You probably want to tie your Start mode to moveto-UPD pin. This will start the move each time Start is pulsed instead of only when stepper-device is created or modified.
I have try, I manage to start whit pulse on upd but it`s move only once, need reset again.
Moveto implies it is moving to a specific position. Are you changing that value and pulsing start again? How are you using this now you have created?
Solved! Ad an UPD input on accelstepper Device and change line code inside,whit this one :
void evaluate(Context ctx) {
if (!isInputDirty<input_UPD>(ctx))
return;
now i is work.
A couple issues with this solution:
- You have modified a library, so you will have issues getting future updates
- You are creating device multiple times within the patch, and calling the patch multiple times creating more objects.
Running the START pin to the setmaxspeed-UPD pin avoids having to modify the accellstepper-device node (it also means movement will not happen at boot unless you pulse the START pin on boot).
This also eliminates re-initializing the device node every time you want to move.
Looking at your main program using your drvaccel node, you have 4 copies of the node that are exactly the same except for N. This is a good indication that you should probably just have one copy of the node that changes N.
A possible failure mode for this is what happens when button is pressed again while you are mid-cycle? This would generate a second pulse that is trying to move stepper to 1st position while 1st pulse is trying to move it somewhere else. Having only one object with changing inputs avoids this issue. It will either restart the movement or you can disable button until movement is completed (or add code to do something completely different…).
Possible solution using nth-input node with a counter:
Pressing the button resets counter. Output of counter dictates which nth-input value gets selected to pass to drvaccel. Any time that nth-input output value changes, pulse drvaccel-START (via pulse-on-change node). When drvaccel finishes, INC count.
Though simple, there is a bug in this. Count will initialize to 0, so button press will not cause a change to start the whole process. This can be fixed by pulsing drvaccel-START when button is pressed:
I used a defer to link button to any just to make sure output of nth-input has updated before drvaccel tries to run; it may (or may not…) work without that defer. (After the 1st cycle, it might start the next cycle with -3000 value instead of 3000 value without the defer)
Note that count will actually be 4 when the cycle completes (last run of drvaccel will increment count again). Since we only use this for nth-input-IDX with X0-X3, a 4 will simply return the X3 value (the same as a 3 would), so output will not change and cycle will be stopped (there will be no pulse-on-change since there was no change). There might be other cases where using count like this will need extra code to make sure processing stops when you reach the maximum value.
If you want the cycle to run on boot, you can expand the any node and link a boot node to the new any input. Since count will initialize to 0, you do not need to worry about doing anything with it on boot like you do on button press.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.