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 PWM.cpp Source File

PWM.cpp

00001 #include "SETUP.h"
00002 
00003 extern PwmOut Servo;
00004 extern PwmOut Cutter_1;
00005 extern PwmOut Cutter_2;
00006 extern PwmOut Spleisser_1;
00007 extern PwmOut Spleisser_2;
00008 
00009 float duty1 = (GOOD_FIL*0.2666666+22.5)/100;
00010 float duty2 = (BAD_FIL*0.2666666+22.5)/100;
00011 
00012 
00013 /* ---------------------------- SERVO --------------------------------------- */
00014 void Init_Servo()
00015 {
00016     Servo.period(1/(float)SERVO_FR);
00017     Servo = 0.0;
00018 }
00019 
00020 void Set_Servo_Good_Fil()
00021 {
00022     Servo.period(1/(float)SERVO_FR);
00023     Servo = duty1;
00024 }
00025 
00026 void Set_Servo_Bad_Fil()
00027 {
00028     Servo.period(1/(float)SERVO_FR);
00029     Servo = duty2;
00030 }
00031 void Servo_Off()
00032 {
00033     Thread::wait(250);
00034     Servo.period(1/(float)SERVO_FR);
00035     Servo = 0.0;
00036 }
00037 
00038 /* ---------------------------- END ----------------------------------------- */
00039 
00040 
00041 
00042 /* ---------------------------- CUTTER -------------------------------------- */
00043 void Init_Cutter()
00044 {
00045     Cutter_1.period(1/(float)CUTTER_FRQ_1);
00046     Cutter_1 = 0.0;
00047     
00048     Cutter_2.period(1/(float)CUTTER_FRQ_2);
00049     Cutter_2 = 0.0;
00050 }
00051     
00052 void Set_Cutter(int arc_on_time, int arc_off_time, int repeats)
00053 {
00054     Cutter_1.period(1/(float)CUTTER_FRQ_1);
00055     Cutter_2.period(1/(float)CUTTER_FRQ_2);
00056     
00057     for(int i = repeats; i>0; i--)
00058     {
00059         Cutter_1 = (float)CUTTER_DUTY/100;
00060         Cutter_2 = (float)CUTTER_DUTY/100;
00061         Thread::wait(arc_on_time);
00062         Cutter_1 = 0.0;
00063         Cutter_2 = 0.0;
00064         Thread::wait(arc_off_time);
00065     }
00066     Cutter_1 = 0.0;
00067     Cutter_2 = 0.0;
00068 }
00069 /* ---------------------------- END ----------------------------------------- */
00070 
00071 
00072 
00073 /* ---------------------------- SPLEISSER ----------------------------------- */
00074 void Init_Spleisser()
00075 {
00076     Spleisser_1.period(1/(float)SPLEISSER_FRQ_1);
00077     Spleisser_1 = 0.0;
00078     
00079     Spleisser_2.period(1/(float)SPLEISSER_FRQ_2);
00080     Spleisser_2 = 0.0;
00081 }
00082 
00083 void Set_Spleisser(int arc_on_time, int arc_off_time, int repeats)
00084 {
00085     Spleisser_1.period(1/(float)SPLEISSER_FRQ_1);
00086     Spleisser_2.period(1/(float)SPLEISSER_FRQ_2);
00087     
00088     for(int i = repeats; i>0; i--)
00089     {
00090         Spleisser_1 = (float)SPLEISSER_DUTY/100;
00091         Spleisser_2 = (float)SPLEISSER_DUTY/100;
00092         Thread::wait(arc_on_time);
00093         Spleisser_1 = 0.0;
00094         Spleisser_2 = 0.0;
00095         Thread::wait(arc_off_time);
00096     }
00097     Spleisser_1 = 0.0;
00098     Spleisser_2 = 0.0;
00099 }
00100 /* ---------------------------- END ----------------------------------------- */