PES_4_Spleisser / Mbed 2 deprecated SpleisserProgramm_V11

Dependencies:   mbed mbed-rtos X_NUCLEO_IHM02A1

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers STEPPER.cpp Source File

STEPPER.cpp

00001 #include "SETUP.h"
00002 /* --------------------------- Variables ------------------------------------ */
00003 extern L6470B **motors2;
00004 extern L6470 **motors;
00005 /* ---------------------------- END ----------------------------------------- */
00006 
00007 
00008 
00009 /* -------------------------- Leerlauf -------------------------------------- */
00010 void Stepper_1_Leerlauf()
00011 {
00012     motors[0]->hard_hiz();
00013     motors[0]->wait_while_active();
00014 }
00015 void Stepper_2_Leerlauf()
00016 {
00017     motors[1]->hard_hiz();
00018     motors[1]->wait_while_active();
00019 }
00020 void Stepper_3_Leerlauf()
00021 {
00022     motors2[0]->hard_hiz();
00023     motors2[0]->wait_while_active();
00024 }
00025 void Stepper_4_Leerlauf()
00026 {
00027     motors2[1]->hard_hiz();
00028     motors2[1]->wait_while_active();
00029 }
00030 /* ---------------------------- END ----------------------------------------- */
00031 
00032 
00033 
00034 /* --------------------------- Stop ----------------------------------------- */
00035 void Stepper_1_Stop()
00036 {
00037     motors[0]->hard_stop();
00038     motors[0]->wait_while_active();
00039 }
00040 void Stepper_2_Stop()
00041 {
00042     motors[1]->hard_stop();
00043     motors[1]->wait_while_active();
00044 }
00045 void Stepper_3_Stop()
00046 {
00047     motors2[0]->hard_stop();
00048     motors2[0]->wait_while_active();
00049 }
00050 void Stepper_4_Stop()
00051 {
00052     motors2[1]->hard_stop();
00053     motors2[1]->wait_while_active();
00054 }
00055 /* ---------------------------- END ----------------------------------------- */
00056 
00057 
00058 
00059 /* ---------------------- Setzte Home Position ------------------------------ */
00060 void Stepper_1_SetHome()
00061 {
00062     motors[0]->set_home();
00063     motors[0]->wait_while_active();
00064 }
00065 void Stepper_2_SetHome()
00066 {
00067     motors[1]->set_home();
00068     motors[1]->wait_while_active();
00069 }
00070 void Stepper_3_SetHome()
00071 {
00072     motors2[0]->set_home();
00073     motors2[0]->wait_while_active();
00074 }
00075 void Stepper_4_SetHome()
00076 {
00077     motors2[1]->set_home();
00078     motors2[1]->wait_while_active();
00079 }
00080 /* ---------------------------- END ----------------------------------------- */
00081 
00082 
00083 
00084 /* -------- Setting the current position to be the marked position ---------- */
00085 void Stepper_1_MarkPos()
00086 {
00087     motors[0]->set_mark();
00088     motors[0]->wait_while_active();
00089 }
00090 void Stepper_2_MarkPos()
00091 {
00092     motors[1]->set_mark();
00093     motors[1]->wait_while_active();
00094 }
00095 void Stepper_3_MarkPos()
00096 {
00097     motors2[0]->set_mark();
00098     motors2[0]->wait_while_active();
00099 }
00100 void Stepper_4_MarkPos()
00101 {
00102     motors2[1]->set_mark();
00103     motors2[1]->wait_while_active();
00104 }
00105 /* ---------------------------- END ----------------------------------------- */
00106 
00107 
00108 
00109 /* ------------------------ Get Current Position ---------------------------- */
00110 int Stepper_1_GetPosition()
00111 {
00112     return motors[0]->get_position();
00113 }
00114 int Stepper_2_GetPosition()
00115 {
00116     return motors[1]->get_position();
00117 }
00118 int Stepper_3_GetPosition()
00119 {
00120     return motors2[0]->get_position();
00121 }
00122 int Stepper_4_GetPosition()
00123 {
00124     return motors2[1]->get_position();
00125 }
00126 /* ---------------------------- END ----------------------------------------- */
00127 
00128 
00129 
00130 /* ---------------------- Get Marked Position ------------------------------- */
00131 
00132 int Stepper_1_GetMark()
00133 {
00134     return motors[0]->get_mark();
00135 }
00136 int Stepper_2_GetMark()
00137 {
00138     return motors[1]->get_mark();
00139 }
00140 int Stepper_3_GetMark()
00141 {
00142     return motors2[0]->get_mark();
00143 }
00144 int Stepper_4_GetMark()
00145 {
00146     return motors2[1]->get_mark();
00147 }
00148 
00149 /* ---------------------------- END ----------------------------------------- */
00150 
00151 
00152 
00153 /* ------------------ Going to a specified position ------------------------- */
00154 void Stepper_1_GoTo(signed int position)
00155 {
00156     motors[0]->go_to(position);
00157     motors[0]->wait_while_active();
00158 }
00159 void Stepper_2_GoTo(signed int position)
00160 {
00161     motors[1]->go_to(position);
00162     motors[1]->wait_while_active();
00163 }
00164 void Stepper_3_GoTo(signed int position)
00165 {
00166     motors2[0]->go_to(position);
00167     motors2[0]->wait_while_active();
00168 }
00169 void Stepper_4_GoTo(signed int position)
00170 {
00171     motors2[1]->go_to(position);
00172     motors2[1]->wait_while_active();
00173 }
00174 /* ---------------------------- END ----------------------------------------- */
00175 
00176 
00177 
00178 /* ------------------------- Go to Home ------------------------------------- */
00179 void Stepper_1_GoHome()
00180 {
00181     motors[0]->go_home();
00182     motors[0]->wait_while_active();
00183 }
00184 void Stepper_2_GoHome()
00185 {
00186     motors[1]->go_home();
00187     motors[1]->wait_while_active();
00188 }
00189 void Stepper_3_GoHome()
00190 {
00191     motors2[0]->go_home();
00192     motors2[0]->wait_while_active();
00193 }
00194 void Stepper_4_GoHome()
00195 {
00196     motors[1]->go_home();
00197     motors[1]->wait_while_active();
00198 }
00199 /* ---------------------------- END ----------------------------------------- */
00200 
00201 
00202 
00203 /* ----------------------------- Go to Mark --------------------------------- */
00204 void Stepper_1_GoMark()
00205 {
00206     motors[0]->go_mark();
00207     motors[0]->wait_while_active();
00208 }
00209 void Stepper_2_GoMark()
00210 {
00211     motors[1]->go_mark();
00212     motors[1]->wait_while_active();
00213 }
00214 void Stepper_3_GoMark()
00215 {
00216     motors2[0]->go_mark();
00217     motors2[0]->wait_while_active();
00218 }
00219 void Stepper_4_GoMark()
00220 {
00221     motors2[1]->go_mark();
00222     motors2[1]->wait_while_active();
00223 }
00224 /* ---------------------------- END ----------------------------------------- */
00225 
00226 
00227 
00228 /* --------------------------------- MOVE ----------------------------------- */
00229 void Stepper_1_Move(char direction, unsigned int steps)
00230 {
00231     if( direction == 'V') {
00232         motors[0]->move(StepperMotor::FWD, 128*steps);
00233         motors[0]->wait_while_active();
00234     } else if ( direction == 'R') {
00235         motors[0]->move(StepperMotor::BWD, 128*steps);
00236         motors[0]->wait_while_active();
00237     }
00238 
00239 }
00240 void Stepper_2_Move(char direction, unsigned int steps)
00241 {
00242     if( direction == 'V') {
00243         motors[1]->move(StepperMotor::FWD, 128*steps);
00244         motors[1]->wait_while_active();
00245     } else if ( direction == 'R') {
00246         motors[1]->move(StepperMotor::BWD, 128*steps);
00247         motors[1]->wait_while_active();
00248     }
00249 }
00250 void Stepper_3_Move(char direction, unsigned int steps)
00251 {
00252     if( direction == 'V') {
00253         motors2[0]->move(StepperMotor::FWD, 128*steps);
00254         motors2[0]->wait_while_active();
00255     } else if ( direction == 'R') {
00256         motors2[0]->move(StepperMotor::BWD, 128*steps);
00257         motors2[0]->wait_while_active();
00258     }
00259 }
00260 void Stepper_4_Move(char direction, unsigned int steps)
00261 {
00262     if( direction == 'V') {
00263         motors2[1]->move(StepperMotor::FWD, 128*steps);
00264         motors2[1]->wait_while_active();
00265     } else if ( direction == 'R') {
00266         motors2[1]->move(StepperMotor::BWD, 128*steps);
00267         motors2[1]->wait_while_active();
00268     }
00269 }
00270 /* ---------------------------- END ----------------------------------------- */
00271 
00272 
00273 
00274 /* --------------------------------- RUN ------------------------------------ */
00275 void Stepper_1_Run(char direction, unsigned int speed)
00276 {
00277     if( direction == 'V') {
00278         motors[0]->run(StepperMotor::FWD, speed);
00279         motors[0]->wait_while_active();
00280     } else if ( direction == 'R') {
00281         motors[0]->run(StepperMotor::BWD, speed);
00282         motors[0]->wait_while_active();
00283     }
00284 
00285 }
00286 void Stepper_2_Run(char direction, unsigned int speed)
00287 {
00288     if( direction == 'V') {
00289         motors[1]->run(StepperMotor::FWD, speed);
00290         motors[1]->wait_while_active();
00291     } else if ( direction == 'R') {
00292         motors[1]->run(StepperMotor::BWD, speed);
00293         motors[1]->wait_while_active();
00294     }
00295 }
00296 void Stepper_3_Run(char direction, unsigned int speed)
00297 {
00298     if( direction == 'V') {
00299         motors2[0]->run(StepperMotor::FWD, speed);
00300         motors2[0]->wait_while_active();
00301     } else if ( direction == 'R') {
00302         motors2[0]->run(StepperMotor::BWD, speed);
00303         motors2[0]->wait_while_active();
00304     }
00305 }
00306 void Stepper_4_Run(char direction, unsigned int speed)
00307 {
00308     if( direction == 'V') {
00309         motors2[1]->run(StepperMotor::FWD, speed);
00310         motors2[1]->wait_while_active();
00311     } else if ( direction == 'R') {
00312         motors2[1]->run(StepperMotor::BWD, speed);
00313         motors2[1]->wait_while_active();
00314     }
00315 }
00316 /* ---------------------------- END ----------------------------------------- */
00317 
00318 
00319 
00320 
00321 /* ------------------------- SET_SPEED_AC ----------------------------------- */
00322 void Stepper_1_SetPara(int speed, int acc)
00323 {
00324     motors[0]->set_max_speed(speed);
00325     motors[0]->set_acceleration(acc);
00326 }
00327 void Stepper_2_SetPara(int speed, int acc)
00328 {
00329     motors[1]->set_max_speed(speed);
00330     motors[1]->set_acceleration(acc);
00331 }
00332 void Stepper_3_SetPara(int speed, int acc)
00333 {
00334     motors2[0]->set_max_speed(speed);
00335     motors2[0]->set_acceleration(acc);
00336 }
00337 void Stepper_4_SetPara(int speed, int acc)
00338 {
00339     motors2[1]->set_max_speed(speed);
00340     motors2[1]->set_acceleration(acc);
00341 }
00342 /* ---------------------------- END ----------------------------------------- */