OK.
When I wish to learn more about your concept of a millis, I use your program as in original. The point is that I dont understand your plan, what would you like to do with a millis?
Perhaps to say to motor to run, until the output is high(regulated by millis value), and to stop when is becomes low. And that is more interesting, where is here comes the deceleration, and the reading of encoder value.
I was find one sketch based on the millis. Is that something similar, what you want to do?
[code]
//Use the jumpers on the board to select which pins will be used
int EnablePin1 = 13;
int PWMPinA1 = 11;
int PWMPinB1 = 3;
int extendtime = 5 * 1000; // 10 seconds, times 1000 to convert to milliseconds
int retracttime = 5 * 1000; // 10 seconds, times 1000 to convert to milliseconds
int timetorun = 300 * 1000; // 300 seconds, times 1000 to convert to milliseconds
int duty;
int elapsedTime;
boolean keepMoving;
void setup() {
Serial.begin(9600);
pinMode(EnablePin1, OUTPUT);//Enable the board
pinMode(PWMPinA1, OUTPUT);
pinMode(PWMPinB1, OUTPUT);//Set motor outputs
elapsedTime = 0; // Set time to 0
keepMoving = true; //The system will move
}//end setup
void loop() {
if (keepMoving)
{
digitalWrite(EnablePin1, HIGH); // enable the motor
pushActuator();
delay(extendtime);
stopActuator();
delay(1000);//small delay before retracting
pullActuator();
delay(retracttime);
stopActuator();
elapsedTime = millis();//how long has it been?
if (elapsedTime > timetorun) {//if it's been 300 seconds, stop
Serial.print("Elapsed time is over max run time. Max run time: ");
Serial.println(timetorun);
keepMoving = false;
}
}//end if
}//end main loop
void stopActuator() {
analogWrite(PWMPinA1, 0);
analogWrite(PWMPinB1, 0); // speed 0-255
}
void pushActuator() {
analogWrite(PWMPinA1, 55);
analogWrite(PWMPinB1, 0); // speed 0-255
}
void pullActuator() {
analogWrite(PWMPinA1, 0);
analogWrite(PWMPinB1, 55);//speed 0-255
}
[/code]
Please explain to me your concept in a words, to understand how to build up the program with encoder, and decelartion function in all moves.
Also pls clear it up, how can I give a command to the arduino, where to go? We need to have more fixed points(for example 5).
A