Modifying the Simple-Stepper program to remove getchar
Posted: Sat Feb 18, 2017 1:00 pm
All.
I'm running the simple-stepper.c program and have modifed it to set the current, accel, veloc and can control the motor...using the 1067 controller and a raspberryPi3.
Now. I am missing some understanding of the useage of the getchar() function as when I start modifying the code to go one direction for a set amount of steps and then to reverse the same amount of steps I can only perform this operation as shown below. If I am correct in my recall, as I've been messing with this code for hours...if I remove any of the 3 getchar() functions the routine does not function as desired. I'm working towards runnnig the stepper without user input. Tried creating while loops, delays, and not sure what i need to code as I don't understand the intimacies of C vs needed delay times between the function calls...or??
Any help will be greatly appreciated. Thank you, Brian
This is just part of code where steps1-4 were located to where the stepper is disengaged.
//keep displaying stepper event data until user input is read
printf("Press any key to continue as we are about to start\n");
getchar();
CPhidgetStepper_setCurrentPosition(stepper, 0, 0);
printf("Current Position within If loop: %lld\n", curr_pos);
CPhidgetStepper_setEngaged(stepper, 0, 1);
CPhidgetStepper_setTargetPosition(stepper, 0,34000);
getchar();
printf("Current Position within If loop: %lld\n", curr_pos);
CPhidgetStepper_setCurrentPosition(stepper, 0, 0);
CPhidgetStepper_setTargetPosition(stepper, 0, -34000);
getchar();
// printf("Press any key to end the stepper function\n");
// getchar();
CPhidgetStepper_setEngaged(stepper, 0, 0);
CPhidgetStepper_setCurrentPosition(stepper, 0, 0);
I'm running the simple-stepper.c program and have modifed it to set the current, accel, veloc and can control the motor...using the 1067 controller and a raspberryPi3.
Now. I am missing some understanding of the useage of the getchar() function as when I start modifying the code to go one direction for a set amount of steps and then to reverse the same amount of steps I can only perform this operation as shown below. If I am correct in my recall, as I've been messing with this code for hours...if I remove any of the 3 getchar() functions the routine does not function as desired. I'm working towards runnnig the stepper without user input. Tried creating while loops, delays, and not sure what i need to code as I don't understand the intimacies of C vs needed delay times between the function calls...or??
Any help will be greatly appreciated. Thank you, Brian
This is just part of code where steps1-4 were located to where the stepper is disengaged.
//keep displaying stepper event data until user input is read
printf("Press any key to continue as we are about to start\n");
getchar();
CPhidgetStepper_setCurrentPosition(stepper, 0, 0);
printf("Current Position within If loop: %lld\n", curr_pos);
CPhidgetStepper_setEngaged(stepper, 0, 1);
CPhidgetStepper_setTargetPosition(stepper, 0,34000);
getchar();
printf("Current Position within If loop: %lld\n", curr_pos);
CPhidgetStepper_setCurrentPosition(stepper, 0, 0);
CPhidgetStepper_setTargetPosition(stepper, 0, -34000);
getchar();
// printf("Press any key to end the stepper function\n");
// getchar();
CPhidgetStepper_setEngaged(stepper, 0, 0);
CPhidgetStepper_setCurrentPosition(stepper, 0, 0);