From c9e2f9ea93e7cdc37c47e20a5108e22033a4fd87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Fri, 10 Jan 2020 11:05:47 +0100 Subject: [PATCH] application: fix relay control --- application.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/application.c b/application.c index 9b6fc3c..81ce97b 100644 --- a/application.c +++ b/application.c @@ -73,7 +73,7 @@ bool tacho_display = false; /**< if the current tachometer count should be displ #define TACHO_PIN PB11 /**< tachometer input on SWIM pin, pulled up to 3V3 by 680R */ #define TACHO_TARGET_DEFAULT 20 /**< the default target tachometer count (slow for safety) */ uint32_t tacho_target = TACHO_TARGET_DEFAULT; /**< the target tachometer count (switch SSR on when below, off when above) */ -#define SSR_PIN PB14 /**< pin to control the SSR (active low, open drain to 5V) */ +#define SSR_PIN PB14 /**< pin to control the SSR (SWDIO, active low, open drain to 5V) */ size_t putc(char c) { @@ -429,7 +429,7 @@ void main(void) printf("setup SSR: "); rcc_periph_clock_enable(GPIO_RCC(SSR_PIN)); // enable clock for GPIO peripheral - gpio_set(GPIO_PORT(SSR_PIN), GPIO_PIN(TACHO_PIN)); // set high to switch off + gpio_set(GPIO_PORT(SSR_PIN), GPIO_PIN(SSR_PIN)); // set high to switch off gpio_set_mode(GPIO_PORT(SSR_PIN), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO_PIN(SSR_PIN)); // set SSR - control pin to open drain. active low, connected to 5V on the + pin printf("OK\n"); @@ -483,13 +483,13 @@ void main(void) led_toggle(); // toggle LED (good to indicate if main function is stuck) if (!tacho_safety) { if (tacho < tacho_target) { - gpio_clear(GPIO_PORT(SSR_PIN), GPIO_PIN(TACHO_PIN)); // switch SSR on to provide power + gpio_clear(GPIO_PORT(SSR_PIN), GPIO_PIN(SSR_PIN)); // switch SSR on to provide power } else { - gpio_set(GPIO_PORT(SSR_PIN), GPIO_PIN(TACHO_PIN)); // switch SSR off to cut power + gpio_set(GPIO_PORT(SSR_PIN), GPIO_PIN(SSR_PIN)); // switch SSR off to cut power } if (0 == tacho && rtc_get_counter_val() > time_start + 5 * RTC_TICKS) { // the motor does not seem to turn, after 5 s tacho_safety = true; // turn safety on - gpio_set(GPIO_PORT(SSR_PIN), GPIO_PIN(TACHO_PIN)); // switch SSR off to cut power + gpio_set(GPIO_PORT(SSR_PIN), GPIO_PIN(SSR_PIN)); // switch SSR off to cut power printf("tachometer does not indicate the motor is turning\n"); printf("either the tachometer is defective, or the motor is stuck\n"); printf("switching the motor off for safety\n");