Hi,
I’ve got simple requirements for my NEMA17 stepper motor and uStepper controller, but I can’t get it to do what I want. I’m completely new to Arduino.
My requirements are:
- Move a carriage 20cm in one direction (CCW) over 8 hours;
- Move the carriage 40 cm in the opposite direction (CW) EITHER over 8 hours, or if possible just quickly and then pause for eight hours;
- Move the carriage 20cm in one direction (CCW) back to the middle point over 8 hours.
- Repeat
The reason for the repeat of steps 1 and 3 are that I need this to run from 6:00 - 22:00, then return to the start position. By starting the code in the middle I can set the experiment running at 14:00 rather than 6:00. This experiment should run continuously for four months.
Some data to support the code:
Distance/rev (mm): 60
Steps/rev: 3200?
Time (hours): 8
time (secs): 28800
Distance 1 (mm): 200
Distance 2 (mm): 400
Move 1 (200mm) steps: 10666.66667
Move 2 (400mm) steps 21333.33333
Move 1 speed (steps/sec): 0.37037037
Move 2 speed (steps/sec): 0.740740741
According to the documentation, the NEMA17 stepper motor has 200 steps/rev, having from testing it it seems to be around 3200. Ideally I’d want a precise number, perhaps using moveAngle instead if I don’t know the step number.
Either way, I can’t get this simple code to work, and any help would be very appreciated!
Here’s what I’ve got:
#include <uStepper.h> uStepper stepper; void setup() { // put your setup code here, to run once: stepper.setup(); Serial.begin(115200); } void loop() { // put your main code here, to run repeatedly: stepper.setMaxVelocity(0.37037); stepper.moveSteps(10667, CCW, HARD); stepper.setMaxVelocity(0.74074); stepper.moveSteps(21334, CW, HARD); stepper.setMaxVelocity(0.37037); stepper.moveSteps(10667, CCW, HARD); }
Many thanks.