Miguel Angel Caycho
/
Pruebas_Ventilador_Eplimin_01_Backup
para el ventilador
Diff: stepper_motor_driver.cpp
- Revision:
- 11:5cb7ae8bd831
- Parent:
- 10:b2d87404309a
- Child:
- 12:3bc2465b034a
--- a/stepper_motor_driver.cpp Mon Apr 27 19:52:02 2020 +0000 +++ b/stepper_motor_driver.cpp Thu May 07 03:52:31 2020 +0000 @@ -7,6 +7,7 @@ #include "nextion_interface.h" #include "FastPWM.h" #include "ventilator.h" +#include "pressure_sensors.h" /* Object definition */ InterruptIn stepper_pulse_feedback(STEPPER_PULSE_FEEDBACK_PIN); @@ -22,10 +23,6 @@ // These parameters are configurer through the graphic interface */ uint32_t inspiration_stepper_pulses_setpoint = STEPPER_DRIVER_INSPIRATION_PULSES_DEFAULT ; -//uint32_t expiration_stepper_pulses_setpoint = STEPPER_DRIVER_MAX_PULSES ; // Not used in this version -//uint32_t inspiration_stepper_pulse_period_us = STEPPER_DRIVER_DEFAULT_PULSE_PERIOD_US; -//uint32_t expiration_stepper_pulse_period_us = STEPPER_DRIVER_DEFAULT_PULSE_PERIOD_US; -//uint32_t calibration_stepper_pulse_period_us = STEPPER_DRIVER_DEFAULT_PULSE_PERIOD_US; float inspiration_stepper_pulse_period = 0.005; float expiration_stepper_pulse_period = 0.005; @@ -34,17 +31,17 @@ // Volume setpoint (250mL, 300mL, 350ml ... 750ml) expressed in steps uint32_t volume_in_steps[VOLUME_SETPOINT_INDEX_LIMIT] = { - 40, // 1600, //250 mL//720 - 44, // 1700, //300 mL//765 - 46, // 1800, //350 mL//810 - 49, // 1900, //400 mL//855 - 52, // 2000, //450 mL//900 - 55, // 2100, //500 mL//945 - 57, // 2200, //550 mL//990 - 60, // 2300, //600 mL //1035 - 63, // 2400, //650 mL//1080 - 65, // 2500, //700 mL//1125 - 67 // 2600 //750 mL//1170 + 70, // 1600, //250 mL//720//47 + 75, // 1700, //300 mL//765 + 80, // 1800, //350 mL//810 + 85, // 1900, //400 mL//855 + 90, // 2000, //450 mL//900 + 95, // 2100, //500 mL//945 + 100, // 2200, //550 mL//990 + 105, // 2300, //600 mL //1035 + 110, // 2400, //650 mL//1080 + 115, // 2500, //700 mL//1125 + 120 // 2600 //750 mL//1170 }; @@ -83,11 +80,7 @@ void Stepper_Update_Parameters(void){ int8_t stepper_volume_index; - uint32_t regular_steps; float total_time, total_time_sec, insp_time_sec, exp_time_sec; - float inspiration_stepper_pulse_period_sec, expiration_stepper_pulse_period_sec; - float ramp_max_pulse_freq_hz, ramp_time_sec, short_ramp_time_sec; - float inspiration_stepper_regular_frequency_hz; /* Update the value of the volume setpoint (expressed in steps) */ stepper_volume_index = (volume_setpoint - VOLUME_SETPOINT_MINIMUM_VALUE) / VOLUME_SETPOINT_STEP; @@ -104,6 +97,8 @@ /* Calculate stepper pulse period for expiration */ expiration_stepper_pulse_period = ((float)exp_time_sec) / ((float)inspiration_stepper_pulses_setpoint); + volume_ml = 0.0; + } @@ -124,7 +119,7 @@ stepper_pulse.period(expiration_stepper_pulse_period); stepper_pulse.write(0.5); stepper_driver_state = Stepper_Expiration; - // pressure_sensor_display_update_flag = 1; + //pressure_sensor_display_update_flag = 1; break; // ----------------------------------------------------------------------- @@ -145,6 +140,8 @@ stepper_pulse.write(0.5); stepper_driver_state = Stepper_Inspiration; + //pressure_sensor_display_update_flag = 1; + break; // -------------------------------------------------------------------- case Stepper_Limit_Sensor_Error: