Open drp0 opened 4 years ago
Expanding on the description above...I'm not a C developer, so I had to fumble with this until I figured it out.
You'll need to edit the library .cpp and .h files.
in CheapStepper.cpp, add this to the end:
void CheapStepper::stepReset(){
stepN = 0;
}
in CheapStepper.h, I added this right after void stop();
void stepReset();
Once you've edited those two files, this modification is complete. Worked like a champ for me!
Thanks @drp0 and @tyhenry !
I added one more feature for my project. I needed to set a certain position instead of zero (0) position. In CheapStepper.cpp:
void CheapStepper::stepReset(int SetStepPos){
stepN = SetStepPos;
}
and in the CheapStepper.h :
void stepReset(int SetStepPos);
I wanted to set the start position of the stepper and attached an opto sensor to allow the stepper motor to be moved until a hole in a rotated cardboard disc, caused the opto to read Low. This all went to plan until I realised that the library initialised its position from the first call to CheapStepper stepper (8,9,10,11) . I realised I needed a new library call (stepReset) to set stepN = 0 and hence establish a new base position.
This works well.
My centering code;
Others may find this useful,
David