para el ventilador

Dependencies:   QEI FastPWM

project_defines.h

Committer:
miguelangel_2511
Date:
2020-04-20
Revision:
7:f4e248182d31
Parent:
6:d38287621cca
Child:
8:208d965a3bd2

File content as of revision 7:f4e248182d31:


#ifndef PROJECT_DEFINES_H_
#define PROJECT_DEFINES_H_

/* File inclusion */

/* Pin definition */

// Switches and buttons
#define ENTER_SW_PIN                            PA_15
#define LIMIT_SW_01_PIN                         PB_7
#define GAS_INPUT_SW_PIN                        PC_13

// Rotary encoder
#define ENCODER_A_SIGNAL                        PA_13
#define ENCODER_B_SIGNAL                        PA_14
 
//Nextion display
#define NEXTION_DISPLAY_TX_PIN                  PC_10
#define NEXTION_DISPLAY_RX_PIN                  PC_11

// Pressure sensors
#define PRESSURE_SENSOR_01_SDA_PIN              PB_9
#define PRESSURE_SENSOR_01_SCL_PIN              PB_8

#define PRESSURE_SENSOR_02_SDA_PIN              PB_10
#define PRESSURE_SENSOR_02_SCL_PIN              PB_11

//Stepper motor
#define STEPPER_PULSE_PIN                       PC_8
#define STEPPER_ENABLE_PIN                      PC_6
#define STEPPER_DIRECTION_PIN                   PC_5
#define STEPPER_PULSE_FEEDBACK_PIN              PA_12


/* Constants and macros */

/* Defines for the switches and buttons */
#define ENTER_SW                                0
#define LIMIT_SW_01                             1
#define GAS_INPUT_SW                            2

/* Defines for the encoder user interface */
#define ENCODER_THRESHOLD                       8

#define PARAMETER_SELECTION_INDEX_LIMIT         3
#define VOLUME_SETPOINT_INDEX_LIMIT             11
#define RESP_FREQUENCY_INDEX_LIMIT              21
#define I_E_RATIO_INDEX_LIMIT                   3

#define PARAMETER_SELECTION_INDEX_DEFAULT       0
#define VOLUME_SETPOINT_INDEX_DEFAULT           5
#define RESP_FREQUENCY_INDEX_DEFAULT            10
#define I_E_RATIO_INDEX_DEFAULT                 0

/* Defines for the Nextion user interface */

#define NEXTION_DISPLAY_BAUD_RATE               9600

#define BLACK                                   0
#define BLUE                                    31
#define BROWN                                   48192
#define GREEN                                   2016
#define YELLOW                                  65504
#define RED                                     63488
#define GRAY                                    33840
#define WHITE                                   65535

#define NORMAL_COLOR                            BLACK
#define SELECT_COLOR                            BLUE
#define ADJUST_COLOR                            GREEN

//#define BACKGROUND_COLOR                        Black
//#define INDICATOR_BOX_LINE_COLOR                Green
//#define INDICATOR_HEADER_TEXT_COLOR             Yellow
//#define INDICATOR_VALUE_TEXT_COLOR              White
//#define INDICATOR_UNITS_TEXT_COLOR              White
//#define PARAMETER_SELECTION_BOX_COLOR           Yellow
//#define PARAMETER_ADJUST_TEXT_COLOR             Green 

#define HEADERS_ROW1_Y_POS                      20
#define HEADERS_ROW2_Y_POS                      180
#define UNITS_ROW1_Y_POS                        103
#define UNITS_ROW2_Y_POS                        263
#define VALUES_ROW1_Y_POS                       60
#define VALUES_ROW2_Y_POS                       220

#define VOLUME_SETPOINT_VALUE_DEFAULT           500
#define RESP_FREQUENCY_VALUE_DEFAULT            20
#define INSPIRATION_TIME_VALUE_DEFAULT          1.0
#define EXPIRATION_TIME_VALUE_DEFAULT           2.0

#define VOLUME_SETPOINT_MINIMUM_VALUE           250
#define VOLUME_SETPOINT_STEP                    50

#define AIR_INPUT                               0
#define OXYGEN_INPUT                            1

#define MAIN_SCREEN_DEFAULT_STATE                       Main_Screen_Cursor_Disable

/* Defines for the pressure sensors */
#define PRESSURE_SENSOR_I2C_CLK_HZ                      200000
#define PRESSURE_SENSOR_01_SLAVE_ADDRESS                0x28
#define PRESSURE_SENSOR_02_SLAVE_ADDRESS                0x28
#define PRESSURE_SENSOR_01_SWA                          (PRESSURE_SENSOR_01_SLAVE_ADDRESS << 1)
#define PRESSURE_SENSOR_02_SWA                          (PRESSURE_SENSOR_02_SLAVE_ADDRESS << 1)
#define PRESSURE_SENSOR_01_SRA                          (PRESSURE_SENSOR_01_SWA  | 1)
#define PRESSURE_SENSOR_02_SRA                          (PRESSURE_SENSOR_02_SWA  | 1)
#define PRESSURE_DISPLAY_THRESHOLD                      0.01f

/* Defines for the stepper motor control */ 
#define TO_HOME                                         0
#define TO_AIRBAG                                       1
#define STEPPER_ENABLED                                 0
#define STEPPER_DISABLED                                1                                 
                
#define STEPPER_DRIVER_PULSE_MIN_PERIOD_US              100     
#define STEPPER_DRIVER_PULSE_HOME_PERIOD_US             1000  
#define STEPPER_DRIVER_DEFAULT_PULSE_PERIOD_US          1000  
 
#define STEPPER_DRIVER_MAX_PULSES                       6000 // Limite de pasos cuando no encuentra el sensor    
#define STEPPER_DRIVER_MIN_PULSES                       (2*RAMP_STEPS + 2)
#define STEPPER_DRIVER_INSPIRATION_PULSES_DEFAULT       2000
   
#define STEPPER_DRIVER_DEFAULT_STATE                    Stepper_Driver_Home_Ramp

#define STEPPER_CALIBRATION_FREQUENCY_HZ                200

// Number of steps used for the speed ramp, can be either 50 or 100  
#define RAMP_STEPS                                      50

#if RAMP_STEPS  == 50
    #define STEPPER_START_BRAKE_FREQUENCY_HZ            300 
#elif RAMP_STEPS == 100
    #define STEPPER_START_BRAKE_FREQUENCY_HZ            500 
#else
    #error "Select a valid value for RAMP_STEPS: either 50 or 100"    
#endif

#define STEPPER_MAX_FREQUENCY_HZ                        3000

#define STEPPER_START_BRAKE_PERIOD_US                   (1000000.0/STEPPER_START_BRAKE_FREQUENCY_HZ)
#define SHORT_RAMP_STEPS                                25

#define TUNING_FACTOR                                   1.25

#endif