| [41] | 1 | #include "relais.h"
|
|---|
| 2 | #include "main.h"
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 | #define PULS_TIME 50
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 | unsigned int onTimeCounterSET; //Set Coil
|
|---|
| 10 | unsigned int onTimeCounterRESET; //Reset Coil
|
|---|
| 11 | unsigned int relaisState;
|
|---|
| 12 | int32_t relais_temperature;
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | uint16_t RELAIS_GetTemp(void)
|
|---|
| 16 | {
|
|---|
| 17 | return relais_temperature;
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | void RELAIS_Exec(uint32_t adcValue)
|
|---|
| 21 | {
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | int32_t temp = adcValue;
|
|---|
| 25 | temp = temp * VREF;
|
|---|
| 26 | temp = temp / 65635; // Spannung
|
|---|
| 27 | temp = (temp - 600) / 10; //Temperatur
|
|---|
| 28 | relais_temperature = temp;
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 | if (onTimeCounterSET > 0)
|
|---|
| 32 | {
|
|---|
| 33 | onTimeCounterSET--;
|
|---|
| 34 | if (onTimeCounterSET == 0)
|
|---|
| 35 | {
|
|---|
| 36 | HAL_GPIO_WritePin(GPIO_OUTPUT_RELAIS_SET_GPIO_Port, GPIO_OUTPUT_RELAIS_SET_Pin, GPIO_PIN_RESET);
|
|---|
| 37 | }
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 | if (onTimeCounterRESET > 0)
|
|---|
| 43 | {
|
|---|
| 44 | onTimeCounterRESET--;
|
|---|
| 45 | if (onTimeCounterRESET == 0)
|
|---|
| 46 | {
|
|---|
| 47 | HAL_GPIO_WritePin(GPIO_OUTPUT_RELAIS_RESET_GPIO_Port, GPIO_OUTPUT_RELAIS_RESET_Pin, GPIO_PIN_RESET);
|
|---|
| 48 | }
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | void RELAIS_SetPuls(void)
|
|---|
| 54 | {
|
|---|
| 55 |
|
|---|
| 56 | //Sicherstellen das nicht noch die Reset Spule aktiv geschaltet ist
|
|---|
| 57 | HAL_GPIO_WritePin(GPIO_OUTPUT_RELAIS_RESET_GPIO_Port, GPIO_OUTPUT_RELAIS_RESET_Pin, GPIO_PIN_RESET);
|
|---|
| 58 |
|
|---|
| 59 | //Puls starten
|
|---|
| 60 | HAL_GPIO_WritePin(GPIO_OUTPUT_RELAIS_SET_GPIO_Port, GPIO_OUTPUT_RELAIS_SET_Pin, GPIO_PIN_SET);
|
|---|
| 61 | onTimeCounterSET = PULS_TIME;
|
|---|
| 62 | relaisState = 1;
|
|---|
| 63 |
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | void RELAIS_ResetPuls(void)
|
|---|
| 67 | {
|
|---|
| 68 |
|
|---|
| 69 | //Sicherstellen das nicht noch die Set Spule aktiv geschaltet ist
|
|---|
| 70 | HAL_GPIO_WritePin(GPIO_OUTPUT_RELAIS_SET_GPIO_Port, GPIO_OUTPUT_RELAIS_SET_Pin, GPIO_PIN_RESET);
|
|---|
| 71 |
|
|---|
| 72 | //Puls starten
|
|---|
| 73 | HAL_GPIO_WritePin(GPIO_OUTPUT_RELAIS_RESET_GPIO_Port, GPIO_OUTPUT_RELAIS_RESET_Pin, GPIO_PIN_SET);
|
|---|
| 74 | onTimeCounterRESET = PULS_TIME;
|
|---|
| 75 | relaisState = 0;
|
|---|
| 76 |
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 | unsigned int RELAIS_GetState(void)
|
|---|
| 81 | {
|
|---|
| 82 | return relaisState;
|
|---|
| 83 | }
|
|---|