AcelStepper HELP


hi all,

i tried find clue on how solve problem below seems stuck. appreciate help.
i'll make story simpler. trying operate valve driven small stepper. @ closed position valve hits limit switch. using switch open or close valve. easydrive board used driving stepper.  i implement following logic: in case open command received motor should turn 8000 steps 1 side. in case close command received motor should turn 8000 steps other side. then, in case limit switch not activated turn additional 1000 steps. use accelstepper library because plan operate more 1 valve in parallel.
anyhow code without limit switch seems work fine, see below:
code: [select]

void loop ( )  {
 cmdvent = digitalread (cmdpinvent); //read vent valve command open (low) or close (high)
  if (ventvalve1.distancetogo ( ) == 0) {
   //check open command
   if ( cmdvent == low && cmdventold == high ) {
     ventvalve1.move (8000);
     cmdventold = cmdvent;
   }
   //check close command
   if ( cmdvent == high && cmdventold == low) {
    ventvalve1.move (-8000);
    cmdventold = cmdvent;
     switchvent1=digitalread (switchpinvent1);
     if (switchvent1 != high) {
     ventvalve1.move (-1000);
     }
   }
 }
 ventvalve1 .run( );
}


but not able implement switch work correctly
looking forward assistance

best,

morel

it's hard follow code when haven't put in code tags looks this. please go post , modify it. instructions in how use forum thread

from description of problem need have variables record state of things - whether limit switch pressed, , command selected. if project separate code 2 functions - 1 deal switches , 1 deal motor commands. make logic easier see. loop() function this

code: [select]
void loop() {
   readandsaveswitches();
   updatemotorcommands();
   ventvalve1.run( );
}


...r


Arduino Forum > Using Arduino > Programming Questions > AcelStepper HELP


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support